Re: [PATCH 2/2] i2c: amd8111: switch to devm_ functions

From: Andy Shevchenko

Date: Mon Feb 23 2026 - 11:28:44 EST


On Mon, Feb 02, 2026 at 02:13:04PM +0100, Filippo Muscherà wrote:
> Use devm_kzalloc() to manage the memory allocation of the smbus structure
> and devm_request_region() to manage the I/O port region.
>
> This simplifies the error handling paths in the probe function by removing
> manual cleanup and allows for the removal of the explicit cleanup in the
> remove function.

...

> - if (!request_region(smbus->base, smbus->size, amd8111_driver.name)) {
> - error = -EBUSY;
> - goto out_kfree;
> - }
> + if (!devm_request_region(&dev->dev, smbus->base, smbus->size, amd8111_driver.name))
> + return -EBUSY;

This is a PCI driver. Why not using the pcim_enable_device() with the
respective pcim_*() call for the IO region?

I believe the driver misses pci_disable_device() as of the current
implementation, switching to pcim_*() should address that as well.

...

> static void amd8111_remove(struct pci_dev *dev)

> struct amd_smbus *smbus = pci_get_drvdata(dev);
>
> i2c_del_adapter(&smbus->adapter);
> - release_region(smbus->base, smbus->size);
> - kfree(smbus);

(Somewhere here I would expect pci_disable_device() to be called.)

> }

--
With Best Regards,
Andy Shevchenko