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

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.

Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
Tested-by: Fabio Estevam <fabio.estevam@freescale.com>
Cc: Richard Purdie <rpurdie@rpsys.net>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>

authored by

Mark Brown and committed by
Linus Torvalds
0556dc34 2967b0ad

+24 -47
+2 -4
arch/arm/mach-imx/mach-mx27_3ds.c
··· 241 241 }; 242 242 243 243 static struct regulator_consumer_supply vmmc1_consumers[] = { 244 - REGULATOR_SUPPLY("lcd_2v8", NULL), 244 + REGULATOR_SUPPLY("vcore", "spi0.0"), 245 245 }; 246 246 247 247 static struct regulator_init_data vmmc1_init = { ··· 257 257 }; 258 258 259 259 static struct regulator_consumer_supply vgen_consumers[] = { 260 - REGULATOR_SUPPLY("vdd_lcdio", NULL), 260 + REGULATOR_SUPPLY("vdd", "spi0.0"), 261 261 }; 262 262 263 263 static struct regulator_init_data vgen_init = { ··· 348 348 static struct l4f00242t03_pdata mx27_3ds_lcd_pdata = { 349 349 .reset_gpio = LCD_RESET, 350 350 .data_enable_gpio = LCD_ENABLE, 351 - .core_supply = "lcd_2v8", 352 - .io_supply = "vdd_lcdio", 353 351 }; 354 352 355 353 static struct spi_board_info mx27_3ds_spi_devs[] __initdata = {
+2 -4
arch/arm/mach-imx/mach-mx31_3ds.c
··· 285 285 static struct l4f00242t03_pdata mx31_3ds_l4f00242t03_pdata = { 286 286 .reset_gpio = IOMUX_TO_GPIO(MX31_PIN_LCS1), 287 287 .data_enable_gpio = IOMUX_TO_GPIO(MX31_PIN_SER_RS), 288 - .core_supply = "lcd_2v8", 289 - .io_supply = "vdd_lcdio", 290 288 }; 291 289 292 290 /* ··· 409 411 }; 410 412 411 413 static struct regulator_consumer_supply vmmc1_consumers[] = { 412 - REGULATOR_SUPPLY("lcd_2v8", NULL), 414 + REGULATOR_SUPPLY("vcore", "spi0.0"), 413 415 REGULATOR_SUPPLY("cmos_2v8", "soc-camera-pdrv.0"), 414 416 }; 415 417 ··· 426 428 }; 427 429 428 430 static struct regulator_consumer_supply vgen_consumers[] = { 429 - REGULATOR_SUPPLY("vdd_lcdio", NULL), 431 + REGULATOR_SUPPLY("vdd", "spi0.0"), 430 432 }; 431 433 432 434 static struct regulator_init_data vgen_init = {
+20 -37
drivers/video/backlight/l4f00242t03.c
··· 52 52 53 53 dev_dbg(&spi->dev, "initializing LCD\n"); 54 54 55 - if (priv->io_reg) { 56 - regulator_set_voltage(priv->io_reg, 1800000, 1800000); 57 - regulator_enable(priv->io_reg); 58 - } 55 + regulator_set_voltage(priv->io_reg, 1800000, 1800000); 56 + regulator_enable(priv->io_reg); 59 57 60 - if (priv->core_reg) { 61 - regulator_set_voltage(priv->core_reg, 2800000, 2800000); 62 - regulator_enable(priv->core_reg); 63 - } 58 + regulator_set_voltage(priv->core_reg, 2800000, 2800000); 59 + regulator_enable(priv->core_reg); 64 60 65 61 l4f00242t03_reset(pdata->reset_gpio); 66 62 ··· 74 78 75 79 gpio_set_value(pdata->data_enable_gpio, 0); 76 80 77 - if (priv->io_reg) 78 - regulator_disable(priv->io_reg); 79 - 80 - if (priv->core_reg) 81 - regulator_disable(priv->core_reg); 81 + regulator_disable(priv->io_reg); 82 + regulator_disable(priv->core_reg); 82 83 } 83 84 84 85 static int l4f00242t03_lcd_power_get(struct lcd_device *ld) ··· 194 201 if (ret) 195 202 goto err3; 196 203 197 - if (pdata->io_supply) { 198 - priv->io_reg = regulator_get(NULL, pdata->io_supply); 199 - 200 - if (IS_ERR(priv->io_reg)) { 201 - pr_err("%s: Unable to get the IO regulator\n", 202 - __func__); 203 - goto err3; 204 - } 204 + priv->io_reg = regulator_get(&spi->dev, "vdd"); 205 + if (IS_ERR(priv->io_reg)) { 206 + dev_err(&spi->dev, "%s: Unable to get the IO regulator\n", 207 + __func__); 208 + goto err3; 205 209 } 206 210 207 - if (pdata->core_supply) { 208 - priv->core_reg = regulator_get(NULL, pdata->core_supply); 209 - 210 - if (IS_ERR(priv->core_reg)) { 211 - pr_err("%s: Unable to get the core regulator\n", 212 - __func__); 213 - goto err4; 214 - } 211 + priv->core_reg = regulator_get(&spi->dev, "vcore"); 212 + if (IS_ERR(priv->core_reg)) { 213 + dev_err(&spi->dev, "%s: Unable to get the core regulator\n", 214 + __func__); 215 + goto err4; 215 216 } 216 217 217 218 priv->ld = lcd_device_register("l4f00242t03", ··· 225 238 return 0; 226 239 227 240 err5: 228 - if (priv->core_reg) 229 - regulator_put(priv->core_reg); 241 + regulator_put(priv->core_reg); 230 242 err4: 231 - if (priv->io_reg) 232 - regulator_put(priv->io_reg); 243 + regulator_put(priv->io_reg); 233 244 err3: 234 245 gpio_free(pdata->data_enable_gpio); 235 246 err2: ··· 251 266 gpio_free(pdata->data_enable_gpio); 252 267 gpio_free(pdata->reset_gpio); 253 268 254 - if (priv->io_reg) 255 - regulator_put(priv->io_reg); 256 - if (priv->core_reg) 257 - regulator_put(priv->core_reg); 269 + regulator_put(priv->io_reg); 270 + regulator_put(priv->core_reg); 258 271 259 272 kfree(priv); 260 273
-2
include/linux/spi/l4f00242t03.h
··· 24 24 struct l4f00242t03_pdata { 25 25 unsigned int reset_gpio; 26 26 unsigned int data_enable_gpio; 27 - const char *io_supply; /* will be set to 1.8 V */ 28 - const char *core_supply; /* will be set to 2.8 V */ 29 27 }; 30 28 31 29 #endif /* _INCLUDE_LINUX_SPI_L4F00242T03_H_ */