aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRoger Quadros <rogerq@ti.com>2014-05-19 01:43:42 -0400
committerDmitry Torokhov <dmitry.torokhov@gmail.com>2014-05-19 02:25:56 -0400
commite9d4718dcd53281c191cb5fccb53ce0246e10104 (patch)
treeab1967f73add4d926c91583905eea5cbb44019af
parent19318de1daf25aa1ca4fe76e1d7ac834f1bfb0c4 (diff)
Input: pixcir_i2c_ts - use devres managed resource allocations
Use devm_() and friends for allocating memory, input device and IRQ. Signed-off-by: Roger Quadros <rogerq@ti.com> Acked-by: Mugunthan V N <mugunthanvnm@ti.com> Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
-rw-r--r--drivers/input/touchscreen/pixcir_i2c_ts.c38
1 files changed, 15 insertions, 23 deletions
diff --git a/drivers/input/touchscreen/pixcir_i2c_ts.c b/drivers/input/touchscreen/pixcir_i2c_ts.c
index 02392d2061d6..5d36243bdc79 100644
--- a/drivers/input/touchscreen/pixcir_i2c_ts.c
+++ b/drivers/input/touchscreen/pixcir_i2c_ts.c
@@ -130,6 +130,7 @@ static int pixcir_i2c_ts_probe(struct i2c_client *client,
130{ 130{
131 const struct pixcir_ts_platform_data *pdata = 131 const struct pixcir_ts_platform_data *pdata =
132 dev_get_platdata(&client->dev); 132 dev_get_platdata(&client->dev);
133 struct device *dev = &client->dev;
133 struct pixcir_i2c_ts_data *tsdata; 134 struct pixcir_i2c_ts_data *tsdata;
134 struct input_dev *input; 135 struct input_dev *input;
135 int error; 136 int error;
@@ -139,12 +140,14 @@ static int pixcir_i2c_ts_probe(struct i2c_client *client,
139 return -EINVAL; 140 return -EINVAL;
140 } 141 }
141 142
142 tsdata = kzalloc(sizeof(*tsdata), GFP_KERNEL); 143 tsdata = devm_kzalloc(dev, sizeof(*tsdata), GFP_KERNEL);
143 input = input_allocate_device(); 144 if (!tsdata)
144 if (!tsdata || !input) { 145 return -ENOMEM;
145 dev_err(&client->dev, "Failed to allocate driver data!\n"); 146
146 error = -ENOMEM; 147 input = devm_input_allocate_device(dev);
147 goto err_free_mem; 148 if (!input) {
149 dev_err(dev, "Failed to allocate input device\n");
150 return -ENOMEM;
148 } 151 }
149 152
150 tsdata->client = client; 153 tsdata->client = client;
@@ -165,29 +168,22 @@ static int pixcir_i2c_ts_probe(struct i2c_client *client,
165 168
166 input_set_drvdata(input, tsdata); 169 input_set_drvdata(input, tsdata);
167 170
168 error = request_threaded_irq(client->irq, NULL, pixcir_ts_isr, 171 error = devm_request_threaded_irq(dev, client->irq, NULL, pixcir_ts_isr,
169 IRQF_TRIGGER_FALLING | IRQF_ONESHOT, 172 IRQF_TRIGGER_FALLING | IRQF_ONESHOT,
170 client->name, tsdata); 173 client->name, tsdata);
171 if (error) { 174 if (error) {
172 dev_err(&client->dev, "Unable to request touchscreen IRQ.\n"); 175 dev_err(dev, "failed to request irq %d\n", client->irq);
173 goto err_free_mem; 176 return error;
174 } 177 }
175 178
176 error = input_register_device(input); 179 error = input_register_device(input);
177 if (error) 180 if (error)
178 goto err_free_irq; 181 return error;
179 182
180 i2c_set_clientdata(client, tsdata); 183 i2c_set_clientdata(client, tsdata);
181 device_init_wakeup(&client->dev, 1); 184 device_init_wakeup(&client->dev, 1);
182 185
183 return 0; 186 return 0;
184
185err_free_irq:
186 free_irq(client->irq, tsdata);
187err_free_mem:
188 input_free_device(input);
189 kfree(tsdata);
190 return error;
191} 187}
192 188
193static int pixcir_i2c_ts_remove(struct i2c_client *client) 189static int pixcir_i2c_ts_remove(struct i2c_client *client)
@@ -198,10 +194,6 @@ static int pixcir_i2c_ts_remove(struct i2c_client *client)
198 194
199 tsdata->exiting = true; 195 tsdata->exiting = true;
200 mb(); 196 mb();
201 free_irq(client->irq, tsdata);
202
203 input_unregister_device(tsdata->input);
204 kfree(tsdata);
205 197
206 return 0; 198 return 0;
207} 199}