Use i2c_adapter_dev() where applicable in order to avoid direct
dereferencing of struct device embedded within struct i2c_adapter.
Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@oss.qualcomm.com>
---
drivers/i2c/busses/i2c-piix4.c | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/drivers/i2c/busses/i2c-piix4.c b/drivers/i2c/busses/i2c-piix4.c
index ac3bb550303fe5893822af50c385004c9292e695..4fe0c49284646a9f2910939c98b51ee6777e8b52 100644
--- a/drivers/i2c/busses/i2c-piix4.c
+++ b/drivers/i2c/busses/i2c-piix4.c
@@ -788,7 +788,7 @@ static s32 piix4_access_sb800(struct i2c_adapter *adap, u16 addr,
u8 prev_port;
int retval;
- retval = piix4_sb800_region_request(&adap->dev, &adapdata->mmio_cfg);
+ retval = piix4_sb800_region_request(i2c_adapter_dev(adap), &adapdata->mmio_cfg);
if (retval)
return retval;
@@ -859,7 +859,7 @@ static s32 piix4_access_sb800(struct i2c_adapter *adap, u16 addr,
piix4_imc_wakeup();
release:
- piix4_sb800_region_release(&adap->dev, &adapdata->mmio_cfg);
+ piix4_sb800_region_release(i2c_adapter_dev(adap), &adapdata->mmio_cfg);
return retval;
}
@@ -947,7 +947,7 @@ static int piix4_add_adapter(struct pci_dev *dev, unsigned short smba,
adap->dev.parent = &dev->dev;
if (has_acpi_companion(&dev->dev)) {
- acpi_preset_companion(&adap->dev,
+ acpi_preset_companion(i2c_adapter_dev(adap),
ACPI_COMPANION(&dev->dev),
hw_port_nr);
}
--
2.47.3
Hi Bartosz,
On Tue, 23 Dec 2025 11:08:19 +0100, Bartosz Golaszewski wrote:
> Use i2c_adapter_dev() where applicable in order to avoid direct
> dereferencing of struct device embedded within struct i2c_adapter.
I will confess that I don't know what is wrong with the current way of
embedding struct device in a more specific device structure. I seem to
recall it was fairly standard to do things this way back when we
implemented this in the i2c subsystem. But I will trust you that this
change is needed now.
>
> Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@oss.qualcomm.com>
> ---
> drivers/i2c/busses/i2c-piix4.c | 6 +++---
> 1 file changed, 3 insertions(+), 3 deletions(-)
>
> diff --git a/drivers/i2c/busses/i2c-piix4.c b/drivers/i2c/busses/i2c-piix4.c
> index ac3bb550303fe5893822af50c385004c9292e695..4fe0c49284646a9f2910939c98b51ee6777e8b52 100644
> --- a/drivers/i2c/busses/i2c-piix4.c
> +++ b/drivers/i2c/busses/i2c-piix4.c
> @@ -788,7 +788,7 @@ static s32 piix4_access_sb800(struct i2c_adapter *adap, u16 addr,
> u8 prev_port;
> int retval;
>
> - retval = piix4_sb800_region_request(&adap->dev, &adapdata->mmio_cfg);
> + retval = piix4_sb800_region_request(i2c_adapter_dev(adap), &adapdata->mmio_cfg);
> if (retval)
> return retval;
>
> @@ -859,7 +859,7 @@ static s32 piix4_access_sb800(struct i2c_adapter *adap, u16 addr,
> piix4_imc_wakeup();
>
> release:
> - piix4_sb800_region_release(&adap->dev, &adapdata->mmio_cfg);
> + piix4_sb800_region_release(i2c_adapter_dev(adap), &adapdata->mmio_cfg);
> return retval;
> }
>
> @@ -947,7 +947,7 @@ static int piix4_add_adapter(struct pci_dev *dev, unsigned short smba,
> adap->dev.parent = &dev->dev;
>
> if (has_acpi_companion(&dev->dev)) {
> - acpi_preset_companion(&adap->dev,
> + acpi_preset_companion(i2c_adapter_dev(adap),
> ACPI_COMPANION(&dev->dev),
> hw_port_nr);
> }
>
Acked-by: Jean Delvare <jdelvare@suse.de>
I see that you left one occurrence:
adap->dev.parent = &dev->dev;
I presume we'll need a wrapper for this construct as well?
Thanks,
--
Jean Delvare
SUSE L3 Support
Hi Jean, > > Use i2c_adapter_dev() where applicable in order to avoid direct > > dereferencing of struct device embedded within struct i2c_adapter. > > I will confess that I don't know what is wrong with the current way of > embedding struct device in a more specific device structure. I seem to > recall it was fairly standard to do things this way back when we > implemented this in the i2c subsystem. But I will trust you that this > change is needed now. I guess more people will wonder about the upcoming I2C core changes, so I wrote a bit of explanation: https://lore.kernel.org/all/aWYYZEPX-_1GfQtL@ninjato/ Happy hacking, Wolfram
© 2016 - 2026 Red Hat, Inc.