lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20210803084456.198-7-alistair@alistair23.me>
Date:   Tue,  3 Aug 2021 18:44:54 +1000
From:   Alistair Francis <alistair@...stair23.me>
To:     lee.jones@...aro.org, robh+dt@...nel.org, lgirdwood@...il.com,
        broonie@...nel.org, linux-imx@....com, kernel@...gutronix.de
Cc:     devicetree@...r.kernel.org, linux-kernel@...r.kernel.org,
        alistair23@...il.com, Alistair Francis <alistair@...stair23.me>
Subject: [PATCH v8 07/11] 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 <alistair@...stair23.me>
---
 drivers/regulator/sy7636a-regulator.c | 21 ++++++++++++++++-----
 1 file changed, 16 insertions(+), 5 deletions(-)

diff --git a/drivers/regulator/sy7636a-regulator.c b/drivers/regulator/sy7636a-regulator.c
index 0bd21c3ea24a..37bf2a3c06b7 100644
--- a/drivers/regulator/sy7636a-regulator.c
+++ b/drivers/regulator/sy7636a-regulator.c
@@ -13,6 +13,11 @@
 #include <linux/gpio/consumer.h>
 #include <linux/mfd/sy7636a.h>
 
+struct sy7636a_data {
+	struct sy7636a *sy7636a;
+	struct gpio_desc *pgood_gpio;
+};
+
 static int sy7636a_get_vcom_voltage_op(struct regulator_dev *rdev)
 {
 	int ret;
@@ -33,10 +38,10 @@ static int sy7636a_get_vcom_voltage_op(struct regulator_dev *rdev)
 
 static int sy7636a_get_status(struct regulator_dev *rdev)
 {
-	struct sy7636a *sy7636a = dev_get_drvdata(rdev->dev.parent);
+	struct sy7636a_data *data = dev_get_drvdata(rdev->dev.parent);
 	int ret = 0;
 
-	ret = gpiod_get_value_cansleep(sy7636a->pgood_gpio);
+	ret = gpiod_get_value_cansleep(data->pgood_gpio);
 	if (ret < 0)
 		dev_err(&rdev->dev, "Failed to read pgood gpio: %d\n", ret);
 
@@ -69,20 +74,26 @@ static int sy7636a_regulator_probe(struct platform_device *pdev)
 	struct regulator_config config = { };
 	struct regulator_dev *rdev;
 	struct gpio_desc *gdp;
+	struct sy7636a_data *data;
 	int ret;
 
 	if (!sy7636a)
 		return -EPROBE_DEFER;
 
-	platform_set_drvdata(pdev, sy7636a);
-
 	gdp = devm_gpiod_get(pdev->dev.parent, "epd-pwr-good", GPIOD_IN);
 	if (IS_ERR(gdp)) {
 		dev_err(pdev->dev.parent, "Power good GPIO fault %ld\n", PTR_ERR(gdp));
 		return PTR_ERR(gdp);
 	}
 
-	sy7636a->pgood_gpio = gdp;
+	data = devm_kzalloc(&pdev->dev, sizeof(struct sy7636a_data), GFP_KERNEL);
+	if (!data)
+		return -ENOMEM;
+
+	data->sy7636a = sy7636a;
+	data->pgood_gpio = gdp;
+
+	platform_set_drvdata(pdev, data);
 
 	ret = regmap_write(sy7636a->regmap, SY7636A_REG_POWER_ON_DELAY_TIME, 0x0);
 	if (ret) {
-- 
2.31.1

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