i2c: sun6i-p2wi: Prevent potential division by zero

[ Upstream commit 5ac61d26b8 ]

Make sure we don't OOPS in case clock-frequency is set to 0 in a DT. The
variable set here is later used as a divisor.

Signed-off-by: Axel Lin <axel.lin@ingics.com>
Acked-by: Boris Brezillon <boris.brezillon@free-electrons.com>
Signed-off-by: Wolfram Sang <wsa@kernel.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
This commit is contained in:
Axel Lin 2016-04-13 08:54:30 +08:00 committed by Greg Kroah-Hartman
parent 38cd56fc9d
commit 807828f053

View file

@ -202,6 +202,11 @@ static int p2wi_probe(struct platform_device *pdev)
return -EINVAL;
}
if (clk_freq == 0) {
dev_err(dev, "clock-frequency is set to 0 in DT\n");
return -EINVAL;
}
if (of_get_child_count(np) > 1) {
dev_err(dev, "P2WI only supports one slave device\n");
return -EINVAL;