Skip to contentSkip to conversation

backlight: Fix broken regulator API usage in l4f00242t03

PATCH New Mark Brown 2 participants 4 messages Aug 15, 2011

Subsystems (6)
lore
Share & tools
lore

Mark Brown

author
#0 lore raw

PATCH 1/1 backlight: Fix broken regulator API usage in l4f00242t03

The regulator support in the l4f00242t03 is very non-idiomatic, rather than requesting the regulators based on the device name and the supply names used by the device the driver requires boards to pass system specific supply names around through platform data. The driver also conditionally requests the regulators based on this platform data, adding unneeded conditional code to the driver.

Fix this by removing the platform data and converting to the standard idiom, also updating all in tree users of the driver. As no datasheet appears to be available for the LCD I'm guessing the names for the supplies based on the existing users and I've no ability to do anything more than compile test.

The use of regulator_set_voltage() in the driver is also problematic, since fixed voltages are required the expectation would be that the voltages would be fixed in the constraints set by the machines rather than manually configured by the driver, but is less problematic.

---
 arch/arm/mach-imx/mach-mx27_3ds.c     |    6 +--
 arch/arm/mach-imx/mach-mx31_3ds.c     |    6 +--
 drivers/video/backlight/l4f00242t03.c |   57 +++++++++++---------------------
 include/linux/spi/l4f00242t03.h       |    2 -
 4 files changed, 24 insertions(+), 47 deletions(-)
