* [PATCH] max17042: propagate of_node to power supply device
@ 2018-02-20 15:03 Pierre Bourdon
2018-02-20 17:34 ` Andy Shevchenko
2018-02-22 20:40 ` Sebastian Reichel
0 siblings, 2 replies; 5+ messages in thread
From: Pierre Bourdon @ 2018-02-20 15:03 UTC (permalink / raw)
Cc: Pierre Bourdon, Andre Heider, Sebastian Reichel, linux-pm, linux-kernel
max17042_get_status uses the core power_supply_am_i_supplied. That
function relies on DT properties to figure out the power supply
topology, and will error out without DT.
Fixes max17042 battery status being reported as "unknown".
Signed-off-by: Andre Heider <a.heider@gmail.com>
---
drivers/power/supply/max17042_battery.c | 1 +
1 file changed, 1 insertion(+)
diff --git a/drivers/power/supply/max17042_battery.c b/drivers/power/supply/max17042_battery.c
index 35dde81b1c9b..1a568df383db 100644
--- a/drivers/power/supply/max17042_battery.c
+++ b/drivers/power/supply/max17042_battery.c
@@ -1053,6 +1053,7 @@ static int max17042_probe(struct i2c_client *client,
i2c_set_clientdata(client, chip);
psy_cfg.drv_data = chip;
+ psy_cfg.of_node = dev->of_node;
/* When current is not measured,
* CURRENT_NOW and CURRENT_AVG properties should be invisible. */
--
2.16.1.291.g4437f3f132-goog
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [PATCH] max17042: propagate of_node to power supply device
2018-02-20 15:03 [PATCH] max17042: propagate of_node to power supply device Pierre Bourdon
@ 2018-02-20 17:34 ` Andy Shevchenko
2018-02-20 17:58 ` Pierre Bourdon (delroth)
2018-02-22 20:40 ` Sebastian Reichel
1 sibling, 1 reply; 5+ messages in thread
From: Andy Shevchenko @ 2018-02-20 17:34 UTC (permalink / raw)
To: Pierre Bourdon
Cc: Andre Heider, Sebastian Reichel, Linux PM, Linux Kernel Mailing List
On Tue, Feb 20, 2018 at 5:03 PM, Pierre Bourdon <delroth@google.com> wrote:
> max17042_get_status uses the core power_supply_am_i_supplied. That
> function relies on DT properties to figure out the power supply
> topology, and will error out without DT.
> + psy_cfg.of_node = dev->of_node;
Perhaps do this in general manner, see how GPIOLIB takes care of it:
$ git grep -n -A4 -w CONFIG_OF_GPIO -- drivers/gpio/gpiolib.c
drivers/gpio/gpiolib.c:1161:#ifdef CONFIG_OF_GPIO
drivers/gpio/gpiolib.c-1162- /* If the gpiochip has an assigned OF
node this takes precedence */
drivers/gpio/gpiolib.c-1163- if (chip->of_node)
drivers/gpio/gpiolib.c-1164- gdev->dev.of_node = chip->of_node;
drivers/gpio/gpiolib.c-1165-#endif
...
--
With Best Regards,
Andy Shevchenko
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] max17042: propagate of_node to power supply device
2018-02-20 17:34 ` Andy Shevchenko
@ 2018-02-20 17:58 ` Pierre Bourdon (delroth)
2018-02-22 20:46 ` Sebastian Reichel
0 siblings, 1 reply; 5+ messages in thread
From: Pierre Bourdon (delroth) @ 2018-02-20 17:58 UTC (permalink / raw)
To: Andy Shevchenko
Cc: Andre Heider, Sebastian Reichel, Linux PM, Linux Kernel Mailing List
On Tue, Feb 20, 2018 at 6:34 PM, Andy Shevchenko
<andy.shevchenko@gmail.com> wrote:
> On Tue, Feb 20, 2018 at 5:03 PM, Pierre Bourdon <delroth@google.com> wrote:
>> max17042_get_status uses the core power_supply_am_i_supplied. That
>> function relies on DT properties to figure out the power supply
>> topology, and will error out without DT.
>
>> + psy_cfg.of_node = dev->of_node;
>
> Perhaps do this in general manner, see how GPIOLIB takes care of it:
>
> $ git grep -n -A4 -w CONFIG_OF_GPIO -- drivers/gpio/gpiolib.c
> drivers/gpio/gpiolib.c:1161:#ifdef CONFIG_OF_GPIO
> drivers/gpio/gpiolib.c-1162- /* If the gpiochip has an assigned OF
> node this takes precedence */
> drivers/gpio/gpiolib.c-1163- if (chip->of_node)
> drivers/gpio/gpiolib.c-1164- gdev->dev.of_node = chip->of_node;
> drivers/gpio/gpiolib.c-1165-#endif
> ...
Makes sense. From a quick look in existing drivers, it looks like the
only values being used currently as psy_cfg.of_node are the nodes from
the parent device, so it seems like it could be made generic.
Are we aware of any driver that is not propagating the of_node on
purpose? Is this something that should be supported? If not, I guess
we could get rid of power_supply_config.of_node and always use the one
from the parent device in __power_supply_register.
(I'm very new to this codebase, sorry for the possibly dumb questions!)
--
Pierre Bourdon (delroth@)
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] max17042: propagate of_node to power supply device
2018-02-20 15:03 [PATCH] max17042: propagate of_node to power supply device Pierre Bourdon
2018-02-20 17:34 ` Andy Shevchenko
@ 2018-02-22 20:40 ` Sebastian Reichel
1 sibling, 0 replies; 5+ messages in thread
From: Sebastian Reichel @ 2018-02-22 20:40 UTC (permalink / raw)
To: Pierre Bourdon; +Cc: Andre Heider, linux-pm, linux-kernel
[-- Attachment #1: Type: text/plain, Size: 1123 bytes --]
Hi,
On Tue, Feb 20, 2018 at 04:03:18PM +0100, Pierre Bourdon wrote:
> max17042_get_status uses the core power_supply_am_i_supplied. That
> function relies on DT properties to figure out the power supply
> topology, and will error out without DT.
>
> Fixes max17042 battery status being reported as "unknown".
>
> Signed-off-by: Andre Heider <a.heider@gmail.com>
> ---
Thanks, queued to power-supply's fixes branch.
-- Sebastian
> drivers/power/supply/max17042_battery.c | 1 +
> 1 file changed, 1 insertion(+)
>
> diff --git a/drivers/power/supply/max17042_battery.c b/drivers/power/supply/max17042_battery.c
> index 35dde81b1c9b..1a568df383db 100644
> --- a/drivers/power/supply/max17042_battery.c
> +++ b/drivers/power/supply/max17042_battery.c
> @@ -1053,6 +1053,7 @@ static int max17042_probe(struct i2c_client *client,
>
> i2c_set_clientdata(client, chip);
> psy_cfg.drv_data = chip;
> + psy_cfg.of_node = dev->of_node;
>
> /* When current is not measured,
> * CURRENT_NOW and CURRENT_AVG properties should be invisible. */
> --
> 2.16.1.291.g4437f3f132-goog
>
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] max17042: propagate of_node to power supply device
2018-02-20 17:58 ` Pierre Bourdon (delroth)
@ 2018-02-22 20:46 ` Sebastian Reichel
0 siblings, 0 replies; 5+ messages in thread
From: Sebastian Reichel @ 2018-02-22 20:46 UTC (permalink / raw)
To: Pierre Bourdon (delroth)
Cc: Andy Shevchenko, Andre Heider, Linux PM, Linux Kernel Mailing List
[-- Attachment #1: Type: text/plain, Size: 1812 bytes --]
Hi,
On Tue, Feb 20, 2018 at 06:58:56PM +0100, Pierre Bourdon (delroth) wrote:
> On Tue, Feb 20, 2018 at 6:34 PM, Andy Shevchenko
> <andy.shevchenko@gmail.com> wrote:
> > On Tue, Feb 20, 2018 at 5:03 PM, Pierre Bourdon <delroth@google.com> wrote:
> >> max17042_get_status uses the core power_supply_am_i_supplied. That
> >> function relies on DT properties to figure out the power supply
> >> topology, and will error out without DT.
> >
> >> + psy_cfg.of_node = dev->of_node;
> >
> > Perhaps do this in general manner, see how GPIOLIB takes care of it:
> >
> > $ git grep -n -A4 -w CONFIG_OF_GPIO -- drivers/gpio/gpiolib.c
> > drivers/gpio/gpiolib.c:1161:#ifdef CONFIG_OF_GPIO
> > drivers/gpio/gpiolib.c-1162- /* If the gpiochip has an assigned OF
> > node this takes precedence */
> > drivers/gpio/gpiolib.c-1163- if (chip->of_node)
> > drivers/gpio/gpiolib.c-1164- gdev->dev.of_node = chip->of_node;
> > drivers/gpio/gpiolib.c-1165-#endif
> > ...
>
> Makes sense. From a quick look in existing drivers, it looks like the
> only values being used currently as psy_cfg.of_node are the nodes from
> the parent device, so it seems like it could be made generic.
>
> Are we aware of any driver that is not propagating the of_node on
> purpose? Is this something that should be supported? If not, I guess
> we could get rid of power_supply_config.of_node and always use the one
> from the parent device in __power_supply_register.
>
> (I'm very new to this codebase, sorry for the possibly dumb questions!)
I think it makes sense to keep psy_cfg.of_node in case a driver
needs to use a subnode for some reason. I think it makes sense
to use dev->of_node as default value, though. Anyways I have
applied this patch to my fixes branch.
-- Sebastian
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2018-02-22 20:46 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-02-20 15:03 [PATCH] max17042: propagate of_node to power supply device Pierre Bourdon
2018-02-20 17:34 ` Andy Shevchenko
2018-02-20 17:58 ` Pierre Bourdon (delroth)
2018-02-22 20:46 ` Sebastian Reichel
2018-02-22 20:40 ` Sebastian Reichel
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.