aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/input
diff options
context:
space:
mode:
authorLaurent Pinchart <laurent.pinchart+renesas@ideasonboard.com>2013-04-15 12:23:00 -0400
committerDmitry Torokhov <dmitry.torokhov@gmail.com>2013-04-15 13:00:30 -0400
commit95b24d22135549ac8352d719a052002838bb9f80 (patch)
tree5a814c021d626cab5fc9a070f2f91f907de3e176 /drivers/input
parenta0ef6a348a47bdb3896c468608f9cd19c1c26949 (diff)
Input: st1232 - convert to devm_* infrastructure
Use the devm_* managed functions to allocate resources. Signed-off-by: Laurent Pinchart <laurent.pinchart+renesas@ideasonboard.com> Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
Diffstat (limited to 'drivers/input')
-rw-r--r--drivers/input/touchscreen/st1232.c34
1 files changed, 12 insertions, 22 deletions
diff --git a/drivers/input/touchscreen/st1232.c b/drivers/input/touchscreen/st1232.c
index d9d05e222428..75d8eb5ee609 100644
--- a/drivers/input/touchscreen/st1232.c
+++ b/drivers/input/touchscreen/st1232.c
@@ -156,13 +156,13 @@ static int st1232_ts_probe(struct i2c_client *client,
156 return -EINVAL; 156 return -EINVAL;
157 } 157 }
158 158
159 ts = devm_kzalloc(&client->dev, sizeof(*ts), GFP_KERNEL);
160 if (!ts)
161 return -ENOMEM;
159 162
160 ts = kzalloc(sizeof(struct st1232_ts_data), GFP_KERNEL); 163 input_dev = devm_input_allocate_device(&client->dev);
161 input_dev = input_allocate_device(); 164 if (!input_dev)
162 if (!ts || !input_dev) { 165 return -ENOMEM;
163 error = -ENOMEM;
164 goto err_free_mem;
165 }
166 166
167 ts->client = client; 167 ts->client = client;
168 ts->input_dev = input_dev; 168 ts->input_dev = input_dev;
@@ -179,41 +179,31 @@ static int st1232_ts_probe(struct i2c_client *client,
179 input_set_abs_params(input_dev, ABS_MT_POSITION_X, MIN_X, MAX_X, 0, 0); 179 input_set_abs_params(input_dev, ABS_MT_POSITION_X, MIN_X, MAX_X, 0, 0);
180 input_set_abs_params(input_dev, ABS_MT_POSITION_Y, MIN_Y, MAX_Y, 0, 0); 180 input_set_abs_params(input_dev, ABS_MT_POSITION_Y, MIN_Y, MAX_Y, 0, 0);
181 181
182 error = request_threaded_irq(client->irq, NULL, st1232_ts_irq_handler, 182 error = devm_request_threaded_irq(&client->dev, client->irq,
183 IRQF_ONESHOT, client->name, ts); 183 NULL, st1232_ts_irq_handler,
184 IRQF_ONESHOT,
185 client->name, ts);
184 if (error) { 186 if (error) {
185 dev_err(&client->dev, "Failed to register interrupt\n"); 187 dev_err(&client->dev, "Failed to register interrupt\n");
186 goto err_free_mem; 188 return error;
187 } 189 }
188 190
189 error = input_register_device(ts->input_dev); 191 error = input_register_device(ts->input_dev);
190 if (error) { 192 if (error) {
191 dev_err(&client->dev, "Unable to register %s input device\n", 193 dev_err(&client->dev, "Unable to register %s input device\n",
192 input_dev->name); 194 input_dev->name);
193 goto err_free_irq; 195 return error;
194 } 196 }
195 197
196 i2c_set_clientdata(client, ts); 198 i2c_set_clientdata(client, ts);
197 device_init_wakeup(&client->dev, 1); 199 device_init_wakeup(&client->dev, 1);
198 200
199 return 0; 201 return 0;
200
201err_free_irq:
202 free_irq(client->irq, ts);
203err_free_mem:
204 input_free_device(input_dev);
205 kfree(ts);
206 return error;
207} 202}
208 203
209static int st1232_ts_remove(struct i2c_client *client) 204static int st1232_ts_remove(struct i2c_client *client)
210{ 205{
211 struct st1232_ts_data *ts = i2c_get_clientdata(client);
212
213 device_init_wakeup(&client->dev, 0); 206 device_init_wakeup(&client->dev, 0);
214 free_irq(client->irq, ts);
215 input_unregister_device(ts->input_dev);
216 kfree(ts);
217 207
218 return 0; 208 return 0;
219} 209}