Skip to content

Commit 417c0fc

Browse files
Linus WalleijLee Jones
authored andcommitted
mfd/power: ab8500: Push data to power supply code
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>
1 parent 53207aa commit 417c0fc

8 files changed

Lines changed: 27 additions & 79 deletions

File tree

‎drivers/mfd/ab8500-core.c‎

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@
1919
#include <linux/mfd/core.h>
2020
#include <linux/mfd/abx500.h>
2121
#include <linux/mfd/abx500/ab8500.h>
22-
#include <linux/mfd/abx500/ab8500-bm.h>
2322
#include <linux/mfd/dbx500-prcmu.h>
2423
#include <linux/of.h>
2524
#include <linux/of_device.h>
@@ -609,14 +608,14 @@ int ab8500_suspend(struct ab8500 *ab8500)
609608
}
610609

611610
static const struct mfd_cell ab8500_bm_devs[] = {
612-
MFD_CELL_OF("ab8500-charger", NULL, &ab8500_bm_data,
613-
sizeof(ab8500_bm_data), 0, "stericsson,ab8500-charger"),
614-
MFD_CELL_OF("ab8500-btemp", NULL, &ab8500_bm_data,
615-
sizeof(ab8500_bm_data), 0, "stericsson,ab8500-btemp"),
616-
MFD_CELL_OF("ab8500-fg", NULL, &ab8500_bm_data,
617-
sizeof(ab8500_bm_data), 0, "stericsson,ab8500-fg"),
618-
MFD_CELL_OF("ab8500-chargalg", NULL, &ab8500_bm_data,
619-
sizeof(ab8500_bm_data), 0, "stericsson,ab8500-chargalg"),
611+
MFD_CELL_OF("ab8500-charger", NULL, NULL, 0, 0,
612+
"stericsson,ab8500-charger"),
613+
MFD_CELL_OF("ab8500-btemp", NULL, NULL, 0, 0,
614+
"stericsson,ab8500-btemp"),
615+
MFD_CELL_OF("ab8500-fg", NULL, NULL, 0, 0,
616+
"stericsson,ab8500-fg"),
617+
MFD_CELL_OF("ab8500-chargalg", NULL, NULL, 0, 0,
618+
"stericsson,ab8500-chargalg"),
620619
};
621620

