diff options
author | Dmitry Torokhov <dtor@insightbb.com> | 2006-11-05 22:39:56 -0500 |
---|---|---|
committer | Dmitry Torokhov <dtor@insightbb.com> | 2006-11-05 22:39:56 -0500 |
commit | 2b03b60e6b8635fffdd15d5d24943950f2bbf96e (patch) | |
tree | 17f0354b7edb08920a89e663ef724c84518c49fa | |
parent | 41ad5fbabda0c3930136bb40cfc7a0c23013365f (diff) |
Input: keyboards - handle errors when registering input devices
Signed-off-by: Dmitry Torokhov <dtor@mail.ru>
-rw-r--r-- | drivers/input/keyboard/amikbd.c | 22 | ||||
-rw-r--r-- | drivers/input/keyboard/atkbd.c | 159 | ||||
-rw-r--r-- | drivers/input/keyboard/corgikbd.c | 17 | ||||
-rw-r--r-- | drivers/input/keyboard/lkkbd.c | 14 | ||||
-rw-r--r-- | drivers/input/keyboard/locomokbd.c | 28 | ||||
-rw-r--r-- | drivers/input/keyboard/maple_keyb.c | 14 | ||||
-rw-r--r-- | drivers/input/keyboard/newtonkbd.c | 14 | ||||
-rw-r--r-- | drivers/input/keyboard/spitzkbd.c | 24 | ||||
-rw-r--r-- | drivers/input/keyboard/sunkbd.c | 20 | ||||
-rw-r--r-- | drivers/input/keyboard/xtkbd.c | 14 |
10 files changed, 234 insertions, 92 deletions
diff --git a/drivers/input/keyboard/amikbd.c b/drivers/input/keyboard/amikbd.c index 8abdbd0ee8f..16583d71753 100644 --- a/drivers/input/keyboard/amikbd.c +++ b/drivers/input/keyboard/amikbd.c | |||
@@ -190,7 +190,7 @@ static int __init amikbd_init(void) | |||
190 | int i, j; | 190 | int i, j; |
191 | 191 | ||
192 | if (!AMIGAHW_PRESENT(AMI_KEYBOARD)) | 192 | if (!AMIGAHW_PRESENT(AMI_KEYBOARD)) |
193 | return -EIO; | 193 | return -ENODEV; |
194 | 194 | ||
195 | if (!request_mem_region(CIAA_PHYSADDR-1+0xb00, 0x100, "amikeyb")) | 195 | if (!request_mem_region(CIAA_PHYSADDR-1+0xb00, 0x100, "amikeyb")) |
196 | return -EBUSY; | 196 | return -EBUSY; |
@@ -198,8 +198,8 @@ static int __init amikbd_init(void) | |||
198 | amikbd_dev = input_allocate_device(); | 198 | amikbd_dev = input_allocate_device(); |
199 | if (!amikbd_dev) { | 199 | if (!amikbd_dev) { |
200 | printk(KERN_ERR "amikbd: not enough memory for input device\n"); | 200 | printk(KERN_ERR "amikbd: not enough memory for input device\n"); |
201 | release_mem_region(CIAA_PHYSADDR - 1 + 0xb00, 0x100); | 201 | err = -ENOMEM; |
202 | return -ENOMEM; | 202 | goto fail1; |
203 | } | 203 | } |
204 | 204 | ||
205 | amikbd_dev->name = "Amiga Keyboard"; | 205 | amikbd_dev->name = "Amiga Keyboard"; |
@@ -231,10 +231,22 @@ static int __init amikbd_init(void) | |||
231 | memcpy(key_maps[i], temp_map, sizeof(temp_map)); | 231 | memcpy(key_maps[i], temp_map, sizeof(temp_map)); |
232 | } | 232 | } |
233 | ciaa.cra &= ~0x41; /* serial data in, turn off TA */ | 233 | ciaa.cra &= ~0x41; /* serial data in, turn off TA */ |
234 | request_irq(IRQ_AMIGA_CIAA_SP, amikbd_interrupt, 0, "amikbd", amikbd_interrupt); | 234 | if (request_irq(IRQ_AMIGA_CIAA_SP, amikbd_interrupt, 0, "amikbd", |
235 | amikbd_interrupt)) { | ||
236 | err = -EBUSY; | ||
237 | goto fail2; | ||
238 | } | ||
239 | |||
240 | err = input_register_device(amikbd_dev); | ||
241 | if (err) | ||
242 | goto fail3; | ||
235 | 243 | ||
236 | input_register_device(amikbd_dev); | ||
237 | return 0; | 244 | return 0; |
245 | |||
246 | fail3: free_irq(IRQ_AMIGA_CIAA_SP, amikbd_interrupt); | ||
247 | fail2: input_free_device(amikbd_dev); | ||
248 | fail1: release_mem_region(CIAA_PHYSADDR - 1 + 0xb00, 0x100); | ||
249 | return err; | ||
238 | } | 250 | } |
239 | 251 | ||
240 | static void __exit amikbd_exit(void) | 252 | static void __exit amikbd_exit(void) |
diff --git a/drivers/input/keyboard/atkbd.c b/drivers/input/keyboard/atkbd.c index cbb93669d1c..73c6946b2d9 100644 --- a/drivers/input/keyboard/atkbd.c +++ b/drivers/input/keyboard/atkbd.c | |||
@@ -939,7 +939,7 @@ static int atkbd_connect(struct serio *serio, struct serio_driver *drv) | |||
939 | atkbd = kzalloc(sizeof(struct atkbd), GFP_KERNEL); | 939 | atkbd = kzalloc(sizeof(struct atkbd), GFP_KERNEL); |
940 | dev = input_allocate_device(); | 940 | dev = input_allocate_device(); |
941 | if (!atkbd || !dev) | 941 | if (!atkbd || !dev) |
942 | goto fail; | 942 | goto fail1; |
943 | 943 | ||
944 | atkbd->dev = dev; | 944 | atkbd->dev = dev; |
945 | ps2_init(&atkbd->ps2dev, serio); | 945 | ps2_init(&atkbd->ps2dev, serio); |
@@ -967,14 +967,13 @@ static int atkbd_connect(struct serio *serio, struct serio_driver *drv) | |||
967 | 967 | ||
968 | err = serio_open(serio, drv); | 968 | err = serio_open(serio, drv); |
969 | if (err) | 969 | if (err) |
970 | goto fail; | 970 | goto fail2; |
971 | 971 | ||
972 | if (atkbd->write) { | 972 | if (atkbd->write) { |
973 | 973 | ||
974 | if (atkbd_probe(atkbd)) { | 974 | if (atkbd_probe(atkbd)) { |
975 | serio_close(serio); | ||
976 | err = -ENODEV; | 975 | err = -ENODEV; |
977 | goto fail; | 976 | goto fail3; |
978 | } | 977 | } |
979 | 978 | ||
980 | atkbd->set = atkbd_select_set(atkbd, atkbd_set, atkbd_extra); | 979 | atkbd->set = atkbd_select_set(atkbd, atkbd_set, atkbd_extra); |
@@ -988,16 +987,22 @@ static int atkbd_connect(struct serio *serio, struct serio_driver *drv) | |||
988 | atkbd_set_keycode_table(atkbd); | 987 | atkbd_set_keycode_table(atkbd); |
989 | atkbd_set_device_attrs(atkbd); | 988 | atkbd_set_device_attrs(atkbd); |
990 | 989 | ||
991 | sysfs_create_group(&serio->dev.kobj, &atkbd_attribute_group); | 990 | err = sysfs_create_group(&serio->dev.kobj, &atkbd_attribute_group); |
991 | if (err) | ||
992 | goto fail3; | ||
992 | 993 | ||
993 | atkbd_enable(atkbd); | 994 | atkbd_enable(atkbd); |
994 | 995 | ||
995 | input_register_device(atkbd->dev); | 996 | err = input_register_device(atkbd->dev); |
997 | if (err) | ||
998 | goto fail4; | ||
996 | 999 | ||
997 | return 0; | 1000 | return 0; |
998 | 1001 | ||
999 | fail: serio_set_drvdata(serio, NULL); | 1002 | fail4: sysfs_remove_group(&serio->dev.kobj, &atkbd_attribute_group); |
1000 | input_free_device(dev); | 1003 | fail3: serio_close(serio); |
1004 | fail2: serio_set_drvdata(serio, NULL); | ||
1005 | fail1: input_free_device(dev); | ||
1001 | kfree(atkbd); | 1006 | kfree(atkbd); |
1002 | return err; | 1007 | return err; |
1003 | } | 1008 | } |
@@ -1133,9 +1138,11 @@ static ssize_t atkbd_show_extra(struct atkbd *atkbd, char *buf) | |||
1133 | 1138 | ||
1134 | static ssize_t atkbd_set_extra(struct atkbd *atkbd, const char *buf, size_t count) | 1139 | static ssize_t atkbd_set_extra(struct atkbd *atkbd, const char *buf, size_t count) |
1135 | { | 1140 | { |
1136 | struct input_dev *new_dev; | 1141 | struct input_dev *old_dev, *new_dev; |
1137 | unsigned long value; | 1142 | unsigned long value; |
1138 | char *rest; | 1143 | char *rest; |
1144 | int err; | ||
1145 | unsigned char old_extra, old_set; | ||
1139 | 1146 | ||
1140 | if (!atkbd->write) | 1147 | if (!atkbd->write) |
1141 | return -EIO; | 1148 | return -EIO; |
@@ -1147,17 +1154,36 @@ static ssize_t atkbd_set_extra(struct atkbd *atkbd, const char *buf, size_t coun | |||
1147 | if (atkbd->extra != value) { | 1154 | if (atkbd->extra != value) { |
1148 | /* | 1155 | /* |
1149 | * Since device's properties will change we need to | 1156 | * Since device's properties will change we need to |
1150 | * unregister old device. But allocate new one first | 1157 | * unregister old device. But allocate and register |
1151 | * to make sure we have it. | 1158 | * new one first to make sure we have it. |
1152 | */ | 1159 | */ |
1153 | if (!(new_dev = input_allocate_device())) | 1160 | old_dev = atkbd->dev; |
1161 | old_extra = atkbd->extra; | ||
1162 | old_set = atkbd->set; | ||
1163 | |||
1164 | new_dev = input_allocate_device(); | ||
1165 | if (!new_dev) | ||
1154 | return -ENOMEM; | 1166 | return -ENOMEM; |
1155 | input_unregister_device(atkbd->dev); | 1167 | |
1156 | atkbd->dev = new_dev; | 1168 | atkbd->dev = new_dev; |
1157 | atkbd->set = atkbd_select_set(atkbd, atkbd->set, value); | 1169 | atkbd->set = atkbd_select_set(atkbd, atkbd->set, value); |
1158 | atkbd_activate(atkbd); | 1170 | atkbd_activate(atkbd); |
1171 | atkbd_set_keycode_table(atkbd); | ||
1159 | atkbd_set_device_attrs(atkbd); | 1172 | atkbd_set_device_attrs(atkbd); |
1160 | input_register_device(atkbd->dev); | 1173 | |
1174 | err = input_register_device(atkbd->dev); | ||
1175 | if (err) { | ||
1176 | input_free_device(new_dev); | ||
1177 | |||
1178 | atkbd->dev = old_dev; | ||
1179 | atkbd->set = atkbd_select_set(atkbd, old_set, old_extra); | ||
1180 | atkbd_set_keycode_table(atkbd); | ||
1181 | atkbd_set_device_attrs(atkbd); | ||
1182 | |||
1183 | return err; | ||
1184 | } | ||
1185 | input_unregister_device(old_dev); | ||
1186 | |||
1161 | } | 1187 | } |
1162 | return count; | 1188 | return count; |
1163 | } | 1189 | } |
@@ -1169,23 +1195,41 @@ static ssize_t atkbd_show_scroll(struct atkbd *atkbd, char *buf) | |||
1169 | 1195 | ||
1170 | static ssize_t atkbd_set_scroll(struct atkbd *atkbd, const char *buf, size_t count) | 1196 | static ssize_t atkbd_set_scroll(struct atkbd *atkbd, const char *buf, size_t count) |
1171 | { | 1197 | { |
1172 | struct input_dev *new_dev; | 1198 | struct input_dev *old_dev, *new_dev; |
1173 | unsigned long value; | 1199 | unsigned long value; |
1174 | char *rest; | 1200 | char *rest; |
1201 | int err; | ||
1202 | unsigned char old_scroll; | ||
1175 | 1203 | ||
1176 | value = simple_strtoul(buf, &rest, 10); | 1204 | value = simple_strtoul(buf, &rest, 10); |
1177 | if (*rest || value > 1) | 1205 | if (*rest || value > 1) |
1178 | return -EINVAL; | 1206 | return -EINVAL; |
1179 | 1207 | ||
1180 | if (atkbd->scroll != value) { | 1208 | if (atkbd->scroll != value) { |
1181 | if (!(new_dev = input_allocate_device())) | 1209 | old_dev = atkbd->dev; |
1210 | old_scroll = atkbd->scroll; | ||
1211 | |||
1212 | new_dev = input_allocate_device(); | ||
1213 | if (!new_dev) | ||
1182 | return -ENOMEM; | 1214 | return -ENOMEM; |
1183 | input_unregister_device(atkbd->dev); | 1215 | |
1184 | atkbd->dev = new_dev; | 1216 | atkbd->dev = new_dev; |
1185 | atkbd->scroll = value; | 1217 | atkbd->scroll = value; |
1186 | atkbd_set_keycode_table(atkbd); | 1218 | atkbd_set_keycode_table(atkbd); |
1187 | atkbd_set_device_attrs(atkbd); | 1219 | atkbd_set_device_attrs(atkbd); |
1188 | input_register_device(atkbd->dev); | 1220 | |
1221 | err = input_register_device(atkbd->dev); | ||
1222 | if (err) { | ||
1223 | input_free_device(new_dev); | ||
1224 | |||
1225 | atkbd->scroll = old_scroll; | ||
1226 | atkbd->dev = old_dev; | ||
1227 | atkbd_set_keycode_table(atkbd); | ||
1228 | atkbd_set_device_attrs(atkbd); | ||
1229 | |||
1230 | return err; | ||
1231 | } | ||
1232 | input_unregister_device(old_dev); | ||
1189 | } | 1233 | } |
1190 | return count; | 1234 | return count; |
1191 | } | 1235 | } |
@@ -1197,9 +1241,11 @@ static ssize_t atkbd_show_set(struct atkbd *atkbd, char *buf) | |||
1197 | 1241 | ||
1198 | static ssize_t atkbd_set_set(struct atkbd *atkbd, const char *buf, size_t count) | 1242 | static ssize_t atkbd_set_set(struct atkbd *atkbd, const char *buf, size_t count) |
1199 | { | 1243 | { |
1200 | struct input_dev *new_dev; | 1244 | struct input_dev *old_dev, *new_dev; |
1201 | unsigned long value; | 1245 | unsigned long value; |
1202 | char *rest; | 1246 | char *rest; |
1247 | int err; | ||
1248 | unsigned char old_set, old_extra; | ||
1203 | 1249 | ||
1204 | if (!atkbd->write) | 1250 | if (!atkbd->write) |
1205 | return -EIO; | 1251 | return -EIO; |
@@ -1209,15 +1255,32 @@ static ssize_t atkbd_set_set(struct atkbd *atkbd, const char *buf, size_t count) | |||
1209 | return -EINVAL; | 1255 | return -EINVAL; |
1210 | 1256 | ||
1211 | if (atkbd->set != value) { | 1257 | if (atkbd->set != value) { |
1212 | if (!(new_dev = input_allocate_device())) | 1258 | old_dev = atkbd->dev; |
1259 | old_extra = atkbd->extra; | ||
1260 | old_set = atkbd->set; | ||
1261 | |||
1262 | new_dev = input_allocate_device(); | ||
1263 | if (!new_dev) | ||
1213 | return -ENOMEM; | 1264 | return -ENOMEM; |
1214 | input_unregister_device(atkbd->dev); | 1265 | |
1215 | atkbd->dev = new_dev; | 1266 | atkbd->dev = new_dev; |
1216 | atkbd->set = atkbd_select_set(atkbd, value, atkbd->extra); | 1267 | atkbd->set = atkbd_select_set(atkbd, value, atkbd->extra); |
1217 | atkbd_activate(atkbd); | 1268 | atkbd_activate(atkbd); |
1218 | atkbd_set_keycode_table(atkbd); | 1269 | atkbd_set_keycode_table(atkbd); |
1219 | atkbd_set_device_attrs(atkbd); | 1270 | atkbd_set_device_attrs(atkbd); |
1220 | input_register_device(atkbd->dev); | 1271 | |
1272 | err = input_register_device(atkbd->dev); | ||
1273 | if (err) { | ||
1274 | input_free_device(new_dev); | ||
1275 | |||
1276 | atkbd->dev = old_dev; | ||
1277 | atkbd->set = atkbd_select_set(atkbd, old_set, old_extra); | ||
1278 | atkbd_set_keycode_table(atkbd); | ||
1279 | atkbd_set_device_attrs(atkbd); | ||
1280 | |||
1281 | return err; | ||
1282 | } | ||
1283 | input_unregister_device(old_dev); | ||
1221 | } | 1284 | } |
1222 | return count; | 1285 | return count; |
1223 | } | 1286 | } |
@@ -1229,9 +1292,11 @@ static ssize_t atkbd_show_softrepeat(struct atkbd *atkbd, char *buf) | |||
1229 | 1292 | ||
1230 | static ssize_t atkbd_set_softrepeat(struct atkbd *atkbd, const char *buf, size_t count) | 1293 | static ssize_t atkbd_set_softrepeat(struct atkbd *atkbd, const char *buf, size_t count) |
1231 | { | 1294 | { |
1232 | struct input_dev *new_dev; | 1295 | struct input_dev *old_dev, *new_dev; |
1233 | unsigned long value; | 1296 | unsigned long value; |
1234 | char *rest; | 1297 | char *rest; |
1298 | int err; | ||
1299 | unsigned char old_softrepeat, old_softraw; | ||
1235 | 1300 | ||
1236 | if (!atkbd->write) | 1301 | if (!atkbd->write) |
1237 | return -EIO; | 1302 | return -EIO; |
@@ -1241,15 +1306,32 @@ static ssize_t atkbd_set_softrepeat(struct atkbd *atkbd, const char *buf, size_t | |||
1241 | return -EINVAL; | 1306 | return -EINVAL; |
1242 | 1307 | ||
1243 | if (atkbd->softrepeat != value) { | 1308 | if (atkbd->softrepeat != value) { |
1244 | if (!(new_dev = input_allocate_device())) | 1309 | old_dev = atkbd->dev; |
1310 | old_softrepeat = atkbd->softrepeat; | ||
1311 | old_softraw = atkbd->softraw; | ||
1312 | |||
1313 | new_dev = input_allocate_device(); | ||
1314 | if (!new_dev) | ||
1245 | return -ENOMEM; | 1315 | return -ENOMEM; |
1246 | input_unregister_device(atkbd->dev); | 1316 | |
1247 | atkbd->dev = new_dev; | 1317 | atkbd->dev = new_dev; |
1248 | atkbd->softrepeat = value; | 1318 | atkbd->softrepeat = value; |
1249 | if (atkbd->softrepeat) | 1319 | if (atkbd->softrepeat) |
1250 | atkbd->softraw = 1; | 1320 | atkbd->softraw = 1; |
1251 | atkbd_set_device_attrs(atkbd); | 1321 | atkbd_set_device_attrs(atkbd); |
1252 | input_register_device(atkbd->dev); | 1322 | |
1323 | err = input_register_device(atkbd->dev); | ||
1324 | if (err) { | ||
1325 | input_free_device(new_dev); | ||
1326 | |||
1327 | atkbd->dev = old_dev; | ||
1328 | atkbd->softrepeat = old_softrepeat; | ||
1329 | atkbd->softraw = old_softraw; | ||
1330 | atkbd_set_device_attrs(atkbd); | ||
1331 | |||
1332 | return err; | ||
1333 | } | ||
1334 | input_unregister_device(old_dev); | ||
1253 | } | 1335 | } |
1254 | return count; | 1336 | return count; |
1255 | } | 1337 | } |
@@ -1262,22 +1344,39 @@ static ssize_t atkbd_show_softraw(struct atkbd *atkbd, char *buf) | |||
1262 | 1344 | ||
1263 | static ssize_t atkbd_set_softraw(struct atkbd *atkbd, const char *buf, size_t count) | 1345 | static ssize_t atkbd_set_softraw(struct atkbd *atkbd, const char *buf, size_t count) |
1264 | { | 1346 | { |
1265 | struct input_dev *new_dev; | 1347 | struct input_dev *old_dev, *new_dev; |
1266 | unsigned long value; | 1348 | unsigned long value; |
1267 | char *rest; | 1349 | char *rest; |
1350 | int err; | ||
1351 | unsigned char old_softraw; | ||
1268 | 1352 | ||
1269 | value = simple_strtoul(buf, &rest, 10); | 1353 | value = simple_strtoul(buf, &rest, 10); |
1270 | if (*rest || value > 1) | 1354 | if (*rest || value > 1) |
1271 | return -EINVAL; | 1355 | return -EINVAL; |
1272 | 1356 | ||
1273 | if (atkbd->softraw != value) { | 1357 | if (atkbd->softraw != value) { |
1274 | if (!(new_dev = input_allocate_device())) | 1358 | old_dev = atkbd->dev; |
1359 | old_softraw = atkbd->softraw; | ||
1360 | |||
1361 | new_dev = input_allocate_device(); | ||
1362 | if (!new_dev) | ||
1275 | return -ENOMEM; | 1363 | return -ENOMEM; |
1276 | input_unregister_device(atkbd->dev); | 1364 | |
1277 | atkbd->dev = new_dev; | 1365 | atkbd->dev = new_dev; |
1278 | atkbd->softraw = value; | 1366 | atkbd->softraw = value; |
1279 | atkbd_set_device_attrs(atkbd); | 1367 | atkbd_set_device_attrs(atkbd); |
1280 | input_register_device(atkbd->dev); | 1368 | |
1369 | err = input_register_device(atkbd->dev); | ||
1370 | if (err) { | ||
1371 | input_free_device(new_dev); | ||
1372 | |||
1373 | atkbd->dev = old_dev; | ||
1374 | atkbd->softraw = old_softraw; | ||
1375 | atkbd_set_device_attrs(atkbd); | ||
1376 | |||
1377 | return err; | ||
1378 | } | ||
1379 | input_unregister_device(old_dev); | ||
1281 | } | 1380 | } |
1282 | return count; | 1381 | return count; |
1283 | } | 1382 | } |
diff --git a/drivers/input/keyboard/corgikbd.c b/drivers/input/keyboard/corgikbd.c index befdd6006b5..1016c94e65d 100644 --- a/drivers/input/keyboard/corgikbd.c +++ b/drivers/input/keyboard/corgikbd.c | |||
@@ -291,15 +291,12 @@ static int __init corgikbd_probe(struct platform_device *pdev) | |||
291 | { | 291 | { |
292 | struct corgikbd *corgikbd; | 292 | struct corgikbd *corgikbd; |
293 | struct input_dev *input_dev; | 293 | struct input_dev *input_dev; |
294 | int i; | 294 | int i, err = -ENOMEM; |
295 | 295 | ||
296 | corgikbd = kzalloc(sizeof(struct corgikbd), GFP_KERNEL); | 296 | corgikbd = kzalloc(sizeof(struct corgikbd), GFP_KERNEL); |
297 | input_dev = input_allocate_device(); | 297 | input_dev = input_allocate_device(); |
298 | if (!corgikbd || !input_dev) { | 298 | if (!corgikbd || !input_dev) |
299 | kfree(corgikbd); | 299 | goto fail; |
300 | input_free_device(input_dev); | ||
301 | return -ENOMEM; | ||
302 | } | ||
303 | 300 | ||
304 | platform_set_drvdata(pdev, corgikbd); | 301 | platform_set_drvdata(pdev, corgikbd); |
305 | 302 | ||
@@ -341,7 +338,9 @@ static int __init corgikbd_probe(struct platform_device *pdev) | |||
341 | set_bit(SW_TABLET_MODE, input_dev->swbit); | 338 | set_bit(SW_TABLET_MODE, input_dev->swbit); |
342 | set_bit(SW_HEADPHONE_INSERT, input_dev->swbit); | 339 | set_bit(SW_HEADPHONE_INSERT, input_dev->swbit); |
343 | 340 | ||
344 | input_register_device(corgikbd->input); | 341 | err = input_register_device(corgikbd->input); |
342 | if (err) | ||
343 | goto fail; | ||
345 | 344 | ||
346 | mod_timer(&corgikbd->htimer, jiffies + msecs_to_jiffies(HINGE_SCAN_INTERVAL)); | 345 | mod_timer(&corgikbd->htimer, jiffies + msecs_to_jiffies(HINGE_SCAN_INTERVAL)); |
347 | 346 | ||
@@ -362,6 +361,10 @@ static int __init corgikbd_probe(struct platform_device *pdev) | |||
362 | pxa_gpio_mode(CORGI_GPIO_AK_INT | GPIO_IN); | 361 | pxa_gpio_mode(CORGI_GPIO_AK_INT | GPIO_IN); |
363 | 362 | ||
364 | return 0; | 363 | return 0; |
364 | |||
365 | fail: input_free_device(input_dev); | ||
366 | kfree(corgikbd); | ||
367 | return err; | ||
365 | } | 368 | } |
366 | 369 | ||
367 | static int corgikbd_remove(struct platform_device *pdev) | 370 | static int corgikbd_remove(struct platform_device *pdev) |
diff --git a/drivers/input/keyboard/lkkbd.c b/drivers/input/keyboard/lkkbd.c index 708d5a1bc3d..0067c1fe3d4 100644 --- a/drivers/input/keyboard/lkkbd.c +++ b/drivers/input/keyboard/lkkbd.c | |||
@@ -651,7 +651,7 @@ lkkbd_connect (struct serio *serio, struct serio_driver *drv) | |||
651 | input_dev = input_allocate_device (); | 651 | input_dev = input_allocate_device (); |
652 | if (!lk || !input_dev) { | 652 | if (!lk || !input_dev) { |
653 | err = -ENOMEM; | 653 | err = -ENOMEM; |
654 | goto fail; | 654 | goto fail1; |
655 | } | 655 | } |
656 | 656 | ||
657 | lk->serio = serio; | 657 | lk->serio = serio; |
@@ -696,15 +696,19 @@ lkkbd_connect (struct serio *serio, struct serio_driver *drv) | |||
696 | 696 | ||
697 | err = serio_open (serio, drv); | 697 | err = serio_open (serio, drv); |
698 | if (err) | 698 | if (err) |
699 | goto fail; | 699 | goto fail2; |
700 | |||
701 | err = input_register_device (lk->dev); | ||
702 | if (err) | ||
703 | goto fail3; | ||
700 | 704 | ||
701 | input_register_device (lk->dev); | ||
702 | lk->serio->write (lk->serio, LK_CMD_POWERCYCLE_RESET); | 705 | lk->serio->write (lk->serio, LK_CMD_POWERCYCLE_RESET); |
703 | 706 | ||
704 | return 0; | 707 | return 0; |
705 | 708 | ||
706 | fail: serio_set_drvdata (serio, NULL); | 709 | fail3: serio_close (serio); |
707 | input_free_device (input_dev); | 710 | fail2: serio_set_drvdata (serio, NULL); |
711 | fail1: input_free_device (input_dev); | ||
708 | kfree (lk); | 712 | kfree (lk); |
709 | return err; | 713 | return err; |
710 | } | 714 | } |
diff --git a/drivers/input/keyboard/locomokbd.c b/drivers/input/keyboard/locomokbd.c index 5788dbc317b..2ade5186cc4 100644 --- a/drivers/input/keyboard/locomokbd.c +++ b/drivers/input/keyboard/locomokbd.c | |||
@@ -193,22 +193,22 @@ static int locomokbd_probe(struct locomo_dev *dev) | |||
193 | { | 193 | { |
194 | struct locomokbd *locomokbd; | 194 | struct locomokbd *locomokbd; |
195 | struct input_dev *input_dev; | 195 | struct input_dev *input_dev; |
196 | int i, ret; | 196 | int i, err; |
197 | 197 | ||
198 | locomokbd = kzalloc(sizeof(struct locomokbd), GFP_KERNEL); | 198 | locomokbd = kzalloc(sizeof(struct locomokbd), GFP_KERNEL); |
199 | input_dev = input_allocate_device(); | 199 | input_dev = input_allocate_device(); |
200 | if (!locomokbd || !input_dev) { | 200 | if (!locomokbd || !input_dev) { |
201 | ret = -ENOMEM; | 201 | err = -ENOMEM; |
202 | goto free; | 202 | goto err_free_mem; |
203 | } | 203 | } |
204 | 204 | ||
205 | /* try and claim memory region */ | 205 | /* try and claim memory region */ |
206 | if (!request_mem_region((unsigned long) dev->mapbase, | 206 | if (!request_mem_region((unsigned long) dev->mapbase, |
207 | dev->length, | 207 | dev->length, |
208 | LOCOMO_DRIVER_NAME(dev))) { | 208 | LOCOMO_DRIVER_NAME(dev))) { |
209 | ret = -EBUSY; | 209 | err = -EBUSY; |
210 | printk(KERN_ERR "locomokbd: Can't acquire access to io memory for keyboard\n"); | 210 | printk(KERN_ERR "locomokbd: Can't acquire access to io memory for keyboard\n"); |
211 | goto free; | 211 | goto err_free_mem; |
212 | } | 212 | } |
213 | 213 | ||
214 | locomokbd->ldev = dev; | 214 | locomokbd->ldev = dev; |
@@ -244,24 +244,28 @@ static int locomokbd_probe(struct locomo_dev *dev) | |||
244 | clear_bit(0, input_dev->keybit); | 244 | clear_bit(0, input_dev->keybit); |
245 | 245 | ||
246 | /* attempt to get the interrupt */ | 246 | /* attempt to get the interrupt */ |
247 | ret = request_irq(dev->irq[0], locomokbd_interrupt, 0, "locomokbd", locomokbd); | 247 | err = request_irq(dev->irq[0], locomokbd_interrupt, 0, "locomokbd", locomokbd); |
248 | if (ret) { | 248 | if (err) { |
249 | printk(KERN_ERR "locomokbd: Can't get irq for keyboard\n"); | 249 | printk(KERN_ERR "locomokbd: Can't get irq for keyboard\n"); |
250 | goto out; | 250 | goto err_release_region; |
251 | } | 251 | } |
252 | 252 | ||
253 | input_register_device(locomokbd->input); | 253 | err = input_register_device(locomokbd->input); |
254 | if (err) | ||
255 | goto err_free_irq; | ||
254 | 256 | ||
255 | return 0; | 257 | return 0; |
256 | 258 | ||
257 | out: | 259 | err_free_irq: |
260 | free_irq(dev->irq[0], locomokbd); | ||
261 | err_release_region: | ||
258 | release_mem_region((unsigned long) dev->mapbase, dev->length); | 262 | release_mem_region((unsigned long) dev->mapbase, dev->length); |
259 | locomo_set_drvdata(dev, NULL); | 263 | locomo_set_drvdata(dev, NULL); |
260 | free: | 264 | err_free_mem: |
261 | input_free_device(input_dev); | 265 | input_free_device(input_dev); |
262 | kfree(locomokbd); | 266 | kfree(locomokbd); |
263 | 267 | ||
264 | return ret; | 268 | return err; |
265 | } | 269 | } |
266 | 270 | ||
267 | static int locomokbd_remove(struct locomo_dev *dev) | 271 | static int locomokbd_remove(struct locomo_dev *dev) |
diff --git a/drivers/input/keyboard/maple_keyb.c b/drivers/input/keyboard/maple_keyb.c index cc6aaf9e85b..99836b3af47 100644 --- a/drivers/input/keyboard/maple_keyb.c +++ b/drivers/input/keyboard/maple_keyb.c | |||
@@ -94,13 +94,13 @@ static int dc_kbd_connect(struct maple_device *dev) | |||
94 | struct input_dev *input_dev; | 94 | struct input_dev *input_dev; |
95 | unsigned long data = be32_to_cpu(dev->devinfo.function_data[0]); | 95 | unsigned long data = be32_to_cpu(dev->devinfo.function_data[0]); |
96 | int i; | 96 | int i; |
97 | int err; | ||
97 | 98 | ||
98 | dev->private_data = kbd = kzalloc(sizeof(struct dc_kbd), GFP_KERNEL); | 99 | dev->private_data = kbd = kzalloc(sizeof(struct dc_kbd), GFP_KERNEL); |
99 | input_dev = input_allocate_device(); | 100 | input_dev = input_allocate_device(); |
100 | if (!kbd || !input_dev) { | 101 | if (!kbd || !input_dev) { |
101 | kfree(kbd); | 102 | err = -ENOMEM; |
102 | input_free_device(input_dev); | 103 | goto fail; |
103 | return -ENOMEM; | ||
104 | } | 104 | } |
105 | 105 | ||
106 | kbd->dev = input_dev; | 106 | kbd->dev = input_dev; |
@@ -113,10 +113,16 @@ static int dc_kbd_connect(struct maple_device *dev) | |||
113 | set_bit(dc_kbd_keycode[i], input_dev->keybit); | 113 | set_bit(dc_kbd_keycode[i], input_dev->keybit); |
114 | clear_bit(0, input_dev->keybit); | 114 | clear_bit(0, input_dev->keybit); |
115 | 115 | ||
116 | input_register_device(kbd->dev); | 116 | err = input_register_device(kbd->dev); |
117 | if (err) | ||
118 | goto fail; | ||
117 | 119 | ||
118 | maple_getcond_callback(dev, dc_kbd_callback, 1, MAPLE_FUNC_KEYBOARD); | 120 | maple_getcond_callback(dev, dc_kbd_callback, 1, MAPLE_FUNC_KEYBOARD); |
119 | return 0; | 121 | return 0; |
122 | |||
123 | fail: input_free_device(input_dev); | ||
124 | kfree(kbd); | ||
125 | return err; | ||
120 | } | 126 | } |
121 | 127 | ||
122 | 128 | ||
diff --git a/drivers/input/keyboard/newtonkbd.c b/drivers/input/keyboard/newtonkbd.c index 9282e4e082b..33e813948d6 100644 --- a/drivers/input/keyboard/newtonkbd.c +++ b/drivers/input/keyboard/newtonkbd.c | |||
@@ -91,7 +91,7 @@ static int nkbd_connect(struct serio *serio, struct serio_driver *drv) | |||
91 | nkbd = kzalloc(sizeof(struct nkbd), GFP_KERNEL); | 91 | nkbd = kzalloc(sizeof(struct nkbd), GFP_KERNEL); |
92 | input_dev = input_allocate_device(); | 92 | input_dev = input_allocate_device(); |
93 | if (!nkbd || !input_dev) | 93 | if (!nkbd || !input_dev) |
94 | goto fail; | 94 | goto fail1; |
95 | 95 | ||
96 | nkbd->serio = serio; | 96 | nkbd->serio = serio; |
97 | nkbd->dev = input_dev; | 97 | nkbd->dev = input_dev; |
@@ -119,13 +119,17 @@ static int nkbd_connect(struct serio *serio, struct serio_driver *drv) | |||
119 | 119 | ||
120 | err = serio_open(serio, drv); | 120 | err = serio_open(serio, drv); |
121 | if (err) | 121 | if (err) |
122 | goto fail; | 122 | goto fail2; |
123 | |||
124 | err = input_register_device(nkbd->dev); | ||
125 | if (err) | ||
126 | goto fail3; | ||
123 | 127 | ||
124 | input_register_device(nkbd->dev); | ||
125 | return 0; | 128 | return 0; |
126 | 129 | ||
127 | fail: serio_set_drvdata(serio, NULL); | 130 | fail3: serio_close(serio); |
128 | input_free_device(input_dev); | 131 | fail2: serio_set_drvdata(serio, NULL); |
132 | fail1: input_free_device(input_dev); | ||
129 | kfree(nkbd); | 133 | kfree(nkbd); |
130 | return err; | 134 | return err; |
131 | } | 135 | } |
diff --git a/drivers/input/keyboard/spitzkbd.c b/drivers/input/keyboard/spitzkbd.c index 28b2748e82d..8a2166c77ff 100644 --- a/drivers/input/keyboard/spitzkbd.c +++ b/drivers/input/keyboard/spitzkbd.c | |||
@@ -346,17 +346,12 @@ static int __init spitzkbd_probe(struct platform_device *dev) | |||
346 | { | 346 | { |
347 | struct spitzkbd *spitzkbd; | 347 | struct spitzkbd *spitzkbd; |
348 | struct input_dev *input_dev; | 348 | struct input_dev *input_dev; |
349 | int i; | 349 | int i, err = -ENOMEM; |
350 | 350 | ||
351 | spitzkbd = kzalloc(sizeof(struct spitzkbd), GFP_KERNEL); | 351 | spitzkbd = kzalloc(sizeof(struct spitzkbd), GFP_KERNEL); |
352 | if (!spitzkbd) | ||
353 | return -ENOMEM; | ||
354 | |||
355 | input_dev = input_allocate_device(); | 352 | input_dev = input_allocate_device(); |
356 | if (!input_dev) { | 353 | if (!spitzkbd || !input_dev) |
357 | kfree(spitzkbd); | 354 | goto fail; |
358 | return -ENOMEM; | ||
359 | } | ||
360 | 355 | ||
361 | platform_set_drvdata(dev, spitzkbd); | 356 | platform_set_drvdata(dev, spitzkbd); |
362 | strcpy(spitzkbd->phys, "spitzkbd/input0"); | 357 | strcpy(spitzkbd->phys, "spitzkbd/input0"); |
@@ -400,7 +395,9 @@ static int __init spitzkbd_probe(struct platform_device *dev) | |||
400 | set_bit(SW_TABLET_MODE, input_dev->swbit); | 395 | set_bit(SW_TABLET_MODE, input_dev->swbit); |
401 | set_bit(SW_HEADPHONE_INSERT, input_dev->swbit); | 396 | set_bit(SW_HEADPHONE_INSERT, input_dev->swbit); |
402 | 397 | ||
403 | input_register_device(input_dev); | 398 | err = input_register_device(input_dev); |
399 | if (err) | ||
400 | goto fail; | ||
404 | 401 | ||
405 | mod_timer(&spitzkbd->htimer, jiffies + msecs_to_jiffies(HINGE_SCAN_INTERVAL)); | 402 | mod_timer(&spitzkbd->htimer, jiffies + msecs_to_jiffies(HINGE_SCAN_INTERVAL)); |
406 | 403 | ||
@@ -434,13 +431,15 @@ static int __init spitzkbd_probe(struct platform_device *dev) | |||
434 | request_irq(SPITZ_IRQ_GPIO_SWB, spitzkbd_hinge_isr, | 431 | request_irq(SPITZ_IRQ_GPIO_SWB, spitzkbd_hinge_isr, |
435 | IRQF_DISABLED | IRQF_TRIGGER_RISING | IRQF_TRIGGER_FALLING, | 432 | IRQF_DISABLED | IRQF_TRIGGER_RISING | IRQF_TRIGGER_FALLING, |
436 | "Spitzkbd SWB", spitzkbd); | 433 | "Spitzkbd SWB", spitzkbd); |
437 | request_irq(SPITZ_IRQ_GPIO_AK_INT, spitzkbd_hinge_isr, | 434 | request_irq(SPITZ_IRQ_GPIO_AK_INT, spitzkbd_hinge_isr, |
438 | IRQF_DISABLED | IRQF_TRIGGER_RISING | IRQF_TRIGGER_FALLING, | 435 | IRQF_DISABLED | IRQF_TRIGGER_RISING | IRQF_TRIGGER_FALLING, |
439 | "Spitzkbd HP", spitzkbd); | 436 | "Spitzkbd HP", spitzkbd); |
440 | 437 | ||
441 | printk(KERN_INFO "input: Spitz Keyboard Registered\n"); | ||
442 | |||
443 | return 0; | 438 | return 0; |
439 | |||
440 | fail: input_free_device(input_dev); | ||
441 | kfree(spitzkbd); | ||
442 | return err; | ||
444 | } | 443 | } |
445 | 444 | ||
446 | static int spitzkbd_remove(struct platform_device *dev) | 445 | static int spitzkbd_remove(struct platform_device *dev) |
@@ -474,6 +473,7 @@ static struct platform_driver spitzkbd_driver = { | |||
474 | .resume = spitzkbd_resume, | 473 | .resume = spitzkbd_resume, |
475 | .driver = { | 474 | .driver = { |
476 | .name = "spitz-keyboard", | 475 | .name = "spitz-keyboard", |
476 | .owner = THIS_MODULE, | ||
477 | }, | 477 | }, |
478 | }; | 478 | }; |
479 | 479 | ||
diff --git a/drivers/input/keyboard/sunkbd.c b/drivers/input/keyboard/sunkbd.c index cac4781103c..d1b62f77a71 100644 --- a/drivers/input/keyboard/sunkbd.c +++ b/drivers/input/keyboard/sunkbd.c | |||
@@ -243,7 +243,7 @@ static int sunkbd_connect(struct serio *serio, struct serio_driver *drv) | |||
243 | sunkbd = kzalloc(sizeof(struct sunkbd), GFP_KERNEL); | 243 | sunkbd = kzalloc(sizeof(struct sunkbd), GFP_KERNEL); |
244 | input_dev = input_allocate_device(); | 244 | input_dev = input_allocate_device(); |
245 | if (!sunkbd || !input_dev) | 245 | if (!sunkbd || !input_dev) |
246 | goto fail; | 246 | goto fail1; |
247 | 247 | ||
248 | sunkbd->serio = serio; | 248 | sunkbd->serio = serio; |
249 | sunkbd->dev = input_dev; | 249 | sunkbd->dev = input_dev; |
@@ -255,11 +255,11 @@ static int sunkbd_connect(struct serio *serio, struct serio_driver *drv) | |||
255 | 255 | ||
256 | err = serio_open(serio, drv); | 256 | err = serio_open(serio, drv); |
257 | if (err) | 257 | if (err) |
258 | goto fail; | 258 | goto fail2; |
259 | 259 | ||
260 | if (sunkbd_initialize(sunkbd) < 0) { | 260 | if (sunkbd_initialize(sunkbd) < 0) { |
261 | serio_close(serio); | 261 | err = -ENODEV; |
262 | goto fail; | 262 | goto fail3; |
263 | } | 263 | } |
264 | 264 | ||
265 | snprintf(sunkbd->name, sizeof(sunkbd->name), "Sun Type %d keyboard", sunkbd->type); | 265 | snprintf(sunkbd->name, sizeof(sunkbd->name), "Sun Type %d keyboard", sunkbd->type); |
@@ -287,11 +287,17 @@ static int sunkbd_connect(struct serio *serio, struct serio_driver *drv) | |||
287 | clear_bit(0, input_dev->keybit); | 287 | clear_bit(0, input_dev->keybit); |
288 | 288 | ||
289 | sunkbd_enable(sunkbd, 1); | 289 | sunkbd_enable(sunkbd, 1); |
290 | input_register_device(sunkbd->dev); | 290 | |
291 | err = input_register_device(sunkbd->dev); | ||
292 | if (err) | ||
293 | goto fail4; | ||
294 | |||
291 | return 0; | 295 | return 0; |
292 | 296 | ||
293 | fail: serio_set_drvdata(serio, NULL); | 297 | fail4: sunkbd_enable(sunkbd, 0); |
294 | input_free_device(input_dev); | 298 | fail3: serio_close(serio); |
299 | fail2: serio_set_drvdata(serio, NULL); | ||
300 | fail1: input_free_device(input_dev); | ||
295 | kfree(sunkbd); | 301 | kfree(sunkbd); |
296 | return err; | 302 | return err; |
297 | } | 303 | } |
diff --git a/drivers/input/keyboard/xtkbd.c b/drivers/input/keyboard/xtkbd.c index 8c11dc93545..b53f7163858 100644 --- a/drivers/input/keyboard/xtkbd.c +++ b/drivers/input/keyboard/xtkbd.c | |||
@@ -95,7 +95,7 @@ static int xtkbd_connect(struct serio *serio, struct serio_driver *drv) | |||
95 | xtkbd = kmalloc(sizeof(struct xtkbd), GFP_KERNEL); | 95 | xtkbd = kmalloc(sizeof(struct xtkbd), GFP_KERNEL); |
96 | input_dev = input_allocate_device(); | 96 | input_dev = input_allocate_device(); |
97 | if (!xtkbd || !input_dev) | 97 | if (!xtkbd || !input_dev) |
98 | goto fail; | 98 | goto fail1; |
99 | 99 | ||
100 | xtkbd->serio = serio; | 100 | xtkbd->serio = serio; |
101 | xtkbd->dev = input_dev; | 101 | xtkbd->dev = input_dev; |
@@ -124,13 +124,17 @@ static int xtkbd_connect(struct serio *serio, struct serio_driver *drv) | |||
124 | 124 | ||
125 | err = serio_open(serio, drv); | 125 | err = serio_open(serio, drv); |
126 | if (err) | 126 | if (err) |
127 | goto fail; | 127 | goto fail2; |
128 | |||
129 | err = input_register_device(xtkbd->dev); | ||
130 | if (err) | ||
131 | goto fail3; | ||
128 | 132 | ||
129 | input_register_device(xtkbd->dev); | ||
130 | return 0; | 133 | return 0; |
131 | 134 | ||
132 | fail: serio_set_drvdata(serio, NULL); | 135 | fail3: serio_close(serio); |
133 | input_free_device(input_dev); | 136 | fail2: serio_set_drvdata(serio, NULL); |
137 | fail1: input_free_device(input_dev); | ||
134 | kfree(xtkbd); | 138 | kfree(xtkbd); |
135 | return err; | 139 | return err; |
136 | } | 140 | } |