Skip to content

Commit 44f89c6

Browse files
committed
Merge tag 'for-v6.9' of git://git.kernel.org/pub/scm/linux/kernel/git/sre/linux-power-supply
Pull power supply and reset updates from Sebastian Reichel: "New features: - axp20x_usb_power: report USB type Cleanups: - convert lots of drivers to use devm_power_supply_register() - convert lots of reset drivers to use devm_register_sys_off_handler() - constify device_type and power_supply_class - axp20x_usb_power: use correct property to report input current limit - mm8013: correct handling of "not charging" status register - core: fix charge_behaviour formatting - minor fixes cleanups" * tag 'for-v6.9' of git://git.kernel.org/pub/scm/linux/kernel/git/sre/linux-power-supply: (66 commits) power: supply: core: fix charge_behaviour formatting power: supply: core: ease special formatting implementations power: supply: mm8013: fix "not charging" detection power: supply: move power_supply_attr_groups definition back to sysfs power: supply: core: simplify power_supply_class_init power: supply: core: add power_supply_for_each_device() power: supply: core: make power_supply_class constant power: supply: bq2415x_charger: report online status power: supply: core: move power_supply_attr_group into #ifdef block power: supply: core: Fix power_supply_init_attrs() stub power: supply: bq27xxx: Report charge full state correctly power: reset: rmobile-reset: Make sysc_base2 local power: supply: core: constify the struct device_type usage power: supply: axp288_fuel_gauge: Deny ROCK Pi X power: reset: rmobile-reset: Map correct MMIO resource power: reset: xgene-reboot: Fix a NULL vs IS_ERR() test power: supply: axp288_fuel_gauge: Add STCK1A* Intel Compute Sticks to the deny-list power: reset: syscon-poweroff: Use devm_register_sys_off_handler(POWER_OFF) power: reset: syscon-poweroff: Move device data into a struct power: reset: restart-poweroff: Use devm_register_sys_off_handler(POWER_OFF) ...
2 parents 80d80de + 4e61f1e commit 44f89c6

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

47 files changed

+558
-745
lines changed

drivers/power/reset/as3722-poweroff.c

Lines changed: 11 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -11,29 +11,26 @@
1111
#include <linux/module.h>
1212
#include <linux/of.h>
1313
#include <linux/platform_device.h>
14+
#include <linux/reboot.h>
1415
#include <linux/slab.h>
1516

1617
struct as3722_poweroff {
1718
struct device *dev;
1819
struct as3722 *as3722;
1920
};
2021

21-
static struct as3722_poweroff *as3722_pm_poweroff;
22-
23-
static void as3722_pm_power_off(void)
22+
static int as3722_pm_power_off(struct sys_off_data *data)
2423
{
24+
struct as3722_poweroff *as3722_pm_poweroff = data->cb_data;
2525
int ret;
2626

27-
if (!as3722_pm_poweroff) {
28-
pr_err("AS3722 poweroff is not initialised\n");
29-
return;
30-
}
31-
3227
ret = as3722_update_bits(as3722_pm_poweroff->as3722,
3328
AS3722_RESET_CONTROL_REG, AS3722_POWER_OFF, AS3722_POWER_OFF);
3429
if (ret < 0)
3530
dev_err(as3722_pm_poweroff->dev,
3631
"RESET_CONTROL_REG update failed, %d\n", ret);
32+
33+
return NOTIFY_DONE;
3734
}
3835

3936
static int as3722_poweroff_probe(struct platform_device *pdev)
@@ -54,26 +51,21 @@ static int as3722_poweroff_probe(struct platform_device *pdev)
5451

5552
as3722_poweroff->as3722 = dev_get_drvdata(pdev->dev.parent);
5653
as3722_poweroff->dev = &pdev->dev;
57-
as3722_pm_poweroff = as3722_poweroff;
58-
if (!pm_power_off)
59-
pm_power_off = as3722_pm_power_off;
6054

61-
return 0;
62-
}
55+
return devm_register_sys_off_handler(as3722_poweroff->dev,
56+
SYS_OFF_MODE_POWER_OFF,
57+
SYS_OFF_PRIO_DEFAULT,
58+
as3722_pm_power_off,
59+
as3722_poweroff);
6360

64-
static void as3722_poweroff_remove(struct platform_device *pdev)
65-
{
66-
if (pm_power_off == as3722_pm_power_off)
67-
pm_power_off = NULL;
68-
as3722_pm_poweroff = NULL;
61+
return 0;
6962
}
7063

7164
static struct platform_driver as3722_poweroff_driver = {
7265
.driver = {
7366
.name = "as3722-power-off",
7467
},
7568
.probe = as3722_poweroff_probe,
76-
.remove_new = as3722_poweroff_remove,
7769
};
7870

