History

mfd: rk808: Stop using syscore ops

Setting the SLEEP pin to its shutdown function for appropriate PMICs doesn't need to happen in single-CPU context, so there's really no point involving the syscore machinery. Hook it up to the standard driver model shutdown method instead. This also obviates the issue that the syscore ops weren't being unregistered on probe failure or module removal.

Robin Murphy committed 6 years ago

Commit 90df3a81 parent 08e8c0d1 file · +12 −14Browse files

Unified · Split

drivers/mfd/rk808.c+12−14
@@ -19,7 +19,6 @@ · 18 unmodified lines
1919 #include <linux/module.h>
2020 #include <linux/of_device.h>
2121 #include <linux/regmap.h>
22−#include <linux/syscore_ops.h>
2322
2423 struct rk808_reg_data {
2524 int addr;
@@ -509,28 +508,27 @@ static void rk818_device_shutdown(void) · 483 unmodified lines
509508 dev_err(&rk808_i2c_client->dev, "Failed to shutdown device!\n");
510509 }
511510
512−static void rk8xx_syscore_shutdown(void)
511+static void rk8xx_shutdown(struct i2c_client *client)
513512 {
514− struct rk808 *rk808 = i2c_get_clientdata(rk808_i2c_client);
513+ struct rk808 *rk808 = i2c_get_clientdata(client);
515514 int ret;
516515
517− if (system_state == SYSTEM_POWER_OFF &&
518− (rk808->variant == RK809_ID || rk808->variant == RK817_ID)) {
516+ switch (rk808->variant) {
517+ case RK809_ID:
518+ case RK817_ID:
519519 ret = regmap_update_bits(rk808->regmap,
520520 RK817_SYS_CFG(3),
521521 RK817_SLPPIN_FUNC_MSK,
522522 SLPPIN_DN_FUN);
523− if (ret) {
524− dev_warn(&rk808_i2c_client->dev,
525− "Cannot switch to power down function\n");
526− }
523+ break;
524+ default:
525+ return;
527526 }
527+ if (ret)
528+ dev_warn(&client->dev,
529+ "Cannot switch to power down function\n");
528530 }
529531
530−static struct syscore_ops rk808_syscore_ops = {
531− .shutdown = rk8xx_syscore_shutdown,
532−};
533−
534532 static const struct of_device_id rk808_of_match[] = {
535533 { .compatible = "rockchip,rk805" },
536534 { .compatible = "rockchip,rk808" },
@@ -623,7 +621,6 @@ static int rk808_probe(struct i2c_client *client, · 86 unmodified lines
623621 nr_pre_init_regs = ARRAY_SIZE(rk817_pre_init_reg);
624622 cells = rk817s;
625623 nr_cells = ARRAY_SIZE(rk817s);
626− register_syscore_ops(&rk808_syscore_ops);
627624 break;
628625 default:
629626 dev_err(&client->dev, "Unsupported RK8XX ID %lu\n",
@@ -759,6 +756,7 @@ static struct i2c_driver rk808_i2c_driver = { · 129 unmodified lines
759756 },
760757 .probe = rk808_probe,
761758 .remove = rk808_remove,
759+ .shutdown = rk8xx_shutdown,
762760 };
763761
764762 module_i2c_driver(rk808_i2c_driver);