622621
static const struct mfd_cell ab8500_devs[] = {
Lines changed: 3 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,7 @@
11
/* SPDX-License-Identifier: GPL-2.0-only */
2-
/*
3-
* Copyright ST-Ericsson 2012.
4-
*
5-
* Author: Arun Murthy <arun.murthy@stericsson.com>
6-
*/
72

8-
#ifndef _AB8500_BM_H
9-
#define _AB8500_BM_H
3+
#ifndef _AB8500_CHARGER_H_
4+
#define _AB8500_CHARGER_H_
105

116
#include <linux/kernel.h>
127
#include <linux/mfd/abx500.h>
@@ -453,24 +448,16 @@ struct ab8500_bm_data {
453448
};
454449

455450
struct ab8500_btemp;
456-
struct ab8500_gpadc;
457451
struct ab8500_fg;
458452

459-
#ifdef CONFIG_AB8500_BM
460453
extern struct abx500_bm_data ab8500_bm_data;
461454

462455
void ab8500_charger_usb_state_changed(u8 bm_usb_state, u16 mA);
463-
struct ab8500_btemp *ab8500_btemp_get(void);
464-
int ab8500_btemp_get_batctrl_temp(struct ab8500_btemp *btemp);
465-
int ab8500_btemp_get_temp(struct ab8500_btemp *btemp);
466456
struct ab8500_fg *ab8500_fg_get(void);
467457
int ab8500_fg_inst_curr_blocking(struct ab8500_fg *dev);
468458
int ab8500_fg_inst_curr_start(struct ab8500_fg *di);
469459
int ab8500_fg_inst_curr_finalize(struct ab8500_fg *di, int *res);
470460
int ab8500_fg_inst_curr_started(struct ab8500_fg *di);
471461
int ab8500_fg_inst_curr_done(struct ab8500_fg *di);
472462

473-
#else
474-
static struct abx500_bm_data ab8500_bm_data;
475-
#endif
476-
#endif /* _AB8500_BM_H */
463+
#endif /* _AB8500_CHARGER_H_ */

‎drivers/power/supply/ab8500_bmdata.c‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,8 @@
44
#include <linux/of.h>
55
#include <linux/mfd/abx500.h>
66
#include <linux/mfd/abx500/ab8500.h>
7-
#include <linux/mfd/abx500/ab8500-bm.h>
7+
8+
#include "ab8500-bm.h"
89

910
/*
1011
* These are the defined batteries that uses a NTC and ID resistor placed

‎drivers/power/supply/ab8500_btemp.c‎

Lines changed: 4 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -25,9 +25,10 @@
2525
#include <linux/mfd/core.h>
2626
#include <linux/mfd/abx500.h>
2727
#include <linux/mfd/abx500/ab8500.h>
28-
#include <linux/mfd/abx500/ab8500-bm.h>
2928
#include <linux/iio/consumer.h>
3029

30+
#include "ab8500-bm.h"
31+
3132
#define VTVOUT_V 1800
3233

3334
#define BTEMP_THERMAL_LOW_LIMIT -10
@@ -119,16 +120,6 @@ static enum power_supply_property ab8500_btemp_props[] = {
119120

120121
static LIST_HEAD(ab8500_btemp_list);
121122

122-
/**
123-
* ab8500_btemp_get() - returns a reference to the primary AB8500 BTEMP
124-
* (i.e. the first BTEMP in the instance list)
125-
*/
126-
struct ab8500_btemp *ab8500_btemp_get(void)
127-
{
128-
return list_first_entry(&ab8500_btemp_list, struct ab8500_btemp, node);
129-
}
130-
EXPORT_SYMBOL(ab8500_btemp_get);
131-
132123
/**
133124
* ab8500_btemp_batctrl_volt_to_res() - convert batctrl voltage to resistance
134125
* @di: pointer to the ab8500_btemp structure
@@ -754,7 +745,7 @@ static void ab8500_btemp_periodic(struct ab8500_btemp *di,
754745
*
755746
* Returns battery temperature
756747
*/
757-
int ab8500_btemp_get_temp(struct ab8500_btemp *di)
748+
static int ab8500_btemp_get_temp(struct ab8500_btemp *di)
758749
{
759750
int temp = 0;
760751

@@ -790,19 +781,6 @@ int ab8500_btemp_get_temp(struct ab8500_btemp *di)
790781
}
791782
return temp;
792783
}
793-
EXPORT_SYMBOL(ab8500_btemp_get_temp);
794-
795-
/**
796-
* ab8500_btemp_get_batctrl_temp() - get the temperature
797-
* @btemp: pointer to the btemp structure
798-
*
799-
* Returns the batctrl temperature in millidegrees
800-
*/
801-
int ab8500_btemp_get_batctrl_temp(struct ab8500_btemp *btemp)
802-
{
803-
return btemp->bat_temp * 1000;
804-
}
805-
EXPORT_SYMBOL(ab8500_btemp_get_batctrl_temp);
806784