7971
module_platform_driver(as3722_poweroff_driver);

drivers/power/reset/atc260x-poweroff.c

Lines changed: 21 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -16,13 +16,9 @@
1616
struct atc260x_pwrc {
1717
struct device *dev;
1818
struct regmap *regmap;
19-
struct notifier_block restart_nb;
2019
int (*do_poweroff)(const struct atc260x_pwrc *pwrc, bool restart);
2120
};
2221

23-
/* Global variable needed only for pm_power_off */
24-
static struct atc260x_pwrc *atc260x_pwrc_data;
25-
2622
static int atc2603c_do_poweroff(const struct atc260x_pwrc *pwrc, bool restart)
2723
{
2824
int ret, deep_sleep = 0;
@@ -165,18 +161,20 @@ static int atc2609a_init(const struct atc260x_pwrc *pwrc)
165161
return ret;
166162
}
167163

168-
static void atc260x_pwrc_pm_handler(void)
164+
static int atc260x_pwrc_pm_handler(struct sys_off_data *data)
169165
{
170-
atc260x_pwrc_data->do_poweroff(atc260x_pwrc_data, false);
166+
struct atc260x_pwrc *pwrc = data->cb_data;
167+
168+
pwrc->do_poweroff(pwrc, false);
171169

172170
WARN_ONCE(1, "Unable to power off system\n");
171+
172+
return NOTIFY_DONE;
173173
}
174174

