linux-gbmc: aspeedg7: i2c-usb: revert the code for using static memory
Per
https://github.com/torvalds/linux/blob/c4dce0c094a89b1bc8fde1163342bd6fe29c0370/drivers/usb/core/message.c#L192-L195
the data pointer must be to dynamically allocated memory.
Tested:
```
root@fdtp120-nfd01:~# dmesg | grep 140
[ 0.831645] spi-aspeed-smc 14000000.spi: user mode and normal read are used
[ 0.896218] spi-aspeed-smc 14000000.spi: CE0 read buswidth: 4 [0x406c0641]
[ 0.903910] spi-aspeed-smc 14000000.spi: CE0 write buswidth: 1 [0x00120602]
[ 0.973036] spi_aspeed_txrx 14010000.spi: cs: 0, ctrl_val: 0x00000407
[ 0.987426] ftgmac100 14050000.ftgmac: Read MAC address 04:00:6e:ea:86:ce from chip
[ 0.996013] ftgmac100 14050000.ftgmac: Using NCSI interface
[ 1.025237] ftgmac100 14050000.ftgmac eth0: irq 47, mapped at 00000000792e8784
[ 1.033837] ftgmac100 14060000.ftgmac: Read MAC address 04:00:6e:ea:86:cf from chip
[ 1.049360] Broadcom BCM54210E 14040008.mdio-1:00: attached PHY driver (mii_bus:phy_addr=14040008.mdio-1:00, irq=POLL)
[ 1.081663] ftgmac100 14060000.ftgmac eth1: irq 48, mapped at 000000009ad9f34e
[ 1.101406] usbserial: USB Serial support registered for pl2303
[ 1.643596] i2c i2c-140: I2C-over-USB adapter i2c-usb-1-1:1.1-0
[ 23.614022] systemd[1]: Started Dispatch Password Requests to Console Directory Watch.
[ 25.939521] ftgmac100 14060000.ftgmac front: renamed from eth1
[ 25.975223] ftgmac100 14050000.ftgmac nic0: renamed from eth0
[ 34.289945] ftgmac100 14050000.ftgmac nic0: Link is Up - 100Mbps/Full - flow control off
[ 34.753392] ftgmac100 14050000.ftgmac nic0: entered promiscuous mode
[ 38.426870] ftgmac100 14060000.ftgmac front: Link is Up - 1Gbps/Full - flow control rx/tx
[ 50.673655] ftgmac100 14050000.ftgmac nic0: NCSI: No channel found to configure!
[ 51.697577] ftgmac100 14050000.ftgmac nic0: Wrong NCSI state 0x100 in workqueue
// no error shows up
```
Google-Bug-Id: 427798958
Change-Id: I92ecd14b5433420ab21d4e4be3e192477de810fc
Signed-off-by: Tom Tung <tomtung@google.com>
diff --git a/recipes-kernel/linux/files/0001-platforms-i2c-i2c-usb-update-a-few-nits.patch b/recipes-kernel/linux/files/0001-platforms-i2c-i2c-usb-update-a-few-nits.patch
index 1303cc8..92f0444 100644
--- a/recipes-kernel/linux/files/0001-platforms-i2c-i2c-usb-update-a-few-nits.patch
+++ b/recipes-kernel/linux/files/0001-platforms-i2c-i2c-usb-update-a-few-nits.patch
@@ -1,11 +1,9 @@
-From 680bd92dfca4664ab197d7e776dc0f7b6429a919 Mon Sep 17 00:00:00 2001
+From 11d005487bae57d1d731e938800f009bdf97d5b3 Mon Sep 17 00:00:00 2001
From: Tom Tung <shes050117@gmail.com>
Date: Tue, 17 Jun 2025 07:54:38 +0000
Subject: [PATCH] platforms/i2c: i2c-usb: update a few nits
- Add a license statement.
-- Remove unneeded dynamic allocation for buf and directly passing the variable
- in i2c_usb_get_bus_status.
- Initialize all raw pointer variables to NULL.
- Specify the type in memcpy after calculation.
@@ -13,11 +11,11 @@
Google-Bug-Id: 416173054
Signed-off-by: Tom Tung <shes050117@gmail.com>
---
- drivers/i2c/busses/i2c-usb.c | 35 +++++++++++++++++++----------------
- 1 file changed, 19 insertions(+), 16 deletions(-)
+ drivers/i2c/busses/i2c-usb.c | 25 ++++++++++++++++++-------
+ 1 file changed, 18 insertions(+), 7 deletions(-)
diff --git a/drivers/i2c/busses/i2c-usb.c b/drivers/i2c/busses/i2c-usb.c
-index 29210020ea7b..0536c0ddf732 100644
+index 29210020ea7b..2b0c3449aa2d 100644
--- a/drivers/i2c/busses/i2c-usb.c
+++ b/drivers/i2c/busses/i2c-usb.c
@@ -1,4 +1,15 @@
@@ -36,29 +34,7 @@
* I2C-over-USB bus driver. Design doc: go/usb-i2c
*
* This drivers supports a limited subset of generic i2c commands which is
-@@ -222,20 +233,12 @@ static int i2c_usb_get_bus_status(struct i2c_usb_bus *bus)
- struct usb_device *usbdev = bus->usbdev;
- int ret;
- __le16 status;
-- u16 *buf;
--
-- buf = kzalloc(sizeof(u16), GFP_KERNEL);
-- if (!buf)
-- return -ENOMEM;
-
- ret = usb_control_msg(usbdev, usb_rcvctrlpipe(usbdev, 0),
- USB_REQ_GET_STATUS, I2C_USB_REQTYPE_BUS | USB_DIR_IN,
-- 0, bus->index, buf, sizeof(u16),
-+ 0, bus->index, &status, sizeof(status),
- I2C_USB_CTRL_READ_TIMEOUT_MS);
-
-- status = *buf;
-- kfree(buf);
--
- if (ret < 0) {
- dev_err(&bus->adap.dev, "GetBusStatus(%04x) failed: %d\n",
- bus->index, ret);
-@@ -461,14 +464,14 @@ static int i2c_usb_transfer(
+@@ -461,14 +472,14 @@ static int i2c_usb_transfer(
void *out_buf, size_t out_len,
void *read_buf, size_t read_len, size_t *actual_read)
{
@@ -77,7 +53,7 @@
priv = i2c_get_adapdata(&bus->adap);
mutex_lock(&priv->lock);
-@@ -482,7 +485,7 @@ static int i2c_usb_transfer(
+@@ -482,7 +493,7 @@ static int i2c_usb_transfer(
memcpy(wbuf, xfer, sizeof(*xfer));
if (out_buf)
@@ -86,7 +62,7 @@
priv->xfer.status = -EINPROGRESS;
init_completion(&priv->xfer.complete);
-@@ -834,7 +837,7 @@ static int i2c_usb_parse_intf_desc(struct i2c_usb_data *priv,
+@@ -834,7 +845,7 @@ static int i2c_usb_parse_intf_desc(struct i2c_usb_data *priv,
struct usb_host_interface *altsetting)
{
struct usb_interface *intf = priv->intf;
@@ -95,7 +71,7 @@
int buflen;
int ret;
-@@ -983,7 +986,7 @@ static int i2c_usb_probe(struct usb_interface *intf,
+@@ -983,7 +994,7 @@ static int i2c_usb_probe(struct usb_interface *intf,
static void i2c_usb_disconnect(struct usb_interface *interface)
{
@@ -105,5 +81,5 @@
priv = usb_get_intfdata(interface);
--
-2.50.0.rc2.696.g1fc2a0284f-goog
+2.50.0.727.gbf7dc18ff4-goog