Re: [PATCH] extcon : callback function to read cable property

From: Anton Vorontsov
Date: Tue Nov 20 2012 - 06:24:30 EST


On Tue, Nov 20, 2012 at 11:08:54AM +0000, Tc, Jenny wrote:
[...]
> > | We may have:
> > | enum extcon_cable_type {
> > | EXTCON_CT_REGULATOR,
> > | EXTCON_CT_PSY,
> > | EXTCON_CT_CHARGER_CB,
> > | ...
> > | };
> > | and have the following included at struct extcon_cable:
> > | union {
> > | struct regulator *reg;
> > | struct power_supply *psy;
> > | struct charger_cable *charger_cb;
> > | ...
> > | } cable data;
> > | enum extcon_cable_type cable_type;
[...]
> struct charger_cable_props {
> unsigned long state;
> int mA;
> }
> struct extcon_cable {
> .....
> union {
> struct charger_cable_props chrgr_props;
> .....
> } data;
> enum extcon_cable_name cable_name;
> };
>
> This way we are not restricting the cable properties just to the charger cable.
> We can add other charger cable properties as we identify the properties for them.

Well, to me, it seems that if we have cable *type*, then having properties
of the cable is the next logical step.

So, personally I see nothing wrong with it.

But you can look at this at the different angle: the type is just another
property of the cable. Would it be better to have power_supply-like API
for extcon? :)

if (extcon->get_prop(extcon, EXC_PROP_TYPE) == EXC_TYPE_CHARGER)) {
int max_uA = extcon->get_prop(extcon, EXC_PROP_MAX_CURRENT;
...
}

> We can use the cable_name variable to identify which cable property to use.

This I didn't get, tho. Why would 'cable_name' tell us which property to
use?. The type of the cable defines a set of its properties -- this I can
understand.

Thanks,
Anton.
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/