Commit c75cfa9e authored by Krzysztof Kozlowski's avatar Krzysztof Kozlowski Committed by Sebastian Reichel

power_supply: ab8500_fg: Simplify creation and removal of sysfs entries

Simplify a little ab8500_fg_sysfs_psy_create_attrs () and
ab8500_fg_sysfs_psy_remove_attrs() functions because they received
pointer to power supply device which was then converted into power
supply instance. Then it was converted into struct ab8500_fg. The path
looked like:
	ab8500_fg->psy.dev -> psy -> ab8500_fg

Instead just pass pointer to struct ab8500_fg directly so all
conversions won't be necessary.
Signed-off-by: default avatarKrzysztof Kozlowski <k.kozlowski@samsung.com>
Signed-off-by: default avatarSebastian Reichel <sre@kernel.org>
parent e7143fdb
...@@ -2954,44 +2954,37 @@ static struct device_attribute ab8505_fg_sysfs_psy_attrs[] = { ...@@ -2954,44 +2954,37 @@ static struct device_attribute ab8505_fg_sysfs_psy_attrs[] = {
ab8505_powercut_enable_status_read, NULL), ab8505_powercut_enable_status_read, NULL),
}; };
static int ab8500_fg_sysfs_psy_create_attrs(struct device *dev) static int ab8500_fg_sysfs_psy_create_attrs(struct ab8500_fg *di)
{ {
unsigned int i; unsigned int i;
struct power_supply *psy = dev_get_drvdata(dev);
struct ab8500_fg *di;
di = to_ab8500_fg_device_info(psy);
if (((is_ab8505(di->parent) || is_ab9540(di->parent)) && if (((is_ab8505(di->parent) || is_ab9540(di->parent)) &&
abx500_get_chip_id(dev->parent) >= AB8500_CUT2P0) abx500_get_chip_id(di->dev) >= AB8500_CUT2P0)
|| is_ab8540(di->parent)) { || is_ab8540(di->parent)) {
for (i = 0; i < ARRAY_SIZE(ab8505_fg_sysfs_psy_attrs); i++) for (i = 0; i < ARRAY_SIZE(ab8505_fg_sysfs_psy_attrs); i++)
if (device_create_file(dev, if (device_create_file(di->fg_psy.dev,
&ab8505_fg_sysfs_psy_attrs[i])) &ab8505_fg_sysfs_psy_attrs[i]))
goto sysfs_psy_create_attrs_failed_ab8505; goto sysfs_psy_create_attrs_failed_ab8505;
} }
return 0; return 0;
sysfs_psy_create_attrs_failed_ab8505: sysfs_psy_create_attrs_failed_ab8505:
dev_err(dev, "Failed creating sysfs psy attrs for ab8505.\n"); dev_err(di->fg_psy.dev, "Failed creating sysfs psy attrs for ab8505.\n");
while (i--) while (i--)
device_remove_file(dev, &ab8505_fg_sysfs_psy_attrs[i]); device_remove_file(di->fg_psy.dev, &ab8505_fg_sysfs_psy_attrs[i]);
return -EIO; return -EIO;
} }
static void ab8500_fg_sysfs_psy_remove_attrs(struct device *dev) static void ab8500_fg_sysfs_psy_remove_attrs(struct ab8500_fg *di)
{ {
unsigned int i; unsigned int i;
struct power_supply *psy = dev_get_drvdata(dev);
struct ab8500_fg *di;
di = to_ab8500_fg_device_info(psy);
if (((is_ab8505(di->parent) || is_ab9540(di->parent)) && if (((is_ab8505(di->parent) || is_ab9540(di->parent)) &&
abx500_get_chip_id(dev->parent) >= AB8500_CUT2P0) abx500_get_chip_id(di->dev) >= AB8500_CUT2P0)
|| is_ab8540(di->parent)) { || is_ab8540(di->parent)) {
for (i = 0; i < ARRAY_SIZE(ab8505_fg_sysfs_psy_attrs); i++) for (i = 0; i < ARRAY_SIZE(ab8505_fg_sysfs_psy_attrs); i++)
(void)device_remove_file(dev, &ab8505_fg_sysfs_psy_attrs[i]); (void)device_remove_file(di->fg_psy.dev,
&ab8505_fg_sysfs_psy_attrs[i]);
} }
} }
...@@ -3056,7 +3049,7 @@ static int ab8500_fg_remove(struct platform_device *pdev) ...@@ -3056,7 +3049,7 @@ static int ab8500_fg_remove(struct platform_device *pdev)
ab8500_fg_sysfs_exit(di); ab8500_fg_sysfs_exit(di);
flush_scheduled_work(); flush_scheduled_work();
ab8500_fg_sysfs_psy_remove_attrs(di->fg_psy.dev); ab8500_fg_sysfs_psy_remove_attrs(di);
power_supply_unregister(&di->fg_psy); power_supply_unregister(&di->fg_psy);
return ret; return ret;
} }
...@@ -3221,7 +3214,7 @@ static int ab8500_fg_probe(struct platform_device *pdev) ...@@ -3221,7 +3214,7 @@ static int ab8500_fg_probe(struct platform_device *pdev)
goto free_irq; goto free_irq;
} }
ret = ab8500_fg_sysfs_psy_create_attrs(di->fg_psy.dev); ret = ab8500_fg_sysfs_psy_create_attrs(di);
if (ret) { if (ret) {
dev_err(di->dev, "failed to create FG psy\n"); dev_err(di->dev, "failed to create FG psy\n");
ab8500_fg_sysfs_exit(di); ab8500_fg_sysfs_exit(di);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment