Skip to contentSkip to conversation

i2c: robotfuzz-osif: Propagate parent device to I2C core

PATCH In review Andy Shevchenko 3 participants 5 messages Feb 4, 2022 – Feb 21, 2022 I2C subsystem host drivers

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 i2c: robotfuzz-osif: Propagate parent device to I2C core

I2C core might use parent device to retrieve properties of the controller. Propagate parent device for that.

Fixes 83e53a8f120f ("i2c: Add bus driver for for OSIF USB i2c device.")
Reported-by [email protected]
---
 drivers/i2c/busses/i2c-robotfuzz-osif.c | 2 ++
 1 file changed, 2 insertions(+)
drivers/i2c/busses/i2c-robotfuzz-osif.c +2 -0
index 66dfa211e736..bfbfa0d07bb2 100644
@@ -128,6 +128,7 @@ MODULE_DEVICE_TABLE(usb, osif_table);
 static int osif_probe(struct usb_interface *interface,
 			     const struct usb_device_id *id)
 {
+	struct device *dev = &interface->dev;
 	int ret;
 	struct osif_priv *priv;
 	u16 version;
@@ -145,6 +146,7 @@ static int osif_probe(struct usb_interface *interface,
 	priv->adapter.class = I2C_CLASS_HWMON;
 	priv->adapter.algo = &osif_algorithm;
 	priv->adapter.algo_data = priv;
+	priv->adapter.dev.parent = dev;
 	snprintf(priv->adapter.name, sizeof(priv->adapter.name),
 		 "OSIF at bus %03d device %03d",
 		 priv->usb_dev->bus->busnum, priv->usb_dev->devnum);
Signature · 1 line
2.34.1
#1 lore raw

drivers/i2c/busses/i2c-robotfuzz-osif.c MODULE_DEVICE_TABLE(usb, osif_table); · line 131

Quoted 2 lines
drivers/i2c/busses/i2c-robotfuzz-osif.c +1 -0
+	struct device *dev = &interface->dev;

This now creates a mixture of 'dev' and '&interface->dev'...

drivers/i2c/busses/i2c-robotfuzz-osif.c static int osif_probe(struct usb_interface *interface, · line 149

Quoted 1 line
drivers/i2c/busses/i2c-robotfuzz-osif.c +1 -0
+	priv->adapter.dev.parent = dev;

I propose to use &interface->dev here in this patch and convert to dev in a later patch?

#2 lore raw
Quoted 9 lines · Wolfram Sang

drivers/i2c/busses/i2c-robotfuzz-osif.c MODULE_DEVICE_TABLE(usb, osif_table); · line 131

Quoted 2 lines
drivers/i2c/busses/i2c-robotfuzz-osif.c +1 -0
+	struct device *dev = &interface->dev;

This now creates a mixture of 'dev' and '&interface->dev'...

drivers/i2c/busses/i2c-robotfuzz-osif.c static int osif_probe(struct usb_interface *interface, · line 149

Quoted 1 line
drivers/i2c/busses/i2c-robotfuzz-osif.c +1 -0
+	priv->adapter.dev.parent = dev;

I propose to use &interface->dev here in this patch and convert to dev in a later patch?

Why not?
Will do for next version (next week).

Signature · 2 lines
With Best Regards,
Andy Shevchenko
#3 lore raw
In reply to Andy Shevchenko
Quoted 2 lines · Andy Shevchenko

I2C core might use parent device to retrieve properties of the controller. Propagate parent device for that.

What is the problem you're trying to solve here?

If you've changed some core function so that the kernel crashes because of this, you need to address this in core.

Looks like you're also changing the device topology with this change.

This needs more details.

Quoted 1 line
Fixes 83e53a8f120f ("i2c: Add bus driver for for OSIF USB i2c device.")

This isn't the commit causing the NULL deref.

Quoted 19 lines
---
 drivers/i2c/busses/i2c-robotfuzz-osif.c | 2 ++
 1 file changed, 2 insertions(+)
drivers/i2c/busses/i2c-robotfuzz-osif.c +1 -0
index 66dfa211e736..bfbfa0d07bb2 100644
@@ -128,6 +128,7 @@ MODULE_DEVICE_TABLE(usb, osif_table);
 static int osif_probe(struct usb_interface *interface,
 			     const struct usb_device_id *id)
 {
+	struct device *dev = &interface->dev;
 	int ret;
 	struct osif_priv *priv;
 	u16 version;

drivers/i2c/busses/i2c-robotfuzz-osif.c static int osif_probe(struct usb_interface *interface, · line 152

Quoted 7 lines
drivers/i2c/busses/i2c-robotfuzz-osif.c +1 -0
@@ -145,6 +146,7 @@ static int osif_probe(struct usb_interface *interface,
 	priv->adapter.class = I2C_CLASS_HWMON;
 	priv->adapter.algo = &osif_algorithm;
 	priv->adapter.algo_data = priv;
+	priv->adapter.dev.parent = dev;
 	snprintf(priv->adapter.name, sizeof(priv->adapter.name),
 		 "OSIF at bus %03d device %03d",
 		 priv->usb_dev->bus->busnum, priv->usb_dev->devnum);

Johan

#4 lore raw
Quoted 5 lines · Johan Hovold
Quoted 2 lines · Andy Shevchenko

I2C core might use parent device to retrieve properties of the controller. Propagate parent device for that.

What is the problem you're trying to solve here?

Okay, let's drop the patch.

Signature · 2 lines
With Best Regards,
Andy Shevchenko