aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/gpio/gpio-tps65912.c
diff options
context:
space:
mode:
authorAxel Lin <axel.lin@gmail.com>2012-09-01 05:44:27 -0400
committerLinus Walleij <linus.walleij@linaro.org>2012-09-01 06:55:30 -0400
commit45e253a7eb23844344bf08dad9961771a643758e (patch)
treea158b4c0d0d9e89576bace02724c4cf459332d83 /drivers/gpio/gpio-tps65912.c
parenteb7cf95a55a0d737e5f5694e71f65966a1c4e7aa (diff)
gpio: tps65912: Convert to use devm_kzalloc API
Signed-off-by: Axel Lin <axel.lin@gmail.com> Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
Diffstat (limited to 'drivers/gpio/gpio-tps65912.c')
-rw-r--r--drivers/gpio/gpio-tps65912.c17
1 files changed, 4 insertions, 13 deletions
diff --git a/drivers/gpio/gpio-tps65912.c b/drivers/gpio/gpio-tps65912.c
index 79e66c002350..99106d1e2e55 100644
--- a/drivers/gpio/gpio-tps65912.c
+++ b/drivers/gpio/gpio-tps65912.c
@@ -70,7 +70,6 @@ static int tps65912_gpio_input(struct gpio_chip *gc, unsigned offset)
70 70
71 return tps65912_clear_bits(tps65912, TPS65912_GPIO1 + offset, 71 return tps65912_clear_bits(tps65912, TPS65912_GPIO1 + offset,
72 GPIO_CFG_MASK); 72 GPIO_CFG_MASK);
73
74} 73}
75 74
76static struct gpio_chip template_chip = { 75static struct gpio_chip template_chip = {
@@ -92,7 +91,8 @@ static int __devinit tps65912_gpio_probe(struct platform_device *pdev)
92 struct tps65912_gpio_data *tps65912_gpio; 91 struct tps65912_gpio_data *tps65912_gpio;
93 int ret; 92 int ret;
94 93
95 tps65912_gpio = kzalloc(sizeof(*tps65912_gpio), GFP_KERNEL); 94 tps65912_gpio = devm_kzalloc(&pdev->dev, sizeof(*tps65912_gpio),
95 GFP_KERNEL);
96 if (tps65912_gpio == NULL) 96 if (tps65912_gpio == NULL)
97 return -ENOMEM; 97 return -ENOMEM;
98 98
@@ -105,28 +105,19 @@ static int __devinit tps65912_gpio_probe(struct platform_device *pdev)
105 ret = gpiochip_add(&tps65912_gpio->gpio_chip); 105 ret = gpiochip_add(&tps65912_gpio->gpio_chip);
106 if (ret < 0) { 106 if (ret < 0) {
107 dev_err(&pdev->dev, "Failed to register gpiochip, %d\n", ret); 107 dev_err(&pdev->dev, "Failed to register gpiochip, %d\n", ret);
108 goto err; 108 return ret;
109 } 109 }
110 110
111 platform_set_drvdata(pdev, tps65912_gpio); 111 platform_set_drvdata(pdev, tps65912_gpio);
112 112
113 return ret; 113 return ret;
114
115err:
116 kfree(tps65912_gpio);
117 return ret;
118} 114}
119 115
120static int __devexit tps65912_gpio_remove(struct platform_device *pdev) 116static int __devexit tps65912_gpio_remove(struct platform_device *pdev)
121{ 117{
122 struct tps65912_gpio_data *tps65912_gpio = platform_get_drvdata(pdev); 118 struct tps65912_gpio_data *tps65912_gpio = platform_get_drvdata(pdev);
123 int ret;
124
125 ret = gpiochip_remove(&tps65912_gpio->gpio_chip);
126 if (ret == 0)
127 kfree(tps65912_gpio);
128 119
129 return ret; 120 return gpiochip_remove(&tps65912_gpio->gpio_chip);
130} 121}
131 122
132static struct platform_driver tps65912_gpio_driver = { 123static struct platform_driver tps65912_gpio_driver = {