Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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.

Signed-off-by: Robin Murphy <robin.murphy@arm.com>
Signed-off-by: Lee Jones <lee.jones@linaro.org>

authored by

Robin Murphy and committed by
Lee Jones
90df3a82 08e8c0d9

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