807785
/**
808786
* ab8500_btemp_get_property() - get the btemp properties
@@ -991,7 +969,6 @@ static const struct power_supply_desc ab8500_btemp_desc = {
991969
static int ab8500_btemp_probe(struct platform_device *pdev)
992970
{
993971
struct device_node *np = pdev->dev.of_node;
994-
struct abx500_bm_data *plat = pdev->dev.platform_data;
995972
struct power_supply_config psy_cfg = {};
996973
struct device *dev = &pdev->dev;
997974
struct ab8500_btemp *di;
@@ -1002,11 +979,7 @@ static int ab8500_btemp_probe(struct platform_device *pdev)
1002979
if (!di)
1003980
return -ENOMEM;
1004981

1005-
if (!plat) {
1006-
dev_err(dev, "no battery management data supplied\n");
1007-
return -EINVAL;
1008-
}
1009-
di->bm = plat;
982+
di->bm = &ab8500_bm_data;
1010983

1011984
ret = ab8500_bm_of_probe(dev, np, di->bm);
1012985
if (ret) {

‎drivers/power/supply/ab8500_charger.c‎

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -28,12 +28,13 @@
2828
#include <linux/mfd/core.h>
2929
#include <linux/mfd/abx500/ab8500.h>
3030
#include <linux/mfd/abx500.h>
31-
#include <linux/mfd/abx500/ab8500-bm.h>
3231
#include <linux/mfd/abx500/ux500_chargalg.h>
3332
#include <linux/usb/otg.h>
3433
#include <linux/mutex.h>
3534
#include <linux/iio/consumer.h>
3635

36+
#include "ab8500-bm.h"
37+
3738
/* Charger constants */
3839
#define NO_PW_CONN 0
3940
#define AC_PW_CONN 1
@@ -3344,7 +3345,6 @@ static const struct power_supply_desc ab8500_usb_chg_desc = {
33443345
static int ab8500_charger_probe(struct platform_device *pdev)
33453346
{
33463347
struct device_node *np = pdev->dev.of_node;
3347-
struct abx500_bm_data *plat = pdev->dev.platform_data;
33483348
struct power_supply_config ac_psy_cfg = {}, usb_psy_cfg = {};
33493349
struct ab8500_charger *di;
33503350
int irq, i, charger_status, ret = 0, ch_stat;
@@ -3354,11 +3354,7 @@ static int ab8500_charger_probe(struct platform_device *pdev)
33543354
if (!di)
33553355
return -ENOMEM;
33563356

3357-
if (!plat) {
3358-
dev_err(dev, "no battery management data supplied\n");
3359-
return -EINVAL;
3360-
}
3361-
di->bm = plat;
3357+
di->bm = &ab8500_bm_data;
33623358

33633359
ret = ab8500_bm_of_probe(dev, np, di->bm);
33643360
if (ret) {

‎drivers/power/supply/ab8500_fg.c‎

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -31,10 +31,11 @@
3131
#include <linux/mfd/core.h>
3232
#include <linux/mfd/abx500.h>
3333
#include <linux/mfd/abx500/ab8500.h>
34-
#include <linux/mfd/abx500/ab8500-bm.h>
3534
#include <linux/iio/consumer.h>
3635
#include <linux/kernel.h>
3736

37+
#include "ab8500-bm.h"
38+
3839
#define MILLI_TO_MICRO 1000
3940
#define FG_LSB_IN_MA 1627
4041
#define QLSB_NANO_AMP_HOURS_X10 1071
@@ -3026,7 +3027,6 @@ static const struct power_supply_desc ab8500_fg_desc = {
30263027
static int ab8500_fg_probe(struct platform_device *pdev)
30273028
{
30283029
struct device_node *np = pdev->dev.of_node;
3029-
struct abx500_bm_data *plat = pdev->dev.platform_data;
30303030
struct power_supply_config psy_cfg = {};
30313031
struct device *dev = &pdev->dev;
30323032
struct ab8500_fg *di;
@@ -3037,11 +3037,7 @@ static int ab8500_fg_probe(struct platform_device *pdev)
30373037
if (!di)
30383038
return -ENOMEM;
30393039

3040-
if (!plat) {
3041-
dev_err(dev, "no battery management data supplied\n");
3042-
return -EINVAL;
3043-
}
3044-
di->bm = plat;
3040+
di->bm = &ab8500_bm_data;
30453041

30463042
ret = ab8500_bm_of_probe(dev, np, di->bm);
30473043
if (ret) {

‎drivers/power/supply/abx500_chargalg.c‎

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -29,9 +29,10 @@
2929
#include <linux/mfd/abx500.h>
3030
#include <linux/mfd/abx500/ab8500.h>
3131
#include <linux/mfd/abx500/ux500_chargalg.h>
32-
#include <linux/mfd/abx500/ab8500-bm.h>
3332
#include <linux/notifier.h>
3433

34+
#include "ab8500-bm.h"
35+
3536
/* Watchdog kick interval */
3637
#define CHG_WD_INTERVAL (6 * HZ)
3738

@@ -1980,7 +1981,6 @@ static const struct power_supply_desc abx500_chargalg_desc = {
19801981
static int abx500_chargalg_probe(struct platform_device *pdev)
19811982
{
19821983
struct device_node *np = pdev->dev.of_node;
1983-
struct abx500_bm_data *plat = pdev->dev.platform_data;
19841984
struct power_supply_config psy_cfg = {};
19851985
struct abx500_chargalg *di;
19861986
int ret = 0;
@@ -1991,11 +1991,7 @@ static int abx500_chargalg_probe(struct platform_device *pdev)
19911991
return -ENOMEM;
19921992
}
19931993

1994-
if (!plat) {
1995-
dev_err(&pdev->dev, "no battery management data supplied\n");
1996-
return -EINVAL;
1997-
}
1998-
di->bm = plat;
1994+
di->bm = &ab8500_bm_data;
19991995

20001996
ret = ab8500_bm_of_probe(&pdev->dev, np, di->bm);
20011997
if (ret) {

‎drivers/power/supply/pm2301_charger.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,13 +18,13 @@
1818
#include <linux/i2c.h>
1919
#include <linux/workqueue.h>
2020
#include <linux/mfd/abx500/ab8500.h>
21-
#include <linux/mfd/abx500/ab8500-bm.h>
2221
#include <linux/mfd/abx500/ux500_chargalg.h>
2322
#include <linux/pm2301_charger.h>
2423
#include <linux/gpio.h>
2524
#include <linux/pm_runtime.h>
2625
#include <linux/pm.h>
2726

27+
#include "ab8500-bm.h"
2828
#include "pm2301_charger.h"
2929

3030
#define to_pm2xxx_charger_ac_device_info(x) container_of((x), \

0 commit comments

Comments
 (0)