Commit ba4a887a authored by Jingoo Han's avatar Jingoo Han Committed by Linus Torvalds

backlight: l4f00242t03: use devm_ functions

The devm_ functions allocate memory that is released when a driver
detaches.  This patch uses devm_kzalloc of these functions.
Signed-off-by: default avatarJingoo Han <jg1.han@samsung.com>
Cc: Alberto Panizzo <alberto@amarulasolutions.com>
Cc: Richard Purdie <rpurdie@rpsys.net>
Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
parent 9828eb09
...@@ -161,7 +161,8 @@ static int __devinit l4f00242t03_probe(struct spi_device *spi) ...@@ -161,7 +161,8 @@ static int __devinit l4f00242t03_probe(struct spi_device *spi)
return -EINVAL; return -EINVAL;
} }
priv = kzalloc(sizeof(struct l4f00242t03_priv), GFP_KERNEL); priv = devm_kzalloc(&spi->dev, sizeof(struct l4f00242t03_priv),
GFP_KERNEL);
if (priv == NULL) { if (priv == NULL) {
dev_err(&spi->dev, "No memory for this device.\n"); dev_err(&spi->dev, "No memory for this device.\n");
...@@ -179,7 +180,7 @@ static int __devinit l4f00242t03_probe(struct spi_device *spi) ...@@ -179,7 +180,7 @@ static int __devinit l4f00242t03_probe(struct spi_device *spi)
if (ret) { if (ret) {
dev_err(&spi->dev, dev_err(&spi->dev,
"Unable to get the lcd l4f00242t03 reset gpio.\n"); "Unable to get the lcd l4f00242t03 reset gpio.\n");
goto err; return ret;
} }
ret = gpio_request_one(pdata->data_enable_gpio, GPIOF_OUT_INIT_LOW, ret = gpio_request_one(pdata->data_enable_gpio, GPIOF_OUT_INIT_LOW,
...@@ -187,7 +188,7 @@ static int __devinit l4f00242t03_probe(struct spi_device *spi) ...@@ -187,7 +188,7 @@ static int __devinit l4f00242t03_probe(struct spi_device *spi)
if (ret) { if (ret) {
dev_err(&spi->dev, dev_err(&spi->dev,
"Unable to get the lcd l4f00242t03 data en gpio.\n"); "Unable to get the lcd l4f00242t03 data en gpio.\n");
goto err2; goto err;
} }
priv->io_reg = regulator_get(&spi->dev, "vdd"); priv->io_reg = regulator_get(&spi->dev, "vdd");
...@@ -195,7 +196,7 @@ static int __devinit l4f00242t03_probe(struct spi_device *spi) ...@@ -195,7 +196,7 @@ static int __devinit l4f00242t03_probe(struct spi_device *spi)
ret = PTR_ERR(priv->io_reg); ret = PTR_ERR(priv->io_reg);
dev_err(&spi->dev, "%s: Unable to get the IO regulator\n", dev_err(&spi->dev, "%s: Unable to get the IO regulator\n",
__func__); __func__);
goto err3; goto err2;
} }
priv->core_reg = regulator_get(&spi->dev, "vcore"); priv->core_reg = regulator_get(&spi->dev, "vcore");
...@@ -203,14 +204,14 @@ static int __devinit l4f00242t03_probe(struct spi_device *spi) ...@@ -203,14 +204,14 @@ static int __devinit l4f00242t03_probe(struct spi_device *spi)
ret = PTR_ERR(priv->core_reg); ret = PTR_ERR(priv->core_reg);
dev_err(&spi->dev, "%s: Unable to get the core regulator\n", dev_err(&spi->dev, "%s: Unable to get the core regulator\n",
__func__); __func__);
goto err4; goto err3;
} }
priv->ld = lcd_device_register("l4f00242t03", priv->ld = lcd_device_register("l4f00242t03",
&spi->dev, priv, &l4f_ops); &spi->dev, priv, &l4f_ops);
if (IS_ERR(priv->ld)) { if (IS_ERR(priv->ld)) {
ret = PTR_ERR(priv->ld); ret = PTR_ERR(priv->ld);
goto err5; goto err4;
} }
/* Init the LCD */ /* Init the LCD */
...@@ -222,16 +223,14 @@ static int __devinit l4f00242t03_probe(struct spi_device *spi) ...@@ -222,16 +223,14 @@ static int __devinit l4f00242t03_probe(struct spi_device *spi)
return 0; return 0;
err5:
regulator_put(priv->core_reg);
err4: err4:
regulator_put(priv->io_reg); regulator_put(priv->core_reg);
err3: err3:
gpio_free(pdata->data_enable_gpio); regulator_put(priv->io_reg);
err2: err2:
gpio_free(pdata->reset_gpio); gpio_free(pdata->data_enable_gpio);
err: err:
kfree(priv); gpio_free(pdata->reset_gpio);
return ret; return ret;
} }
...@@ -252,8 +251,6 @@ static int __devexit l4f00242t03_remove(struct spi_device *spi) ...@@ -252,8 +251,6 @@ static int __devexit l4f00242t03_remove(struct spi_device *spi)
regulator_put(priv->io_reg); regulator_put(priv->io_reg);
regulator_put(priv->core_reg); regulator_put(priv->core_reg);
kfree(priv);
return 0; return 0;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment