aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/input/touchscreen
diff options
context:
space:
mode:
authorDmitry Torokhov <dmitry.torokhov@gmail.com>2011-12-01 02:44:31 -0500
committerDmitry Torokhov <dmitry.torokhov@gmail.com>2011-12-12 03:02:31 -0500
commitff4d049246727087ee797b6802e7c1bd4d5d172c (patch)
treea804a6a340303cf3d8d899f677e57c42a704adee /drivers/input/touchscreen
parentec20861260824a1be53d24c05636529d45a4e228 (diff)
Input: migor-ts - rework probe() to simplify error path
Register input device last so that we do not have to reset input device pointer after calling input_unregister_device(). Signed-off-by: Dmitry Torokhov <dtor@mail.ru>
Diffstat (limited to 'drivers/input/touchscreen')
-rw-r--r--drivers/input/touchscreen/migor_ts.c43
1 files changed, 18 insertions, 25 deletions
diff --git a/drivers/input/touchscreen/migor_ts.c b/drivers/input/touchscreen/migor_ts.c
index 704169f16c7d..5226194aa78e 100644
--- a/drivers/input/touchscreen/migor_ts.c
+++ b/drivers/input/touchscreen/migor_ts.c
@@ -137,21 +137,20 @@ static int migor_ts_probe(struct i2c_client *client,
137 int error; 137 int error;
138 138
139 priv = kzalloc(sizeof(*priv), GFP_KERNEL); 139 priv = kzalloc(sizeof(*priv), GFP_KERNEL);
140 if (!priv) {
141 dev_err(&client->dev, "failed to allocate driver data\n");
142 error = -ENOMEM;
143 goto err0;
144 }
145
146 input = input_allocate_device(); 140 input = input_allocate_device();
147 if (!input) { 141 if (!priv || !input) {
148 dev_err(&client->dev, "Failed to allocate input device.\n"); 142 dev_err(&client->dev, "failed to allocate memory\n");
149 error = -ENOMEM; 143 error = -ENOMEM;
150 goto err1; 144 goto err_free_mem;
151 } 145 }
152 146
147 priv->client = client;
148 priv->input = input;
149 priv->irq = client->irq;
150
153 input->evbit[0] = BIT_MASK(EV_KEY) | BIT_MASK(EV_ABS); 151 input->evbit[0] = BIT_MASK(EV_KEY) | BIT_MASK(EV_ABS);
154 input->keybit[BIT_WORD(BTN_TOUCH)] = BIT_MASK(BTN_TOUCH); 152
153 __set_bit(BTN_TOUCH, input->keybit);
155 154
156 input_set_abs_params(input, ABS_X, 95, 955, 0, 0); 155 input_set_abs_params(input, ABS_X, 95, 955, 0, 0);
157 input_set_abs_params(input, ABS_Y, 85, 935, 0, 0); 156 input_set_abs_params(input, ABS_Y, 85, 935, 0, 0);
@@ -165,34 +164,28 @@ static int migor_ts_probe(struct i2c_client *client,
165 164
166 input_set_drvdata(input, priv); 165 input_set_drvdata(input, priv);
167 166
168 priv->client = client;
169 priv->input = input;
170 priv->irq = client->irq;
171
172 error = input_register_device(input);
173 if (error)
174 goto err1;
175
176 error = request_threaded_irq(priv->irq, NULL, migor_ts_isr, 167 error = request_threaded_irq(priv->irq, NULL, migor_ts_isr,
177 IRQF_TRIGGER_LOW | IRQF_ONESHOT, 168 IRQF_TRIGGER_LOW | IRQF_ONESHOT,
178 client->name, priv); 169 client->name, priv);
179 if (error) { 170 if (error) {
180 dev_err(&client->dev, "Unable to request touchscreen IRQ.\n"); 171 dev_err(&client->dev, "Unable to request touchscreen IRQ.\n");
181 goto err2; 172 goto err_free_mem;
182 } 173 }
183 174
175 error = input_register_device(input);
176 if (error)
177 goto err_free_irq;
178
184 i2c_set_clientdata(client, priv); 179 i2c_set_clientdata(client, priv);
185 device_init_wakeup(&client->dev, 1); 180 device_init_wakeup(&client->dev, 1);
181
186 return 0; 182 return 0;
187 183
188 err2: 184 err_free_irq:
189 input_unregister_device(input); 185 free_irq(priv->irq, priv);
190 input = NULL; /* so we dont try to free it below */ 186 err_free_mem:
191 err1:
192 input_free_device(input); 187 input_free_device(input);
193 kfree(priv); 188 kfree(priv);
194 err0:
195 dev_set_drvdata(&client->dev, NULL);
196 return error; 189 return error;
197} 190}
198 191