linux-pm.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* power_supply: Making "enum power_supply_type type" dynamic
@ 2015-07-02 17:56 Pallala, Ramakrishna
  2015-07-24 15:26 ` Sebastian Reichel
  0 siblings, 1 reply; 2+ messages in thread
From: Pallala, Ramakrishna @ 2015-07-02 17:56 UTC (permalink / raw)
  To: linux-pm@vger.kernel.org, Krzysztof Kozlowski, Sebastian Reichel

Hi Sebastian/Krzysztof,

Currently 'enum power_supply_type type' is part of 'struct power_supply_desc' which is again defined as a 'const *' in 'struct power_supply'

Can we move the 'enum power_supply_type type' to 'struct power_supply' itself?

Rational behind this is, if you take any mobile  or tablet device it comes with one USB charging port but it can support multiple charging cables like
SDP, CDP and DCP etc.. So whenever we connect any of these cables we need to adjust the charger parameters accordingly.

So the point here is, If we are using same physical charging port and the same charger IC for setting up the charging we can have one power supply class registration
from  the charger driver and change the power supply type based on the cable detection at runtime.

The current implementation forces us to create multiple power supply objects for each cable type which is not optimal as all these objects set/get methods
operate on the same set of registers.

Thanks,
Ram


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

* Re: power_supply: Making "enum power_supply_type type" dynamic
  2015-07-02 17:56 power_supply: Making "enum power_supply_type type" dynamic Pallala, Ramakrishna
@ 2015-07-24 15:26 ` Sebastian Reichel
  0 siblings, 0 replies; 2+ messages in thread
From: Sebastian Reichel @ 2015-07-24 15:26 UTC (permalink / raw)
  To: Pallala, Ramakrishna; +Cc: linux-pm@vger.kernel.org, Krzysztof Kozlowski

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

Hi,

On Thu, Jul 02, 2015 at 05:56:17PM +0000, Pallala, Ramakrishna wrote:
> Currently 'enum power_supply_type type' is part of 'struct
> power_supply_desc' which is again defined as a 'const *' in
> 'struct power_supply'
> 
> Can we move the 'enum power_supply_type type' to 'struct
> power_supply' itself?
> 
> Rational behind this is, if you take any mobile or tablet device
> it comes with one USB charging port but it can support multiple
> charging cables like SDP, CDP and DCP etc.. So whenever we connect
> any of these cables we need to adjust the charger parameters
> accordingly.
>
> So the point here is, If we are using same physical charging port
> and the same charger IC for setting up the charging we can have
> one power supply class registration from the charger driver and
> change the power supply type based on the cable detection at
> runtime.
> 
> The current implementation forces us to create multiple power
> supply objects for each cable type which is not optimal as all
> these objects set/get methods operate on the same set of
> registers.

Sounds legit. I would prefer not to modify all existing drivers, though.
Instead of 'moving' the type field I suggest the following strategy:

struct power_supply_desc {
    ...
    enum power_supply_type type;
    ...
}

struct power_supply {
    ...
    enum power_supply_type type;
    ...
}

struct power_supply * power_supply_register(...) {
    ...
    psy.type = psy_desc.type;
    ...
}

This way chargers with static type, batteries, ... do not have
to be changed at all and runtime changeable chargers have a
nice default value.

-- Sebastian

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

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

end of thread, other threads:[~2015-07-24 15:26 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-07-02 17:56 power_supply: Making "enum power_supply_type type" dynamic Pallala, Ramakrishna
2015-07-24 15:26 ` 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).