diff -ruP -X ../ignorediff linux-2.4.7-ben0-benh20010729.orij/drivers/macintosh/adbhid.c linux-2.4.7-ben0-benh20010729-buttons/drivers/macintosh/adbhid.c
--- linux-2.4.7-ben0-benh20010729.orij/drivers/macintosh/adbhid.c	Thu Jul 26 15:19:01 2001
+++ linux-2.4.7-ben0-benh20010729-buttons/drivers/macintosh/adbhid.c	Sun Jul 29 22:40:32 2001
@@ -275,22 +275,28 @@
 	  {
 #ifdef CONFIG_PMAC_BACKLIGHT
 		int backlight = get_backlight_level();
-
+#endif
 		/*
 		 * XXX: Where is the contrast control for the passive?
 		 *  -- Cort
 		 */
 
-		switch (data[1]) {
+		switch (data[1]&0xf) {
 		case 0x8:	/* mute */
+				input_report_key(&adbhid[id]->input, KEY_MUTE, data[1] == (data[1] & 0xf));
 			break;
 
-		case 0x7:	/* contrast decrease */
+		case 0x7:	/* volume decrease */
+				input_report_key(&adbhid[id]->input, KEY_VOLUMEDOWN, data[1] == (data[1] & 0xf));
 			break;
 
-		case 0x6:	/* contrast increase */
+		case 0x6:	/* volume increase */
+				input_report_key(&adbhid[id]->input, KEY_VOLUMEUP, data[1] == (data[1] & 0xf));
 			break;
-
+		case 0xb:	/* eject */
+				input_report_key(&adbhid[id]->input, KEY_EJECTCD, data[1] == (data[1] & 0xf));
+			break;
+#ifdef CONFIG_PMAC_BACKLIGHT
 		case 0xa:	/* brightness decrease */
 			if (backlight < 0)
 				break;
@@ -308,8 +314,8 @@
 			else 
 				set_backlight_level(BACKLIGHT_MAX);
 			break;
+#endif
 		}
-#endif /* CONFIG_PMAC_BACKLIGHT */
 	  }
 	  break;
 	}
@@ -504,6 +510,11 @@
 		case 0x1f: /* Powerbook button device */
 			sprintf(adbhid[id]->name, "ADB Powerbook buttons on ID %d:%d.%02x",
 				id, default_id, original_handler_id);
+			adbhid[id]->input.evbit[0] = BIT(EV_KEY) | BIT(EV_REP);
+			set_bit(KEY_MUTE, adbhid[id]->input.keybit);
+			set_bit(KEY_VOLUMEUP, adbhid[id]->input.keybit);
+			set_bit(KEY_VOLUMEDOWN, adbhid[id]->input.keybit);
+			set_bit(KEY_EJECTCD, adbhid[id]->input.keybit);
 			break;
 		}
 		if (adbhid[id]->name[0])
@@ -541,17 +552,35 @@
 	adbhid[id] = 0;
 }
 
