aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/video
diff options
context:
space:
mode:
authorJulia Lawall <Julia.Lawall@lip6.fr>2012-03-23 18:02:00 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2012-03-23 19:58:33 -0400
commitce969228fdb54a7e3d7cc1ed27367fd4b9525d74 (patch)
tree9850c7cc96d582302769c442e00142ac30a7bbc3 /drivers/video
parent1107d40a50956146d1272f5cffcdf1d83f7e703e (diff)
drivers/video/backlight: use devm_ functions
The various devm_ functions allocate memory that is released when a driver detaches. This patch uses these functions for data that is allocated in the probe function of a platform device and is only freed in the remove function. Signed-off-by: Julia Lawall <Julia.Lawall@lip6.fr> Cc: Dimitris Papastamos <dp@opensource.wolfsonmicro.com> Cc: Richard Purdie <rpurdie@rpsys.net> Cc: Florian Tobias Schandinat <FlorianSchandinat@gmx.de> Cc: Mark Brown <broonie@opensource.wolfsonmicro.com> Cc: Michael Hennerich <michael.hennerich@analog.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'drivers/video')
-rw-r--r--drivers/video/backlight/88pm860x_bl.c8
-rw-r--r--drivers/video/backlight/aat2870_bl.c9
-rw-r--r--drivers/video/backlight/cr_bllcd.c3
-rw-r--r--drivers/video/backlight/da903x_bl.c6
-rw-r--r--drivers/video/backlight/max8925_bl.c7
-rw-r--r--drivers/video/backlight/omap1_bl.c9
-rw-r--r--drivers/video/backlight/pcf50633-backlight.c16
-rw-r--r--drivers/video/backlight/pwm_bl.c7
8 files changed, 18 insertions, 47 deletions
diff --git a/drivers/video/backlight/88pm860x_bl.c b/drivers/video/backlight/88pm860x_bl.c
index a1376dc73d71..915943af3f21 100644
--- a/drivers/video/backlight/88pm860x_bl.c
+++ b/drivers/video/backlight/88pm860x_bl.c
@@ -187,7 +187,8 @@ static int pm860x_backlight_probe(struct platform_device *pdev)
187 return -EINVAL; 187 return -EINVAL;
188 } 188 }
189 189
190 data = kzalloc(sizeof(struct pm860x_backlight_data), GFP_KERNEL); 190 data = devm_kzalloc(&pdev->dev, sizeof(struct pm860x_backlight_data),
191 GFP_KERNEL);
191 if (data == NULL) 192 if (data == NULL)
192 return -ENOMEM; 193 return -ENOMEM;
193 strncpy(name, res->name, MFD_NAME_SIZE); 194 strncpy(name, res->name, MFD_NAME_SIZE);
@@ -200,7 +201,6 @@ static int pm860x_backlight_probe(struct platform_device *pdev)
200 data->port = pdata->flags; 201 data->port = pdata->flags;
201 if (data->port < 0) { 202 if (data->port < 0) {
202 dev_err(&pdev->dev, "wrong platform data is assigned"); 203 dev_err(&pdev->dev, "wrong platform data is assigned");
203 kfree(data);
204 return -EINVAL; 204 return -EINVAL;
205 } 205 }
206 206
@@ -211,7 +211,6 @@ static int pm860x_backlight_probe(struct platform_device *pdev)
211 &pm860x_backlight_ops, &props); 211 &pm860x_backlight_ops, &props);
212 if (IS_ERR(bl)) { 212 if (IS_ERR(bl)) {
213 dev_err(&pdev->dev, "failed to register backlight\n"); 213 dev_err(&pdev->dev, "failed to register backlight\n");
214 kfree(data);
215 return PTR_ERR(bl); 214 return PTR_ERR(bl);
216 } 215 }
217 bl->props.brightness = MAX_BRIGHTNESS; 216 bl->props.brightness = MAX_BRIGHTNESS;
@@ -247,17 +246,14 @@ static int pm860x_backlight_probe(struct platform_device *pdev)
247 return 0; 246 return 0;
248out: 247out:
249 backlight_device_unregister(bl); 248 backlight_device_unregister(bl);
250 kfree(data);
251 return ret; 249 return ret;
252} 250}
253 251
254static int pm860x_backlight_remove(struct platform_device *pdev) 252static int pm860x_backlight_remove(struct platform_device *pdev)
255{ 253{
256 struct backlight_device *bl = platform_get_drvdata(pdev); 254 struct backlight_device *bl = platform_get_drvdata(pdev);
257 struct pm860x_backlight_data *data = bl_get_data(bl);
258 255
259 backlight_device_unregister(bl); 256 backlight_device_unregister(bl);
260 kfree(data);
261 return 0; 257 return 0;
262} 258}
263 259
diff --git a/drivers/video/backlight/aat2870_bl.c b/drivers/video/backlight/aat2870_bl.c
index 331f1ef1dad5..7ff752288b92 100644
--- a/drivers/video/backlight/aat2870_bl.c
+++ b/drivers/video/backlight/aat2870_bl.c
@@ -145,7 +145,9 @@ static int aat2870_bl_probe(struct platform_device *pdev)
145 goto out; 145 goto out;
146 } 146 }
147 147
148 aat2870_bl = kzalloc(sizeof(struct aat2870_bl_driver_data), GFP_KERNEL); 148 aat2870_bl = devm_kzalloc(&pdev->dev,
149 sizeof(struct aat2870_bl_driver_data),
150 GFP_KERNEL);
149 if (!aat2870_bl) { 151 if (!aat2870_bl) {
150 dev_err(&pdev->dev, 152 dev_err(&pdev->dev,
151 "Failed to allocate memory for aat2870 backlight\n"); 153 "Failed to allocate memory for aat2870 backlight\n");
@@ -162,7 +164,7 @@ static int aat2870_bl_probe(struct platform_device *pdev)
162 dev_err(&pdev->dev, 164 dev_err(&pdev->dev,
163 "Failed allocate memory for backlight device\n"); 165 "Failed allocate memory for backlight device\n");
164 ret = PTR_ERR(bd); 166 ret = PTR_ERR(bd);
165 goto out_kfree; 167 goto out;
166 } 168 }
167 169
168 aat2870_bl->pdev = pdev; 170 aat2870_bl->pdev = pdev;
@@ -199,8 +201,6 @@ static int aat2870_bl_probe(struct platform_device *pdev)
199 201
200out_bl_dev_unregister: 202out_bl_dev_unregister:
201 backlight_device_unregister(bd); 203 backlight_device_unregister(bd);
202out_kfree:
203 kfree(aat2870_bl);
204out: 204out:
205 return ret; 205 return ret;
206} 206}
@@ -215,7 +215,6 @@ static int aat2870_bl_remove(struct platform_device *pdev)
215 backlight_update_status(bd); 215 backlight_update_status(bd);
216 216
217 backlight_device_unregister(bd); 217 backlight_device_unregister(bd);
218 kfree(aat2870_bl);
219 218
220 return 0; 219 return 0;
221} 220}
diff --git a/drivers/video/backlight/cr_bllcd.c b/drivers/video/backlight/cr_bllcd.c
index 6c8c54041fae..22489eb5f3e0 100644
--- a/drivers/video/backlight/cr_bllcd.c
+++ b/drivers/video/backlight/cr_bllcd.c
@@ -212,7 +212,7 @@ static int cr_backlight_probe(struct platform_device *pdev)
212 &gpio_bar); 212 &gpio_bar);
213 gpio_bar &= ~0x3F; 213 gpio_bar &= ~0x3F;
214 214
215 crp = kzalloc(sizeof(*crp), GFP_KERNEL); 215 crp = devm_kzalloc(&pdev->dev, sizeof(*crp), GFP_KERNEL);
216 if (!crp) { 216 if (!crp) {
217 lcd_device_unregister(ldp); 217 lcd_device_unregister(ldp);
218 backlight_device_unregister(bdp); 218 backlight_device_unregister(bdp);
@@ -243,7 +243,6 @@ static int cr_backlight_remove(struct platform_device *pdev)
243 backlight_device_unregister(crp->cr_backlight_device); 243 backlight_device_unregister(crp->cr_backlight_device);
244 lcd_device_unregister(crp->cr_lcd_device); 244 lcd_device_unregister(crp->cr_lcd_device);
245 pci_dev_put(lpc_dev); 245 pci_dev_put(lpc_dev);
246 kfree(crp);
247 246
248 return 0; 247 return 0;
249} 248}
diff --git a/drivers/video/backlight/da903x_bl.c b/drivers/video/backlight/da903x_bl.c
index abb4a06268f1..30e19681a30b 100644
--- a/drivers/video/backlight/da903x_bl.c
+++ b/drivers/video/backlight/da903x_bl.c
@@ -110,7 +110,7 @@ static int da903x_backlight_probe(struct platform_device *pdev)
110 struct backlight_properties props; 110 struct backlight_properties props;
111 int max_brightness; 111 int max_brightness;
112 112
113 data = kzalloc(sizeof(*data), GFP_KERNEL); 113 data = devm_kzalloc(&pdev->dev, sizeof(*data), GFP_KERNEL);
114 if (data == NULL) 114 if (data == NULL)
115 return -ENOMEM; 115 return -ENOMEM;
116 116
@@ -124,7 +124,6 @@ static int da903x_backlight_probe(struct platform_device *pdev)
124 default: 124 default:
125 dev_err(&pdev->dev, "invalid backlight device ID(%d)\n", 125 dev_err(&pdev->dev, "invalid backlight device ID(%d)\n",
126 pdev->id); 126 pdev->id);
127 kfree(data);
128 return -EINVAL; 127 return -EINVAL;
129 } 128 }
130 129
@@ -143,7 +142,6 @@ static int da903x_backlight_probe(struct platform_device *pdev)
143 &da903x_backlight_ops, &props); 142 &da903x_backlight_ops, &props);
144 if (IS_ERR(bl)) { 143 if (IS_ERR(bl)) {
145 dev_err(&pdev->dev, "failed to register backlight\n"); 144 dev_err(&pdev->dev, "failed to register backlight\n");
146 kfree(data);
147 return PTR_ERR(bl); 145 return PTR_ERR(bl);
148 } 146 }
149 147
@@ -157,10 +155,8 @@ static int da903x_backlight_probe(struct platform_device *pdev)
157static int da903x_backlight_remove(struct platform_device *pdev) 155static int da903x_backlight_remove(struct platform_device *pdev)
158{ 156{
159 struct backlight_device *bl = platform_get_drvdata(pdev); 157 struct backlight_device *bl = platform_get_drvdata(pdev);
160 struct da903x_backlight_data *data = bl_get_data(bl);
161 158
162 backlight_device_unregister(bl); 159 backlight_device_unregister(bl);
163 kfree(data);
164 return 0; 160 return 0;
165} 161}
166 162
diff --git a/drivers/video/backlight/max8925_bl.c b/drivers/video/backlight/max8925_bl.c
index c915e3b53886..e833ac72e063 100644
--- a/drivers/video/backlight/max8925_bl.c
+++ b/drivers/video/backlight/max8925_bl.c
@@ -129,7 +129,8 @@ static int __devinit max8925_backlight_probe(struct platform_device *pdev)
129 return -EINVAL; 129 return -EINVAL;
130 } 130 }
131 131
132 data = kzalloc(sizeof(struct max8925_backlight_data), GFP_KERNEL); 132 data = devm_kzalloc(&pdev->dev, sizeof(struct max8925_backlight_data),
133 GFP_KERNEL);
133 if (data == NULL) 134 if (data == NULL)
134 return -ENOMEM; 135 return -ENOMEM;
135 strncpy(name, res->name, MAX8925_NAME_SIZE); 136 strncpy(name, res->name, MAX8925_NAME_SIZE);
@@ -143,7 +144,6 @@ static int __devinit max8925_backlight_probe(struct platform_device *pdev)
143 &max8925_backlight_ops, &props); 144 &max8925_backlight_ops, &props);
144 if (IS_ERR(bl)) { 145 if (IS_ERR(bl)) {
145 dev_err(&pdev->dev, "failed to register backlight\n"); 146 dev_err(&pdev->dev, "failed to register backlight\n");
146 kfree(data);
147 return PTR_ERR(bl); 147 return PTR_ERR(bl);
148 } 148 }
149 bl->props.brightness = MAX_BRIGHTNESS; 149 bl->props.brightness = MAX_BRIGHTNESS;
@@ -165,17 +165,14 @@ static int __devinit max8925_backlight_probe(struct platform_device *pdev)
165 return 0; 165 return 0;
166out: 166out:
167 backlight_device_unregister(bl); 167 backlight_device_unregister(bl);
168 kfree(data);
169 return ret; 168 return ret;
170} 169}
171 170
172static int __devexit max8925_backlight_remove(struct platform_device *pdev) 171static int __devexit max8925_backlight_remove(struct platform_device *pdev)
173{ 172{
174 struct backlight_device *bl = platform_get_drvdata(pdev); 173 struct backlight_device *bl = platform_get_drvdata(pdev);
175 struct max8925_backlight_data *data = bl_get_data(bl);
176 174
177 backlight_device_unregister(bl); 175 backlight_device_unregister(bl);
178 kfree(data);
179 return 0; 176 return 0;
180} 177}
181 178
diff --git a/drivers/video/backlight/omap1_bl.c b/drivers/video/backlight/omap1_bl.c
index d8cde277ec83..0175bfb08a1c 100644
--- a/drivers/video/backlight/omap1_bl.c
+++ b/drivers/video/backlight/omap1_bl.c
@@ -141,7 +141,8 @@ static int omapbl_probe(struct platform_device *pdev)
141 if (!pdata) 141 if (!pdata)
142 return -ENXIO; 142 return -ENXIO;
143 143
144 bl = kzalloc(sizeof(struct omap_backlight), GFP_KERNEL); 144 bl = devm_kzalloc(&pdev->dev, sizeof(struct omap_backlight),
145 GFP_KERNEL);
145 if (unlikely(!bl)) 146 if (unlikely(!bl))
146 return -ENOMEM; 147 return -ENOMEM;
147 148
@@ -150,10 +151,8 @@ static int omapbl_probe(struct platform_device *pdev)
150 props.max_brightness = OMAPBL_MAX_INTENSITY; 151 props.max_brightness = OMAPBL_MAX_INTENSITY;
151 dev = backlight_device_register("omap-bl", &pdev->dev, bl, &omapbl_ops, 152 dev = backlight_device_register("omap-bl", &pdev->dev, bl, &omapbl_ops,
152 &props); 153 &props);
153 if (IS_ERR(dev)) { 154 if (IS_ERR(dev))
154 kfree(bl);
155 return PTR_ERR(dev); 155 return PTR_ERR(dev);
156 }
157 156
158 bl->powermode = FB_BLANK_POWERDOWN; 157 bl->powermode = FB_BLANK_POWERDOWN;
159 bl->current_intensity = 0; 158 bl->current_intensity = 0;
@@ -177,10 +176,8 @@ static int omapbl_probe(struct platform_device *pdev)
177static int omapbl_remove(struct platform_device *pdev) 176static int omapbl_remove(struct platform_device *pdev)
178{ 177{
179 struct backlight_device *dev = platform_get_drvdata(pdev); 178 struct backlight_device *dev = platform_get_drvdata(pdev);
180 struct omap_backlight *bl = dev_get_drvdata(&dev->dev);
181 179
182 backlight_device_unregister(dev); 180 backlight_device_unregister(dev);
183 kfree(bl);
184 181
185 return 0; 182 return 0;
186} 183}
diff --git a/drivers/video/backlight/pcf50633-backlight.c b/drivers/video/backlight/pcf50633-backlight.c
index 13e88b71daec..c65853cb9740 100644
--- a/drivers/video/backlight/pcf50633-backlight.c
+++ b/drivers/video/backlight/pcf50633-backlight.c
@@ -101,14 +101,13 @@ static const struct backlight_ops pcf50633_bl_ops = {
101 101
102static int __devinit pcf50633_bl_probe(struct platform_device *pdev) 102static int __devinit pcf50633_bl_probe(struct platform_device *pdev)
103{ 103{
104 int ret;
105 struct pcf50633_bl *pcf_bl; 104 struct pcf50633_bl *pcf_bl;
106 struct device *parent = pdev->dev.parent; 105 struct device *parent = pdev->dev.parent;
107 struct pcf50633_platform_data *pcf50633_data = parent->platform_data; 106 struct pcf50633_platform_data *pcf50633_data = parent->platform_data;
108 struct pcf50633_bl_platform_data *pdata = pcf50633_data->backlight_data; 107 struct pcf50633_bl_platform_data *pdata = pcf50633_data->backlight_data;
109 struct backlight_properties bl_props; 108 struct backlight_properties bl_props;
110 109
111 pcf_bl = kzalloc(sizeof(*pcf_bl), GFP_KERNEL); 110 pcf_bl = devm_kzalloc(&pdev->dev, sizeof(*pcf_bl), GFP_KERNEL);
112 if (!pcf_bl) 111 if (!pcf_bl)
113 return -ENOMEM; 112 return -ENOMEM;
114 113
@@ -129,10 +128,8 @@ static int __devinit pcf50633_bl_probe(struct platform_device *pdev)
129 pcf_bl->bl = backlight_device_register(pdev->name, &pdev->dev, pcf_bl, 128 pcf_bl->bl = backlight_device_register(pdev->name, &pdev->dev, pcf_bl,
130 &pcf50633_bl_ops, &bl_props); 129 &pcf50633_bl_ops, &bl_props);
131 130
132 if (IS_ERR(pcf_bl->bl)) { 131 if (IS_ERR(pcf_bl->bl))
133 ret = PTR_ERR(pcf_bl->bl); 132 return PTR_ERR(pcf_bl->bl);
134 goto err_free;
135 }
136 133
137 platform_set_drvdata(pdev, pcf_bl); 134 platform_set_drvdata(pdev, pcf_bl);
138 135
@@ -145,11 +142,6 @@ static int __devinit pcf50633_bl_probe(struct platform_device *pdev)
145 backlight_update_status(pcf_bl->bl); 142 backlight_update_status(pcf_bl->bl);
146 143
147 return 0; 144 return 0;
148
149err_free:
150 kfree(pcf_bl);
151
152 return ret;
153} 145}
154 146
155static int __devexit pcf50633_bl_remove(struct platform_device *pdev) 147static int __devexit pcf50633_bl_remove(struct platform_device *pdev)
@@ -160,8 +152,6 @@ static int __devexit pcf50633_bl_remove(struct platform_device *pdev)
160 152
161 platform_set_drvdata(pdev, NULL); 153 platform_set_drvdata(pdev, NULL);
162 154
163 kfree(pcf_bl);
164
165 return 0; 155 return 0;
166} 156}
167 157
diff --git a/drivers/video/backlight/pwm_bl.c b/drivers/video/backlight/pwm_bl.c
index 7496d04e1d3c..342b7d7cbb63 100644
--- a/drivers/video/backlight/pwm_bl.c
+++ b/drivers/video/backlight/pwm_bl.c
@@ -102,7 +102,7 @@ static int pwm_backlight_probe(struct platform_device *pdev)
102 return ret; 102 return ret;
103 } 103 }
104 104
105 pb = kzalloc(sizeof(*pb), GFP_KERNEL); 105 pb = devm_kzalloc(&pdev->dev, sizeof(*pb), GFP_KERNEL);
106 if (!pb) { 106 if (!pb) {
107 dev_err(&pdev->dev, "no memory for state\n"); 107 dev_err(&pdev->dev, "no memory for state\n");
108 ret = -ENOMEM; 108 ret = -ENOMEM;
@@ -121,7 +121,7 @@ static int pwm_backlight_probe(struct platform_device *pdev)
121 if (IS_ERR(pb->pwm)) { 121 if (IS_ERR(pb->pwm)) {
122 dev_err(&pdev->dev, "unable to request PWM for backlight\n"); 122 dev_err(&pdev->dev, "unable to request PWM for backlight\n");
123 ret = PTR_ERR(pb->pwm); 123 ret = PTR_ERR(pb->pwm);
124 goto err_pwm; 124 goto err_alloc;
125 } else 125 } else
126 dev_dbg(&pdev->dev, "got pwm for backlight\n"); 126 dev_dbg(&pdev->dev, "got pwm for backlight\n");
127 127
@@ -144,8 +144,6 @@ static int pwm_backlight_probe(struct platform_device *pdev)
144 144
145err_bl: 145err_bl:
146 pwm_free(pb->pwm); 146 pwm_free(pb->pwm);
147err_pwm:
148 kfree(pb);
149err_alloc: 147err_alloc:
150 if (data->exit) 148 if (data->exit)
151 data->exit(&pdev->dev); 149 data->exit(&pdev->dev);
@@ -162,7 +160,6 @@ static int pwm_backlight_remove(struct platform_device *pdev)
162 pwm_config(pb->pwm, 0, pb->period); 160 pwm_config(pb->pwm, 0, pb->period);
163 pwm_disable(pb->pwm); 161 pwm_disable(pb->pwm);
164 pwm_free(pb->pwm); 162 pwm_free(pb->pwm);
165 kfree(pb);
166 if (data->exit) 163 if (data->exit)
167 data->exit(&pdev->dev); 164 data->exit(&pdev->dev);
168 return 0; 165 return 0;