Re: [PATCH 3/5] charger-manager: Add support sysfs entry for charger

From: Anton Vorontsov
Date: Fri Sep 21 2012 - 01:15:11 EST


On Tue, Aug 21, 2012 at 05:06:49PM +0900, Chanwoo Choi wrote:
> This patch add support sysfs entry for each charger(regulator).
> Charger-manager use one or more chargers for charging battery but
> some charger isn't necessary on specific scenario. So, if some charger
> isn't needed, can disable specific charger through 'externally_control'
> entry while system is on state and confirm the information(name, state)
> of charger.
>
> the list of added sysfs entry
> - /sys/class/power_supply/battery/chargers/charger.[index]/name
> : show name of charger(regulator)
> - /sys/class/power_supply/battery/chargers/charger.[index]/state
> : show either enabled or disabled state of charger
> - /sys/class/power_supply/battery/chargers/charger.[index]/externally_control

The API looks sane.

For the future, you might want to get rid of the 'name', and instead
just point to a regulator device (via a sysfs symlink). I.e.

/sys/class/power_supply/battery/chargers/charger.[index]/device
would be a symlink to the regulator device.

But for the time being, I guess it's OK as is (although I wouldn't
mind if it'll use the symlink from the start. :-)

[...]
> for (j = 0 ; j < charger->num_cables ; j++) {
> struct charger_cable *cable = &charger->cables[j];
> @@ -1287,6 +1386,71 @@ static int charger_manager_probe(struct platform_device *pdev)
> cable->charger = charger;
> cable->cm = cm;
> }
> +
[...]
> + charger->attr_g.attrs = charger->attrs;
> +
> + sysfs_attr_init(&cable->attr_name.attr);

Notice that 'cable' is declared in the 'for' loop above,
so this doesn't compile for me:

CHECK drivers/power/charger-manager.c
drivers/power/charger-manager.c:1559:17: error: undefined identifier 'cable'
drivers/power/charger-manager.c:1564:17: error: undefined identifier 'cable'
drivers/power/charger-manager.c:1569:17: error: undefined identifier 'cable'
CC drivers/power/charger-manager.o
drivers/power/charger-manager.c: In function âcharger_manager_probeâ:
drivers/power/charger-manager.c:1559:3: error: âcableâ undeclared (first use in this function)
drivers/power/charger-manager.c:1559:3: note: each undeclared identifier is reported only once for each function it appears in
make[1]: *** [drivers/power/charger-manager.o] Error 1

Also:
- Please adhere to the codingstyle, there should be no spaces
before ';' in the for loop statement.
- If possible, please consider splitting _probe routine, it is more
than 300 lines long nowadays.

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/