arch/arm/mach-imx/mach-mx27_3ds.c +2 -4
index 6fa6934..08e5e20 100644
@@ -241,7 +241,7 @@ static struct regulator_init_data gpo_init = {
 };
 
 static struct regulator_consumer_supply vmmc1_consumers[] = {
-	REGULATOR_SUPPLY("lcd_2v8", NULL),
+	REGULATOR_SUPPLY("vcore", "spi0.0"),
 };
 
 static struct regulator_init_data vmmc1_init = {
@@ -257,7 +257,7 @@ static struct regulator_init_data vmmc1_init = {
 };
 
 static struct regulator_consumer_supply vgen_consumers[] = {
-	REGULATOR_SUPPLY("vdd_lcdio", NULL),
+	REGULATOR_SUPPLY("vdd", "spi0.0"),
 };
 
 static struct regulator_init_data vgen_init = {
@@ -348,8 +348,6 @@ static const struct imx_fb_platform_data mx27_3ds_fb_data __initconst = {
 static struct l4f00242t03_pdata mx27_3ds_lcd_pdata = {
 	.reset_gpio		= LCD_RESET,
 	.data_enable_gpio	= LCD_ENABLE,
-	.core_supply		= "lcd_2v8",
-	.io_supply		= "vdd_lcdio",
 };
 
 static struct spi_board_info mx27_3ds_spi_devs[] __initdata = {
arch/arm/mach-imx/mach-mx31_3ds.c +2 -4
index c20be75..154ed32 100644
@@ -285,8 +285,6 @@ static struct mx3fb_platform_data mx3fb_pdata __initdata = {
 static struct l4f00242t03_pdata mx31_3ds_l4f00242t03_pdata = {
 	.reset_gpio		= IOMUX_TO_GPIO(MX31_PIN_LCS1),
 	.data_enable_gpio	= IOMUX_TO_GPIO(MX31_PIN_SER_RS),
-	.core_supply		= "lcd_2v8",
-	.io_supply		= "vdd_lcdio",
 };
 
 /*
@@ -411,7 +409,7 @@ static struct regulator_init_data vmmc2_init = {
 };
 
 static struct regulator_consumer_supply vmmc1_consumers[] = {
-	REGULATOR_SUPPLY("lcd_2v8", NULL),
+	REGULATOR_SUPPLY("vcore", "spi0.0"),
 	REGULATOR_SUPPLY("cmos_2v8", "soc-camera-pdrv.0"),
 };
 
@@ -428,7 +426,7 @@ static struct regulator_init_data vmmc1_init = {
 };
 
 static struct regulator_consumer_supply vgen_consumers[] = {
-	REGULATOR_SUPPLY("vdd_lcdio", NULL),
+	REGULATOR_SUPPLY("vdd", "spi0.0"),
 };
 
 static struct regulator_init_data vgen_init = {
drivers/video/backlight/l4f00242t03.c +20 -37

91 lines not on this page · raw message

include/linux/spi/l4f00242t03.h +0 -2
index aee1dbd..bc8677c 100644
@@ -24,8 +24,6 @@
 struct l4f00242t03_pdata {
 	unsigned int	reset_gpio;
 	unsigned int	data_enable_gpio;
-	const char 	*io_supply;	/* will be set to 1.8 V */
-	const char 	*core_supply;	/* will be set to 2.8 V */
 };
 
 #endif /* _INCLUDE_LINUX_SPI_L4F00242T03_H_ */
Signature · 1 line
1.7.5.4
maintainer
#1 lore raw

PATCH 1/1 backlight: Fix broken regulator API usage in l4f00242t03

Quoted 42 lines · Mark Brown

The regulator support in the l4f00242t03 is very non-idiomatic, rather than requesting the regulators based on the device name and the supply names used by the device the driver requires boards to pass system specific supply names around through platform data. The driver also conditionally requests the regulators based on this platform data, adding unneeded conditional code to the driver.

Fix this by removing the platform data and converting to the standard idiom, also updating all in tree users of the driver. As no datasheet appears to be available for the LCD I'm guessing the names for the supplies based on the existing users and I've no ability to do anything more than compile test.

The use of regulator_set_voltage() in the driver is also problematic, since fixed voltages are required the expectation would be that the voltages would be fixed in the constraints set by the machines rather than manually configured by the driver, but is less problematic.

static int l4f00242t03_lcd_power_get(struct lcd_device *ld)

drivers/video/backlight/l4f00242t03.c +5 -12
@@ -202,24 +195,18 @@ static int __devinit l4f00242t03_probe(struct spi_device *spi)
 	if (ret)
 		goto err3;
 
-	if (pdata->io_supply) {
-		priv->io_reg = regulator_get(NULL, pdata->io_supply);
-
-		if (IS_ERR(priv->io_reg)) {
-			pr_err("%s: Unable to get the IO regulator\n",
-								__func__);
-			goto err3;
-		}
+	priv->io_reg = regulator_get(&spi->dev, "vdd");
+	if (IS_ERR(priv->io_reg)) {
+		pr_err("%s: Unable to get the IO regulator\n",
+		       __func__);
+		goto err3;
 	}
 
-	if (pdata->core_supply) {
-		priv->core_reg = regulator_get(NULL, pdata->core_supply);
-
-		if (IS_ERR(priv->core_reg)) {

drivers/video/backlight/l4f00242t03.c static int __devinit l4f00242t03_probe(struct spi_device *spi) · line 210

Quoted 10 lines
drivers/video/backlight/l4f00242t03.c +5 -4
-			pr_err("%s: Unable to get the core regulator\n",
-								__func__);
-			goto err4;
-		}
+	priv->core_reg = regulator_get(&spi->dev, "vcore");
+	if (IS_ERR(priv->core_reg)) {
+		pr_err("%s: Unable to get the core regulator\n",
+		       __func__);
+		goto err4;
 	}

Maybe you could change these pr_err to dev_err on the way. The rest of the driver already uses dev_*.

Sascha

Signature · 4 lines
Pengutronix e.K.                           |                             |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |
author
#2 lore raw

PATCH 1/1 backlight: Fix broken regulator API usage in l4f00242t03

Quoted 2 lines · Sascha Hauer

Maybe you could change these pr_err to dev_err on the way. The rest of the driver already uses dev_*.

Minimal diff and all that...

maintainer
#3 lore raw

PATCH 1/1 backlight: Fix broken regulator API usage in l4f00242t03

Quoted 6 lines · Mark Brown
Quoted 2 lines · Sascha Hauer

Maybe you could change these pr_err to dev_err on the way. The rest of the driver already uses dev_*.

Minimal diff and all that...

It just came to my mind because you touch the lines anyway, but I'm fine with the posted version aswell.

Sascha

Signature · 4 lines
Pengutronix e.K.                           |                             |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |