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

serial: sccnxp: Replace pdata.init/exit with regulator API

Typical usage of pdata.init/exit is enable/disable power and/or toggle
reset for the target chip.
This patch replaces these callbacks with regulator API.

Signed-off-by: Alexander Shiyan <shc_work@mail.ru>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

authored by

Alexander Shiyan and committed by
Greg Kroah-Hartman
31815c08 289b8dd6

+15 -10
+15 -6
drivers/tty/serial/sccnxp.c
··· 27 27 #include <linux/spinlock.h> 28 28 #include <linux/platform_device.h> 29 29 #include <linux/platform_data/serial-sccnxp.h> 30 + #include <linux/regulator/consumer.h> 30 31 31 32 #define SCCNXP_NAME "uart-sccnxp" 32 33 #define SCCNXP_MAJOR 204 ··· 132 131 struct timer_list timer; 133 132 134 133 struct sccnxp_pdata pdata; 134 + 135 + struct regulator *regulator; 135 136 }; 136 137 137 138 static inline u8 sccnxp_raw_read(void __iomem *base, u8 reg, u8 shift) ··· 919 916 goto err_out; 920 917 } 921 918 919 + s->regulator = devm_regulator_get(&pdev->dev, "VCC"); 920 + if (!IS_ERR(s->regulator)) { 921 + ret = regulator_enable(s->regulator); 922 + if (ret) { 923 + dev_err(&pdev->dev, 924 + "Failed to enable regulator: %i\n", ret); 925 + return ret; 926 + } 927 + } 928 + 922 929 membase = devm_ioremap_resource(&pdev->dev, res); 923 930 if (IS_ERR(membase)) { 924 931 ret = PTR_ERR(membase); ··· 978 965 s->imr = 0; 979 966 sccnxp_write(&s->port[0], SCCNXP_IMR_REG, 0); 980 967 981 - /* Board specific configure */ 982 - if (s->pdata.init) 983 - s->pdata.init(); 984 - 985 968 if (!s->poll) { 986 969 ret = devm_request_threaded_irq(&pdev->dev, s->irq, NULL, 987 970 sccnxp_ist, ··· 1018 1009 uart_unregister_driver(&s->uart); 1019 1010 platform_set_drvdata(pdev, NULL); 1020 1011 1021 - if (s->pdata.exit) 1022 - s->pdata.exit(); 1012 + if (!IS_ERR(s->regulator)) 1013 + return regulator_disable(s->regulator); 1023 1014 1024 1015 return 0; 1025 1016 }
-4
include/linux/platform_data/serial-sccnxp.h
··· 86 86 const u32 mctrl_cfg[SCCNXP_MAX_UARTS]; 87 87 /* Timer value for polling mode (usecs) */ 88 88 const unsigned int poll_time_us; 89 - /* Called during startup */ 90 - void (*init)(void); 91 - /* Called before finish */ 92 - void (*exit)(void); 93 89 }; 94 90 95 91 #endif