mail archive of the barebox mailing list
 help / color / mirror / Atom feed
From: Ahmad Fatoum <a.fatoum@pengutronix.de>
To: barebox@lists.infradead.org
Cc: Ahmad Fatoum <a.fatoum@pengutronix.de>
Subject: [PATCH 2/9] ARM: i.MX: guf-santaro: fix passing around of uninitialized variable
Date: Sat, 30 Oct 2021 19:58:05 +0200	[thread overview]
Message-ID: <20211030175812.2276705-3-a.fatoum@pengutronix.de> (raw)
In-Reply-To: <20211030175812.2276705-1-a.fatoum@pengutronix.de>

i2c_device_present() does a zero byte read to probe for the i2c
device. Make i2c_write_reg handle a NULL buf to silence the compiler
warning.

Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de>
---
 arch/arm/boards/guf-santaro/board.c | 3 +--
 drivers/i2c/i2c.c                   | 3 ++-
 2 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/arch/arm/boards/guf-santaro/board.c b/arch/arm/boards/guf-santaro/board.c
index 34005ff7bf17..cfc85af59ee7 100644
--- a/arch/arm/boards/guf-santaro/board.c
+++ b/arch/arm/boards/guf-santaro/board.c
@@ -22,12 +22,11 @@
 static int i2c_device_present(struct i2c_adapter *adapter, int addr)
 {
 	struct i2c_client client = {};
-	u8 reg;
 
 	client.adapter = adapter;
 	client.addr = addr;
 
-	return i2c_write_reg(&client, 0x00, &reg, 0) < 0 ? false : true;
+	return i2c_write_reg(&client, 0x00, NULL, 0) < 0 ? false : true;
 }
 
 #define TOUCH_RESET_GPIO	IMX_GPIO_NR(1, 20)
diff --git a/drivers/i2c/i2c.c b/drivers/i2c/i2c.c
index c33ce81b1827..432d0e233332 100644
--- a/drivers/i2c/i2c.c
+++ b/drivers/i2c/i2c.c
@@ -214,7 +214,8 @@ int i2c_write_reg(struct i2c_client *client, u32 addr, const u8 *buf, u16 count)
 	msgbuf[i++] = addr;
 	msg->len += i;
 
-	memcpy(msg->buf + i, buf, count);
+	if (count)
+		memcpy(msg->buf + i, buf, count);
 
 	status = i2c_transfer(client->adapter, msg, ARRAY_SIZE(msg));
 	dev_dbg(&client->adapter->dev, "%s: %u@%u --> %d\n", __func__,
-- 
2.30.2


_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox


  parent reply	other threads:[~2021-10-30 18:00 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-10-30 17:58 [PATCH 0/9] COMPILE_TEST: fix misc issues Ahmad Fatoum
2021-10-30 17:58 ` [PATCH 1/9] ARM: Rockchip: move ARCH_RK3568_OPTEE into ARCH_ROCKCHIP menu Ahmad Fatoum
2021-10-30 17:58 ` Ahmad Fatoum [this message]
2021-10-30 17:58 ` [PATCH 3/9] regulator: fix bitrotted EXPORT_SYMBOL_GPL Ahmad Fatoum
2021-10-30 17:58 ` [PATCH 4/9] aiodev: fix bitrotted EXPORT_SYMBOL Ahmad Fatoum
2021-10-30 17:58 ` [PATCH 5/9] mtd: remove NULLness check for IOMEM() Ahmad Fatoum
2021-10-30 17:58 ` [PATCH 6/9] clocksource: clint: restrict to RISC-V Ahmad Fatoum
2021-10-30 17:58 ` [PATCH 7/9] ddr: fsl: make ARCH_LAYERSCAPE only Ahmad Fatoum
2021-10-30 17:58 ` [PATCH 8/9] reset: socfpga: error out on failure to request memory Ahmad Fatoum
2021-10-30 17:58 ` [PATCH 9/9] i2c-mux-pca954x: drop duplicate warning message on probe Ahmad Fatoum
2021-11-01 10:33 ` [PATCH 0/9] COMPILE_TEST: fix misc issues Sascha Hauer

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20211030175812.2276705-3-a.fatoum@pengutronix.de \
    --to=a.fatoum@pengutronix.de \
    --cc=barebox@lists.infradead.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox