aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/power
diff options
context:
space:
mode:
authorKrzysztof Kozlowski <k.kozlowski@samsung.com>2015-01-29 09:39:38 -0500
committerSebastian Reichel <sre@kernel.org>2015-02-25 16:26:32 -0500
commitc75cfa9e27818b67e55ef9153c3f4fb9c867f7f0 (patch)
treef32ae4397d076fd97a2214dc03764cd49b0ce2b8 /drivers/power
parente7143fdb79619b0b452b02f694e4d16649a0c449 (diff)
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: Krzysztof Kozlowski <k.kozlowski@samsung.com> Signed-off-by: Sebastian Reichel <sre@kernel.org>
Diffstat (limited to 'drivers/power')
-rw-r--r--drivers/power/ab8500_fg.c29
1 files changed, 11 insertions, 18 deletions
diff --git a/drivers/power/ab8500_fg.c b/drivers/power/ab8500_fg.c
index c908658aa31a..94d3b10a21ff 100644
--- a/drivers/power/ab8500_fg.c
+++ b/drivers/power/ab8500_fg.c
@@ -2954,44 +2954,37 @@ static struct device_attribute ab8505_fg_sysfs_psy_attrs[] = {
2954 ab8505_powercut_enable_status_read, NULL), 2954 ab8505_powercut_enable_status_read, NULL),
2955}; 2955};
2956 2956
2957static int ab8500_fg_sysfs_psy_create_attrs(struct device *dev) 2957static int ab8500_fg_sysfs_psy_create_attrs(struct ab8500_fg *di)
2958{ 2958{
2959 unsigned int i; 2959 unsigned int i;
2960 struct power_supply *psy = dev_get_drvdata(dev);
2961 struct ab8500_fg *di;
2962
2963 di = to_ab8500_fg_device_info(psy);
2964 2960
2965 if (((is_ab8505(di->parent) || is_ab9540(di->parent)) && 2961 if (((is_ab8505(di->parent) || is_ab9540(di->parent)) &&
2966 abx500_get_chip_id(dev->parent) >= AB8500_CUT2P0) 2962 abx500_get_chip_id(di->dev) >= AB8500_CUT2P0)
2967 || is_ab8540(di->parent)) { 2963 || is_ab8540(di->parent)) {
2968 for (i = 0; i < ARRAY_SIZE(ab8505_fg_sysfs_psy_attrs); i++) 2964 for (i = 0; i < ARRAY_SIZE(ab8505_fg_sysfs_psy_attrs); i++)
2969 if (device_create_file(dev, 2965 if (device_create_file(di->fg_psy.dev,
2970 &ab8505_fg_sysfs_psy_attrs[i])) 2966 &ab8505_fg_sysfs_psy_attrs[i]))
2971 goto sysfs_psy_create_attrs_failed_ab8505; 2967 goto sysfs_psy_create_attrs_failed_ab8505;
2972 } 2968 }
2973 return 0; 2969 return 0;
2974sysfs_psy_create_attrs_failed_ab8505: 2970sysfs_psy_create_attrs_failed_ab8505:
2975 dev_err(dev, "Failed creating sysfs psy attrs for ab8505.\n"); 2971 dev_err(di->fg_psy.dev, "Failed creating sysfs psy attrs for ab8505.\n");
2976 while (i--) 2972 while (i--)
2977 device_remove_file(dev, &ab8505_fg_sysfs_psy_attrs[i]); 2973 device_remove_file(di->fg_psy.dev, &ab8505_fg_sysfs_psy_attrs[i]);
2978 2974
2979 return -EIO; 2975 return -EIO;
2980} 2976}
2981 2977
2982static void ab8500_fg_sysfs_psy_remove_attrs(struct device *dev) 2978static void ab8500_fg_sysfs_psy_remove_attrs(struct ab8500_fg *di)
2983{ 2979{
2984 unsigned int i; 2980 unsigned int i;
2985 struct power_supply *psy = dev_get_drvdata(dev);
2986 struct ab8500_fg *di;
2987
2988 di = to_ab8500_fg_device_info(psy);
2989 2981
2990 if (((is_ab8505(di->parent) || is_ab9540(di->parent)) && 2982 if (((is_ab8505(di->parent) || is_ab9540(di->parent)) &&
2991 abx500_get_chip_id(dev->parent) >= AB8500_CUT2P0) 2983 abx500_get_chip_id(di->dev) >= AB8500_CUT2P0)
2992 || is_ab8540(di->parent)) { 2984 || is_ab8540(di->parent)) {
2993 for (i = 0; i < ARRAY_SIZE(ab8505_fg_sysfs_psy_attrs); i++) 2985 for (i = 0; i < ARRAY_SIZE(ab8505_fg_sysfs_psy_attrs); i++)
2994 (void)device_remove_file(dev, &ab8505_fg_sysfs_psy_attrs[i]); 2986 (void)device_remove_file(di->fg_psy.dev,
2987 &ab8505_fg_sysfs_psy_attrs[i]);
2995 } 2988 }
2996} 2989}
2997 2990
@@ -3056,7 +3049,7 @@ static int ab8500_fg_remove(struct platform_device *pdev)
3056 ab8500_fg_sysfs_exit(di); 3049 ab8500_fg_sysfs_exit(di);
3057 3050
3058 flush_scheduled_work(); 3051 flush_scheduled_work();
3059 ab8500_fg_sysfs_psy_remove_attrs(di->fg_psy.dev); 3052 ab8500_fg_sysfs_psy_remove_attrs(di);
3060 power_supply_unregister(&di->fg_psy); 3053 power_supply_unregister(&di->fg_psy);
3061 return ret; 3054 return ret;
3062} 3055}
@@ -3221,7 +3214,7 @@ static int ab8500_fg_probe(struct platform_device *pdev)
3221 goto free_irq; 3214 goto free_irq;
3222 } 3215 }
3223 3216
3224 ret = ab8500_fg_sysfs_psy_create_attrs(di->fg_psy.dev); 3217 ret = ab8500_fg_sysfs_psy_create_attrs(di);
3225 if (ret) { 3218 if (ret) {
3226 dev_err(di->dev, "failed to create FG psy\n"); 3219 dev_err(di->dev, "failed to create FG psy\n");
3227 ab8500_fg_sysfs_exit(di); 3220 ab8500_fg_sysfs_exit(di);