]> pilppa.org Git - linux-2.6-omap-h63xx.git/blobdiff - drivers/macintosh/adbhid.c
Merge git://git.infradead.org/mtd-2.6
[linux-2.6-omap-h63xx.git] / drivers / macintosh / adbhid.c
index b7fb367808d862edbb61badfc22b21c8fd66d923..b46817f699f157899257907d0c77cbf113d61573 100644 (file)
@@ -222,7 +222,7 @@ static struct adbhid *adbhid[16];
 
 static void adbhid_probe(void);
 
-static void adbhid_input_keycode(int, int, int, struct pt_regs *);
+static void adbhid_input_keycode(int, int, int);
 
 static void init_trackpad(int id);
 static void init_trackball(int id);
@@ -253,7 +253,7 @@ static struct adb_ids buttons_ids;
 #define ADBMOUSE_MACALLY2      9       /* MacAlly 2-button mouse */
 
 static void
-adbhid_keyboard_input(unsigned char *data, int nb, struct pt_regs *regs, int apoll)
+adbhid_keyboard_input(unsigned char *data, int nb, int apoll)
 {
        int id = (data[0] >> 4) & 0x0f;
 
@@ -266,13 +266,13 @@ adbhid_keyboard_input(unsigned char *data, int nb, struct pt_regs *regs, int apo
        /* first check this is from register 0 */
        if (nb != 3 || (data[0] & 3) != KEYB_KEYREG)
                return;         /* ignore it */
-       adbhid_input_keycode(id, data[1], 0, regs);
+       adbhid_input_keycode(id, data[1], 0);
        if (!(data[2] == 0xff || (data[2] == 0x7f && data[1] == 0x7f)))
-               adbhid_input_keycode(id, data[2], 0, regs);
+               adbhid_input_keycode(id, data[2], 0);
 }
 
 static void
-adbhid_input_keycode(int id, int keycode, int repeat, struct pt_regs *regs)
+adbhid_input_keycode(int id, int keycode, int repeat)
 {
        struct adbhid *ahid = adbhid[id];
        int up_flag;
@@ -282,7 +282,6 @@ adbhid_input_keycode(int id, int keycode, int repeat, struct pt_regs *regs)
 
        switch (keycode) {
        case ADB_KEY_CAPSLOCK: /* Generate down/up events for CapsLock everytime. */
-               input_regs(ahid->input, regs);
                input_report_key(ahid->input, KEY_CAPSLOCK, 1);
                input_report_key(ahid->input, KEY_CAPSLOCK, 0);
                input_sync(ahid->input);
@@ -338,7 +337,6 @@ adbhid_input_keycode(int id, int keycode, int repeat, struct pt_regs *regs)
        }
 
        if (adbhid[id]->keycode[keycode]) {
-               input_regs(adbhid[id]->input, regs);
                input_report_key(adbhid[id]->input,
                                 adbhid[id]->keycode[keycode], !up_flag);
                input_sync(adbhid[id]->input);
@@ -349,7 +347,7 @@ adbhid_input_keycode(int id, int keycode, int repeat, struct pt_regs *regs)
 }
 
 static void
-adbhid_mouse_input(unsigned char *data, int nb, struct pt_regs *regs, int autopoll)
+adbhid_mouse_input(unsigned char *data, int nb, int autopoll)
 {
        int id = (data[0] >> 4) & 0x0f;
 
@@ -432,8 +430,6 @@ adbhid_mouse_input(unsigned char *data, int nb, struct pt_regs *regs, int autopo
                 break;
        }
 
-       input_regs(adbhid[id]->input, regs);
-
        input_report_key(adbhid[id]->input, BTN_LEFT,   !((data[1] >> 7) & 1));
        input_report_key(adbhid[id]->input, BTN_MIDDLE, !((data[2] >> 7) & 1));
 
@@ -449,7 +445,7 @@ adbhid_mouse_input(unsigned char *data, int nb, struct pt_regs *regs, int autopo
 }
 
 static void
-adbhid_buttons_input(unsigned char *data, int nb, struct pt_regs *regs, int autopoll)
+adbhid_buttons_input(unsigned char *data, int nb, int autopoll)
 {
        int id = (data[0] >> 4) & 0x0f;
 
@@ -458,8 +454,6 @@ adbhid_buttons_input(unsigned char *data, int nb, struct pt_regs *regs, int auto
                return;
        }
 
-       input_regs(adbhid[id]->input, regs);
-
        switch (adbhid[id]->original_handler_id) {
        default:
        case 0x02: /* Adjustable keyboard button device */
@@ -580,8 +574,8 @@ static struct adb_request led_request;
 static int leds_pending[16];
 static int leds_req_pending;
 static int pending_devs[16];
-static int pending_led_start=0;
-static int pending_led_end=0;
+static int pending_led_start;
+static int pending_led_end;
 static DEFINE_SPINLOCK(leds_lock);
 
 static void leds_done(struct adb_request *req)
@@ -634,16 +628,16 @@ static void real_leds(unsigned char leds, int device)
  */
 static int adbhid_kbd_event(struct input_dev *dev, unsigned int type, unsigned int code, int value)
 {
-       struct adbhid *adbhid = dev->private;
+       struct adbhid *adbhid = input_get_drvdata(dev);
        unsigned char leds;
 
        switch (type) {
        case EV_LED:
-         leds = (test_bit(LED_SCROLLL, dev->led) ? 4 : 0)
-              | (test_bit(LED_NUML,    dev->led) ? 1 : 0)
-              | (test_bit(LED_CAPSL,   dev->led) ? 2 : 0);
-         real_leds(leds, adbhid->id);
-         return 0;
+               leds =  (test_bit(LED_SCROLLL, dev->led) ? 4 : 0) |
+                       (test_bit(LED_NUML,    dev->led) ? 1 : 0) |
+                       (test_bit(LED_CAPSL,   dev->led) ? 2 : 0);
+               real_leds(leds, adbhid->id);
+               return 0;
        }
 
        return -1;
@@ -655,7 +649,7 @@ adb_message_handler(struct notifier_block *this, unsigned long code, void *x)
        switch (code) {
        case ADB_MSG_PRE_RESET:
        case ADB_MSG_POWERDOWN:
-               /* Stop the repeat timer. Autopoll is already off at this point */
+               /* Stop the repeat timer. Autopoll is already off at this point */
                {
                        int i;
                        for (i = 1; i < 16; i++) {
@@ -695,7 +689,6 @@ adbhid_input_register(int id, int default_id, int original_handler_id,
        if (!hid || !input_dev) {
                err = -ENOMEM;
                goto fail;
-
        }
 
        sprintf(hid->phys, "adb%d:%d.%02x/input", id, default_id, original_handler_id);
@@ -706,7 +699,7 @@ adbhid_input_register(int id, int default_id, int original_handler_id,
        hid->current_handler_id = current_handler_id;
        hid->mouse_kind = mouse_kind;
        hid->flags = 0;
-       input_dev->private = hid;
+       input_set_drvdata(input_dev, hid);
        input_dev->name = hid->name;
        input_dev->phys = hid->phys;
        input_dev->id.bustype = BUS_ADB;
@@ -813,7 +806,9 @@ adbhid_input_register(int id, int default_id, int original_handler_id,
 
        input_dev->keycode = hid->keycode;
 
-       input_register_device(input_dev);
+       err = input_register_device(input_dev);
+       if (err)
+               goto fail;
 
        if (default_id == ADB_KEYBOARD) {
                /* HACK WARNING!! This should go away as soon there is an utility
@@ -826,7 +821,10 @@ adbhid_input_register(int id, int default_id, int original_handler_id,
        return 0;
 
  fail: input_free_device(input_dev);
-       kfree(hid);
+       if (hid) {
+               kfree(hid->keycode);
+               kfree(hid);
+       }
        adbhid[id] = NULL;
        return err;
 }