Commit d0c082d1068751e80562d6f894e310d16a985645

Authored by Sachin Kamat
Committed by Dmitry Torokhov
1 parent 7bcbcaa584

Input: amikbd - remove redundant platform_set_drvdata()

Commit 0998d06310 (device-core: Ensure drvdata = NULL when no
driver is bound) removes the need to set driver data field to
NULL.

Signed-off-by: Sachin Kamat <sachin.kamat@linaro.org>
Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>

Showing 1 changed file with 0 additions and 1 deletions Inline Diff

drivers/input/keyboard/amikbd.c
1 /* 1 /*
2 * Copyright (c) 2000-2001 Vojtech Pavlik 2 * Copyright (c) 2000-2001 Vojtech Pavlik
3 * 3 *
4 * Based on the work of: 4 * Based on the work of:
5 * Hamish Macdonald 5 * Hamish Macdonald
6 */ 6 */
7 7
8 /* 8 /*
9 * Amiga keyboard driver for Linux/m68k 9 * Amiga keyboard driver for Linux/m68k
10 */ 10 */
11 11
12 /* 12 /*
13 * This program is free software; you can redistribute it and/or modify 13 * This program is free software; you can redistribute it and/or modify
14 * it under the terms of the GNU General Public License as published by 14 * it under the terms of the GNU General Public License as published by
15 * the Free Software Foundation; either version 2 of the License, or 15 * the Free Software Foundation; either version 2 of the License, or
16 * (at your option) any later version. 16 * (at your option) any later version.
17 * 17 *
18 * This program is distributed in the hope that it will be useful, 18 * This program is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of 19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU General Public License for more details. 21 * GNU General Public License for more details.
22 * 22 *
23 * You should have received a copy of the GNU General Public License 23 * You should have received a copy of the GNU General Public License
24 * along with this program; if not, write to the Free Software 24 * along with this program; if not, write to the Free Software
25 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 25 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
26 * 26 *
27 * Should you need to contact me, the author, you can do so either by 27 * Should you need to contact me, the author, you can do so either by
28 * e-mail - mail your message to <vojtech@ucw.cz>, or by paper mail: 28 * e-mail - mail your message to <vojtech@ucw.cz>, or by paper mail:
29 * Vojtech Pavlik, Simunkova 1594, Prague 8, 182 00 Czech Republic 29 * Vojtech Pavlik, Simunkova 1594, Prague 8, 182 00 Czech Republic
30 */ 30 */
31 31
32 #include <linux/module.h> 32 #include <linux/module.h>
33 #include <linux/init.h> 33 #include <linux/init.h>
34 #include <linux/input.h> 34 #include <linux/input.h>
35 #include <linux/delay.h> 35 #include <linux/delay.h>
36 #include <linux/interrupt.h> 36 #include <linux/interrupt.h>
37 #include <linux/keyboard.h> 37 #include <linux/keyboard.h>
38 #include <linux/platform_device.h> 38 #include <linux/platform_device.h>
39 39
40 #include <asm/amigaints.h> 40 #include <asm/amigaints.h>
41 #include <asm/amigahw.h> 41 #include <asm/amigahw.h>
42 #include <asm/irq.h> 42 #include <asm/irq.h>
43 43
44 MODULE_AUTHOR("Vojtech Pavlik <vojtech@ucw.cz>"); 44 MODULE_AUTHOR("Vojtech Pavlik <vojtech@ucw.cz>");
45 MODULE_DESCRIPTION("Amiga keyboard driver"); 45 MODULE_DESCRIPTION("Amiga keyboard driver");
46 MODULE_LICENSE("GPL"); 46 MODULE_LICENSE("GPL");
47 47
48 static unsigned char amikbd_keycode[0x78] __initdata = { 48 static unsigned char amikbd_keycode[0x78] __initdata = {
49 [0] = KEY_GRAVE, 49 [0] = KEY_GRAVE,
50 [1] = KEY_1, 50 [1] = KEY_1,
51 [2] = KEY_2, 51 [2] = KEY_2,
52 [3] = KEY_3, 52 [3] = KEY_3,
53 [4] = KEY_4, 53 [4] = KEY_4,
54 [5] = KEY_5, 54 [5] = KEY_5,
55 [6] = KEY_6, 55 [6] = KEY_6,
56 [7] = KEY_7, 56 [7] = KEY_7,
57 [8] = KEY_8, 57 [8] = KEY_8,
58 [9] = KEY_9, 58 [9] = KEY_9,
59 [10] = KEY_0, 59 [10] = KEY_0,
60 [11] = KEY_MINUS, 60 [11] = KEY_MINUS,
61 [12] = KEY_EQUAL, 61 [12] = KEY_EQUAL,
62 [13] = KEY_BACKSLASH, 62 [13] = KEY_BACKSLASH,
63 [15] = KEY_KP0, 63 [15] = KEY_KP0,
64 [16] = KEY_Q, 64 [16] = KEY_Q,
65 [17] = KEY_W, 65 [17] = KEY_W,
66 [18] = KEY_E, 66 [18] = KEY_E,
67 [19] = KEY_R, 67 [19] = KEY_R,
68 [20] = KEY_T, 68 [20] = KEY_T,
69 [21] = KEY_Y, 69 [21] = KEY_Y,
70 [22] = KEY_U, 70 [22] = KEY_U,
71 [23] = KEY_I, 71 [23] = KEY_I,
72 [24] = KEY_O, 72 [24] = KEY_O,
73 [25] = KEY_P, 73 [25] = KEY_P,
74 [26] = KEY_LEFTBRACE, 74 [26] = KEY_LEFTBRACE,
75 [27] = KEY_RIGHTBRACE, 75 [27] = KEY_RIGHTBRACE,
76 [29] = KEY_KP1, 76 [29] = KEY_KP1,
77 [30] = KEY_KP2, 77 [30] = KEY_KP2,
78 [31] = KEY_KP3, 78 [31] = KEY_KP3,
79 [32] = KEY_A, 79 [32] = KEY_A,
80 [33] = KEY_S, 80 [33] = KEY_S,
81 [34] = KEY_D, 81 [34] = KEY_D,
82 [35] = KEY_F, 82 [35] = KEY_F,
83 [36] = KEY_G, 83 [36] = KEY_G,
84 [37] = KEY_H, 84 [37] = KEY_H,
85 [38] = KEY_J, 85 [38] = KEY_J,
86 [39] = KEY_K, 86 [39] = KEY_K,
87 [40] = KEY_L, 87 [40] = KEY_L,
88 [41] = KEY_SEMICOLON, 88 [41] = KEY_SEMICOLON,
89 [42] = KEY_APOSTROPHE, 89 [42] = KEY_APOSTROPHE,
90 [43] = KEY_BACKSLASH, 90 [43] = KEY_BACKSLASH,
91 [45] = KEY_KP4, 91 [45] = KEY_KP4,
92 [46] = KEY_KP5, 92 [46] = KEY_KP5,
93 [47] = KEY_KP6, 93 [47] = KEY_KP6,
94 [48] = KEY_102ND, 94 [48] = KEY_102ND,
95 [49] = KEY_Z, 95 [49] = KEY_Z,
96 [50] = KEY_X, 96 [50] = KEY_X,
97 [51] = KEY_C, 97 [51] = KEY_C,
98 [52] = KEY_V, 98 [52] = KEY_V,
99 [53] = KEY_B, 99 [53] = KEY_B,
100 [54] = KEY_N, 100 [54] = KEY_N,
101 [55] = KEY_M, 101 [55] = KEY_M,
102 [56] = KEY_COMMA, 102 [56] = KEY_COMMA,
103 [57] = KEY_DOT, 103 [57] = KEY_DOT,
104 [58] = KEY_SLASH, 104 [58] = KEY_SLASH,
105 [60] = KEY_KPDOT, 105 [60] = KEY_KPDOT,
106 [61] = KEY_KP7, 106 [61] = KEY_KP7,
107 [62] = KEY_KP8, 107 [62] = KEY_KP8,
108 [63] = KEY_KP9, 108 [63] = KEY_KP9,
109 [64] = KEY_SPACE, 109 [64] = KEY_SPACE,
110 [65] = KEY_BACKSPACE, 110 [65] = KEY_BACKSPACE,
111 [66] = KEY_TAB, 111 [66] = KEY_TAB,
112 [67] = KEY_KPENTER, 112 [67] = KEY_KPENTER,
113 [68] = KEY_ENTER, 113 [68] = KEY_ENTER,
114 [69] = KEY_ESC, 114 [69] = KEY_ESC,
115 [70] = KEY_DELETE, 115 [70] = KEY_DELETE,
116 [74] = KEY_KPMINUS, 116 [74] = KEY_KPMINUS,
117 [76] = KEY_UP, 117 [76] = KEY_UP,
118 [77] = KEY_DOWN, 118 [77] = KEY_DOWN,
119 [78] = KEY_RIGHT, 119 [78] = KEY_RIGHT,
120 [79] = KEY_LEFT, 120 [79] = KEY_LEFT,
121 [80] = KEY_F1, 121 [80] = KEY_F1,
122 [81] = KEY_F2, 122 [81] = KEY_F2,
123 [82] = KEY_F3, 123 [82] = KEY_F3,
124 [83] = KEY_F4, 124 [83] = KEY_F4,
125 [84] = KEY_F5, 125 [84] = KEY_F5,
126 [85] = KEY_F6, 126 [85] = KEY_F6,
127 [86] = KEY_F7, 127 [86] = KEY_F7,
128 [87] = KEY_F8, 128 [87] = KEY_F8,
129 [88] = KEY_F9, 129 [88] = KEY_F9,
130 [89] = KEY_F10, 130 [89] = KEY_F10,
131 [90] = KEY_KPLEFTPAREN, 131 [90] = KEY_KPLEFTPAREN,
132 [91] = KEY_KPRIGHTPAREN, 132 [91] = KEY_KPRIGHTPAREN,
133 [92] = KEY_KPSLASH, 133 [92] = KEY_KPSLASH,
134 [93] = KEY_KPASTERISK, 134 [93] = KEY_KPASTERISK,
135 [94] = KEY_KPPLUS, 135 [94] = KEY_KPPLUS,
136 [95] = KEY_HELP, 136 [95] = KEY_HELP,
137 [96] = KEY_LEFTSHIFT, 137 [96] = KEY_LEFTSHIFT,
138 [97] = KEY_RIGHTSHIFT, 138 [97] = KEY_RIGHTSHIFT,
139 [98] = KEY_CAPSLOCK, 139 [98] = KEY_CAPSLOCK,
140 [99] = KEY_LEFTCTRL, 140 [99] = KEY_LEFTCTRL,
141 [100] = KEY_LEFTALT, 141 [100] = KEY_LEFTALT,
142 [101] = KEY_RIGHTALT, 142 [101] = KEY_RIGHTALT,
143 [102] = KEY_LEFTMETA, 143 [102] = KEY_LEFTMETA,
144 [103] = KEY_RIGHTMETA 144 [103] = KEY_RIGHTMETA
145 }; 145 };
146 146
147 static const char *amikbd_messages[8] = { 147 static const char *amikbd_messages[8] = {
148 [0] = KERN_ALERT "amikbd: Ctrl-Amiga-Amiga reset warning!!\n", 148 [0] = KERN_ALERT "amikbd: Ctrl-Amiga-Amiga reset warning!!\n",
149 [1] = KERN_WARNING "amikbd: keyboard lost sync\n", 149 [1] = KERN_WARNING "amikbd: keyboard lost sync\n",
150 [2] = KERN_WARNING "amikbd: keyboard buffer overflow\n", 150 [2] = KERN_WARNING "amikbd: keyboard buffer overflow\n",
151 [3] = KERN_WARNING "amikbd: keyboard controller failure\n", 151 [3] = KERN_WARNING "amikbd: keyboard controller failure\n",
152 [4] = KERN_ERR "amikbd: keyboard selftest failure\n", 152 [4] = KERN_ERR "amikbd: keyboard selftest failure\n",
153 [5] = KERN_INFO "amikbd: initiate power-up key stream\n", 153 [5] = KERN_INFO "amikbd: initiate power-up key stream\n",
154 [6] = KERN_INFO "amikbd: terminate power-up key stream\n", 154 [6] = KERN_INFO "amikbd: terminate power-up key stream\n",
155 [7] = KERN_WARNING "amikbd: keyboard interrupt\n" 155 [7] = KERN_WARNING "amikbd: keyboard interrupt\n"
156 }; 156 };
157 157
158 static irqreturn_t amikbd_interrupt(int irq, void *data) 158 static irqreturn_t amikbd_interrupt(int irq, void *data)
159 { 159 {
160 struct input_dev *dev = data; 160 struct input_dev *dev = data;
161 unsigned char scancode, down; 161 unsigned char scancode, down;
162 162
163 scancode = ~ciaa.sdr; /* get and invert scancode (keyboard is active low) */ 163 scancode = ~ciaa.sdr; /* get and invert scancode (keyboard is active low) */
164 ciaa.cra |= 0x40; /* switch SP pin to output for handshake */ 164 ciaa.cra |= 0x40; /* switch SP pin to output for handshake */
165 udelay(85); /* wait until 85 us have expired */ 165 udelay(85); /* wait until 85 us have expired */
166 ciaa.cra &= ~0x40; /* switch CIA serial port to input mode */ 166 ciaa.cra &= ~0x40; /* switch CIA serial port to input mode */
167 167
168 down = !(scancode & 1); /* lowest bit is release bit */ 168 down = !(scancode & 1); /* lowest bit is release bit */
169 scancode >>= 1; 169 scancode >>= 1;
170 170
171 if (scancode < 0x78) { /* scancodes < 0x78 are keys */ 171 if (scancode < 0x78) { /* scancodes < 0x78 are keys */
172 if (scancode == 98) { /* CapsLock is a toggle switch key on Amiga */ 172 if (scancode == 98) { /* CapsLock is a toggle switch key on Amiga */
173 input_report_key(dev, scancode, 1); 173 input_report_key(dev, scancode, 1);
174 input_report_key(dev, scancode, 0); 174 input_report_key(dev, scancode, 0);
175 } else { 175 } else {
176 input_report_key(dev, scancode, down); 176 input_report_key(dev, scancode, down);
177 } 177 }
178 178
179 input_sync(dev); 179 input_sync(dev);
180 } else /* scancodes >= 0x78 are error codes */ 180 } else /* scancodes >= 0x78 are error codes */
181 printk(amikbd_messages[scancode - 0x78]); 181 printk(amikbd_messages[scancode - 0x78]);
182 182
183 return IRQ_HANDLED; 183 return IRQ_HANDLED;
184 } 184 }
185 185
186 static int __init amikbd_probe(struct platform_device *pdev) 186 static int __init amikbd_probe(struct platform_device *pdev)
187 { 187 {
188 struct input_dev *dev; 188 struct input_dev *dev;
189 int i, j, err; 189 int i, j, err;
190 190
191 dev = input_allocate_device(); 191 dev = input_allocate_device();
192 if (!dev) { 192 if (!dev) {
193 dev_err(&pdev->dev, "Not enough memory for input device\n"); 193 dev_err(&pdev->dev, "Not enough memory for input device\n");
194 return -ENOMEM; 194 return -ENOMEM;
195 } 195 }
196 196
197 dev->name = pdev->name; 197 dev->name = pdev->name;
198 dev->phys = "amikbd/input0"; 198 dev->phys = "amikbd/input0";
199 dev->id.bustype = BUS_AMIGA; 199 dev->id.bustype = BUS_AMIGA;
200 dev->id.vendor = 0x0001; 200 dev->id.vendor = 0x0001;
201 dev->id.product = 0x0001; 201 dev->id.product = 0x0001;
202 dev->id.version = 0x0100; 202 dev->id.version = 0x0100;
203 dev->dev.parent = &pdev->dev; 203 dev->dev.parent = &pdev->dev;
204 204
205 dev->evbit[0] = BIT_MASK(EV_KEY) | BIT_MASK(EV_REP); 205 dev->evbit[0] = BIT_MASK(EV_KEY) | BIT_MASK(EV_REP);
206 206
207 for (i = 0; i < 0x78; i++) 207 for (i = 0; i < 0x78; i++)
208 set_bit(i, dev->keybit); 208 set_bit(i, dev->keybit);
209 209
210 for (i = 0; i < MAX_NR_KEYMAPS; i++) { 210 for (i = 0; i < MAX_NR_KEYMAPS; i++) {
211 static u_short temp_map[NR_KEYS] __initdata; 211 static u_short temp_map[NR_KEYS] __initdata;
212 if (!key_maps[i]) 212 if (!key_maps[i])
213 continue; 213 continue;
214 memset(temp_map, 0, sizeof(temp_map)); 214 memset(temp_map, 0, sizeof(temp_map));
215 for (j = 0; j < 0x78; j++) { 215 for (j = 0; j < 0x78; j++) {
216 if (!amikbd_keycode[j]) 216 if (!amikbd_keycode[j])
217 continue; 217 continue;
218 temp_map[j] = key_maps[i][amikbd_keycode[j]]; 218 temp_map[j] = key_maps[i][amikbd_keycode[j]];
219 } 219 }
220 for (j = 0; j < NR_KEYS; j++) { 220 for (j = 0; j < NR_KEYS; j++) {
221 if (!temp_map[j]) 221 if (!temp_map[j])
222 temp_map[j] = 0xf200; 222 temp_map[j] = 0xf200;
223 } 223 }
224 memcpy(key_maps[i], temp_map, sizeof(temp_map)); 224 memcpy(key_maps[i], temp_map, sizeof(temp_map));
225 } 225 }
226 ciaa.cra &= ~0x41; /* serial data in, turn off TA */ 226 ciaa.cra &= ~0x41; /* serial data in, turn off TA */
227 err = request_irq(IRQ_AMIGA_CIAA_SP, amikbd_interrupt, 0, "amikbd", 227 err = request_irq(IRQ_AMIGA_CIAA_SP, amikbd_interrupt, 0, "amikbd",
228 dev); 228 dev);
229 if (err) 229 if (err)
230 goto fail2; 230 goto fail2;
231 231
232 err = input_register_device(dev); 232 err = input_register_device(dev);
233 if (err) 233 if (err)
234 goto fail3; 234 goto fail3;
235 235
236 platform_set_drvdata(pdev, dev); 236 platform_set_drvdata(pdev, dev);
237 237
238 return 0; 238 return 0;
239 239
240 fail3: free_irq(IRQ_AMIGA_CIAA_SP, dev); 240 fail3: free_irq(IRQ_AMIGA_CIAA_SP, dev);
241 fail2: input_free_device(dev); 241 fail2: input_free_device(dev);
242 return err; 242 return err;
243 } 243 }
244 244
245 static int __exit amikbd_remove(struct platform_device *pdev) 245 static int __exit amikbd_remove(struct platform_device *pdev)
246 { 246 {
247 struct input_dev *dev = platform_get_drvdata(pdev); 247 struct input_dev *dev = platform_get_drvdata(pdev);
248 248
249 platform_set_drvdata(pdev, NULL);
250 free_irq(IRQ_AMIGA_CIAA_SP, dev); 249 free_irq(IRQ_AMIGA_CIAA_SP, dev);
251 input_unregister_device(dev); 250 input_unregister_device(dev);
252 return 0; 251 return 0;
253 } 252 }
254 253
255 static struct platform_driver amikbd_driver = { 254 static struct platform_driver amikbd_driver = {
256 .remove = __exit_p(amikbd_remove), 255 .remove = __exit_p(amikbd_remove),
257 .driver = { 256 .driver = {
258 .name = "amiga-keyboard", 257 .name = "amiga-keyboard",
259 .owner = THIS_MODULE, 258 .owner = THIS_MODULE,
260 }, 259 },
261 }; 260 };
262 261
263 module_platform_driver_probe(amikbd_driver, amikbd_probe); 262 module_platform_driver_probe(amikbd_driver, amikbd_probe);
264 263
265 MODULE_ALIAS("platform:amiga-keyboard"); 264 MODULE_ALIAS("platform:amiga-keyboard");
266 265