All of lore.kernel.org
 help / color / mirror / Atom feed
* RFI: devm_power_supply_register and sys/class name
@ 2016-06-09  9:39 Phil Reid
  2016-06-09 10:22 ` Krzysztof Kozlowski
  0 siblings, 1 reply; 3+ messages in thread
From: Phil Reid @ 2016-06-09  9:39 UTC (permalink / raw)
  To: linux-pm

G'day All,

I'm implementing a driver for a sbs manager chip (ltc1760) and running into a problem.
This is a dual smart battery charger ic.

Our hard has two of these connected via a i2c / smbus mux.

One registering the second device with devm_power_supply_register  I am getting a warning
in regards duplicate sysfs entries.
The first device creates this entry
/sys/class/power_supply/sbs-manager/

The second device also creates the same entry.

This name appears to come from power_supply_desc .name field.

Which needs to exists for the lifetime of the driver.
So I'm assuming I need to allocate local memory for this struct in the
driver and set a unique name.

Is this the correct way to go or should devm_power_supply_register be made more
flexible to ensure unique names?

Or have I missed something obvious (most likely this case I think)?


-- 
Regards
Phil Reid


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

* Re: RFI: devm_power_supply_register and sys/class name
  2016-06-09  9:39 RFI: devm_power_supply_register and sys/class name Phil Reid
@ 2016-06-09 10:22 ` Krzysztof Kozlowski
  2016-06-09 15:45   ` Phil Reid
  0 siblings, 1 reply; 3+ messages in thread
From: Krzysztof Kozlowski @ 2016-06-09 10:22 UTC (permalink / raw)
  To: Phil Reid; +Cc: linux-pm

On Thu, Jun 9, 2016 at 11:39 AM, Phil Reid <preid@electromag.com.au> wrote:
> G'day All,
>
> I'm implementing a driver for a sbs manager chip (ltc1760) and running into
> a problem.
> This is a dual smart battery charger ic.
>
> Our hard has two of these connected via a i2c / smbus mux.
>
> One registering the second device with devm_power_supply_register  I am
> getting a warning
> in regards duplicate sysfs entries.
> The first device creates this entry
> /sys/class/power_supply/sbs-manager/
>
> The second device also creates the same entry.
>
> This name appears to come from power_supply_desc .name field.
>
> Which needs to exists for the lifetime of the driver.
> So I'm assuming I need to allocate local memory for this struct in the
> driver and set a unique name.
>
> Is this the correct way to go or should devm_power_supply_register be made
> more
> flexible to ensure unique names?

Hi,

You need to provide one power_supply_desc per power supply instance.
So in your case - you need two of them (with different names). Look at
other drivers doing this.

Best regards,
Krzysztof

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

* Re: RFI: devm_power_supply_register and sys/class name
  2016-06-09 10:22 ` Krzysztof Kozlowski
@ 2016-06-09 15:45   ` Phil Reid
  0 siblings, 0 replies; 3+ messages in thread
From: Phil Reid @ 2016-06-09 15:45 UTC (permalink / raw)
  To: Krzysztof Kozlowski; +Cc: linux-pm

On 9/06/2016 18:22, Krzysztof Kozlowski wrote:
> On Thu, Jun 9, 2016 at 11:39 AM, Phil Reid <preid@electromag.com.au> wrote:
>> G'day All,
>>
>> I'm implementing a driver for a sbs manager chip (ltc1760) and running into
>> a problem.
>> This is a dual smart battery charger ic.
>>
>> Our hard has two of these connected via a i2c / smbus mux.
>>
>> One registering the second device with devm_power_supply_register  I am
>> getting a warning
>> in regards duplicate sysfs entries.
>> The first device creates this entry
>> /sys/class/power_supply/sbs-manager/
>>
>> The second device also creates the same entry.
>>
>> This name appears to come from power_supply_desc .name field.
>>
>> Which needs to exists for the lifetime of the driver.
>> So I'm assuming I need to allocate local memory for this struct in the
>> driver and set a unique name.
>>
>> Is this the correct way to go or should devm_power_supply_register be made
>> more
>> flexible to ensure unique names?
>
> Hi,
>
> You need to provide one power_supply_desc per power supply instance.
> So in your case - you need two of them (with different names). Look at
> other drivers doing this.
>

G'day Krzysztof,

The driver I was following max8998_charger.c used a static struct power_supply_desc.
So I wasn't 100% sure.
Thanks for clarifying.


-- 
Regards
Phil Reid


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

end of thread, other threads:[~2016-06-09 15:45 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-06-09  9:39 RFI: devm_power_supply_register and sys/class name Phil Reid
2016-06-09 10:22 ` Krzysztof Kozlowski
2016-06-09 15:45   ` Phil Reid

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.