On Mon, Jul 13, 2026 at 05:11:58PM +0200, Bartosz Golaszewski wrote: > This driver intentionally uses the fine-grained approach to creating > platform devices. It assigns a software node as the primary firmware > node of the device it creates. Ahead of improving the reference counting > of platform device software nodes, switch to using > device_create_managed_software_node(). This way, we create a dynamic > software node whose life-time is tied to the device to which it's > assigned. > > Signed-off-by: Bartosz Golaszewski <[email protected]>
Cc: Heikki Krogerus <[email protected]> > --- > drivers/gpu/drm/xe/xe_i2c.c | 22 ++++++++-------------- > drivers/gpu/drm/xe/xe_i2c.h | 1 - Acked-by: Rodrigo Vivi <[email protected]> > 2 files changed, 8 insertions(+), 15 deletions(-) > > diff --git a/drivers/gpu/drm/xe/xe_i2c.c b/drivers/gpu/drm/xe/xe_i2c.c > index > 3d80eafb9a1318996d10db11e14af4cfde07ba55..af6e973e5e68125a9c006bb646447ca6e377a6e6 > 100644 > --- a/drivers/gpu/drm/xe/xe_i2c.c > +++ b/drivers/gpu/drm/xe/xe_i2c.c > @@ -93,13 +93,8 @@ static int xe_i2c_register_adapter(struct xe_i2c *i2c) > { > struct pci_dev *pci = to_pci_dev(i2c->drm_dev); > struct platform_device *pdev; > - struct fwnode_handle *fwnode; > int ret; > > - fwnode = fwnode_create_software_node(xe_i2c_adapter_properties, NULL); > - if (IS_ERR(fwnode)) > - return PTR_ERR(fwnode); > - > /* > * Not using platform_device_register_full() here because we don't have > * a handle to the platform_device before it returns. xe_i2c_notifier() > @@ -107,10 +102,14 @@ static int xe_i2c_register_adapter(struct xe_i2c *i2c) > * platform_device_register_full() is done. > */ > pdev = platform_device_alloc(adapter_name, pci_dev_id(pci)); > - if (!pdev) { > - ret = -ENOMEM; > - goto err_fwnode_remove; > - } > + if (!pdev) > + return -ENOMEM; > + > + ret = device_create_managed_software_node(&pdev->dev, > + xe_i2c_adapter_properties, > + NULL); > + if (ret) > + goto err_pdev_put; > > if (i2c->adapter_irq) { > struct resource res; > @@ -123,8 +122,6 @@ static int xe_i2c_register_adapter(struct xe_i2c *i2c) > } > > pdev->dev.parent = i2c->drm_dev; > - platform_device_set_fwnode(pdev, fwnode); > - i2c->adapter_node = fwnode; > i2c->pdev = pdev; > > ret = platform_device_add(pdev); > @@ -135,8 +132,6 @@ static int xe_i2c_register_adapter(struct xe_i2c *i2c) > > err_pdev_put: > platform_device_put(pdev); > -err_fwnode_remove: > - fwnode_remove_software_node(fwnode); > > return ret; > } > @@ -144,7 +139,6 @@ static int xe_i2c_register_adapter(struct xe_i2c *i2c) > static void xe_i2c_unregister_adapter(struct xe_i2c *i2c) > { > platform_device_unregister(i2c->pdev); > - fwnode_remove_software_node(i2c->adapter_node); > } > > /** > diff --git a/drivers/gpu/drm/xe/xe_i2c.h b/drivers/gpu/drm/xe/xe_i2c.h > index > 425d8160835f4648891ff75f2a9c06284241710e..b28229f056c5a664e1d41dc0cc1978782fe1c2f1 > 100644 > --- a/drivers/gpu/drm/xe/xe_i2c.h > +++ b/drivers/gpu/drm/xe/xe_i2c.h > @@ -30,7 +30,6 @@ struct xe_i2c_endpoint { > }; > > struct xe_i2c { > - struct fwnode_handle *adapter_node; > struct platform_device *pdev; > struct i2c_adapter *adapter; > struct i2c_client *client[XE_I2C_MAX_CLIENTS]; > > -- > 2.47.3 >
