All of lore.kernel.org
 help / color / mirror / Atom feed
From: Sebastian Reichel <sre@kernel.org>
To: "Pallala, Ramakrishna" <ramakrishna.pallala@intel.com>
Cc: "linux-pm@vger.kernel.org" <linux-pm@vger.kernel.org>,
	Krzysztof Kozlowski <k.kozlowski@samsung.com>
Subject: Re: power_supply: Making "enum power_supply_type type" dynamic
Date: Fri, 24 Jul 2015 17:26:47 +0200	[thread overview]
Message-ID: <20150724152647.GI27569@earth> (raw)
In-Reply-To: <D854C92F57B1B347B57E531E78D05EAD578645A4@BGSMSX104.gar.corp.intel.com>

[-- 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 --]

      reply	other threads:[~2015-07-24 15:26 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-07-02 17:56 power_supply: Making "enum power_supply_type type" dynamic Pallala, Ramakrishna
2015-07-24 15:26 ` Sebastian Reichel [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20150724152647.GI27569@earth \
    --to=sre@kernel.org \
    --cc=k.kozlowski@samsung.com \
    --cc=linux-pm@vger.kernel.org \
    --cc=ramakrishna.pallala@intel.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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.