Skip to contentSkip to conversation

backlight: l4f00242t03: check return value of regulator_enable()

PATCH Superseded Jingoo Han 2 participants 3 messages Mar 11, 2013

Subsystems (2)

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore

Jingoo Han

author
#0 lore raw

PATCH 1/1 backlight: l4f00242t03: check return value of regulator_enable()

The regulator_enable() was marked as as __must_check, therefore, the return value of regulator_enable() should be checked. Also, this patch checks return value of regulator_set_voltage().

---
 drivers/video/backlight/l4f00242t03.c |   27 ++++++++++++++++++++++-----
 1 files changed, 22 insertions(+), 5 deletions(-)
drivers/video/backlight/l4f00242t03.c +21 -4
index fb61557..8d54c3c 100644
@@ -51,14 +51,31 @@ static void l4f00242t03_lcd_init(struct spi_device *spi)
 	struct l4f00242t03_pdata *pdata = spi->dev.platform_data;
 	struct l4f00242t03_priv *priv = spi_get_drvdata(spi);
 	const u16 cmd[] = { 0x36, param(0), 0x3A, param(0x60) };
+	int ret;
 
 	dev_dbg(&spi->dev, "initializing LCD\n");
 
-	regulator_set_voltage(priv->io_reg, 1800000, 1800000);
-	regulator_enable(priv->io_reg);
+	ret = regulator_set_voltage(priv->io_reg, 1800000, 1800000);
+	if (ret) {
+		dev_err(&spi->dev, "failed to set the IO regulator voltage.\n");
+		return;
+	}
+	ret = regulator_enable(priv->io_reg);
+	if (ret) {
+		dev_err(&spi->dev, "failed to enable the IO regulator.\n");
+		return;
+	}
 
-	regulator_set_voltage(priv->core_reg, 2800000, 2800000);
-	regulator_enable(priv->core_reg);
+	ret = regulator_set_voltage(priv->core_reg, 2800000, 2800000);
+	if (ret) {
+		dev_err(&spi->dev, "failed to set the core regulator voltage.\n");
+		return;
+	}
+	ret = regulator_enable(priv->core_reg);
+	if (ret) {
+		dev_err(&spi->dev, "failed to enable the core regulator.\n");
+		return;
+	}
 
 	l4f00242t03_reset(pdata->reset_gpio);
 
Signature · 1 line
1.7.2.5
#1 lore raw
Quoted 30 lines · On Mon, 11 Mar 2013 12:58:41 +0900 Jingoo Han <[email protected]> wrote:

The regulator_enable() was marked as as __must_check, therefore, the return value of regulator_enable() should be checked. Also, this patch checks return value of regulator_set_voltage().

---
 drivers/video/backlight/l4f00242t03.c |   27 ++++++++++++++++++++++-----
 1 files changed, 22 insertions(+), 5 deletions(-)
drivers/video/backlight/l4f00242t03.c +8 -2
index fb61557..8d54c3c 100644
@@ -51,14 +51,31 @@ static void l4f00242t03_lcd_init(struct spi_device *spi)
 	struct l4f00242t03_pdata *pdata = spi->dev.platform_data;
 	struct l4f00242t03_priv *priv = spi_get_drvdata(spi);
 	const u16 cmd[] = { 0x36, param(0), 0x3A, param(0x60) };
+	int ret;
 
 	dev_dbg(&spi->dev, "initializing LCD\n");
 
-	regulator_set_voltage(priv->io_reg, 1800000, 1800000);
-	regulator_enable(priv->io_reg);
+	ret = regulator_set_voltage(priv->io_reg, 1800000, 1800000);
+	if (ret) {
+		dev_err(&spi->dev, "failed to set the IO regulator voltage.\n");
+		return;
+	}
+	ret = regulator_enable(priv->io_reg);
+	if (ret) {

drivers/video/backlight/l4f00242t03.c static void l4f00242t03_lcd_init(struct spi_device *spi) · line 72

Quoted 10 lines
drivers/video/backlight/l4f00242t03.c +7 -2
+		dev_err(&spi->dev, "failed to enable the IO regulator.\n");
+		return;
+	}
 
-	regulator_set_voltage(priv->core_reg, 2800000, 2800000);
-	regulator_enable(priv->core_reg);
+	ret = regulator_set_voltage(priv->core_reg, 2800000, 2800000);
+	if (ret) {
+		dev_err(&spi->dev, "failed to set the core regulator voltage.\n");
+		return;

Should the IO regulator be disabled before returning?

drivers/video/backlight/l4f00242t03.c static void l4f00242t03_lcd_init(struct spi_device *spi) · line 78

Quoted 6 lines
drivers/video/backlight/l4f00242t03.c +6 -0
+	}
+	ret = regulator_enable(priv->core_reg);
+	if (ret) {
+		dev_err(&spi->dev, "failed to enable the core regulator.\n");
+		return;
+	}

Ditto.

author
#2 lore raw
Quoted 37 lines · Andrew Morton
Quoted 34 lines · On Mon, 11 Mar 2013 12:58:41 +0900 Jingoo Han <[email protected]> wrote:

The regulator_enable() was marked as as __must_check, therefore, the return value of regulator_enable() should be checked. Also, this patch checks return value of regulator_set_voltage().

---
 drivers/video/backlight/l4f00242t03.c |   27 ++++++++++++++++++++++-----
 1 files changed, 22 insertions(+), 5 deletions(-)
drivers/video/backlight/l4f00242t03.c +11 -2
index fb61557..8d54c3c 100644
@@ -51,14 +51,31 @@ static void l4f00242t03_lcd_init(struct spi_device *spi)
 	struct l4f00242t03_pdata *pdata = spi->dev.platform_data;
 	struct l4f00242t03_priv *priv = spi_get_drvdata(spi);
 	const u16 cmd[] = { 0x36, param(0), 0x3A, param(0x60) };
+	int ret;
 
 	dev_dbg(&spi->dev, "initializing LCD\n");
 
-	regulator_set_voltage(priv->io_reg, 1800000, 1800000);
-	regulator_enable(priv->io_reg);
+	ret = regulator_set_voltage(priv->io_reg, 1800000, 1800000);
+	if (ret) {
+		dev_err(&spi->dev, "failed to set the IO regulator voltage.\n");
+		return;
+	}
+	ret = regulator_enable(priv->io_reg);
+	if (ret) {
+		dev_err(&spi->dev, "failed to enable the IO regulator.\n");
+		return;
+	}
 
Quoted 8 lines

drivers/video/backlight/l4f00242t03.c static void l4f00242t03_lcd_init(struct spi_device *spi) · line 72

Quoted 6 lines
drivers/video/backlight/l4f00242t03.c +4 -2
-	regulator_set_voltage(priv->core_reg, 2800000, 2800000);
-	regulator_enable(priv->core_reg);
+	ret = regulator_set_voltage(priv->core_reg, 2800000, 2800000);
+	if (ret) {
+		dev_err(&spi->dev, "failed to set the core regulator voltage.\n");
+		return;

Should the IO regulator be disabled before returning?

Hi Andrew,

OK, I see.
I will send v2 patch.
Thank you :)

Best regards,
Jingoo Han

Quoted 9 lines

drivers/video/backlight/l4f00242t03.c static void l4f00242t03_lcd_init(struct spi_device *spi) · line 78

Quoted 7 lines
drivers/video/backlight/l4f00242t03.c +6 -0
+	}
+	ret = regulator_enable(priv->core_reg);
+	if (ret) {
+		dev_err(&spi->dev, "failed to enable the core regulator.\n");
+		return;
+	}

Ditto.