i2c: jz4780: really prevent potential division by zero

Make sure we avoid a division-by-zero OOPS in case clock-frequency is
set too low in DT. Add missing '\n' while we are here.

Signed-off-by: Wolfram Sang <wsa@the-dreams.de>
Acked-by: Axel Lin <axel.lin@ingics.com>

Changed files
+6 -1
drivers
i2c
busses
+6 -1
drivers/i2c/busses/i2c-jz4780.c
··· 771 771 ret = of_property_read_u32(pdev->dev.of_node, "clock-frequency", 772 772 &clk_freq); 773 773 if (ret) { 774 - dev_err(&pdev->dev, "clock-frequency not specified in DT"); 774 + dev_err(&pdev->dev, "clock-frequency not specified in DT\n"); 775 775 goto err; 776 776 } 777 777 778 778 i2c->speed = clk_freq / 1000; 779 + if (i2c->speed == 0) { 780 + ret = -EINVAL; 781 + dev_err(&pdev->dev, "clock-frequency minimum is 1000\n"); 782 + goto err; 783 + } 779 784 jz4780_i2c_set_speed(i2c); 780 785 781 786 dev_info(&pdev->dev, "Bus frequency is %d KHz\n", i2c->speed);