linux-pm.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 1/1] power: bq24257: Fix use of uninitialized pointer bq->charger
@ 2016-09-08  1:38 Georges Savoundararadj
  2016-09-19 18:57 ` Sebastian Reichel
  0 siblings, 1 reply; 2+ messages in thread
From: Georges Savoundararadj @ 2016-09-08  1:38 UTC (permalink / raw)
  To: linux-pm
  Cc: Georges Savoundararadj, Aurelien Chanot, Andreas Dannenberg,
	Sebastian Reichel, David Woodhouse

bq->charger is initialized in bq24257_power_supply_init.
Therefore, bq24257_power_supply_init should be called before the
registration of the IRQ handler bq24257_irq_handler_thread that calls
power_supply_changed(bq->charger).

Signed-off-by: Georges Savoundararadj <savoundg@gmail.com>
Cc: Aurelien Chanot <chanot.a@gmail.com>
Cc: Andreas Dannenberg <dannenberg@ti.com>
Cc: Sebastian Reichel <sre@kernel.org>
Cc: David Woodhouse <dwmw2@infradead.org>
---
 drivers/power/bq24257_charger.c | 12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)

diff --git a/drivers/power/bq24257_charger.c b/drivers/power/bq24257_charger.c
index 1fea2c7..6fc31bd 100644
--- a/drivers/power/bq24257_charger.c
+++ b/drivers/power/bq24257_charger.c
@@ -1068,6 +1068,12 @@ static int bq24257_probe(struct i2c_client *client,
 		return ret;
 	}
 
+	ret = bq24257_power_supply_init(bq);
+	if (ret < 0) {
+		dev_err(dev, "Failed to register power supply\n");
+		return ret;
+	}
+
 	ret = devm_request_threaded_irq(dev, client->irq, NULL,
 					bq24257_irq_handler_thread,
 					IRQF_TRIGGER_FALLING |
@@ -1078,12 +1084,6 @@ static int bq24257_probe(struct i2c_client *client,
 		return ret;
 	}
 
-	ret = bq24257_power_supply_init(bq);
-	if (ret < 0) {
-		dev_err(dev, "Failed to register power supply\n");
-		return ret;
-	}
-
 	ret = sysfs_create_group(&bq->charger->dev.kobj, &bq24257_attr_group);
 	if (ret < 0) {
 		dev_err(dev, "Can't create sysfs entries\n");
-- 
2.9.3


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH 1/1] power: bq24257: Fix use of uninitialized pointer bq->charger
  2016-09-08  1:38 [PATCH 1/1] power: bq24257: Fix use of uninitialized pointer bq->charger Georges Savoundararadj
@ 2016-09-19 18:57 ` Sebastian Reichel
  0 siblings, 0 replies; 2+ messages in thread
From: Sebastian Reichel @ 2016-09-19 18:57 UTC (permalink / raw)
  To: Georges Savoundararadj
  Cc: linux-pm, Aurelien Chanot, Andreas Dannenberg, David Woodhouse

[-- Attachment #1: Type: text/plain, Size: 1703 bytes --]

Hi,

On Wed, Sep 07, 2016 at 06:38:15PM -0700, Georges Savoundararadj wrote:
> bq->charger is initialized in bq24257_power_supply_init.
> Therefore, bq24257_power_supply_init should be called before the
> registration of the IRQ handler bq24257_irq_handler_thread that calls
> power_supply_changed(bq->charger).
> 
> Signed-off-by: Georges Savoundararadj <savoundg@gmail.com>
> Cc: Aurelien Chanot <chanot.a@gmail.com>
> Cc: Andreas Dannenberg <dannenberg@ti.com>
> Cc: Sebastian Reichel <sre@kernel.org>
> Cc: David Woodhouse <dwmw2@infradead.org>
> ---
>  drivers/power/bq24257_charger.c | 12 ++++++------
>  1 file changed, 6 insertions(+), 6 deletions(-)
> 
> diff --git a/drivers/power/bq24257_charger.c b/drivers/power/bq24257_charger.c
> index 1fea2c7..6fc31bd 100644
> --- a/drivers/power/bq24257_charger.c
> +++ b/drivers/power/bq24257_charger.c
> @@ -1068,6 +1068,12 @@ static int bq24257_probe(struct i2c_client *client,
>  		return ret;
>  	}
>  
> +	ret = bq24257_power_supply_init(bq);
> +	if (ret < 0) {
> +		dev_err(dev, "Failed to register power supply\n");
> +		return ret;
> +	}
> +
>  	ret = devm_request_threaded_irq(dev, client->irq, NULL,
>  					bq24257_irq_handler_thread,
>  					IRQF_TRIGGER_FALLING |
> @@ -1078,12 +1084,6 @@ static int bq24257_probe(struct i2c_client *client,
>  		return ret;
>  	}
>  
> -	ret = bq24257_power_supply_init(bq);
> -	if (ret < 0) {
> -		dev_err(dev, "Failed to register power supply\n");
> -		return ret;
> -	}
> -
>  	ret = sysfs_create_group(&bq->charger->dev.kobj, &bq24257_attr_group);
>  	if (ret < 0) {
>  		dev_err(dev, "Can't create sysfs entries\n");

Thanks, queued.

-- Sebastian

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 819 bytes --]

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2016-09-19 18:58 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-09-08  1:38 [PATCH 1/1] power: bq24257: Fix use of uninitialized pointer bq->charger Georges Savoundararadj
2016-09-19 18:57 ` Sebastian Reichel

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).