提交 d073adc5 编写于 作者: J Jingoo Han 提交者: Linus Torvalds

backlight: tdo24m: 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: NJingoo Han <jg1.han@samsung.com>
Cc: Eric Miao <eric.y.miao@gmail.com>
Cc: Richard Purdie <rpurdie@rpsys.net>
Signed-off-by: NAndrew Morton <akpm@linux-foundation.org>
Signed-off-by: NLinus Torvalds <torvalds@linux-foundation.org>
上级 541f936f
...@@ -349,7 +349,7 @@ static int __devinit tdo24m_probe(struct spi_device *spi) ...@@ -349,7 +349,7 @@ static int __devinit tdo24m_probe(struct spi_device *spi)
if (err) if (err)
return err; return err;
lcd = kzalloc(sizeof(struct tdo24m), GFP_KERNEL); lcd = devm_kzalloc(&spi->dev, sizeof(struct tdo24m), GFP_KERNEL);
if (!lcd) if (!lcd)
return -ENOMEM; return -ENOMEM;
...@@ -357,11 +357,9 @@ static int __devinit tdo24m_probe(struct spi_device *spi) ...@@ -357,11 +357,9 @@ static int __devinit tdo24m_probe(struct spi_device *spi)
lcd->power = FB_BLANK_POWERDOWN; lcd->power = FB_BLANK_POWERDOWN;
lcd->mode = MODE_VGA; /* default to VGA */ lcd->mode = MODE_VGA; /* default to VGA */
lcd->buf = kmalloc(TDO24M_SPI_BUFF_SIZE, GFP_KERNEL); lcd->buf = devm_kzalloc(&spi->dev, TDO24M_SPI_BUFF_SIZE, GFP_KERNEL);
if (lcd->buf == NULL) { if (lcd->buf == NULL)
kfree(lcd);
return -ENOMEM; return -ENOMEM;
}
m = &lcd->msg; m = &lcd->msg;
x = &lcd->xfer; x = &lcd->xfer;
...@@ -383,15 +381,13 @@ static int __devinit tdo24m_probe(struct spi_device *spi) ...@@ -383,15 +381,13 @@ static int __devinit tdo24m_probe(struct spi_device *spi)
break; break;
default: default:
dev_err(&spi->dev, "Unsupported model"); dev_err(&spi->dev, "Unsupported model");
goto out_free; return -EINVAL;
} }
lcd->lcd_dev = lcd_device_register("tdo24m", &spi->dev, lcd->lcd_dev = lcd_device_register("tdo24m", &spi->dev,
lcd, &tdo24m_ops); lcd, &tdo24m_ops);
if (IS_ERR(lcd->lcd_dev)) { if (IS_ERR(lcd->lcd_dev))
err = PTR_ERR(lcd->lcd_dev); return PTR_ERR(lcd->lcd_dev);
goto out_free;
}
dev_set_drvdata(&spi->dev, lcd); dev_set_drvdata(&spi->dev, lcd);
err = tdo24m_power(lcd, FB_BLANK_UNBLANK); err = tdo24m_power(lcd, FB_BLANK_UNBLANK);
...@@ -402,9 +398,6 @@ static int __devinit tdo24m_probe(struct spi_device *spi) ...@@ -402,9 +398,6 @@ static int __devinit tdo24m_probe(struct spi_device *spi)
out_unregister: out_unregister:
lcd_device_unregister(lcd->lcd_dev); lcd_device_unregister(lcd->lcd_dev);
out_free:
kfree(lcd->buf);
kfree(lcd);
return err; return err;
} }
...@@ -414,8 +407,6 @@ static int __devexit tdo24m_remove(struct spi_device *spi) ...@@ -414,8 +407,6 @@ static int __devexit tdo24m_remove(struct spi_device *spi)
tdo24m_power(lcd, FB_BLANK_POWERDOWN); tdo24m_power(lcd, FB_BLANK_POWERDOWN);
lcd_device_unregister(lcd->lcd_dev); lcd_device_unregister(lcd->lcd_dev);
kfree(lcd->buf);
kfree(lcd);
return 0; return 0;
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册