]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
mfd/power: ab8500: Push data to power supply code
authorLinus Walleij <linus.walleij@linaro.org>
Fri, 12 Mar 2021 08:36:02 +0000 (09:36 +0100)
committerLee Jones <lee.jones@linaro.org>
Mon, 22 Mar 2021 14:55:38 +0000 (14:55 +0000)
The global definition of platform data for the battery
management code has no utility after the OF conversion,
move the <linux/mfd/abx500/ab8500-bm.h> to be a local
file in drivers/power/supply and stop defining the
platform data in drivers/power/supply/ab8500_bmdata.c
and broadcast to the kernel only to have it assigned
as platform data to the MFD cells and then picked back
into the same subsystem that defined it in the first
place. This kills off a layer of indirection.

Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
Acked-by: Sebastian Reichel <sebastian.reichel@collabora.com>
Signed-off-by: Lee Jones <lee.jones@linaro.org>
drivers/mfd/ab8500-core.c
drivers/power/supply/ab8500-bm.h [moved from include/linux/mfd/abx500/ab8500-bm.h with 96% similarity]
drivers/power/supply/ab8500_bmdata.c
drivers/power/supply/ab8500_btemp.c
drivers/power/supply/ab8500_charger.c
drivers/power/supply/ab8500_fg.c
drivers/power/supply/abx500_chargalg.c
drivers/power/supply/pm2301_charger.c

index a9037911162b56034831ddc4fe6b4fc814133760..22c0e3d876290d56fdea4b9bd09cd23d8bf44a7a 100644 (file)
@@ -19,7 +19,6 @@
 #include <linux/mfd/core.h>
 #include <linux/mfd/abx500.h>
 #include <linux/mfd/abx500/ab8500.h>
-#include <linux/mfd/abx500/ab8500-bm.h>
 #include <linux/mfd/dbx500-prcmu.h>
 #include <linux/of.h>
 #include <linux/of_device.h>
@@ -609,14 +608,14 @@ int ab8500_suspend(struct ab8500 *ab8500)
 }
 
 static const struct mfd_cell ab8500_bm_devs[] = {
-       MFD_CELL_OF("ab8500-charger", NULL, &ab8500_bm_data,
-                   sizeof(ab8500_bm_data), 0, "stericsson,ab8500-charger"),
-       MFD_CELL_OF("ab8500-btemp", NULL, &ab8500_bm_data,
-                   sizeof(ab8500_bm_data), 0, "stericsson,ab8500-btemp"),
-       MFD_CELL_OF("ab8500-fg", NULL, &ab8500_bm_data,
-                   sizeof(ab8500_bm_data), 0, "stericsson,ab8500-fg"),
-       MFD_CELL_OF("ab8500-chargalg", NULL, &ab8500_bm_data,
-                   sizeof(ab8500_bm_data), 0, "stericsson,ab8500-chargalg"),
+       MFD_CELL_OF("ab8500-charger", NULL, NULL, 0, 0,
+                   "stericsson,ab8500-charger"),
+       MFD_CELL_OF("ab8500-btemp", NULL, NULL, 0, 0,
+                   "stericsson,ab8500-btemp"),
+       MFD_CELL_OF("ab8500-fg", NULL, NULL, 0, 0,
+                   "stericsson,ab8500-fg"),
+       MFD_CELL_OF("ab8500-chargalg", NULL, NULL, 0, 0,
+                   "stericsson,ab8500-chargalg"),
 };
 
 static const struct mfd_cell ab8500_devs[] = {
similarity index 96%
rename from include/linux/mfd/abx500/ab8500-bm.h
rename to drivers/power/supply/ab8500-bm.h
index 903e94c189d8a9781ac6874ad29675710051b610..a1b31c971a45806fe81a054d566a186d65341959 100644 (file)
@@ -1,12 +1,7 @@
 /* SPDX-License-Identifier: GPL-2.0-only */
-/*
- * Copyright ST-Ericsson 2012.
- *
- * Author: Arun Murthy <arun.murthy@stericsson.com>
- */
 
-#ifndef _AB8500_BM_H
-#define _AB8500_BM_H
+#ifndef _AB8500_CHARGER_H_
+#define _AB8500_CHARGER_H_
 
 #include <linux/kernel.h>
 #include <linux/mfd/abx500.h>
@@ -453,16 +448,11 @@ struct ab8500_bm_data {
 };
 
 struct ab8500_btemp;
-struct ab8500_gpadc;
 struct ab8500_fg;
 
-#ifdef CONFIG_AB8500_BM
 extern struct abx500_bm_data ab8500_bm_data;
 
 void ab8500_charger_usb_state_changed(u8 bm_usb_state, u16 mA);
-struct ab8500_btemp *ab8500_btemp_get(void);
-int ab8500_btemp_get_batctrl_temp(struct ab8500_btemp *btemp);
-int ab8500_btemp_get_temp(struct ab8500_btemp *btemp);
 struct ab8500_fg *ab8500_fg_get(void);
 int ab8500_fg_inst_curr_blocking(struct ab8500_fg *dev);
 int ab8500_fg_inst_curr_start(struct ab8500_fg *di);
@@ -470,7 +460,4 @@ int ab8500_fg_inst_curr_finalize(struct ab8500_fg *di, int *res);
 int ab8500_fg_inst_curr_started(struct ab8500_fg *di);
 int ab8500_fg_inst_curr_done(struct ab8500_fg *di);
 
-#else
-static struct abx500_bm_data ab8500_bm_data;
-#endif
-#endif /* _AB8500_BM_H */
+#endif /* _AB8500_CHARGER_H_ */
index f6a66979cbb5238882a7dc7b41eb8d93383b9c97..c2b8c0bb77e275c67671f4c224f41b2c400b5bc3 100644 (file)
@@ -4,7 +4,8 @@
 #include <linux/of.h>
 #include <linux/mfd/abx500.h>
 #include <linux/mfd/abx500/ab8500.h>
-#include <linux/mfd/abx500/ab8500-bm.h>
+
+#include "ab8500-bm.h"
 
 /*
  * These are the defined batteries that uses a NTC and ID resistor placed
index 3cec0affd8660d05e33c5ef759c5158db33033b7..fdfcd59fc43e3789a3a18ae5adf304cbb6b732f2 100644 (file)
 #include <linux/mfd/core.h>
 #include <linux/mfd/abx500.h>
 #include <linux/mfd/abx500/ab8500.h>
-#include <linux/mfd/abx500/ab8500-bm.h>
 #include <linux/iio/consumer.h>
 
+#include "ab8500-bm.h"
+
 #define VTVOUT_V                       1800
 
 #define BTEMP_THERMAL_LOW_LIMIT                -10
@@ -119,16 +120,6 @@ static enum power_supply_property ab8500_btemp_props[] = {
 
 static LIST_HEAD(ab8500_btemp_list);
 
-/**
- * ab8500_btemp_get() - returns a reference to the primary AB8500 BTEMP
- * (i.e. the first BTEMP in the instance list)
- */
-struct ab8500_btemp *ab8500_btemp_get(void)
-{
-       return list_first_entry(&ab8500_btemp_list, struct ab8500_btemp, node);
-}
-EXPORT_SYMBOL(ab8500_btemp_get);
-
 /**
  * ab8500_btemp_batctrl_volt_to_res() - convert batctrl voltage to resistance
  * @di:                pointer to the ab8500_btemp structure
@@ -754,7 +745,7 @@ static void ab8500_btemp_periodic(struct ab8500_btemp *di,
  *
  * Returns battery temperature
  */
-int ab8500_btemp_get_temp(struct ab8500_btemp *di)
+static int ab8500_btemp_get_temp(struct ab8500_btemp *di)
 {
        int temp = 0;
 
@@ -790,19 +781,6 @@ int ab8500_btemp_get_temp(struct ab8500_btemp *di)
        }
        return temp;
 }
-EXPORT_SYMBOL(ab8500_btemp_get_temp);
-
-/**
- * ab8500_btemp_get_batctrl_temp() - get the temperature
- * @btemp:      pointer to the btemp structure
- *
- * Returns the batctrl temperature in millidegrees
- */
-int ab8500_btemp_get_batctrl_temp(struct ab8500_btemp *btemp)
-{
-       return btemp->bat_temp * 1000;
-}
-EXPORT_SYMBOL(ab8500_btemp_get_batctrl_temp);
 
 /**
  * ab8500_btemp_get_property() - get the btemp properties
@@ -991,7 +969,6 @@ static const struct power_supply_desc ab8500_btemp_desc = {
 static int ab8500_btemp_probe(struct platform_device *pdev)
 {
        struct device_node *np = pdev->dev.of_node;
-       struct abx500_bm_data *plat = pdev->dev.platform_data;
        struct power_supply_config psy_cfg = {};
        struct device *dev = &pdev->dev;
        struct ab8500_btemp *di;
@@ -1002,11 +979,7 @@ static int ab8500_btemp_probe(struct platform_device *pdev)
        if (!di)
                return -ENOMEM;
 
-       if (!plat) {
-               dev_err(dev, "no battery management data supplied\n");
-               return -EINVAL;
-       }
-       di->bm = plat;
+       di->bm = &ab8500_bm_data;
 
        ret = ab8500_bm_of_probe(dev, np, di->bm);
        if (ret) {
index aa573cd299e2c4a82a4512e03c987eb141f45d48..50989a5ec95c2d170154d67d5d83279653b25927 100644 (file)
 #include <linux/mfd/core.h>
 #include <linux/mfd/abx500/ab8500.h>
 #include <linux/mfd/abx500.h>
-#include <linux/mfd/abx500/ab8500-bm.h>
 #include <linux/mfd/abx500/ux500_chargalg.h>
 #include <linux/usb/otg.h>
 #include <linux/mutex.h>
 #include <linux/iio/consumer.h>
 
+#include "ab8500-bm.h"
+
 /* Charger constants */
 #define NO_PW_CONN                     0
 #define AC_PW_CONN                     1
