* [PATCH] mfd: axp20x: Add supplied-from property to axp288_fuel_gauge cell
@ 2021-07-05 20:52 Hans de Goede
0 siblings, 0 replies; 6+ messages in thread
From: Hans de Goede @ 2021-07-05 20:52 UTC (permalink / raw)
To: Lee Jones, Chen-Yu Tsai; +Cc: Hans de Goede, linux-kernel
The power-supply framework has the notion of one power-supply device
being supplied by another. A typical example of this is a charger
charging a battery.
A tablet getting plugged in to charge (or plugged out) only results in
events seen by the axp288_charger device / MFD cell. Which means that
a change udev-event only gets send for the charger power-supply class
device, not for the battery (the axp288_fuel_gauge device).
The axp288_fuel_gauge does have an external_power_change'd callback
which will generate a change udev-event when called. But before this
commit this never got called because the power-supply core only calls
this when a power-supply class device's supplier changes and the
supplier link from axp288_charger to axp288_fuel_gauge was missing.
Add a "supplied-from" property to axp288_fuel_gauge cell, pointing
to the "axp288_charger" power-supply class device, so that the
axp288_fuel_gauge's external_power_change'd callback gets called on
axp288_charger state changes.
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
---
drivers/mfd/axp20x.c | 13 +++++++++++++
1 file changed, 13 insertions(+)
diff --git a/drivers/mfd/axp20x.c b/drivers/mfd/axp20x.c
index db6a21465594..a400141be995 100644
--- a/drivers/mfd/axp20x.c
+++ b/drivers/mfd/axp20x.c
@@ -700,6 +700,18 @@ static const struct resource axp288_charger_resources[] = {
DEFINE_RES_IRQ(AXP288_IRQ_CBTO),
};
+static const char * const axp288_fuel_gauge_suppliers[] = { "axp288_charger" };
+
+static const struct property_entry axp288_fuel_gauge_properties[] = {
+ PROPERTY_ENTRY_STRING_ARRAY("supplied-from", axp288_fuel_gauge_suppliers),
+ { }
+};
+
+static const struct software_node axp288_fuel_gauge_sw_node = {
+ .name = "axp288_fuel_gauge",
+ .properties = axp288_fuel_gauge_properties,
+};
+
static const struct mfd_cell axp288_cells[] = {
{
.name = "axp288_adc",
@@ -717,6 +729,7 @@ static const struct mfd_cell axp288_cells[] = {
.name = "axp288_fuel_gauge",
.num_resources = ARRAY_SIZE(axp288_fuel_gauge_resources),
.resources = axp288_fuel_gauge_resources,
+ .swnode = &axp288_fuel_gauge_sw_node,
}, {
.name = "axp221-pek",
.num_resources = ARRAY_SIZE(axp288_power_button_resources),
--
2.31.1
^ permalink raw reply related [flat|nested] 6+ messages in thread
* Re: [PATCH] mfd: axp20x: Add supplied-from property to axp288_fuel_gauge cell
2021-07-17 16:25 Hans de Goede
2021-07-18 3:51 ` Chen-Yu Tsai
2021-07-19 10:48 ` Lee Jones
@ 2021-08-05 13:11 ` Lee Jones
2 siblings, 0 replies; 6+ messages in thread
From: Lee Jones @ 2021-08-05 13:11 UTC (permalink / raw)
To: Hans de Goede; +Cc: Chen-Yu Tsai, C++ / GCC, linux-kernel
On Sat, 17 Jul 2021, Hans de Goede wrote:
> The power-supply framework has the notion of one power-supply device
> being supplied by another. A typical example of this is a charger
> charging a battery.
>
> A tablet getting plugged in to charge (or plugged out) only results in
> events seen by the axp288_charger device / MFD cell. Which means that
> a change udev-event only gets send for the charger power-supply class
> device, not for the battery (the axp288_fuel_gauge device).
>
> The axp288_fuel_gauge does have an external_power_change'd callback
> which will generate a change udev-event when called. But before this
> commit this never got called because the power-supply core only calls
> this when a power-supply class device's supplier changes and the
> supplier link from axp288_charger to axp288_fuel_gauge was missing.
>
> Add a "supplied-from" property to axp288_fuel_gauge cell, pointing
> to the "axp288_charger" power-supply class device, so that the
> axp288_fuel_gauge's external_power_change'd callback gets called on
> axp288_charger state changes.
>
> Signed-off-by: Hans de Goede <hdegoede@redhat.com>
> ---
> drivers/mfd/axp20x.c | 13 +++++++++++++
> 1 file changed, 13 insertions(+)
Applied, thanks.
--
Lee Jones [李琼斯]
Senior Technical Lead - Developer Services
Linaro.org │ Open source software for Arm SoCs
Follow Linaro: Facebook | Twitter | Blog
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] mfd: axp20x: Add supplied-from property to axp288_fuel_gauge cell
2021-07-19 10:48 ` Lee Jones
@ 2021-07-27 19:24 ` Hans de Goede
0 siblings, 0 replies; 6+ messages in thread
From: Hans de Goede @ 2021-07-27 19:24 UTC (permalink / raw)
To: Lee Jones; +Cc: Chen-Yu Tsai, C++ / GCC, linux-kernel
Hi Lee,
On 7/19/21 12:48 PM, Lee Jones wrote:
> On Sat, 17 Jul 2021, Hans de Goede wrote:
>
>> The power-supply framework has the notion of one power-supply device
>> being supplied by another. A typical example of this is a charger
>> charging a battery.
>>
>> A tablet getting plugged in to charge (or plugged out) only results in
>> events seen by the axp288_charger device / MFD cell. Which means that
>> a change udev-event only gets send for the charger power-supply class
>> device, not for the battery (the axp288_fuel_gauge device).
>>
>> The axp288_fuel_gauge does have an external_power_change'd callback
>> which will generate a change udev-event when called. But before this
>> commit this never got called because the power-supply core only calls
>> this when a power-supply class device's supplier changes and the
>> supplier link from axp288_charger to axp288_fuel_gauge was missing.
>>
>> Add a "supplied-from" property to axp288_fuel_gauge cell, pointing
>> to the "axp288_charger" power-supply class device, so that the
>> axp288_fuel_gauge's external_power_change'd callback gets called on
>> axp288_charger state changes.
>>
>> Signed-off-by: Hans de Goede <hdegoede@redhat.com>
>> ---
>> drivers/mfd/axp20x.c | 13 +++++++++++++
>> 1 file changed, 13 insertions(+)
>>
>> diff --git a/drivers/mfd/axp20x.c b/drivers/mfd/axp20x.c
>> index d0ac019850d1..8161a5dc68e8 100644
>> --- a/drivers/mfd/axp20x.c
>> +++ b/drivers/mfd/axp20x.c
>> @@ -700,6 +700,18 @@ static const struct resource axp288_charger_resources[] = {
>> DEFINE_RES_IRQ(AXP288_IRQ_CBTO),
>> };
>>
>> +static const char * const axp288_fuel_gauge_suppliers[] = { "axp288_charger" };
>> +
>> +static const struct property_entry axp288_fuel_gauge_properties[] = {
>> + PROPERTY_ENTRY_STRING_ARRAY("supplied-from", axp288_fuel_gauge_suppliers),
>> + { }
>> +};
>> +
>> +static const struct software_node axp288_fuel_gauge_sw_node = {
>> + .name = "axp288_fuel_gauge",
>> + .properties = axp288_fuel_gauge_properties,
>> +};
>> +
>> static const struct mfd_cell axp288_cells[] = {
>> {
>> .name = "axp288_adc",
>> @@ -717,6 +729,7 @@ static const struct mfd_cell axp288_cells[] = {
>> .name = "axp288_fuel_gauge",
>> .num_resources = ARRAY_SIZE(axp288_fuel_gauge_resources),
>> .resources = axp288_fuel_gauge_resources,
>> + .swnode = &axp288_fuel_gauge_sw_node,
>> }, {
>> .name = "axp221-pek",
>> .num_resources = ARRAY_SIZE(axp288_power_button_resources),
>
> That's a lot of code to pass a string.
>
> Is this really the most efficient method?
Currently there is no other method to provide information about the supplier
consumer relation for non device-tree platforms (in device-tree platforms
this info is present inside the device-tree), so yes this is the most
efficient method available.
Regards,
Hans
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] mfd: axp20x: Add supplied-from property to axp288_fuel_gauge cell
2021-07-17 16:25 Hans de Goede
2021-07-18 3:51 ` Chen-Yu Tsai
@ 2021-07-19 10:48 ` Lee Jones
2021-07-27 19:24 ` Hans de Goede
2021-08-05 13:11 ` Lee Jones
2 siblings, 1 reply; 6+ messages in thread
From: Lee Jones @ 2021-07-19 10:48 UTC (permalink / raw)
To: Hans de Goede; +Cc: Chen-Yu Tsai, C++ / GCC, linux-kernel
On Sat, 17 Jul 2021, Hans de Goede wrote:
> The power-supply framework has the notion of one power-supply device
> being supplied by another. A typical example of this is a charger
> charging a battery.
>
> A tablet getting plugged in to charge (or plugged out) only results in
> events seen by the axp288_charger device / MFD cell. Which means that
> a change udev-event only gets send for the charger power-supply class
> device, not for the battery (the axp288_fuel_gauge device).
>
> The axp288_fuel_gauge does have an external_power_change'd callback
> which will generate a change udev-event when called. But before this
> commit this never got called because the power-supply core only calls
> this when a power-supply class device's supplier changes and the
> supplier link from axp288_charger to axp288_fuel_gauge was missing.
>
> Add a "supplied-from" property to axp288_fuel_gauge cell, pointing
> to the "axp288_charger" power-supply class device, so that the
> axp288_fuel_gauge's external_power_change'd callback gets called on
> axp288_charger state changes.
>
> Signed-off-by: Hans de Goede <hdegoede@redhat.com>
> ---
> drivers/mfd/axp20x.c | 13 +++++++++++++
> 1 file changed, 13 insertions(+)
>
> diff --git a/drivers/mfd/axp20x.c b/drivers/mfd/axp20x.c
> index d0ac019850d1..8161a5dc68e8 100644
> --- a/drivers/mfd/axp20x.c
> +++ b/drivers/mfd/axp20x.c
> @@ -700,6 +700,18 @@ static const struct resource axp288_charger_resources[] = {
> DEFINE_RES_IRQ(AXP288_IRQ_CBTO),
> };
>
> +static const char * const axp288_fuel_gauge_suppliers[] = { "axp288_charger" };
> +
> +static const struct property_entry axp288_fuel_gauge_properties[] = {
> + PROPERTY_ENTRY_STRING_ARRAY("supplied-from", axp288_fuel_gauge_suppliers),
> + { }
> +};
> +
> +static const struct software_node axp288_fuel_gauge_sw_node = {
> + .name = "axp288_fuel_gauge",
> + .properties = axp288_fuel_gauge_properties,
> +};
> +
> static const struct mfd_cell axp288_cells[] = {
> {
> .name = "axp288_adc",
> @@ -717,6 +729,7 @@ static const struct mfd_cell axp288_cells[] = {
> .name = "axp288_fuel_gauge",
> .num_resources = ARRAY_SIZE(axp288_fuel_gauge_resources),
> .resources = axp288_fuel_gauge_resources,
> + .swnode = &axp288_fuel_gauge_sw_node,
> }, {
> .name = "axp221-pek",
> .num_resources = ARRAY_SIZE(axp288_power_button_resources),
That's a lot of code to pass a string.
Is this really the most efficient method?
--
Lee Jones [李琼斯]
Senior Technical Lead - Developer Services
Linaro.org │ Open source software for Arm SoCs
Follow Linaro: Facebook | Twitter | Blog
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] mfd: axp20x: Add supplied-from property to axp288_fuel_gauge cell
2021-07-17 16:25 Hans de Goede
@ 2021-07-18 3:51 ` Chen-Yu Tsai
2021-07-19 10:48 ` Lee Jones
2021-08-05 13:11 ` Lee Jones
2 siblings, 0 replies; 6+ messages in thread
From: Chen-Yu Tsai @ 2021-07-18 3:51 UTC (permalink / raw)
To: Hans de Goede; +Cc: Lee Jones, C++ / GCC, linux-kernel
On Sun, Jul 18, 2021 at 12:25 AM Hans de Goede <hdegoede@redhat.com> wrote:
>
> The power-supply framework has the notion of one power-supply device
> being supplied by another. A typical example of this is a charger
> charging a battery.
>
> A tablet getting plugged in to charge (or plugged out) only results in
> events seen by the axp288_charger device / MFD cell. Which means that
> a change udev-event only gets send for the charger power-supply class
> device, not for the battery (the axp288_fuel_gauge device).
>
> The axp288_fuel_gauge does have an external_power_change'd callback
> which will generate a change udev-event when called. But before this
> commit this never got called because the power-supply core only calls
> this when a power-supply class device's supplier changes and the
> supplier link from axp288_charger to axp288_fuel_gauge was missing.
>
> Add a "supplied-from" property to axp288_fuel_gauge cell, pointing
> to the "axp288_charger" power-supply class device, so that the
> axp288_fuel_gauge's external_power_change'd callback gets called on
> axp288_charger state changes.
>
> Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Makes sense to me.
Reviewed-by: Chen-Yu Tsai <wens@csie.org>
^ permalink raw reply [flat|nested] 6+ messages in thread
* [PATCH] mfd: axp20x: Add supplied-from property to axp288_fuel_gauge cell
@ 2021-07-17 16:25 Hans de Goede
2021-07-18 3:51 ` Chen-Yu Tsai
` (2 more replies)
0 siblings, 3 replies; 6+ messages in thread
From: Hans de Goede @ 2021-07-17 16:25 UTC (permalink / raw)
To: Lee Jones, Chen-Yu Tsai; +Cc: Hans de Goede, C++ / GCC, linux-kernel
The power-supply framework has the notion of one power-supply device
being supplied by another. A typical example of this is a charger
charging a battery.
A tablet getting plugged in to charge (or plugged out) only results in
events seen by the axp288_charger device / MFD cell. Which means that
a change udev-event only gets send for the charger power-supply class
device, not for the battery (the axp288_fuel_gauge device).
The axp288_fuel_gauge does have an external_power_change'd callback
which will generate a change udev-event when called. But before this
commit this never got called because the power-supply core only calls
this when a power-supply class device's supplier changes and the
supplier link from axp288_charger to axp288_fuel_gauge was missing.
Add a "supplied-from" property to axp288_fuel_gauge cell, pointing
to the "axp288_charger" power-supply class device, so that the
axp288_fuel_gauge's external_power_change'd callback gets called on
axp288_charger state changes.
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
---
drivers/mfd/axp20x.c | 13 +++++++++++++
1 file changed, 13 insertions(+)
diff --git a/drivers/mfd/axp20x.c b/drivers/mfd/axp20x.c
index d0ac019850d1..8161a5dc68e8 100644
--- a/drivers/mfd/axp20x.c
+++ b/drivers/mfd/axp20x.c
@@ -700,6 +700,18 @@ static const struct resource axp288_charger_resources[] = {
DEFINE_RES_IRQ(AXP288_IRQ_CBTO),
};
+static const char * const axp288_fuel_gauge_suppliers[] = { "axp288_charger" };
+
+static const struct property_entry axp288_fuel_gauge_properties[] = {
+ PROPERTY_ENTRY_STRING_ARRAY("supplied-from", axp288_fuel_gauge_suppliers),
+ { }
+};
+
+static const struct software_node axp288_fuel_gauge_sw_node = {
+ .name = "axp288_fuel_gauge",
+ .properties = axp288_fuel_gauge_properties,
+};
+
static const struct mfd_cell axp288_cells[] = {
{
.name = "axp288_adc",
@@ -717,6 +729,7 @@ static const struct mfd_cell axp288_cells[] = {
.name = "axp288_fuel_gauge",
.num_resources = ARRAY_SIZE(axp288_fuel_gauge_resources),
.resources = axp288_fuel_gauge_resources,
+ .swnode = &axp288_fuel_gauge_sw_node,
}, {
.name = "axp221-pek",
.num_resources = ARRAY_SIZE(axp288_power_button_resources),
--
2.31.1
^ permalink raw reply related [flat|nested] 6+ messages in thread
end of thread, other threads:[~2021-08-05 13:11 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-07-05 20:52 [PATCH] mfd: axp20x: Add supplied-from property to axp288_fuel_gauge cell Hans de Goede
2021-07-17 16:25 Hans de Goede
2021-07-18 3:51 ` Chen-Yu Tsai
2021-07-19 10:48 ` Lee Jones
2021-07-27 19:24 ` Hans de Goede
2021-08-05 13:11 ` Lee Jones
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).