Skip to content

Commit d38d49b

Browse files
alistair23broonie
authored andcommitted
regulator: sy7636a: Store the epd-pwr-good GPIO locally
Instead of storing the GPIO state in the mfd (where it isn't used) store it in the regulator. Signed-off-by: Alistair Francis <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Mark Brown <[email protected]>
1 parent 4cafe1a commit d38d49b

File tree

1 file changed

+16
-5
lines changed

1 file changed

+16
-5
lines changed

drivers/regulator/sy7636a-regulator.c

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,11 @@
1313
#include <linux/gpio/consumer.h>
1414
#include <linux/mfd/sy7636a.h>
1515

16+
struct sy7636a_data {
17+
struct sy7636a *sy7636a;
18+
struct gpio_desc *pgood_gpio;
19+
};
20+
1621
static int sy7636a_get_vcom_voltage_op(struct regulator_dev *rdev)
1722
{
1823
int ret;
@@ -33,10 +38,10 @@ static int sy7636a_get_vcom_voltage_op(struct regulator_dev *rdev)
3338

3439
static int sy7636a_get_status(struct regulator_dev *rdev)
3540
{
36-
struct sy7636a *sy7636a = dev_get_drvdata(rdev->dev.parent);
41+
struct sy7636a_data *data = dev_get_drvdata(rdev->dev.parent);
3742
int ret = 0;
3843

39-
ret = gpiod_get_value_cansleep(sy7636a->pgood_gpio);
44+
ret = gpiod_get_value_cansleep(data->pgood_gpio);
4045
if (ret < 0)
4146
dev_err(&rdev->dev, "Failed to read pgood gpio: %d\n", ret);
4247

@@ -69,20 +74,26 @@ static int sy7636a_regulator_probe(struct platform_device *pdev)
6974
struct regulator_config config = { };
7075
struct regulator_dev *rdev;
7176
struct gpio_desc *gdp;
77+
struct sy7636a_data *data;
7278
int ret;
7379

7480
if (!sy7636a)
7581
return -EPROBE_DEFER;
7682

77-
platform_set_drvdata(pdev, sy7636a);
78-
7983
gdp = devm_gpiod_get(pdev->dev.parent, "epd-pwr-good", GPIOD_IN);
8084
if (IS_ERR(gdp)) {
8185
dev_err(pdev->dev.parent, "Power good GPIO fault %ld\n", PTR_ERR(gdp));
8286
return PTR_ERR(gdp);
8387
}
8488

85-
sy7636a->pgood_gpio = gdp;
89+
data = devm_kzalloc(&pdev->dev, sizeof(struct sy7636a_data), GFP_KERNEL);
90+
if (!data)
91+
return -ENOMEM;
92+
93+
data->sy7636a = sy7636a;
94+
data->pgood_gpio = gdp;
95+
96+
platform_set_drvdata(pdev, data);
8697

8798
ret = regmap_write(sy7636a->regmap, SY7636A_REG_POWER_ON_DELAY_TIME, 0x0);
8899
if (ret) {

0 commit comments

Comments
 (0)