adb: create class devices for each handler
PATCH 1/1 adb: create class devices for each handler
This patch creates a class device for each registered ADB handler (currently only adbhid) such as /sys/classes/adb/keyboard0/, /sys/classes/adb/mouse0/. This is needed for the next patch, to create a sysfs entry to make SYSRQ key configurable on ADB based machines.
drivers/macintosh/adb.c +21 -0
@@ -102,11 +102,22 @@static void adbdev_init (void );static int try_handler_change (int ,int ); +static char *adb_device_id_string[] = { + [ADB_DONGLE ] ="dongle" , + [ADB_KEYBOARD ] ="keyboard" , + [ADB_MOUSE ] ="mouse" , + [ADB_TABLET ] ="tablet" , + [ADB_MODEM ] ="modem" , + [ADB_MISC ] ="misc" , +}; +static struct adb_handler {void (*handler)(unsigned char *,int ,struct pt_regs *,int );int original_address;int handler_id;int busy; +char name[16 ]; +struct class_device *device; } adb_handler[16 ];/*
@@ -541,6 +552,15 @@write_lock_irq (&adb_handler_lock); adb_handler[i].handler = handler;write_unlock_irq (&adb_handler_lock); + +snprintf (adb_handler[i].name, +sizeof (adb_handler[i].name),"%s%i" , + adb_device_id_string[default_id], ids->nids); + adb_handler[i].device =class_device_create ( + adb_dev_class,NULL , +MKDEV (0 ,0 ),NULL , + adb_handler[i].name); + ids->device[ids->nids] = adb_handler[i].device; ids->id[ids->nids++] = i; } }
@@ -563,6 +583,7 @@ } ret =0 ; adb_handler[index].handler =NULL ; +class_device_del (adb_handler[index].device); }write_unlock_irq (&adb_handler_lock);up (&adb_handler_sem);
include/linux/adb.h +2 -0
@@ -3,6 +3,7 @@*/ #ifndef __ADB_H#define __ADB_H +#include <linux/device.h> /* ADB commands */ #define ADB_BUSRESET 0
@@ -58,6 +59,7 @@struct adb_ids {int nids;unsigned char id[16 ]; +struct class_device *device[16 ]; };/* Structure which encapsulates a low-level ADB driver */
Quoted 4 lines
This patch creates a class device for each registered ADB handler (currently only adbhid) such as
/sys/classes/adb/keyboard0/,/sys/classes/adb/mouse0/. This is needed for the next patch, to create a sysfs entry to make SYSRQ key configurable on ADB based machines.
any comments on this one?
Quoted 78 lines
Signed-off-by Aristeu S. Rozanski F. <[email protected]>Index:
ppc-2.6/drivers/macintosh/adb.c
===================================================================drivers/macintosh/adb.c +21
-0@@ -102,11 +102,22 @@static void adbdev_init (void );static int try_handler_change (int ,int ); +static char *adb_device_id_string[] = { + [ADB_DONGLE ] ="dongle" , + [ADB_KEYBOARD ] ="keyboard" , + [ADB_MOUSE ] ="mouse" , + [ADB_TABLET ] ="tablet" , + [ADB_MODEM ] ="modem" , + [ADB_MISC ] ="misc" , +}; +static struct adb_handler {void (*handler)(unsigned char *,int ,struct pt_regs *,int );int original_address;int handler_id;int busy; +char name[16 ]; +struct class_device *device; } adb_handler[16 ];/* @@ -541,6 +552,15 @@write_lock_irq (&adb_handler_lock); adb_handler[i].handler = handler;write_unlock_irq (&adb_handler_lock); + +snprintf (adb_handler[i].name, +sizeof (adb_handler[i].name),"%s%i" , + adb_device_id_string[default_id], ids->nids); + adb_handler[i].device =class_device_create ( + adb_dev_class,NULL , +MKDEV (0 ,0 ),NULL , + adb_handler[i].name); + ids->device[ids->nids] = adb_handler[i].device; ids->id[ids->nids++] = i; } }@@ -563,6 +583,7 @@ } ret =0 ; adb_handler[index].handler =NULL ; +class_device_del (adb_handler[index].device); }write_unlock_irq (&adb_handler_lock);up (&adb_handler_sem);Index:
ppc-2.6/include/linux/adb.h
===================================================================include/linux/adb.h +2
-0@@ -3,6 +3,7 @@*/ #ifndef __ADB_H#define __ADB_H +#include <linux/device.h> /* ADB commands */ #define ADB_BUSRESET 0@@ -58,6 +59,7 @@struct adb_ids {int nids;unsigned char id[16 ]; +struct class_device *device[16 ]; };/* Structure which encapsulates a low-level ADB driver */ _______________________________________________
Linuxppc-dev mailing list
[email protected]
https://ozlabs.org/mailman/listinfo/linuxppc-dev
Signature · 1 line
Aristeu