@@ -3344,7 +3345,6 @@ static const struct power_supply_desc ab8500_usb_chg_desc = {
 static int ab8500_charger_probe(struct platform_device *pdev)
 {
        struct device_node *np = pdev->dev.of_node;
-       struct abx500_bm_data *plat = pdev->dev.platform_data;
        struct power_supply_config ac_psy_cfg = {}, usb_psy_cfg = {};
        struct ab8500_charger *di;
        int irq, i, charger_status, ret = 0, ch_stat;
@@ -3354,11 +3354,7 @@ static int ab8500_charger_probe(struct platform_device *pdev)
        if (!di)
                return -ENOMEM;
 
-       if (!plat) {
-               dev_err(dev, "no battery management data supplied\n");
-               return -EINVAL;
-       }
-       di->bm = plat;
+       di->bm = &ab8500_bm_data;
 
        ret = ab8500_bm_of_probe(dev, np, di->bm);
        if (ret) {
index 079e11325a810ae24cc79c1c141973d1e1b225fb..0c7c01a0d9790f634317821716fb93d63025e32e 100644 (file)
 #include <linux/mfd/core.h>
 #include <linux/mfd/abx500.h>
 #include <linux/mfd/abx500/ab8500.h>
-#include <linux/mfd/abx500/ab8500-bm.h>
 #include <linux/iio/consumer.h>
 #include <linux/kernel.h>
 
+#include "ab8500-bm.h"
+
 #define MILLI_TO_MICRO                 1000
 #define FG_LSB_IN_MA                   1627
 #define QLSB_NANO_AMP_HOURS_X10                1071
@@ -3026,7 +3027,6 @@ static const struct power_supply_desc ab8500_fg_desc = {
 static int ab8500_fg_probe(struct platform_device *pdev)
 {
        struct device_node *np = pdev->dev.of_node;
-       struct abx500_bm_data *plat = pdev->dev.platform_data;
        struct power_supply_config psy_cfg = {};
        struct device *dev = &pdev->dev;
        struct ab8500_fg *di;
@@ -3037,11 +3037,7 @@ static int ab8500_fg_probe(struct platform_device *pdev)
        if (!di)
                return -ENOMEM;
 
-       if (!plat) {
-               dev_err(dev, "no battery management data supplied\n");
-               return -EINVAL;
-       }
-       di->bm = plat;
+       di->bm = &ab8500_bm_data;
 
        ret = ab8500_bm_of_probe(dev, np, di->bm);
        if (ret) {
index 591ddd2987a3fd09fdd93f3a195d81ba8dcaf1b6..5b28d58041b4b867a1ac77aec636a7dd5ff455d7 100644 (file)
 #include <linux/mfd/abx500.h>
 #include <linux/mfd/abx500/ab8500.h>
 #include <linux/mfd/abx500/ux500_chargalg.h>
-#include <linux/mfd/abx500/ab8500-bm.h>
 #include <linux/notifier.h>
 
+#include "ab8500-bm.h"
+
 /* Watchdog kick interval */
 #define CHG_WD_INTERVAL                        (6 * HZ)
 
@@ -1980,7 +1981,6 @@ static const struct power_supply_desc abx500_chargalg_desc = {
 static int abx500_chargalg_probe(struct platform_device *pdev)
 {
        struct device_node *np = pdev->dev.of_node;
-       struct abx500_bm_data *plat = pdev->dev.platform_data;
        struct power_supply_config psy_cfg = {};
        struct abx500_chargalg *di;
        int ret = 0;
@@ -1991,11 +1991,7 @@ static int abx500_chargalg_probe(struct platform_device *pdev)
                return -ENOMEM;
        }
 
-       if (!plat) {
-               dev_err(&pdev->dev, "no battery management data supplied\n");
-               return -EINVAL;
-       }
-       di->bm = plat;
+       di->bm = &ab8500_bm_data;
 
        ret = ab8500_bm_of_probe(&pdev->dev, np, di->bm);
        if (ret) {
index ac06ecf7fc9ca04004d4abd123f629f2ced4655b..5aeff75db33b415618e6773b4d31755027c9d222 100644 (file)
 #include <linux/i2c.h>
 #include <linux/workqueue.h>
 #include <linux/mfd/abx500/ab8500.h>
-#include <linux/mfd/abx500/ab8500-bm.h>
 #include <linux/mfd/abx500/ux500_chargalg.h>
 #include <linux/pm2301_charger.h>
 #include <linux/gpio.h>
 #include <linux/pm_runtime.h>
 #include <linux/pm.h>
 
+#include "ab8500-bm.h"
 #include "pm2301_charger.h"
 
 #define to_pm2xxx_charger_ac_device_info(x) container_of((x), \