diff mbox series

[v1,1/2] media: atomisp: Put PMIC device after getting its I²C address

Message ID 20240326202813.1425431-2-andriy.shevchenko@linux.intel.com
State Accepted
Commit c780a2c6ae629e1d380753b4df8cbf0bc72f375e
Headers show
Series media: atomisp: Fix and refactor PMIC I��C discovery | expand

Commit Message

Andy Shevchenko March 26, 2024, 8:27 p.m. UTC
We don't use the PMIC I²C client device after getting its address.
Drop the reference to it. We do not expect device to disappear
as it should be taken care by the OpRegion drivers.

Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
---
 .../media/atomisp/pci/atomisp_gmin_platform.c       | 13 ++++++++-----
 1 file changed, 8 insertions(+), 5 deletions(-)

Comments

Hans de Goede April 10, 2024, 10:41 a.m. UTC | #1
Hi,

On 3/26/24 9:27 PM, Andy Shevchenko wrote:
> We don't use the PMIC I²C client device after getting its address.
> Drop the reference to it. We do not expect device to disappear
> as it should be taken care by the OpRegion drivers.
> 
> Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>

Thank you for your patch.

I have merged this in my media-atomisp branch:
https://git.kernel.org/pub/scm/linux/kernel/git/hansg/linux.git/log/?h=media-atomisp

And this patch will be included in my next
pull-request to Mauro (to media subsystem maintainer)

Regards,

Hans



> ---
>  .../media/atomisp/pci/atomisp_gmin_platform.c       | 13 ++++++++-----
>  1 file changed, 8 insertions(+), 5 deletions(-)
> 
> diff --git a/drivers/staging/media/atomisp/pci/atomisp_gmin_platform.c b/drivers/staging/media/atomisp/pci/atomisp_gmin_platform.c
> index 139ad7ad1dcf..80aa2211cdc3 100644
> --- a/drivers/staging/media/atomisp/pci/atomisp_gmin_platform.c
> +++ b/drivers/staging/media/atomisp/pci/atomisp_gmin_platform.c
> @@ -497,16 +497,19 @@ static u8 gmin_get_pmic_id_and_addr(struct device *dev)
>  	if (pmic_id)
>  		return pmic_i2c_addr;
>  
> -	if (gmin_i2c_dev_exists(dev, PMIC_ACPI_TI, &power))
> +	if (gmin_i2c_dev_exists(dev, PMIC_ACPI_TI, &power)) {
>  		pmic_id = PMIC_TI;
> -	else if (gmin_i2c_dev_exists(dev, PMIC_ACPI_AXP, &power))
> +	} else if (gmin_i2c_dev_exists(dev, PMIC_ACPI_AXP, &power)) {
>  		pmic_id = PMIC_AXP;
> -	else if (gmin_i2c_dev_exists(dev, PMIC_ACPI_CRYSTALCOVE, &power))
> +	} else if (gmin_i2c_dev_exists(dev, PMIC_ACPI_CRYSTALCOVE, &power)) {
>  		pmic_id = PMIC_CRYSTALCOVE;
> -	else
> +	} else {
>  		pmic_id = PMIC_REGULATOR;
> +		return 0;
> +	}
>  
> -	pmic_i2c_addr = power ? power->addr : 0;
> +	pmic_i2c_addr = power->addr;
> +	put_device(&power->dev);
>  	return pmic_i2c_addr;
>  }
>
diff mbox series

Patch

diff --git a/drivers/staging/media/atomisp/pci/atomisp_gmin_platform.c b/drivers/staging/media/atomisp/pci/atomisp_gmin_platform.c
index 139ad7ad1dcf..80aa2211cdc3 100644
--- a/drivers/staging/media/atomisp/pci/atomisp_gmin_platform.c
+++ b/drivers/staging/media/atomisp/pci/atomisp_gmin_platform.c
@@ -497,16 +497,19 @@  static u8 gmin_get_pmic_id_and_addr(struct device *dev)
 	if (pmic_id)
 		return pmic_i2c_addr;
 
-	if (gmin_i2c_dev_exists(dev, PMIC_ACPI_TI, &power))
+	if (gmin_i2c_dev_exists(dev, PMIC_ACPI_TI, &power)) {
 		pmic_id = PMIC_TI;
-	else if (gmin_i2c_dev_exists(dev, PMIC_ACPI_AXP, &power))
+	} else if (gmin_i2c_dev_exists(dev, PMIC_ACPI_AXP, &power)) {
 		pmic_id = PMIC_AXP;
-	else if (gmin_i2c_dev_exists(dev, PMIC_ACPI_CRYSTALCOVE, &power))
+	} else if (gmin_i2c_dev_exists(dev, PMIC_ACPI_CRYSTALCOVE, &power)) {
 		pmic_id = PMIC_CRYSTALCOVE;
-	else
+	} else {
 		pmic_id = PMIC_REGULATOR;
+		return 0;
+	}
 
-	pmic_i2c_addr = power ? power->addr : 0;
+	pmic_i2c_addr = power->addr;
+	put_device(&power->dev);
 	return pmic_i2c_addr;
 }