175-
static int atc260x_pwrc_restart_handler(struct notifier_block *nb,
176-
unsigned long mode, void *cmd)
175+
static int atc260x_pwrc_restart_handler(struct sys_off_data *data)
177176
{
178-
struct atc260x_pwrc *pwrc = container_of(nb, struct atc260x_pwrc,
179-
restart_nb);
177+
struct atc260x_pwrc *pwrc = data->cb_data;
180178
pwrc->do_poweroff(pwrc, true);
181179

182180
return NOTIFY_DONE;
@@ -194,8 +192,6 @@ static int atc260x_pwrc_probe(struct platform_device *pdev)
194192

195193
priv->dev = &pdev->dev;
196194
priv->regmap = atc260x->regmap;
197-
priv->restart_nb.notifier_call = atc260x_pwrc_restart_handler;
198-
priv->restart_nb.priority = 192;
199195

200196
switch (atc260x->ic_type) {
201197
case ATC2603C:
@@ -216,38 +212,29 @@ static int atc260x_pwrc_probe(struct platform_device *pdev)
216212
if (ret)
217213
return ret;
218214

219-
platform_set_drvdata(pdev, priv);
220-
221-
if (!pm_power_off) {
222-
atc260x_pwrc_data = priv;
223-
pm_power_off = atc260x_pwrc_pm_handler;
224-
} else {
225-
dev_warn(priv->dev, "Poweroff callback already assigned\n");
226-
}
215+
ret = devm_register_sys_off_handler(priv->dev,
216+
SYS_OFF_MODE_POWER_OFF,
217+
SYS_OFF_PRIO_DEFAULT,
218+
atc260x_pwrc_pm_handler,
219+
priv);
220+
if (ret)
221+
dev_err(priv->dev, "failed to register power-off handler: %d\n",
222+
ret);
227223

228-
ret = register_restart_handler(&priv->restart_nb);
224+
ret = devm_register_sys_off_handler(priv->dev,
225+
SYS_OFF_MODE_RESTART,
226+
SYS_OFF_PRIO_HIGH,
227+
atc260x_pwrc_restart_handler,
228+
priv);
229229
if (ret)
230230
dev_err(priv->dev, "failed to register restart handler: %d\n",
231231
ret);
232232

233233
return ret;
234234
}
235235

236-
static void atc260x_pwrc_remove(struct platform_device *pdev)
237-
{
238-
struct atc260x_pwrc *priv = platform_get_drvdata(pdev);
239-
240-
if (atc260x_pwrc_data == priv) {
241-
pm_power_off = NULL;
242-
atc260x_pwrc_data = NULL;
243-
}
244-
245-
unregister_restart_handler(&priv->restart_nb);
246-
}
247-
248236
static struct platform_driver atc260x_pwrc_driver = {
249237
.probe = atc260x_pwrc_probe,
250-
.remove_new = atc260x_pwrc_remove,
251238
.driver = {
252239
.name = "atc260x-pwrc",
253240
},

drivers/power/reset/axxia-reset.c

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -26,11 +26,10 @@
2626
#define SC_EFUSE_INT_STATUS 0x180c
2727
#define EFUSE_READ_DONE (1<<31)
2828

29-
static struct regmap *syscon;
30-
31-
static int axxia_restart_handler(struct notifier_block *this,
32-
unsigned long mode, void *cmd)
29+
static int axxia_restart_handler(struct sys_off_data *data)
3330
{
31+
struct regmap *syscon = data->cb_data;
32+
3433
/* Access Key (0xab) */
3534
regmap_write(syscon, SC_CRIT_WRITE_KEY, 0xab);
3635
/* Select internal boot from 0xffff0000 */
@@ -44,14 +43,10 @@ static int axxia_restart_handler(struct notifier_block *this,
4443
return NOTIFY_DONE;
4544
}
4645

47-
static struct notifier_block axxia_restart_nb = {
48-
.notifier_call = axxia_restart_handler,
49-
.priority = 128,
50-
};
51-
5246
static int axxia_reset_probe(struct platform_device *pdev)
5347
{
5448
struct device *dev = &pdev->dev;
49+
struct regmap *syscon;
5550
int err;
5651

5752
syscon = syscon_regmap_lookup_by_phandle(dev->of_node, "syscon");
@@ -60,7 +55,8 @@ static int axxia_reset_probe(struct platform_device *pdev)
6055
return PTR_ERR(syscon);
6156
}
6257

63-
err = register_restart_handler(&axxia_restart_nb);
58+
err = devm_register_sys_off_handler(&pdev->dev, SYS_OFF_MODE_RESTART,
59+
128, axxia_restart_handler, syscon);
6460
if (err)
6561
dev_err(dev, "cannot register restart handler (err=%d)\n", err);
6662

drivers/power/reset/brcm-kona-reset.c

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,7 @@
1515

1616
static void __iomem *kona_reset_base;
1717

18-
static int kona_reset_handler(struct notifier_block *this,
19-
unsigned long mode, void *cmd)
18+
static int kona_reset_handler(struct sys_off_data *data)
2019
{
2120
/*
2221
* A soft reset is triggered by writing a 0 to bit 0 of the soft reset
@@ -31,18 +30,14 @@ static int kona_reset_handler(struct notifier_block *this,
3130
return NOTIFY_DONE;
3231
}
3332

34-
static struct notifier_block kona_reset_nb = {
35-
.notifier_call = kona_reset_handler,
36-
.priority = 128,
37-
};
38-
3933
static int kona_reset_probe(struct platform_device *pdev)
4034
{
4135
kona_reset_base = devm_platform_ioremap_resource(pdev, 0);
4236
if (IS_ERR(kona_reset_base))
4337
return PTR_ERR(kona_reset_base);
4438

45-
return register_restart_handler(&kona_reset_nb);
39+
return devm_register_sys_off_handler(&pdev->dev, SYS_OFF_MODE_RESTART,
40+
128, kona_reset_handler, NULL);
4641
}
4742

4843
static const struct of_device_id of_match[] = {

drivers/power/reset/gemini-poweroff.c

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -70,12 +70,9 @@ static irqreturn_t gemini_powerbutton_interrupt(int irq, void *data)
7070
return IRQ_HANDLED;
7171
}
7272

73-
/* This callback needs this static local as it has void as argument */
74-
static struct gemini_powercon *gpw_poweroff;
75-
76-
static void gemini_poweroff(void)
73+
static int gemini_poweroff(struct sys_off_data *data)
7774
{
78-
struct gemini_powercon *gpw = gpw_poweroff;
75+
struct gemini_powercon *gpw = data->cb_data;
7976
u32 val;
8077

8178
dev_crit(gpw->dev, "Gemini power off\n");
@@ -86,6 +83,8 @@ static void gemini_poweroff(void)
8683
val &= ~GEMINI_CTRL_ENABLE;
8784
val |= GEMINI_CTRL_SHUTDOWN;
8885
writel(val, gpw->base + GEMINI_PWC_CTRLREG);
86+
87+
return NOTIFY_DONE;
8988
}
9089

9190
static int gemini_poweroff_probe(struct platform_device *pdev)
@@ -148,8 +147,11 @@ static int gemini_poweroff_probe(struct platform_device *pdev)
148147
if (ret)
149148
return ret;
150149

151-
pm_power_off = gemini_poweroff;
152-
gpw_poweroff = gpw;
150+
ret = devm_register_sys_off_handler(dev, SYS_OFF_MODE_POWER_OFF,
151+
SYS_OFF_PRIO_DEFAULT,
152+
gemini_poweroff, gpw);
153+
if (ret)
154+
return ret;
153155

154156
dev_info(dev, "Gemini poweroff driver registered\n");
155157

drivers/power/reset/msm-poweroff.c

Lines changed: 7 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -14,34 +14,27 @@
1414
#include <linux/pm.h>
1515

1616
static void __iomem *msm_ps_hold;
17-
static int deassert_pshold(struct notifier_block *nb, unsigned long action,
18-
void *data)
17+
18+
static int do_msm_poweroff(struct sys_off_data *data)
1919
{
2020
writel(0, msm_ps_hold);
2121
mdelay(10000);
2222

2323
return NOTIFY_DONE;
2424
}
2525

26-
static struct notifier_block restart_nb = {
27-
.notifier_call = deassert_pshold,
28-
.priority = 128,
29-
};
30-
31-
static void do_msm_poweroff(void)
32-
{
33-
deassert_pshold(&restart_nb, 0, NULL);
34-
}
35-
3626
static int msm_restart_probe(struct platform_device *pdev)
3727
{
3828
msm_ps_hold = devm_platform_ioremap_resource(pdev, 0);
3929
if (IS_ERR(msm_ps_hold))
4030
return PTR_ERR(msm_ps_hold);
4131

42-
register_restart_handler(&restart_nb);
32+
devm_register_sys_off_handler(&pdev->dev, SYS_OFF_MODE_RESTART,
33+
128, do_msm_poweroff, NULL);
4334

44-
pm_power_off = do_msm_poweroff;
35+
devm_register_sys_off_handler(&pdev->dev, SYS_OFF_MODE_POWER_OFF,
36+
SYS_OFF_PRIO_DEFAULT, do_msm_poweroff,
37+
NULL);
4538

4639
return 0;
4740
}

drivers/power/reset/mt6323-poweroff.c

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -14,18 +14,17 @@
1414
#include <linux/platform_device.h>
1515
#include <linux/mfd/mt6397/core.h>
1616
#include <linux/mfd/mt6397/rtc.h>
17+
#include <linux/reboot.h>
1718

1819
struct mt6323_pwrc {
1920
struct device *dev;
2021
struct regmap *regmap;
2122
u32 base;
2223
};
2324

24-
static struct mt6323_pwrc *mt_pwrc;
25-
26-
static void mt6323_do_pwroff(void)
25+
static int mt6323_do_pwroff(struct sys_off_data *data)
2726
{
28-
struct mt6323_pwrc *pwrc = mt_pwrc;
27+
struct mt6323_pwrc *pwrc = data->cb_data;
2928
unsigned int val;
3029
int ret;
3130

@@ -44,13 +43,16 @@ static void mt6323_do_pwroff(void)
4443
mdelay(1000);
4544

4645
WARN_ONCE(1, "Unable to power off system\n");
46+
47+
return NOTIFY_DONE;
4748
}
4849

4950
static int mt6323_pwrc_probe(struct platform_device *pdev)
5051
{
5152
struct mt6397_chip *mt6397_chip = dev_get_drvdata(pdev->dev.parent);
5253
struct mt6323_pwrc *pwrc;
5354
struct resource *res;
55+
int ret;
5456

5557
pwrc = devm_kzalloc(&pdev->dev, sizeof(*pwrc), GFP_KERNEL);
5658
if (!pwrc)
@@ -63,19 +65,18 @@ static int mt6323_pwrc_probe(struct platform_device *pdev)
6365
pwrc->base = res->start;
6466
pwrc->regmap = mt6397_chip->regmap;
6567
pwrc->dev = &pdev->dev;
66-
mt_pwrc = pwrc;
6768

68-
pm_power_off = &mt6323_do_pwroff;
69+
ret = devm_register_sys_off_handler(pwrc->dev,
70+
SYS_OFF_MODE_POWER_OFF,
71+
SYS_OFF_PRIO_DEFAULT,
72+
mt6323_do_pwroff,
73+
pwrc);
74+
if (ret)
75+
return dev_err_probe(pwrc->dev, ret, "failed to register power-off handler\n");
6976

7077
return 0;
7178
}
7279

73-
static void mt6323_pwrc_remove(struct platform_device *pdev)
74-
{
75-
if (pm_power_off == &mt6323_do_pwroff)
76-
pm_power_off = NULL;
77-
}
78-
7980
static const struct of_device_id mt6323_pwrc_dt_match[] = {
8081
{ .compatible = "mediatek,mt6323-pwrc" },
8182
{},
@@ -84,7 +85,6 @@ MODULE_DEVICE_TABLE(of, mt6323_pwrc_dt_match);
8485

8586
static struct platform_driver mt6323_pwrc_driver = {
8687
.probe = mt6323_pwrc_probe,
87-
.remove_new = mt6323_pwrc_remove,
8888
.driver = {
8989
.name = "mt6323-pwrc",
9090
.of_match_table = mt6323_pwrc_dt_match,

0 commit comments

Comments
 (0)