diff options
author | Sebastian Reichel <sebastian.reichel@collabora.co.uk> | 2017-07-25 17:08:48 -0400 |
---|---|---|
committer | Dmitry Torokhov <dmitry.torokhov@gmail.com> | 2017-08-21 16:10:18 -0400 |
commit | 8cc8446b9b62ef954b630ed30e53bd1553e916a6 (patch) | |
tree | 483830314304513b086abdac6294a4103f092b30 /drivers | |
parent | 663c8b55d0ab5512d9aeb6536683271cfdb166f2 (diff) |
Input: atmel_mxt_ts - use more managed resources
Switch mxt_data and interrupt to resource managed allocation methods,
which cleans up the driver slightly and prepares for adding
reset GPIO support.
Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.co.uk>
Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
Diffstat (limited to 'drivers')
-rw-r--r-- | drivers/input/touchscreen/atmel_mxt_ts.c | 24 |
1 files changed, 9 insertions, 15 deletions
diff --git a/drivers/input/touchscreen/atmel_mxt_ts.c b/drivers/input/touchscreen/atmel_mxt_ts.c index dd042a9b0aaa..aeb46522073a 100644 --- a/drivers/input/touchscreen/atmel_mxt_ts.c +++ b/drivers/input/touchscreen/atmel_mxt_ts.c | |||
@@ -3117,11 +3117,9 @@ static int mxt_probe(struct i2c_client *client, const struct i2c_device_id *id) | |||
3117 | if (IS_ERR(pdata)) | 3117 | if (IS_ERR(pdata)) |
3118 | return PTR_ERR(pdata); | 3118 | return PTR_ERR(pdata); |
3119 | 3119 | ||
3120 | data = kzalloc(sizeof(struct mxt_data), GFP_KERNEL); | 3120 | data = devm_kzalloc(&client->dev, sizeof(struct mxt_data), GFP_KERNEL); |
3121 | if (!data) { | 3121 | if (!data) |
3122 | dev_err(&client->dev, "Failed to allocate memory\n"); | ||
3123 | return -ENOMEM; | 3122 | return -ENOMEM; |
3124 | } | ||
3125 | 3123 | ||
3126 | snprintf(data->phys, sizeof(data->phys), "i2c-%u-%04x/input0", | 3124 | snprintf(data->phys, sizeof(data->phys), "i2c-%u-%04x/input0", |
3127 | client->adapter->nr, client->addr); | 3125 | client->adapter->nr, client->addr); |
@@ -3135,19 +3133,20 @@ static int mxt_probe(struct i2c_client *client, const struct i2c_device_id *id) | |||
3135 | init_completion(&data->reset_completion); | 3133 | init_completion(&data->reset_completion); |
3136 | init_completion(&data->crc_completion); | 3134 | init_completion(&data->crc_completion); |
3137 | 3135 | ||
3138 | error = request_threaded_irq(client->irq, NULL, mxt_interrupt, | 3136 | error = devm_request_threaded_irq(&client->dev, client->irq, |
3139 | pdata->irqflags | IRQF_ONESHOT, | 3137 | NULL, mxt_interrupt, |
3140 | client->name, data); | 3138 | pdata->irqflags | IRQF_ONESHOT, |
3139 | client->name, data); | ||
3141 | if (error) { | 3140 | if (error) { |
3142 | dev_err(&client->dev, "Failed to register interrupt\n"); | 3141 | dev_err(&client->dev, "Failed to register interrupt\n"); |
3143 | goto err_free_mem; | 3142 | return error; |
3144 | } | 3143 | } |
3145 | 3144 | ||
3146 | disable_irq(client->irq); | 3145 | disable_irq(client->irq); |
3147 | 3146 | ||
3148 | error = mxt_initialize(data); | 3147 | error = mxt_initialize(data); |
3149 | if (error) | 3148 | if (error) |
3150 | goto err_free_irq; | 3149 | return error; |
3151 | 3150 | ||
3152 | error = sysfs_create_group(&client->dev.kobj, &mxt_attr_group); | 3151 | error = sysfs_create_group(&client->dev.kobj, &mxt_attr_group); |
3153 | if (error) { | 3152 | if (error) { |
@@ -3161,10 +3160,6 @@ static int mxt_probe(struct i2c_client *client, const struct i2c_device_id *id) | |||
3161 | err_free_object: | 3160 | err_free_object: |
3162 | mxt_free_input_device(data); | 3161 | mxt_free_input_device(data); |
3163 | mxt_free_object_table(data); | 3162 | mxt_free_object_table(data); |
3164 | err_free_irq: | ||
3165 | free_irq(client->irq, data); | ||
3166 | err_free_mem: | ||
3167 | kfree(data); | ||
3168 | return error; | 3163 | return error; |
3169 | } | 3164 | } |
3170 | 3165 | ||
@@ -3172,11 +3167,10 @@ static int mxt_remove(struct i2c_client *client) | |||
3172 | { | 3167 | { |
3173 | struct mxt_data *data = i2c_get_clientdata(client); | 3168 | struct mxt_data *data = i2c_get_clientdata(client); |
3174 | 3169 | ||
3170 | disable_irq(data->irq); | ||
3175 | sysfs_remove_group(&client->dev.kobj, &mxt_attr_group); | 3171 | sysfs_remove_group(&client->dev.kobj, &mxt_attr_group); |
3176 | free_irq(data->irq, data); | ||
3177 | mxt_free_input_device(data); | 3172 | mxt_free_input_device(data); |
3178 | mxt_free_object_table(data); | 3173 | mxt_free_object_table(data); |
3179 | kfree(data); | ||
3180 | 3174 | ||
3181 | return 0; | 3175 | return 0; |
3182 | } | 3176 | } |