+static u16
+adbhid_input_reregister(int id, int default_id, int org_handler_id,
+						int cur_handler_id, int mk)
+{
+	if(adbhid[id]){
+		if(adbhid[id]->input.idproduct!=((id << 12)|(default_id << 8)|org_handler_id)){
+		    adbhid_input_unregister(id);
+			adbhid_input_register(id, default_id, org_handler_id, cur_handler_id, mk);
+		}
+	}else
+		adbhid_input_register(id, default_id, org_handler_id, cur_handler_id, mk);
+	return 1<<id;
+}
+
+static void
+adbhid_input_devcleanup(u16 exist)
+{
+    int i;
+	for(i=1;i<16;i++)
+	    if(adbhid[i]&&!(exist&(1<<i)))
+			 adbhid_input_unregister(i);
+}
 
 static void
 adbhid_probe(void)
 {
 	struct adb_request req;
 	int i, default_id, org_handler_id, cur_handler_id;
-
-	for (i = 1; i < 16; i++) {
-		if (adbhid[i])
-			adbhid_input_unregister(i);
-	}
+	u16 reg=0;
 
 	adb_register(ADB_MOUSE, 0, &mouse_ids, adbhid_mouse_input);
 	adb_register(ADB_KEYBOARD, 0, &keyboard_ids, adbhid_keyboard_input);
@@ -580,14 +609,14 @@
 			printk("ADB keyboard at %d, handler 1\n", id);
 
 		adb_get_infos(id, &default_id, &cur_handler_id);
-		adbhid_input_register(id, default_id, org_handler_id, cur_handler_id, 0);
+		reg|=adbhid_input_reregister(id, default_id, org_handler_id, cur_handler_id, 0);
 	}
 
 	for (i = 0; i < buttons_ids.nids; i++) {
 		int id = buttons_ids.id[i];
 
 		adb_get_infos(id, &default_id, &org_handler_id);
-		adbhid_input_register(id, default_id, org_handler_id, org_handler_id, 0);
+		reg|=adbhid_input_reregister(id, default_id, org_handler_id, org_handler_id, 0);
 	}
 
 	/* Try to switch all mice to handler 4, or 2 for three-button
@@ -676,9 +705,10 @@
 		printk("\n");
 
 		adb_get_infos(id, &default_id, &cur_handler_id);
-		adbhid_input_register(id, default_id, org_handler_id,
+		reg|=adbhid_input_reregister(id, default_id, org_handler_id,
 				      cur_handler_id, mouse_kind);
         }
+	adbhid_input_devcleanup(reg);
 }
 
 static void 
diff -ruP -X ../ignorediff linux-2.4.7-ben0-benh20010729.orij/drivers/macintosh/mac_hid.c linux-2.4.7-ben0-benh20010729-buttons/drivers/macintosh/mac_hid.c
--- linux-2.4.7-ben0-benh20010729.orij/drivers/macintosh/mac_hid.c	Thu Jun 28 09:29:50 2001
+++ linux-2.4.7-ben0-benh20010729-buttons/drivers/macintosh/mac_hid.c	Sun Jul 29 18:11:40 2001
@@ -200,15 +200,15 @@
 	0, 0, 0, KEY_KPCOMMA, 0, KEY_INTL3, 0, 0,		/* 0x00-0x07 */
 	0, 0, 0, 0, KEY_LANG1, KEY_LANG2, 0, 0,			/* 0x08-0x0f */
 	0, 0, 0, 0, 0, 0, 0, 0,					/* 0x10-0x17 */
-	0, 0, 0, 0, KEY_KPENTER, KEY_RIGHTCTRL, 0, 0,		/* 0x18-0x1f */
-	0, 0, 0, 0, 0, 0, 0, 0,					/* 0x20-0x27 */
+	0, 0, 0, 0, KEY_KPENTER, KEY_RIGHTCTRL, KEY_VOLUMEUP, 0,		/* 0x18-0x1f */
+	0, 0, 0, 0, 0, KEY_VOLUMEDOWN, KEY_MUTE, 0,					/* 0x20-0x27 */
 	0, 0, 0, 0, 0, 0, 0, 0,					/* 0x28-0x2f */
 	0, 0, 0, 0, 0, KEY_KPSLASH, 0, KEY_SYSRQ,		/* 0x30-0x37 */
-	KEY_RIGHTALT, 0, 0, 0, 0, 0, 0, 0,			/* 0x38-0x3f */
+	KEY_RIGHTALT, 0, 0, KEY_EJECTCD, 0, 0, 0, 0,			/* 0x38-0x3f */
 	0, 0, 0, 0, 0, 0, 0, KEY_HOME,				/* 0x40-0x47 */
 	KEY_UP, KEY_PAGEUP, 0, KEY_LEFT, 0, KEY_RIGHT, 0, KEY_END, /* 0x48-0x4f */
 	KEY_DOWN, KEY_PAGEDOWN, KEY_INSERT, KEY_DELETE, 0, 0, 0, 0, /* 0x50-0x57 */
-	0, 0, 0, KEY_LEFTMETA, KEY_RIGHTMETA, KEY_COMPOSE, 0, 0, /* 0x58-0x5f */
+	0, 0, 0, KEY_LEFTMETA, KEY_RIGHTMETA, KEY_COMPOSE, KEY_POWER, 0, /* 0x58-0x5f */
 	0, 0, 0, 0, 0, 0, 0, 0,					/* 0x60-0x67 */
 	0, 0, 0, 0, 0, 0, 0, KEY_MACRO,				/* 0x68-0x6f */
 	0, 0, 0, 0, 0, 0, 0, 0,					/* 0x70-0x77 */
