mirror of
https://github.com/openwrt/openwrt.git
synced 2024-12-20 22:23:27 +00:00
cddd459140
Add patches for linux-5.4. The patches are from NXP LSDK-20.04 release which was tagged LSDK-20.04-V5.4. https://source.codeaurora.org/external/qoriq/qoriq-components/linux/ For boards LS1021A-IOT, and Traverse-LS1043 which are not involved in LSDK, port the dts patches from 4.14. The patches are sorted into the following categories: 301-arch-xxxx 302-dts-xxxx 303-core-xxxx 701-net-xxxx 801-audio-xxxx 802-can-xxxx 803-clock-xxxx 804-crypto-xxxx 805-display-xxxx 806-dma-xxxx 807-gpio-xxxx 808-i2c-xxxx 809-jailhouse-xxxx 810-keys-xxxx 811-kvm-xxxx 812-pcie-xxxx 813-pm-xxxx 814-qe-xxxx 815-sata-xxxx 816-sdhc-xxxx 817-spi-xxxx 818-thermal-xxxx 819-uart-xxxx 820-usb-xxxx 821-vfio-xxxx Signed-off-by: Yangbo Lu <yangbo.lu@nxp.com>
100 lines
3.2 KiB
Diff
100 lines
3.2 KiB
Diff
From 2c2c7e16ad0401f85dd8ff9bc0789fa10e715c0e Mon Sep 17 00:00:00 2001
|
|
From: Clark Wang <xiaoning.wang@nxp.com>
|
|
Date: Tue, 15 Jan 2019 10:04:30 +0800
|
|
Subject: [PATCH] MLK-20368 i2c-imx: Coverity: fix divide by zero warning
|
|
|
|
"i2c_clk_rate / 2" might be zero when the i2c_clk_rate gets the clock is
|
|
0 or 1, so add a judgment to avoid the denominator is equal to 0.
|
|
|
|
Signed-off-by: Clark Wang <xiaoning.wang@nxp.com>
|
|
[Arul: Add support to check return value everywhere in the driver]
|
|
Signed-off-by: Arulpandiyan Vadivel <arulpandiyan_vadivel@mentor.com>
|
|
|
|
Signed-off-by: Shrikant Bobade <Shrikant_Bobade@mentor.com>
|
|
(cherry picked from commit d382de595bffc0975ab7c0582e08dd4f7afc0c1a)
|
|
(cherry picked from commit 456caa9ba270ca8f4f962918a0625d1a8348f316)
|
|
---
|
|
drivers/i2c/busses/i2c-imx.c | 31 +++++++++++++++++++++++++------
|
|
1 file changed, 25 insertions(+), 6 deletions(-)
|
|
|
|
--- a/drivers/i2c/busses/i2c-imx.c
|
|
+++ b/drivers/i2c/busses/i2c-imx.c
|
|
@@ -492,16 +492,24 @@ static int i2c_imx_acked(struct imx_i2c_
|
|
return 0;
|
|
}
|
|
|
|
-static void i2c_imx_set_clk(struct imx_i2c_struct *i2c_imx,
|
|
+static int i2c_imx_set_clk(struct imx_i2c_struct *i2c_imx,
|
|
unsigned int i2c_clk_rate)
|
|
{
|
|
struct imx_i2c_clk_pair *i2c_clk_div = i2c_imx->hwdata->clk_div;
|
|
unsigned int div;
|
|
int i;
|
|
|
|
- /* Divider value calculation */
|
|
if (i2c_imx->cur_clk == i2c_clk_rate)
|
|
- return;
|
|
+ return 0;
|
|
+
|
|
+ /*
|
|
+ * Keep the denominator of the following program
|
|
+ * always NOT equal to 0.
|
|
+ */
|
|
+
|
|
+ /* Divider value calculation */
|
|
+ if (!(i2c_clk_rate / 2))
|
|
+ return -EINVAL;
|
|
|
|
i2c_imx->cur_clk = i2c_clk_rate;
|
|
|
|
@@ -532,20 +540,23 @@ static void i2c_imx_set_clk(struct imx_i
|
|
dev_dbg(&i2c_imx->adapter.dev, "IFDR[IC]=0x%x, REAL DIV=%d\n",
|
|
i2c_clk_div[i].val, i2c_clk_div[i].div);
|
|
#endif
|
|
+
|
|
+ return 0;
|
|
}
|
|
|
|
static int i2c_imx_clk_notifier_call(struct notifier_block *nb,
|
|
unsigned long action, void *data)
|
|
{
|
|
+ int ret = 0;
|
|
struct clk_notifier_data *ndata = data;
|
|
struct imx_i2c_struct *i2c_imx = container_of(nb,
|
|
struct imx_i2c_struct,
|
|
clk_change_nb);
|
|
|
|
if (action & POST_RATE_CHANGE)
|
|
- i2c_imx_set_clk(i2c_imx, ndata->new_rate);
|
|
+ ret = i2c_imx_set_clk(i2c_imx, ndata->new_rate);
|
|
|
|
- return NOTIFY_OK;
|
|
+ return notifier_from_errno(ret);
|
|
}
|
|
|
|
static int i2c_imx_start(struct imx_i2c_struct *i2c_imx)
|
|
@@ -555,6 +566,10 @@ static int i2c_imx_start(struct imx_i2c_
|
|
|
|
dev_dbg(&i2c_imx->adapter.dev, "<%s>\n", __func__);
|
|
|
|
+ result = i2c_imx_set_clk(i2c_imx, clk_get_rate(i2c_imx->clk));
|
|
+ if (result)
|
|
+ return result;
|
|
+
|
|
imx_i2c_write_reg(i2c_imx->ifdr, i2c_imx, IMX_I2C_IFDR);
|
|
/* Enable I2C controller */
|
|
imx_i2c_write_reg(i2c_imx->hwdata->i2sr_clr_opcode, i2c_imx, IMX_I2C_I2SR);
|
|
@@ -1175,7 +1190,11 @@ static int i2c_imx_probe(struct platform
|
|
i2c_imx->bitrate = pdata->bitrate;
|
|
i2c_imx->clk_change_nb.notifier_call = i2c_imx_clk_notifier_call;
|
|
clk_notifier_register(i2c_imx->clk, &i2c_imx->clk_change_nb);
|
|
- i2c_imx_set_clk(i2c_imx, clk_get_rate(i2c_imx->clk));
|
|
+ ret = i2c_imx_set_clk(i2c_imx, clk_get_rate(i2c_imx->clk));
|
|
+ if (ret < 0) {
|
|
+ dev_err(&pdev->dev, "can't get I2C clock\n");
|
|
+ goto clk_notifier_unregister;
|
|
+ }
|
|
|
|
/*
|
|
* This limit caused by an i.MX7D hardware issue(e7805 in Errata).
|