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
19#include <linux/module.h>19#include <linux/module.h>
20#include <linux/of_device.h>20#include <linux/of_device.h>
21#include <linux/regmap.h>21#include <linux/regmap.h>
22#include <linux/syscore_ops.h>
23 22
24struct rk808_reg_data {23struct rk808_reg_data {
25 int addr;24 int addr;
@@ -509,28 +508,27 @@ static void rk818_device_shutdown(void) · 483 unmodified lines
509 dev_err(&rk808_i2c_client->dev, "Failed to shutdown device!\n");508 dev_err(&rk808_i2c_client->dev, "Failed to shutdown device!\n");
510}509}
511 510
512static void rk8xx_syscore_shutdown(void)511static void rk8xx_shutdown(struct i2c_client *client)
513{512{
514 struct rk808 *rk808 = i2c_get_clientdata(rk808_i2c_client);513 struct rk808 *rk808 = i2c_get_clientdata(client);
515 int ret;514 int ret;
516 515
517 if (system_state == SYSTEM_POWER_OFF &&516 switch (rk808->variant) {
518 (rk808->variant == RK809_ID || rk808->variant == RK817_ID)) {517 case RK809_ID:
518 case RK817_ID:
519 ret = regmap_update_bits(rk808->regmap,519 ret = regmap_update_bits(rk808->regmap,
520 RK817_SYS_CFG(3),520 RK817_SYS_CFG(3),
521 RK817_SLPPIN_FUNC_MSK,521 RK817_SLPPIN_FUNC_MSK,
522 SLPPIN_DN_FUN);522 SLPPIN_DN_FUN);
523 if (ret) {523 break;
524 dev_warn(&rk808_i2c_client->dev,524 default:
525 "Cannot switch to power down function\n");525 return;
526 }
527 }526 }
527 if (ret)
528 dev_warn(&client->dev,
529 "Cannot switch to power down function\n");
528}530}
529 531
530static struct syscore_ops rk808_syscore_ops = {
531 .shutdown = rk8xx_syscore_shutdown,
532};
533
534static const struct of_device_id rk808_of_match[] = {532static const struct of_device_id rk808_of_match[] = {
535 { .compatible = "rockchip,rk805" },533 { .compatible = "rockchip,rk805" },
536 { .compatible = "rockchip,rk808" },534 { .compatible = "rockchip,rk808" },
@@ -623,7 +621,6 @@ static int rk808_probe(struct i2c_client *client, · 86 unmodified lines
623 nr_pre_init_regs = ARRAY_SIZE(rk817_pre_init_reg);621 nr_pre_init_regs = ARRAY_SIZE(rk817_pre_init_reg);
624 cells = rk817s;622 cells = rk817s;
625 nr_cells = ARRAY_SIZE(rk817s);623 nr_cells = ARRAY_SIZE(rk817s);
626 register_syscore_ops(&rk808_syscore_ops);
627 break;624 break;
628 default:625 default:
629 dev_err(&client->dev, "Unsupported RK8XX ID %lu\n",626 dev_err(&client->dev, "Unsupported RK8XX ID %lu\n",
@@ -759,6 +756,7 @@ static struct i2c_driver rk808_i2c_driver = { · 129 unmodified lines
759 },756 },
760 .probe = rk808_probe,757 .probe = rk808_probe,
761 .remove = rk808_remove,758 .remove = rk808_remove,
759 .shutdown = rk8xx_shutdown,
762};760};
763 761
764module_i2c_driver(rk808_i2c_driver);762module_i2c_driver(rk808_i2c_driver);