New set of input patches
cover New set of input patches
Hi,
Here is the 2nd version of my set of input patches that mostly do serio sysfs integration. Among the changes - dropped psmouse KVM resync patch as it was bogus, added platform devices to those of serio providers that don't have proper parent device (i8042, q40kbd, etc).
01-psmouse-state-locking.patch
- Acquire underlying serio lock when changing psmouse state to prevent interrupt handler running on us
02-serio-connect-mandatory.patch
- Make serio driviers connect/disconnect methods mandatory as these methods open/close serio ports and link ports and drivers together. Presently if a driver does not implement connect method it will not be able to bind to a port anyway.
03-serio-rename-1.patch
- Rename serio->driver to serio->port_data as with sysfs integration driver is not the best name for arbitrary data
04-serio-rename-2.patch
- Rename serio_dev to serio_driver as they are drivers in sysfs sense
05-serio-dynamic-alloc.patch
- Switch from static to dynamic serio port allocation so serio ports drivers can be freely unloaded even if not all references to ports are dropped (sysfs req.)
06-serio-no-recursion.patch
- Do not do recursive discovery of children ports, needed for sysfs and generally better for stack usage.
07-serio-sysfs.patch
- sysfs integration. Register ports and drivers in driver model, link them all together under /sys/bus/serio. Every driver has a default attribute "descrip[tion" (from serio_driver->description); serio ports have "decription", "driver" and "legacy_position". Legacy_position porvides access to serio->phys to allow matching with data in /proc/bus/input/devices
08-serio-rebind.patch
- allow user to disconnect or rebind serio port by writing appropriate data to it's sysfs attribute:
echo -n "psmouse" > /sys/bus/serio/devices/serio0/driver echo -n "none" > /sys/bus/serio/devices/serio0/driver echo -n "reconnect" > /sys/bus/serio/devices/serio0/driver echo -n "rescan" > /sys/bus/serio/devices/serio0/driver
09-serio-manual-bind.patch
- allow marking some drivers as requiring manual bind (to be used when driver does not do automatic HW discovery)
10-serio_raw.patch
- raw access to serio data ala 2.4 /dev/psaux
(*) 11-platform-device-simple.patch
- Add platform_device_register_simple to register platform devices requiring minimal resource and memory management. The release function resides in driver core and that allows drivers registering such devices be unloaded without waiting for the last reference to be dropped.
12-i8042-to-platform-device.patch
- Convert i8042 to platform device instead of system device so its ports have proper parent.
13-serio-add-platform-devices.patch
- Add platform devices to ct82c710, maceps2, q40kbd and rpckbd.
14-serio-set-up-parents.patch
- Set up parent devices for serio ports in ambakmi, gscps2, pcips2 and sa1111ps2.c
15-synaptics-passthrough-handling.patch
- If data looks like a pass-through packet and tuchpad has pass-through capability do not pass it to the main handler if child port is disconnected.
(*) 16-bus-default-drv-attrs.patch
- Add bus' default driver attributes (similar to defaulr device attributes)
17-serio-use-bus-default-attrs.patch
- Use bus' default driver and device attributes to manage serio attributes
(*) 18-add-driver-find.patch
- Add driver_find function, similar to device_find, to search for a driver by its name.
19-serio-use-driver-find.patch
- Use driver_find in serio_rebind_driver instead of implementing it locally.
(*) These patches have also been sent to Greg KH.
This time I tried compiling the stuff using defconfing for SPACR64 and PPC64 (thanks to Andrew for pointing to me availability of cross-compile tools), so I should be a bit better now... Alpha failed on cpumask.h...
The patches are against today's Linus tree + recent pull form Vojtech's tree
+ recent pull from Greg KH's tree. I have patches against 2.6.7 that will bring it to my version of the tree at:
http://www.geocities.com/dt_or/input/2_6_7/
Signature · 1 line
Dmitry
PATCH 1/19 psmouse state locking
===================================================================
[email protected], 2004-06-27 15:44:44-05:00, [email protected]
Input: when changing psmouse state (activated, ignore) do it while
holding serio lock so it will not fight with the interrupt handler.
psmouse-base.c | 32 ++++++++++++++++++++++---------- 1 files changed, 22 insertions(+), 10 deletions(-)
===================================================================
drivers/input/mouse/psmouse-base.c +22 -10
@@ -622,6 +622,23 @@ }/* +* psmouse_set_state() sets new psmouse state and resets all flags and +* counters while holding serio lock so fighting with interrupt handler +* is not a concern. +*/ + +static void psmouse_set_state (struct psmouse *psmouse,unsigned char new_state) +{ +unsigned long flags; + +spin_lock_irqsave (&psmouse->serio->lock, flags); + psmouse->state = new_state; + psmouse->pktcnt = psmouse->cmdcnt = psmouse->out_of_sync =0 ; + psmouse->flags =0 ; +spin_unlock_irqrestore (&psmouse->serio->lock, flags); +} + +/* * psmouse_activate() enables the mouse so that we get motion reports from it. */
@@ -630,7 +647,7 @@if (psmouse_command (psmouse,NULL ,PSMOUSE_CMD_ENABLE ))printk (KERN_WARNING "psmouse.c: Failed to enable mouse on %s\n" , psmouse->serio->phys); - psmouse->state =PSMOUSE_ACTIVATED ; +psmouse_set_state (psmouse,PSMOUSE_ACTIVATED ); }/*
@@ -652,7 +669,7 @@ {struct psmouse *psmouse = serio->private; - psmouse->state =PSMOUSE_CMD_MODE ; +psmouse_set_state (psmouse,PSMOUSE_CMD_MODE );if (psmouse->ptport) {if (psmouse->ptport->deactivate)
@@ -665,7 +682,7 @@if (psmouse->disconnect) psmouse->disconnect (psmouse); - psmouse->state =PSMOUSE_IGNORE ; +psmouse_set_state (psmouse,PSMOUSE_IGNORE );input_unregister_device (&psmouse->dev);serio_close (serio);
@@ -693,9 +710,9 @@ psmouse->dev.evbit[0 ] =BIT (EV_KEY ) |BIT (EV_REL ); psmouse->dev.keybit[LONG (BTN_MOUSE )] =BIT (BTN_LEFT ) |BIT (BTN_MIDDLE ) |BIT (BTN_RIGHT ); psmouse->dev.relbit[0 ] =BIT (REL_X ) |BIT (REL_Y ); - psmouse->state =PSMOUSE_CMD_MODE ; psmouse->serio = serio; psmouse->dev.private = psmouse; +psmouse_set_state (psmouse,PSMOUSE_CMD_MODE ); serio->private = psmouse;if (serio_open (serio, dev)) {
@@ -758,12 +775,7 @@return -1 ; } - psmouse->state =PSMOUSE_CMD_MODE ; - -clear_bit (PSMOUSE_FLAG_ACK , &psmouse->flags); -clear_bit (PSMOUSE_FLAG_CMD , &psmouse->flags); - - psmouse->pktcnt = psmouse->out_of_sync =0 ; +psmouse_set_state (psmouse,PSMOUSE_CMD_MODE );if (psmouse->reconnect) {if (psmouse->reconnect (psmouse))
PATCH 2/19 serio connect/disconnect mandatory
===================================================================
[email protected], 2004-06-27 15:45:16-05:00, [email protected]
Input: make connect and disconnect methods mandatory for serio
drivers since that's where serio_{open|close} are called from to actually bind driver to a port.
serio.c | 11 +++++------ 1 files changed, 5 insertions(+), 6 deletions(-)
===================================================================
drivers/input/serio/serio.c +5 -6
@@ -68,8 +68,7 @@list_for_each_entry (dev, &serio_dev_list, node) {if (serio->dev)break ; -if (dev->connect) - dev->connect (serio, dev); + dev->connect (serio, dev); } }
@@ -160,7 +159,7 @@/* reconnect failed - fall through to rescan */ case SERIO_RESCAN : -if (event->serio->dev && event->serio->dev->disconnect) +if (event->serio->dev) event->serio->dev->disconnect (event->serio);serio_find_dev (event->serio);break ;
@@ -282,7 +281,7 @@ {serio_remove_pending_events (serio);list_del_init (&serio->node); -if (serio->dev && serio->dev->disconnect) +if (serio->dev) serio->dev->disconnect (serio); }
@@ -296,7 +295,7 @@down (&serio_sem);list_add_tail (&dev->node, &serio_dev_list);list_for_each_entry (serio, &serio_list, node) -if (!serio->dev && dev->connect) +if (!serio->dev) dev->connect (serio, dev);up (&serio_sem); }
@@ -309,7 +308,7 @@list_del_init (&dev->node);list_for_each_entry (serio, &serio_list, node) { -if (serio->dev == dev && dev->disconnect) +if (serio->dev == dev) dev->disconnect (serio);serio_find_dev (serio); }
PATCH 3/19 serio renames 1
===================================================================
[email protected], 2004-06-27 15:45:46-05:00, [email protected]
Input: rename serio->driver to serio->port_data in preparation
to sysfs integration
drivers/input/mouse/synaptics.c | 4 ++-- drivers/input/serio/ambakmi.c | 22 +++++++++++----------- drivers/input/serio/gscps2.c | 8 ++++---- drivers/input/serio/i8042.c | 14 +++++++------- drivers/input/serio/maceps2.c | 36 ++++++++++++++++++------------------ drivers/input/serio/pcips2.c | 8 ++++---- drivers/input/serio/sa1111ps2.c | 8 ++++---- drivers/input/serio/serport.c | 6 +++--- drivers/serial/sunsu.c | 8 ++++---- drivers/serial/sunzilog.c | 8 ++++---- include/linux/serio.h | 2 +- 11 files changed, 62 insertions(+), 62 deletions(-)
===================================================================
drivers/input/mouse/synaptics.c +2 -2
@@ -214,7 +214,7 @@****************************************************************************/ static int synaptics_pt_write (struct serio *port,unsigned char c) { -struct psmouse *parent = port->driver; +struct psmouse *parent = port->port_data;char rate_param =SYN_PS_CLIENT_CMD ;/* indicates that we want pass-through port */ if (psmouse_sliced_command (parent, c))
@@ -273,7 +273,7 @@ port->serio.name ="Synaptics pass-through" ; port->serio.phys ="synaptics-pt/serio0" ; port->serio.write = synaptics_pt_write; - port->serio.driver = psmouse; + port->serio.port_data = psmouse; port->activate = synaptics_pt_activate; }
drivers/input/serio/ambakmi.c +11 -11
@@ -54,7 +54,7 @@static int amba_kmi_write (struct serio *io,unsigned char val) { -struct amba_kmi_port *kmi = io->driver; +struct amba_kmi_port *kmi = io->port_data;unsigned int timeleft =10000 ;/* timeout in 100ms */ while ((readb (KMISTAT ) &KMISTAT_TXEMPTY ) ==0 && timeleft--)
@@ -68,7 +68,7 @@static int amba_kmi_open (struct serio *io) { -struct amba_kmi_port *kmi = io->driver; +struct amba_kmi_port *kmi = io->port_data;unsigned int divisor;int ret;
@@ -105,7 +105,7 @@static void amba_kmi_close (struct serio *io) { -struct amba_kmi_port *kmi = io->driver; +struct amba_kmi_port *kmi = io->port_data;writeb (0 ,KMICR );
@@ -131,15 +131,15 @@memset (kmi,0 ,sizeof (struct amba_kmi_port )); - kmi->io.type =SERIO_8042 ; - kmi->io.write = amba_kmi_write; - kmi->io.open = amba_kmi_open; - kmi->io.close = amba_kmi_close; - kmi->io.name = dev->dev.bus_id; - kmi->io.phys = dev->dev.bus_id; - kmi->io.driver = kmi; + kmi->io.type =SERIO_8042 ; + kmi->io.write = amba_kmi_write; + kmi->io.open = amba_kmi_open; + kmi->io.close = amba_kmi_close; + kmi->io.name = dev->dev.bus_id; + kmi->io.phys = dev->dev.bus_id; + kmi->io.port_data = kmi; - kmi->base =ioremap (dev->res.start,KMI_SIZE ); + kmi->base =ioremap (dev->res.start,KMI_SIZE );if (!kmi->base) { ret = -ENOMEM ; goto out;
drivers/input/serio/gscps2.c +4 -4
@@ -288,7 +288,7 @@static int gscps2_write (struct serio *port,unsigned char data) { -struct gscps2port *ps2port = port->driver; +struct gscps2port *ps2port = port->port_data;if (!gscps2_writeb_output (ps2port, data)) { printk(KERN_DEBUG PFX "sending byte %#x failed.\n", data);
@@ -304,7 +304,7 @@static int gscps2_open (struct serio *port) { -struct gscps2port *ps2port = port->driver; +struct gscps2port *ps2port = port->port_data;gscps2_reset (ps2port);
@@ -319,7 +319,7 @@static void gscps2_close (struct serio *port) { -struct gscps2port *ps2port = port->driver; +struct gscps2port *ps2port = port->port_data;gscps2_enable (ps2port,DISABLE ); }
@@ -372,7 +372,7 @@ (ps2port->id == GSC_ID_KEYBOARD) ? "keyboard" : "mouse" );memcpy (&ps2port->port, &gscps2_serio_port,sizeof (gscps2_serio_port)); - ps2port->port.driver = ps2port; + ps2port->port.port_data = ps2port; ps2port->port.name = ps2port->name; ps2port->port.phys = dev->dev.bus_id;
drivers/input/serio/i8042.c +7 -7
@@ -223,7 +223,7 @@static int i8042_aux_write (struct serio *port,unsigned char c) { -struct i8042_values *values = port->driver; +struct i8042_values *values = port->port_data;int retval;/*
@@ -251,7 +251,7 @@static int i8042_activate_port (struct serio *port) { -struct i8042_values *values = port->driver; +struct i8042_values *values = port->port_data;i8042_flush ();
@@ -279,7 +279,7 @@static int i8042_open (struct serio *port) { -struct i8042_values *values = port->driver; +struct i8042_values *values = port->port_data;if (values->mux !=-1 )if (i8042_mux_open++)
@@ -318,7 +318,7 @@static void i8042_close (struct serio *port) { -struct i8042_values *values = port->driver; +struct i8042_values *values = port->port_data;if (values->mux !=-1 )if (--i8042_mux_open)
@@ -353,7 +353,7 @@ .write = i8042_kbd_write, .open = i8042_open, .close = i8042_close, - .driver = &i8042_kbd_values, + .port_data = &i8042_kbd_values, .name = "i8042 Kbd Port", .phys = I8042_KBD_PHYS_DESC, };
@@ -371,7 +371,7 @@ .write = i8042_aux_write, .open = i8042_open, .close = i8042_close, - .driver = &i8042_aux_values, + .port_data = &i8042_aux_values, .name = "i8042 Aux Port", .phys = I8042_AUX_PHYS_DESC, };
@@ -941,7 +941,7 @@sprintf (i8042_mux_short[index],"AUX%d" , index); port->name = i8042_mux_names[index]; port->phys = i8042_mux_phys[index]; - port->driver = values; + port->port_data = values; values->name = i8042_mux_short[index]; values->mux = index; }
drivers/input/serio/maceps2.c +18 -18
@@ -54,7 +54,7 @@static int maceps2_write (struct serio *dev,unsigned char val) { -struct mace_ps2port *port = ((struct maceps2_data *)dev->driver)->port; +struct mace_ps2port *port = ((struct maceps2_data *)dev->port_data)->port;unsigned int timeout =MACE_PS2_TIMEOUT ; do {
@@ -72,7 +72,7 @@ struct pt_regs *regs) {struct serio *dev = dev_id; -struct mace_ps2port *port = ((struct maceps2_data *)dev->driver)->port; +struct mace_ps2port *port = ((struct maceps2_data *)dev->port_data)->port;unsigned int byte;if (mace_read (port->status) &PS2_STATUS_RX_FULL ) {
@@ -85,7 +85,7 @@static int maceps2_open (struct serio *dev) { -struct maceps2_data *data = (struct maceps2_data *)dev->driver; +struct maceps2_data *data = (struct maceps2_data *)dev->port_data;if (request_irq (data->irq, maceps2_interrupt,0 ,"PS/2 port" , dev)) {printk (KERN_ERR "Could not allocate PS/2 IRQ\n" );
@@ -106,7 +106,7 @@static void maceps2_close (struct serio *dev) { -struct maceps2_data *data = (struct maceps2_data *)dev->driver; +struct maceps2_data *data = (struct maceps2_data *)dev->port_data;mace_write (PS2_CONTROL_TX_CLOCK_DISABLE |PS2_CONTROL_RESET , data->port->control);
@@ -118,24 +118,24 @@static struct serio maceps2_port0 = { - .type =SERIO_8042 , - .open = maceps2_open, - .close = maceps2_close, - .write = maceps2_write, - .name ="MACE PS/2 port0" , - .phys ="mace/serio0" , - .driver = &port0_data, + .type =SERIO_8042 , + .open = maceps2_open, + .close = maceps2_close, + .write = maceps2_write, + .name ="MACE PS/2 port0" , + .phys ="mace/serio0" , + .port_data = &port0_data, };static struct serio maceps2_port1 = { - .type =SERIO_8042 , - .open = maceps2_open, - .close = maceps2_close, - .write = maceps2_write, - .name ="MACE PS/2 port1" , - .phys ="mace/serio1" , - .driver = &port1_data, + .type =SERIO_8042 , + .open = maceps2_open, + .close = maceps2_close, + .write = maceps2_write, + .name ="MACE PS/2 port1" , + .phys ="mace/serio1" , + .port_data = &port1_data, };static int __init maceps2_init (void )
drivers/input/serio/pcips2.c +4 -4
@@ -45,7 +45,7 @@static int pcips2_write (struct serio *io,unsigned char val) { -struct pcips2_data *ps2if = io->driver; +struct pcips2_data *ps2if = io->port_data;unsigned int stat; do {
@@ -101,7 +101,7 @@static int pcips2_open (struct serio *io) { -struct pcips2_data *ps2if = io->driver; +struct pcips2_data *ps2if = io->port_data;int ret, val =0 ;outb (PS2_CTRL_ENABLE , ps2if->base);
@@ -119,7 +119,7 @@static void pcips2_close (struct serio *io) { -struct pcips2_data *ps2if = io->driver; +struct pcips2_data *ps2if = io->port_data;outb (0 , ps2if->base);
@@ -155,7 +155,7 @@ ps2if->io.close = pcips2_close; ps2if->io.name =pci_name (dev); ps2if->io.phys = dev->dev.bus_id; - ps2if->io.driver = ps2if; + ps2if->io.port_data = ps2if; ps2if->dev = dev; ps2if->base =pci_resource_start (dev,0 );
drivers/input/serio/sa1111ps2.c +4 -4
@@ -95,7 +95,7 @@*/ static int ps2_write (struct serio *io,unsigned char val) { -struct ps2if *ps2if = io->driver; +struct ps2if *ps2if = io->port_data;unsigned long flags;unsigned int head;
@@ -122,7 +122,7 @@static int ps2_open (struct serio *io) { -struct ps2if *ps2if = io->driver; +struct ps2if *ps2if = io->port_data;int ret;sa1111_enable_device (ps2if->dev);
@@ -154,7 +154,7 @@static void ps2_close (struct serio *io) { -struct ps2if *ps2if = io->driver; +struct ps2if *ps2if = io->port_data;sa1111_writel (0 , ps2if->base +SA1111_PS2CR );
@@ -247,7 +247,7 @@ ps2if->io.close = ps2_close; ps2if->io.name = dev->dev.bus_id; ps2if->io.phys = dev->dev.bus_id; - ps2if->io.driver = ps2if; + ps2if->io.port_data = ps2if; ps2if->dev = dev;sa1111_set_drvdata (dev, ps2if);
drivers/input/serio/serport.c +3 -3
@@ -44,13 +44,13 @@static int serport_serio_write (struct serio *serio,unsigned char data) { -struct serport *serport = serio->driver; +struct serport *serport = serio->port_data;return -(serport->tty->driver->write (serport->tty,0 , &data,1 ) !=1 ); }static void serport_serio_close (struct serio *serio) { -struct serport *serport = serio->driver; +struct serport *serport = serio->port_data; serport->serio.type =0 ;wake_up_interruptible (&serport->wait);
@@ -83,7 +83,7 @@ serport->serio.type =SERIO_RS232 ; serport->serio.write = serport_serio_write; serport->serio.close = serport_serio_close; - serport->serio.driver = serport; + serport->serio.port_data = serport;init_waitqueue_head (&serport->wait);
drivers/serial/sunsu.c +4 -4
@@ -994,7 +994,7 @@static int sunsu_serio_write (struct serio *serio,unsigned char ch) { -struct uart_sunsu_port *up = serio->driver; +struct uart_sunsu_port *up = serio->port_data;unsigned long flags;int lsr;
@@ -1014,7 +1014,7 @@static int sunsu_serio_open (struct serio *serio) { -struct uart_sunsu_port *up = serio->driver; +struct uart_sunsu_port *up = serio->port_data;unsigned long flags;int ret;
@@ -1031,7 +1031,7 @@static void sunsu_serio_close (struct serio *serio) { -struct uart_sunsu_port *up = serio->driver; +struct uart_sunsu_port *up = serio->port_data;unsigned long flags;spin_lock_irqsave (&sunsu_serio_lock, flags);
@@ -1311,7 +1311,7 @@#ifdef CONFIG_SERIO memset (&up->serio,0 ,sizeof (up->serio)); - up->serio.driver = up; + up->serio.port_data = up; up->serio.type =SERIO_RS232 ;if (up->su_type ==SU_PORT_KBD ) {
drivers/serial/sunzilog.c +4 -4
@@ -1295,7 +1295,7 @@static int sunzilog_serio_write (struct serio *serio,unsigned char ch) { -struct uart_sunzilog_port *up = serio->driver; +struct uart_sunzilog_port *up = serio->port_data;unsigned long flags;spin_lock_irqsave (&sunzilog_serio_lock, flags);
@@ -1309,7 +1309,7 @@static int sunzilog_serio_open (struct serio *serio) { -struct uart_sunzilog_port *up = serio->driver; +struct uart_sunzilog_port *up = serio->port_data;unsigned long flags;int ret;
@@ -1326,7 +1326,7 @@static void sunzilog_serio_close (struct serio *serio) { -struct uart_sunzilog_port *up = serio->driver; +struct uart_sunzilog_port *up = serio->port_data;unsigned long flags;spin_lock_irqsave (&sunzilog_serio_lock, flags);
@@ -1549,7 +1549,7 @@#ifdef CONFIG_SERIO memset (&up->serio,0 ,sizeof (up->serio)); - up->serio.driver = up; + up->serio.port_data = up; up->serio.type =SERIO_RS232 ;if (channel ==KEYBOARD_LINE ) {
include/linux/serio.h +1 -1
@@ -21,7 +21,7 @@struct serio {void *private; -void *driver; +void *port_data;char *name;char *phys;
PATCH 4/19 serio renames 2
===================================================================
[email protected], 2004-06-27 15:46:16-05:00, [email protected]
Input: more renames in serio in preparations to sysfs integration
- serio_dev -> serio_driver
- serio_[un]register_device -> serio_[un]register_driver
drivers/input/joystick/iforce/iforce-main.c | 4 - drivers/input/joystick/iforce/iforce-serio.c | 6 +- drivers/input/joystick/iforce/iforce.h | 2 drivers/input/joystick/magellan.c | 10 +-- drivers/input/joystick/spaceball.c | 10 +-- drivers/input/joystick/spaceorb.c | 10 +-- drivers/input/joystick/stinger.c | 10 +-- drivers/input/joystick/twidjoy.c | 10 +-- drivers/input/joystick/warrior.c | 10 +-- drivers/input/keyboard/atkbd.c | 14 ++--- drivers/input/keyboard/lkkbd.c | 10 +-- drivers/input/keyboard/newtonkbd.c | 10 +-- drivers/input/keyboard/sunkbd.c | 10 +-- drivers/input/keyboard/xtkbd.c | 10 +-- drivers/input/mouse/psmouse-base.c | 14 ++--- drivers/input/mouse/sermouse.c | 10 +-- drivers/input/mouse/synaptics.c | 2 drivers/input/mouse/vsxxxaa.c | 10 +-- drivers/input/serio/serio.c | 72 +++++++++++++-------------- drivers/input/serio/serport.c | 2 drivers/input/touchscreen/gunze.c | 10 +-- drivers/input/touchscreen/h3600_ts_input.c | 10 +-- include/linux/serio.h | 22 ++++---- 23 files changed, 139 insertions(+), 139 deletions(-)
===================================================================
drivers/input/joystick/iforce/iforce-main.c +2 -2
@@ -524,7 +524,7 @@usb_register (&iforce_usb_driver);#endif #ifdef CONFIG_JOYSTICK_IFORCE_232 -serio_register_device (&iforce_serio_dev); +serio_register_driver (&iforce_serio_drv);#endif return 0 ; }
@@ -535,7 +535,7 @@usb_deregister (&iforce_usb_driver);#endif #ifdef CONFIG_JOYSTICK_IFORCE_232 -serio_unregister_device (&iforce_serio_dev); +serio_unregister_driver (&iforce_serio_drv);#endif }
drivers/input/joystick/iforce/iforce-serio.c +3 -3
@@ -124,7 +124,7 @@return IRQ_HANDLED ; } -static void iforce_serio_connect (struct serio *serio,struct serio_dev *dev) +static void iforce_serio_connect (struct serio *serio,struct serio_driver *drv) {struct iforce *iforce;if (serio->type != (SERIO_RS232 |SERIO_IFORCE ))
@@ -137,7 +137,7 @@ iforce->serio = serio; serio->private = iforce; -if (serio_open (serio, dev)) { +if (serio_open (serio, drv)) {kfree (iforce);return ; }
@@ -158,7 +158,7 @@kfree (iforce); } -struct serio_dev iforce_serio_dev = { +struct serio_driver iforce_serio_drv = { .write_wakeup = iforce_serio_write_wakeup, .interrupt = iforce_serio_irq, .connect = iforce_serio_connect,
drivers/input/joystick/iforce/iforce.h +1 -1
@@ -187,5 +187,5 @@int iforce_upload_condition (struct iforce *,struct ff_effect *,int is_update);/* Public variables */ -extern struct serio_dev iforce_serio_dev; +extern struct serio_driver iforce_serio_drv;extern struct usb_driver iforce_usb_driver;
drivers/input/joystick/magellan.c +5 -5
@@ -146,7 +146,7 @@* it as an input device. */ -static void magellan_connect (struct serio *serio,struct serio_dev *dev) +static void magellan_connect (struct serio *serio,struct serio_driver *drv) {struct magellan *magellan;int i, t;
@@ -184,7 +184,7 @@ serio->private = magellan; -if (serio_open (serio, dev)) { +if (serio_open (serio, drv)) {kfree (magellan);return ; }
@@ -199,7 +199,7 @@* The serio device structure. */ -static struct serio_dev magellan_dev = { +static struct serio_driver magellan_drv = { .interrupt = magellan_interrupt, .connect = magellan_connect, .disconnect = magellan_disconnect,
@@ -211,13 +211,13 @@int __init magellan_init (void ) { -serio_register_device (&magellan_dev); +serio_register_driver (&magellan_drv);return 0 ; } void __exit magellan_exit(void) { -serio_unregister_device (&magellan_dev); +serio_unregister_driver (&magellan_drv); }module_init (magellan_init);
drivers/input/joystick/spaceball.c +5 -5
@@ -201,7 +201,7 @@* it as an input device. */ -static void spaceball_connect (struct serio *serio,struct serio_dev *dev) +static void spaceball_connect (struct serio *serio,struct serio_driver *drv) {struct spaceball *spaceball;int i, t, id;
@@ -254,7 +254,7 @@ serio->private = spaceball; -if (serio_open (serio, dev)) { +if (serio_open (serio, drv)) {kfree (spaceball);return ; }
@@ -269,7 +269,7 @@* The serio device structure. */ -static struct serio_dev spaceball_dev = { +static struct serio_driver spaceball_drv = { .interrupt = spaceball_interrupt, .connect = spaceball_connect, .disconnect = spaceball_disconnect,
@@ -281,13 +281,13 @@int __init spaceball_init (void ) { -serio_register_device (&spaceball_dev); +serio_register_driver (&spaceball_drv);return 0 ; } void __exit spaceball_exit(void) { -serio_unregister_device (&spaceball_dev); +serio_unregister_driver (&spaceball_drv); }module_init (spaceball_init);
drivers/input/joystick/spaceorb.c +5 -5
@@ -162,7 +162,7 @@* it as an input device. */ -static void spaceorb_connect (struct serio *serio,struct serio_dev *dev) +static void spaceorb_connect (struct serio *serio,struct serio_driver *drv) {struct spaceorb *spaceorb;int i, t;
@@ -201,7 +201,7 @@ serio->private = spaceorb; -if (serio_open (serio, dev)) { +if (serio_open (serio, drv)) {kfree (spaceorb);return ; }
@@ -213,7 +213,7 @@* The serio device structure. */ -static struct serio_dev spaceorb_dev = { +static struct serio_driver spaceorb_drv = { .interrupt = spaceorb_interrupt, .connect = spaceorb_connect, .disconnect = spaceorb_disconnect,
@@ -225,13 +225,13 @@int __init spaceorb_init (void ) { -serio_register_device (&spaceorb_dev); +serio_register_driver (&spaceorb_drv);return 0 ; } void __exit spaceorb_exit(void) { -serio_unregister_device (&spaceorb_dev); +serio_unregister_driver (&spaceorb_drv); }module_init (spaceorb_init);
drivers/input/joystick/stinger.c +5 -5
@@ -134,7 +134,7 @@* it as an input device. */ -static void stinger_connect (struct serio *serio,struct serio_dev *dev) +static void stinger_connect (struct serio *serio,struct serio_driver *drv) {struct stinger *stinger;int i;
@@ -172,7 +172,7 @@ stinger->dev.private = stinger; serio->private = stinger; -if (serio_open (serio, dev)) { +if (serio_open (serio, drv)) {kfree (stinger);return ; }
@@ -187,7 +187,7 @@* The serio device structure. */ -static struct serio_dev stinger_dev = { +static struct serio_driver stinger_drv = { .interrupt = stinger_interrupt, .connect = stinger_connect, .disconnect = stinger_disconnect,
@@ -199,13 +199,13 @@int __init stinger_init (void ) { -serio_register_device (&stinger_dev); +serio_register_driver (&stinger_drv);return 0 ; } void __exit stinger_exit(void) { -serio_unregister_device (&stinger_dev); +serio_unregister_driver (&stinger_drv); }module_init (stinger_init);
drivers/input/joystick/twidjoy.c +5 -5
@@ -187,7 +187,7 @@* it as an input device. */ -static void twidjoy_connect (struct serio *serio,struct serio_dev *dev) +static void twidjoy_connect (struct serio *serio,struct serio_driver *drv) {struct twidjoy_button_spec *bp;struct twidjoy *twidjoy;
@@ -232,7 +232,7 @@ twidjoy->dev.private = twidjoy; serio->private = twidjoy; -if (serio_open (serio, dev)) { +if (serio_open (serio, drv)) {kfree (twidjoy);return ; }
@@ -246,7 +246,7 @@* The serio device structure. */ -static struct serio_dev twidjoy_dev = { +static struct serio_driver twidjoy_drv = { .interrupt = twidjoy_interrupt, .connect = twidjoy_connect, .disconnect = twidjoy_disconnect,
@@ -258,13 +258,13 @@int __init twidjoy_init (void ) { -serio_register_device (&twidjoy_dev); +serio_register_driver (&twidjoy_drv);return 0 ; } void __exit twidjoy_exit(void) { -serio_unregister_device (&twidjoy_dev); +serio_unregister_driver (&twidjoy_drv); }module_init (twidjoy_init);
drivers/input/joystick/warrior.c +5 -5
@@ -139,7 +139,7 @@* it as an input device. */ -static void warrior_connect (struct serio *serio,struct serio_dev *dev) +static void warrior_connect (struct serio *serio,struct serio_driver *drv) {struct warrior *warrior;int i;
@@ -185,7 +185,7 @@ serio->private = warrior; -if (serio_open (serio, dev)) { +if (serio_open (serio, drv)) {kfree (warrior);return ; }
@@ -199,7 +199,7 @@* The serio device structure. */ -static struct serio_dev warrior_dev = { +static struct serio_driver warrior_drv = { .interrupt = warrior_interrupt, .connect = warrior_connect, .disconnect = warrior_disconnect,
@@ -211,13 +211,13 @@int __init warrior_init (void ) { -serio_register_device (&warrior_dev); +serio_register_driver (&warrior_drv);return 0 ; } void __exit warrior_exit(void) { -serio_unregister_device (&warrior_dev); +serio_unregister_driver (&warrior_drv); }module_init (warrior_init);
drivers/input/keyboard/atkbd.c +7 -7
@@ -732,7 +732,7 @@* to the input module. */ -static void atkbd_connect (struct serio *serio,struct serio_dev *dev) +static void atkbd_connect (struct serio *serio,struct serio_driver *drv) {struct atkbd *atkbd;int i;
@@ -785,7 +785,7 @@ serio->private = atkbd; -if (serio_open (serio, dev)) { +if (serio_open (serio, drv)) {kfree (atkbd);return ; }
@@ -861,10 +861,10 @@static int atkbd_reconnect (struct serio *serio) {struct atkbd *atkbd = serio->private; -struct serio_dev *dev = serio->dev; +struct serio_driver *drv = serio->drv;unsigned char param[1 ]; -if (!dev) { +if (!drv) {printk (KERN_DEBUG "atkbd: reconnect request, but serio is disconnected, ignoring...\n" );return -1 ; }
@@ -890,7 +890,7 @@return 0 ; } -static struct serio_dev atkbd_dev = { +static struct serio_driver atkbd_drv = { .interrupt = atkbd_interrupt, .connect = atkbd_connect, .reconnect = atkbd_reconnect,
@@ -900,13 +900,13 @@int __init atkbd_init (void ) { -serio_register_device (&atkbd_dev); +serio_register_driver (&atkbd_drv);return 0 ; } void __exit atkbd_exit(void) { -serio_unregister_device (&atkbd_dev); +serio_unregister_driver (&atkbd_drv); }module_init (atkbd_init);
drivers/input/keyboard/lkkbd.c +5 -5
@@ -622,7 +622,7 @@* lkkbd_connect() probes for a LK keyboard and fills the necessary structures. */ static void -lkkbd_connect (struct serio *serio,struct serio_dev *dev) +lkkbd_connect (struct serio *serio,struct serio_driver *drv) {struct lkkbd *lk;int i;
@@ -665,7 +665,7 @@ serio->private = lk; -if (serio_open (serio, dev)) { +if (serio_open (serio, drv)) {kfree (lk);return ; }
@@ -703,7 +703,7 @@kfree (lk); } -static struct serio_dev lkkbd_dev = { +static struct serio_driver lkkbd_drv = { .connect = lkkbd_connect, .disconnect = lkkbd_disconnect, .interrupt = lkkbd_interrupt,
@@ -715,14 +715,14 @@int __init lkkbd_init (void ) { -serio_register_device (&lkkbd_dev); +serio_register_driver (&lkkbd_drv);return 0 ; } void __exitlkkbd_exit (void ) { -serio_unregister_device (&lkkbd_dev); +serio_unregister_driver (&lkkbd_drv); }module_init (lkkbd_init);
drivers/input/keyboard/newtonkbd.c +5 -5
@@ -82,7 +82,7 @@ } -void nkbd_connect (struct serio *serio,struct serio_dev *dev) +void nkbd_connect (struct serio *serio,struct serio_driver *drv) {struct nkbd *nkbd;int i;
@@ -106,7 +106,7 @@ nkbd->dev.private = nkbd; serio->private = nkbd; -if (serio_open (serio, dev)) { +if (serio_open (serio, drv)) {kfree (nkbd);return ; }
@@ -138,7 +138,7 @@kfree (nkbd); } -struct serio_dev nkbd_dev = { +struct serio_driver nkbd_drv = { .interrupt = nkbd_interrupt, .connect = nkbd_connect, .disconnect = nkbd_disconnect
@@ -146,13 +146,13 @@int __init nkbd_init (void ) { -serio_register_device (&nkbd_dev); +serio_register_driver (&nkbd_drv);return 0 ; } void __exit nkbd_exit(void) { -serio_unregister_device (&nkbd_dev); +serio_unregister_driver (&nkbd_drv); }module_init (nkbd_init);
drivers/input/keyboard/sunkbd.c +5 -5
@@ -221,7 +221,7 @@* sunkbd_connect() probes for a Sun keyboard and fills the necessary structures. */ -static void sunkbd_connect (struct serio *serio,struct serio_dev *dev) +static void sunkbd_connect (struct serio *serio,struct serio_driver *drv) {struct sunkbd *sunkbd;int i;
@@ -257,7 +257,7 @@ serio->private = sunkbd; -if (serio_open (serio, dev)) { +if (serio_open (serio, drv)) {kfree (sunkbd);return ; }
@@ -301,7 +301,7 @@kfree (sunkbd); } -static struct serio_dev sunkbd_dev = { +static struct serio_driver sunkbd_drv = { .interrupt = sunkbd_interrupt, .connect = sunkbd_connect, .disconnect = sunkbd_disconnect
@@ -313,13 +313,13 @@int __init sunkbd_init (void ) { -serio_register_device (&sunkbd_dev); +serio_register_driver (&sunkbd_drv);return 0 ; } void __exit sunkbd_exit(void) { -serio_unregister_device (&sunkbd_dev); +serio_unregister_driver (&sunkbd_drv); }module_init (sunkbd_init);
drivers/input/keyboard/xtkbd.c +5 -5
@@ -86,7 +86,7 @@return IRQ_HANDLED ; } -void xtkbd_connect (struct serio *serio,struct serio_dev *dev) +void xtkbd_connect (struct serio *serio,struct serio_driver *drv) {struct xtkbd *xtkbd;int i;
@@ -111,7 +111,7 @@ serio->private = xtkbd; -if (serio_open (serio, dev)) { +if (serio_open (serio, drv)) {kfree (xtkbd);return ; }
@@ -143,7 +143,7 @@kfree (xtkbd); } -struct serio_dev xtkbd_dev = { +struct serio_driver xtkbd_drv = { .interrupt = xtkbd_interrupt, .connect = xtkbd_connect, .disconnect = xtkbd_disconnect
@@ -151,13 +151,13 @@int __init xtkbd_init (void ) { -serio_register_device (&xtkbd_dev); +serio_register_driver (&xtkbd_drv);return 0 ; } void __exit xtkbd_exit(void) { -serio_unregister_device (&xtkbd_dev); +serio_unregister_driver (&xtkbd_drv); }module_init (xtkbd_init);
drivers/input/mouse/psmouse-base.c +7 -7
@@ -693,7 +693,7 @@* psmouse_connect() is a callback from the serio module when * an unhandled serio port is found. */ -static void psmouse_connect (struct serio *serio,struct serio_dev *dev) +static void psmouse_connect (struct serio *serio,struct serio_driver *drv) {struct psmouse *psmouse;
@@ -715,7 +715,7 @@psmouse_set_state (psmouse,PSMOUSE_CMD_MODE ); serio->private = psmouse; -if (serio_open (serio, dev)) { +if (serio_open (serio, drv)) {kfree (psmouse); serio->private =NULL ;return ;
@@ -768,9 +768,9 @@static int psmouse_reconnect (struct serio *serio) {struct psmouse *psmouse = serio->private; -struct serio_dev *dev = serio->dev; +struct serio_driver *drv = serio->drv; -if (!dev || !psmouse) { +if (!drv || !psmouse) {printk (KERN_DEBUG "psmouse: reconnect request, but serio is disconnected, ignoring...\n" );return -1 ; }
@@ -803,7 +803,7 @@ } -static struct serio_dev psmouse_dev = { +static struct serio_driver psmouse_drv = { .interrupt = psmouse_interrupt, .connect = psmouse_connect, .reconnect = psmouse_reconnect,
@@ -828,13 +828,13 @@int __init psmouse_init (void ) {psmouse_parse_proto (); -serio_register_device (&psmouse_dev); +serio_register_driver (&psmouse_drv);return 0 ; } void __exit psmouse_exit(void) { -serio_unregister_device (&psmouse_dev); +serio_unregister_driver (&psmouse_drv); }module_init (psmouse_init);
drivers/input/mouse/sermouse.c +5 -5
@@ -237,7 +237,7 @@* an unhandled serio port is found. */ -static void sermouse_connect (struct serio *serio,struct serio_dev *dev) +static void sermouse_connect (struct serio *serio,struct serio_driver *drv) {struct sermouse *sermouse;unsigned char c;
@@ -279,7 +279,7 @@ sermouse->dev.id.product = c; sermouse->dev.id.version =0x0100 ; -if (serio_open (serio, dev)) { +if (serio_open (serio, drv)) {kfree (sermouse);return ; }
@@ -289,7 +289,7 @@printk (KERN_INFO "input: %s on %s\n" , sermouse_protocols[sermouse->type], serio->phys); } -static struct serio_dev sermouse_dev = { +static struct serio_driver sermouse_drv = { .interrupt = sermouse_interrupt, .connect = sermouse_connect, .disconnect = sermouse_disconnect
@@ -297,13 +297,13 @@int __init sermouse_init (void ) { -serio_register_device (&sermouse_dev); +serio_register_driver (&sermouse_drv);return 0 ; } void __exit sermouse_exit(void) { -serio_unregister_device (&sermouse_dev); +serio_unregister_driver (&sermouse_drv); }module_init (sermouse_init);
drivers/input/mouse/synaptics.c +1 -1
@@ -470,7 +470,7 @@if (unlikely (priv->pkt_type ==SYN_NEWABS )) priv->pkt_type =synaptics_detect_pkt_type (psmouse); -if (psmouse->ptport && psmouse->ptport->serio.dev &&synaptics_is_pt_packet (psmouse->packet)) +if (psmouse->ptport && psmouse->ptport->serio.drv &&synaptics_is_pt_packet (psmouse->packet))synaptics_pass_pt_packet (&psmouse->ptport->serio, psmouse->packet);else synaptics_process_packet (psmouse);
drivers/input/mouse/vsxxxaa.c +5 -5
@@ -482,7 +482,7 @@ }static void -vsxxxaa_connect (struct serio *serio,struct serio_dev *dev) +vsxxxaa_connect (struct serio *serio,struct serio_driver *drv) {struct vsxxxaa *mouse;
@@ -524,7 +524,7 @@ mouse->dev.id.bustype =BUS_RS232 ; mouse->serio = serio; -if (serio_open (serio, dev)) { +if (serio_open (serio, drv)) {kfree (mouse);return ; }
@@ -540,7 +540,7 @@printk (KERN_INFO "input: %s on %s\n" , mouse->name, mouse->phys); } -static struct serio_dev vsxxxaa_dev = { +static struct serio_driver vsxxxaa_drv = { .connect = vsxxxaa_connect, .interrupt = vsxxxaa_interrupt, .disconnect = vsxxxaa_disconnect,
@@ -549,14 +549,14 @@int __init vsxxxaa_init (void ) { -serio_register_device (&vsxxxaa_dev); +serio_register_driver (&vsxxxaa_drv);return 0 ; } void __exitvsxxxaa_exit (void ) { -serio_unregister_device (&vsxxxaa_dev); +serio_unregister_driver (&vsxxxaa_drv); }module_init (vsxxxaa_init);
drivers/input/serio/serio.c +36 -36
158 lines not on this page · raw message
drivers/input/serio/serport.c +1 -1
@@ -170,7 +170,7 @@ {struct serport *sp = (struct serport *) tty->disc_data; -serio_dev_write_wakeup (&sp->serio); +serio_drv_write_wakeup (&sp->serio); }/*
drivers/input/touchscreen/gunze.c +5 -5
@@ -111,7 +111,7 @@* and if yes, registers it as an input device. */ -static void gunze_connect (struct serio *serio,struct serio_dev *dev) +static void gunze_connect (struct serio *serio,struct serio_driver *drv) {struct gunze *gunze;
@@ -142,7 +142,7 @@ gunze->dev.id.product =0x0051 ; gunze->dev.id.version =0x0100 ; -if (serio_open (serio, dev)) { +if (serio_open (serio, drv)) {kfree (gunze);return ; }
@@ -156,7 +156,7 @@* The serio device structure. */ -static struct serio_dev gunze_dev = { +static struct serio_driver gunze_drv = { .interrupt = gunze_interrupt, .connect = gunze_connect, .disconnect = gunze_disconnect,
@@ -168,13 +168,13 @@int __init gunze_init (void ) { -serio_register_device (&gunze_dev); +serio_register_driver (&gunze_drv);return 0 ; } void __exit gunze_exit(void) { -serio_unregister_device (&gunze_dev); +serio_unregister_driver (&gunze_drv); }module_init (gunze_init);
drivers/input/touchscreen/h3600_ts_input.c +5 -5
@@ -373,7 +373,7 @@* new serio device. It looks whether it was registered as a H3600 touchscreen * and if yes, registers it as an input device. */ -static void h3600ts_connect (struct serio *serio,struct serio_dev *dev) +static void h3600ts_connect (struct serio *serio,struct serio_driver *drv) {struct h3600_dev *ts;
@@ -441,7 +441,7 @@ ts->dev.id.product =0x0666 ;/* FIXME !!! We can ask the hardware */ ts->dev.id.version =0x0100 ; -if (serio_open (serio, dev)) { +if (serio_open (serio, drv)) {free_irq (IRQ_GPIO_BITSY_ACTION_BUTTON , ts);free_irq (IRQ_GPIO_BITSY_NPOWER_BUTTON , ts);kfree (ts);
@@ -478,7 +478,7 @@* The serio device structure. */ -static struct serio_dev h3600ts_dev = { +static struct serio_driver h3600ts_drv = { .interrupt = h3600ts_interrupt, .connect = h3600ts_connect, .disconnect = h3600ts_disconnect,
@@ -490,13 +490,13 @@static int __init h3600ts_init (void ) { -serio_register_device (&h3600ts_dev); +serio_register_driver (&h3600ts_drv);return 0 ; } static void __exit h3600ts_exit(void) { -serio_unregister_device (&h3600ts_dev); +serio_unregister_driver (&h3600ts_drv); }module_init (h3600ts_init);
include/linux/serio.h +11 -11
@@ -39,19 +39,19 @@int (*open)(struct serio *);void (*close)(struct serio *); -struct serio_dev *dev;/* Accessed from interrupt, writes must be protected by serio_lock */ +struct serio_driver *drv;/* Accessed from interrupt, writes must be protected by serio_lock */ struct list_head node; }; -struct serio_dev { +struct serio_driver {void *private;char *name;void (*write_wakeup)(struct serio *);irqreturn_t (*interrupt)(struct serio *,unsigned char ,unsigned int ,struct pt_regs *); -void (*connect)(struct serio *,struct serio_dev *dev); +void (*connect)(struct serio *,struct serio_driver *drv);int (*reconnect)(struct serio *);void (*disconnect)(struct serio *);void (*cleanup)(struct serio *);
@@ -59,7 +59,7 @@struct list_head node; }; -int serio_open (struct serio *serio,struct serio_dev *dev); +int serio_open (struct serio *serio,struct serio_driver *drv);void serio_close (struct serio *serio);void serio_rescan (struct serio *serio);void serio_reconnect (struct serio *serio);
@@ -71,8 +71,8 @@void serio_unregister_port (struct serio *serio);void serio_unregister_port_delayed (struct serio *serio);void __serio_unregister_port (struct serio *serio); -void serio_register_device (struct serio_dev *dev); -void serio_unregister_device (struct serio_dev *dev); +void serio_register_driver (struct serio_driver *drv); +void serio_unregister_driver (struct serio_driver *drv);static __inline__int serio_write (struct serio *serio,unsigned char data) {
@@ -82,16 +82,16 @@ return -1; } -static __inline__void serio_dev_write_wakeup (struct serio *serio) +static __inline__void serio_drv_write_wakeup (struct serio *serio) { -if (serio->dev && serio->dev->write_wakeup) - serio->dev->write_wakeup (serio); +if (serio->drv && serio->drv->write_wakeup) + serio->drv->write_wakeup (serio); }static __inline__void serio_cleanup (struct serio *serio) { -if (serio->dev && serio->dev->cleanup) - serio->dev->cleanup (serio); +if (serio->drv && serio->drv->cleanup) + serio->drv->cleanup (serio); }#endif
PATCH 5/19 serio dynamic allocation
===================================================================
[email protected], 2004-06-27 15:54:09-05:00, [email protected]
Input: switch to dynamic (heap) serio port allocation in preparation
to sysfs integration. By having all data structures dynamically allocated serio driver modules can be unloaded without waiting for the last reference to the port to be dropped.
drivers/input/mouse/psmouse-base.c | 12 +- drivers/input/mouse/psmouse.h | 3 drivers/input/mouse/synaptics.c | 33 +++-- drivers/input/serio/ambakmi.c | 35 +++--- drivers/input/serio/ct82c710.c | 62 ++++++----- drivers/input/serio/gscps2.c | 55 ++++++--- drivers/input/serio/i8042.c | 208 ++++++++++++++++++++----------------- drivers/input/serio/i8042.h | 7 + drivers/input/serio/maceps2.c | 69 ++++++------ drivers/input/serio/parkbd.c | 47 +++++--- drivers/input/serio/pcips2.c | 30 +++-- drivers/input/serio/q40kbd.c | 107 ++++++++++++++----- drivers/input/serio/rpckbd.c | 40 +++++-- drivers/input/serio/sa1111ps2.c | 32 +++-- drivers/input/serio/serio.c | 1 drivers/input/serio/serport.c | 45 ++++---- drivers/serial/sunsu.c | 83 ++++++++------ drivers/serial/sunzilog.c | 60 ++++++---- include/linux/serio.h | 5 19 files changed, 562 insertions(+), 372 deletions(-)
===================================================================
drivers/input/mouse/psmouse-base.c +6 -6
@@ -674,7 +674,7 @@if (psmouse->ptport) {if (psmouse->ptport->deactivate) psmouse->ptport->deactivate (psmouse); -__serio_unregister_port (&psmouse->ptport->serio);/* we have serio_sem */ +__serio_unregister_port (psmouse->ptport->serio);/* we have serio_sem */ kfree (psmouse->ptport); psmouse->ptport =NULL ; }
@@ -755,8 +755,8 @@psmouse_initialize (psmouse);if (psmouse->ptport) { -printk (KERN_INFO "serio: %s port at %s\n" , psmouse->ptport->serio.name, psmouse->phys); -__serio_register_port (&psmouse->ptport->serio);/* we have serio_sem */ +printk (KERN_INFO "serio: %s port at %s\n" , psmouse->ptport->serio->name, psmouse->phys); +__serio_register_port (psmouse->ptport->serio);/* we have serio_sem */ if (psmouse->ptport->activate) psmouse->ptport->activate (psmouse); }
@@ -790,9 +790,9 @@psmouse_initialize (psmouse);if (psmouse->ptport) { -if (psmouse_reconnect (&psmouse->ptport->serio)) { -__serio_unregister_port (&psmouse->ptport->serio); -__serio_register_port (&psmouse->ptport->serio); +if (psmouse_reconnect (psmouse->ptport->serio)) { +__serio_unregister_port (psmouse->ptport->serio); +__serio_register_port (psmouse->ptport->serio);if (psmouse->ptport->activate) psmouse->ptport->activate (psmouse); }
drivers/input/mouse/psmouse.h +2 -1
@@ -37,7 +37,8 @@struct psmouse ;struct psmouse_ptport { -struct serio serio; +struct serio *serio; +struct psmouse *parent;void (*activate)(struct psmouse *parent);void (*deactivate)(struct psmouse *parent);
drivers/input/mouse/synaptics.c +20 -13
@@ -214,12 +214,12 @@****************************************************************************/ static int synaptics_pt_write (struct serio *port,unsigned char c) { -struct psmouse *parent = port->port_data; +struct psmouse_ptport *ptport = port->port_data;char rate_param =SYN_PS_CLIENT_CMD ;/* indicates that we want pass-through port */ -if (psmouse_sliced_command (parent, c)) +if (psmouse_sliced_command (ptport->parent, c))return -1 ; -if (psmouse_command (parent, &rate_param,PSMOUSE_CMD_SETRATE )) +if (psmouse_command (ptport->parent, &rate_param,PSMOUSE_CMD_SETRATE ))return -1 ;return 0 ; }
@@ -248,7 +248,7 @@static void synaptics_pt_activate (struct psmouse *psmouse) { -struct psmouse *child = psmouse->ptport->serio.private; +struct psmouse *child = psmouse->ptport->serio->private;/* adjust the touchpad to child's choice of protocol */ if (child && child->type >=PSMOUSE_GENPS ) {
@@ -260,22 +260,29 @@static void synaptics_pt_create (struct psmouse *psmouse) {struct psmouse_ptport *port; +struct serio *serio; - psmouse->ptport = port =kmalloc (sizeof (struct psmouse_ptport ),GFP_KERNEL ); -if (!port) { + port =kmalloc (sizeof (struct psmouse_ptport ),GFP_KERNEL ); + serio =kmalloc (sizeof (struct serio ),GFP_KERNEL ); +if (!port || !serio) {printk (KERN_ERR "synaptics: not enough memory to allocate pass-through port\n" );return ; }memset (port,0 ,sizeof (struct psmouse_ptport )); +memset (serio,0 ,sizeof (struct serio )); - port->serio.type =SERIO_PS_PSTHRU ; - port->serio.name ="Synaptics pass-through" ; - port->serio.phys ="synaptics-pt/serio0" ; - port->serio.write = synaptics_pt_write; - port->serio.port_data = psmouse; + serio->type =SERIO_PS_PSTHRU ; +strlcpy (serio->name,"Synaptics pass-through" ,sizeof (serio->name)); +strlcpy (serio->phys,"synaptics-pt/serio0" ,sizeof (serio->name)); + serio->write = synaptics_pt_write; + serio->port_data = port; + port->serio = serio; + port->parent = psmouse; port->activate = synaptics_pt_activate; + + psmouse->ptport = port; }/*****************************************************************************
@@ -470,8 +477,8 @@if (unlikely (priv->pkt_type ==SYN_NEWABS )) priv->pkt_type =synaptics_detect_pkt_type (psmouse); -if (psmouse->ptport && psmouse->ptport->serio.drv &&synaptics_is_pt_packet (psmouse->packet)) -synaptics_pass_pt_packet (&psmouse->ptport->serio, psmouse->packet); +if (psmouse->ptport && psmouse->ptport->serio->drv &&synaptics_is_pt_packet (psmouse->packet)) +synaptics_pass_pt_packet (psmouse->ptport->serio, psmouse->packet);else synaptics_process_packet (psmouse);
drivers/input/serio/ambakmi.c +20 -15
@@ -29,7 +29,7 @@#define KMI_BASE (kmi->base)struct amba_kmi_port { -struct serio io; +struct serio *io;struct clk *clk;unsigned char *base;unsigned int irq;
@@ -44,7 +44,7 @@int handled =IRQ_NONE ;while (status &KMIIR_RXINTR ) { -serio_interrupt (&kmi->io,readb (KMIDATA ),0 , regs); +serio_interrupt (kmi->io,readb (KMIDATA ),0 , regs); status =readb (KMIIR ); handled =IRQ_HANDLED ; }
@@ -117,6 +117,7 @@static int amba_kmi_probe (struct amba_device *dev,void *id) {struct amba_kmi_port *kmi; +struct serio *io;int ret; ret =amba_request_regions (dev,NULL );
@@ -124,22 +125,25 @@return ret; kmi =kmalloc (sizeof (struct amba_kmi_port ),GFP_KERNEL ); -if (!kmi) { + io =kmalloc (sizeof (struct serio ),GFP_KERNEL ); +if (!kmi || !io) { ret = -ENOMEM ; goto out; }memset (kmi,0 ,sizeof (struct amba_kmi_port )); +memset (io,0 ,sizeof (struct serio )); - kmi->io.type =SERIO_8042 ; - kmi->io.write = amba_kmi_write; - kmi->io.open = amba_kmi_open; - kmi->io.close = amba_kmi_close; - kmi->io.name = dev->dev.bus_id; - kmi->io.phys = dev->dev.bus_id; - kmi->io.port_data = kmi; + io->type =SERIO_8042 ; + io->write = amba_kmi_write; + io->open = amba_kmi_open; + io->close = amba_kmi_close; +strlcpy (io->name, dev->dev.bus_id,sizeof (io->name)); +strlcpy (io->phys, dev->dev.bus_id,sizeof (io->phys)); + io->port_data = kmi; - kmi->base =ioremap (dev->res.start,KMI_SIZE ); + kmi->io = io; + kmi->base =ioremap (dev->res.start,KMI_SIZE );if (!kmi->base) { ret = -ENOMEM ; goto out;
@@ -154,13 +158,14 @@ kmi->irq = dev->irq[0 ];amba_set_drvdata (dev, kmi); -serio_register_port (&kmi->io); +serio_register_port (kmi->io);return 0 ; unmap:iounmap (kmi->base); out:kfree (kmi); +kfree (io);amba_release_regions (dev);return ret; }
@@ -171,7 +176,7 @@amba_set_drvdata (dev,NULL ); -serio_unregister_port (&kmi->io); +serio_unregister_port (kmi->io);clk_put (kmi->clk);iounmap (kmi->base);kfree (kmi);
@@ -184,7 +189,7 @@struct amba_kmi_port *kmi =amba_get_drvdata (dev);/* kick the serio layer to rescan this port */ -serio_rescan (&kmi->io); +serio_reconnect (kmi->io);return 0 ; }
@@ -214,7 +219,7 @@ static void __exit amba_kmi_exit(void) { -return amba_driver_unregister (&ambakmi_driver); +amba_driver_unregister (&ambakmi_driver); }module_init (amba_kmi_init);
drivers/input/serio/ct82c710.c +35 -27
102 lines not on this page · raw message
drivers/input/serio/gscps2.c +34 -21
122 lines not on this page · raw message
drivers/input/serio/i8042.c +115 -93
310 lines not on this page · raw message
drivers/input/serio/i8042.h +7 -0
@@ -104,6 +104,13 @@#define I8042_BUFFER_SIZE 32/* +* Number of AUX ports on controllers supporting active multiplexing +* specification +*/ + +#define I8042_NUM_MUX_PORTS 4 + +/* * Debug. */
drivers/input/serio/maceps2.c +38 -31
104 lines not on this page · raw message
drivers/input/serio/parkbd.c +30 -17
82 lines not on this page · raw message
drivers/input/serio/pcips2.c +18 -12
@@ -38,7 +38,7 @@#define PS2_STAT_TXEMPTY (1<<7)struct pcips2_data { -struct serio io; +struct serio *io;unsigned int base;struct pci_dev *dev; };
@@ -80,7 +80,7 @@if (hweight8 (scancode) &1 ) flag ^=SERIO_PARITY ; -serio_interrupt (&ps2if->io, scancode, flag, regs); +serio_interrupt (ps2if->io, scancode, flag, regs); }while (1 );return IRQ_RETVAL (handled); }
@@ -129,6 +129,7 @@static int __devinit pcips2_probe (struct pci_dev *dev,const struct pci_device_id *id) {struct pcips2_data *ps2if; +struct serio *serio;int ret; ret =pci_enable_device (dev);
@@ -142,29 +143,34 @@ } ps2if =kmalloc (sizeof (struct pcips2_data ),GFP_KERNEL ); -if (!ps2if) { + serio =kmalloc (sizeof (struct serio ),GFP_KERNEL ); +if (!ps2if || !serio) { ret = -ENOMEM ; goto release; }memset (ps2if,0 ,sizeof (struct pcips2_data )); +memset (serio,0 ,sizeof (struct serio )); - ps2if->io.type =SERIO_8042 ; - ps2if->io.write = pcips2_write; - ps2if->io.open = pcips2_open; - ps2if->io.close = pcips2_close; - ps2if->io.name =pci_name (dev); - ps2if->io.phys = dev->dev.bus_id; - ps2if->io.port_data = ps2if; + serio->type =SERIO_8042 ; + serio->write = pcips2_write; + serio->open = pcips2_open; + serio->close = pcips2_close; +strlcpy (serio->name,pci_name (dev),sizeof (serio->name)); +strlcpy (serio->phys, dev->dev.bus_id,sizeof (serio->phys)); + serio->port_data = ps2if; + ps2if->io = serio; ps2if->dev = dev; ps2if->base =pci_resource_start (dev,0 );pci_set_drvdata (dev, ps2if); -serio_register_port (&ps2if->io); +serio_register_port (ps2if->io);return 0 ; release: +kfree (ps2if); +kfree (serio);release_region (pci_resource_start (dev,0 ),pci_resource_len (dev,0 )); disable:
@@ -176,7 +182,7 @@ {struct pcips2_data *ps2if =pci_get_drvdata (dev); -serio_unregister_port (&ps2if->io); +serio_unregister_port (ps2if->io);release_region (pci_resource_start (dev,0 ),pci_resource_len (dev,0 ));pci_set_drvdata (dev,NULL );
drivers/input/serio/q40kbd.c +79 -28
133 lines not on this page · raw message
drivers/input/serio/rpckbd.c +29 -11
@@ -44,6 +44,8 @@MODULE_DESCRIPTION ("Acorn RiscPC PS/2 keyboard controller driver" );MODULE_LICENSE ("GPL" ); +static struct serio *rpckbd_port; +static int rpckbd_write (struct serio *port,unsigned char val) {while (!(iomd_readb (IOMD_KCTRL ) & (1 <<7 )))
@@ -101,25 +103,41 @@free_irq (IRQ_KEYBOARDTX , port); } -static struct serio rpckbd_port = -{ - .type =SERIO_8042 , - .open = rpckbd_open, - .close = rpckbd_close, - .write = rpckbd_write, - .name ="RiscPC PS/2 kbd port" , - .phys ="rpckbd/serio0" , -}; +/* +* Allocate and initialize serio structure for subsequent registration +* with serio core. +*/ + +static struct serio *__init rpckbd_allocate_port (void ) +{ +struct serio *serio; + + serio =kmalloc (sizeof (struct serio ),GFP_KERNEL ); +if (serio) { +memset (serio,0 ,sizeof (struct serio )); + serio->type =SERIO_8042 ; + serio->write = rpckbd_write; + serio->open = rpckbd_open; + serio->close = rpckbd_close; +strlcpy (serio->name,"RiscPC PS/2 kbd port" ,sizeof (serio->name)); +strlcpy (serio->phys,"rpckbd/serio0" ,sizeof (serio->phys)); + } + +return serio; +}static int __init rpckbd_init (void ) { -serio_register_port (&rpckbd_port); +if (!(rpckbd_port =rpckbd_allocate_port ())) +return -ENOMEM ; + +serio_register_port (rpckbd_port);return 0 ; } static void __exit rpckbd_exit(void) { -serio_unregister_port (&rpckbd_port); +serio_unregister_port (rpckbd_port); }module_init (rpckbd_init);
drivers/input/serio/sa1111ps2.c +19 -13
@@ -26,7 +26,7 @@#include <asm/hardware/sa1111.h> struct ps2if { -struct serio io; +struct serio *io;struct sa1111_dev *dev;unsigned long base;unsigned int open;
@@ -59,7 +59,7 @@if (hweight8 (scancode) &1 ) flag ^=SERIO_PARITY ; -serio_interrupt (&ps2if->io, scancode, flag, regs); +serio_interrupt (ps2if->io, scancode, flag, regs); status =sa1111_readl (ps2if->base +SA1111_PS2STAT ); }
@@ -232,22 +232,27 @@static int ps2_probe (struct sa1111_dev *dev) {struct ps2if *ps2if; +struct serio *serio;int ret; ps2if =kmalloc (sizeof (struct ps2if ),GFP_KERNEL ); -if (!ps2if) { -return -ENOMEM ; + serio =kmalloc (sizeof (struct serio ),GFP_KERNEL ); +if (!ps2if || !serio) { + ret = -ENOMEM ; + goto free; }memset (ps2if,0 ,sizeof (struct ps2if )); +memset (serio,0 ,sizeof (struct serio )); - ps2if->io.type =SERIO_8042 ; - ps2if->io.write = ps2_write; - ps2if->io.open = ps2_open; - ps2if->io.close = ps2_close; - ps2if->io.name = dev->dev.bus_id; - ps2if->io.phys = dev->dev.bus_id; - ps2if->io.port_data = ps2if; + serio->type =SERIO_8042 ; + serio->write = ps2_write; + serio->open = ps2_open; + serio->close = ps2_close; +strlcpy (serio->name, dev->dev.bus_id,sizeof (serio->name)); +strlcpy (serio->phys, dev->dev.bus_id,sizeof (serio->phys)); + serio->port_data = ps2if; + ps2if->io = serio; ps2if->dev = dev;sa1111_set_drvdata (dev, ps2if);
@@ -292,7 +297,7 @@ps2_clear_input (ps2if);sa1111_disable_device (ps2if->dev); -serio_register_port (&ps2if->io); +serio_register_port (ps2if->io);return 0 ; out:
@@ -302,6 +307,7 @@ free:sa1111_set_drvdata (dev,NULL );kfree (ps2if); +kfree (serio);return ret; }
@@ -312,7 +318,7 @@ {struct ps2if *ps2if =sa1111_get_drvdata (dev); -serio_unregister_port (&ps2if->io); +serio_unregister_port (ps2if->io);release_mem_region (dev->res.start, dev->res.end - dev->res.start +1 );sa1111_set_drvdata (dev,NULL );
drivers/input/serio/serio.c +1 -0
@@ -283,6 +283,7 @@list_del_init (&serio->node);if (serio->drv) serio->drv->disconnect (serio); +kfree (serio); }/*
drivers/input/serio/serport.c +23 -22
100 lines not on this page · raw message
drivers/serial/sunsu.c +46 -37
138 lines not on this page · raw message
drivers/serial/sunzilog.c +37 -23
100 lines not on this page · raw message
include/linux/serio.h +3 -2
@@ -22,8 +22,9 @@struct serio {void *private;void *port_data; -char *name; -char *phys; + +char name[32 ]; +char phys[32 ];unsigned short idbus;unsigned short idvendor;
PATCH 6/19 serio avoid recursion
===================================================================
[email protected], 2004-06-27 15:55:06-05:00, [email protected]
Input: allow serio drivers to create children ports and register these
ports for them in serio core to avoid having recursion in connect methods.
drivers/input/mouse/psmouse-base.c | 75 ++++++++---- drivers/input/mouse/psmouse.h | 16 -- drivers/input/mouse/synaptics.c | 27 +--- drivers/input/serio/serio.c | 215 ++++++++++++++++++++++++++++--------- include/linux/serio.h | 4 5 files changed, 231 insertions(+), 106 deletions(-)
===================================================================
drivers/input/mouse/psmouse-base.c +48 -27
@@ -667,16 +667,15 @@static void psmouse_disconnect (struct serio *serio) { -struct psmouse *psmouse = serio->private; +struct psmouse *psmouse, *parent; + psmouse = serio->private;psmouse_set_state (psmouse,PSMOUSE_CMD_MODE ); -if (psmouse->ptport) { -if (psmouse->ptport->deactivate) - psmouse->ptport->deactivate (psmouse); -__serio_unregister_port (psmouse->ptport->serio);/* we have serio_sem */ -kfree (psmouse->ptport); - psmouse->ptport =NULL ; +if (serio->parent && (serio->type &SERIO_TYPE ) ==SERIO_PS_PSTHRU ) { + parent = serio->parent->private; +if (parent->pt_deactivate) + parent->pt_deactivate (parent); }if (psmouse->disconnect)
@@ -695,14 +694,17 @@*/ static void psmouse_connect (struct serio *serio,struct serio_driver *drv) { -struct psmouse *psmouse; +struct psmouse *psmouse, *parent =NULL ;if ((serio->type &SERIO_TYPE ) !=SERIO_8042 && (serio->type &SERIO_TYPE ) !=SERIO_PS_PSTHRU )return ; +if (serio->parent && (serio->type &SERIO_TYPE ) ==SERIO_PS_PSTHRU ) + parent = serio->parent->private; +if (!(psmouse =kmalloc (sizeof (struct psmouse ),GFP_KERNEL ))) -return ; + goto out;memset (psmouse,0 ,sizeof (struct psmouse ));
@@ -718,14 +720,14 @@if (serio_open (serio, drv)) {kfree (psmouse); serio->private =NULL ; -return ; + goto out; }if (psmouse_probe (psmouse) <0 ) {serio_close (serio);kfree (psmouse); serio->private =NULL ; -return ; + goto out; } psmouse->type =psmouse_extensions (psmouse, psmouse_max_proto,1 );
@@ -754,20 +756,36 @@psmouse_initialize (psmouse); -if (psmouse->ptport) { -printk (KERN_INFO "serio: %s port at %s\n" , psmouse->ptport->serio->name, psmouse->phys); -__serio_register_port (psmouse->ptport->serio);/* we have serio_sem */ -if (psmouse->ptport->activate) - psmouse->ptport->activate (psmouse); - } +if (parent && parent->pt_activate) + parent->pt_activate (parent); -psmouse_activate (psmouse); +/* +* OK, the device is ready, we just need to activate it (turn the +* stream mode on). But if mouse has a pass-through port we don't +* want to do it yet to not disturb child detection. +* The child will activate this port when it's ready. +*/ + +if (serio->child) { +/* +* Nothing to be done here, serio core will detect that +* the driver set serio->child and will register it for us. +*/ +printk (KERN_INFO "serio: %s port at %s\n" , serio->child->name, psmouse->phys); + }else +psmouse_activate (psmouse); + +out: +/* If this is a pass-through port the parent awaits to be activated */ +if (parent) +psmouse_activate (parent); }static int psmouse_reconnect (struct serio *serio) {struct psmouse *psmouse = serio->private; +struct psmouse *parent =NULL ;struct serio_driver *drv = serio->drv;if (!drv || !psmouse) {
@@ -789,16 +807,19 @@*/ psmouse_initialize (psmouse); -if (psmouse->ptport) { -if (psmouse_reconnect (psmouse->ptport->serio)) { -__serio_unregister_port (psmouse->ptport->serio); -__serio_register_port (psmouse->ptport->serio); -if (psmouse->ptport->activate) - psmouse->ptport->activate (psmouse); - } - } +if (serio->parent && (serio->type &SERIO_TYPE ) ==SERIO_PS_PSTHRU ) + parent = serio->parent->private; + +if (parent && parent->pt_activate) + parent->pt_activate (parent); + +if (!serio->child) +psmouse_activate (psmouse); + +/* If this is a pass-through port the parent waits to be activated */ +if (parent) +psmouse_activate (parent); -psmouse_activate (psmouse);return 0 ; }
drivers/input/mouse/psmouse.h +4 -12
@@ -34,21 +34,10 @@PSMOUSE_FULL_PACKET } psmouse_ret_t; -struct psmouse ; - -struct psmouse_ptport { -struct serio *serio; -struct psmouse *parent; - -void (*activate)(struct psmouse *parent); -void (*deactivate)(struct psmouse *parent); -}; -struct psmouse {void *private;struct input_dev dev;struct serio *serio; -struct psmouse_ptport *ptport;char *vendor;char *name;unsigned char cmdbuf[8 ];
@@ -66,9 +55,12 @@char phys[32 ];unsigned long flags; -psmouse_ret_t (*protocol_handler)(struct psmouse *psmouse,struct pt_regs *regs); +psmouse_ret_t (*protocol_handler)(struct psmouse *psmouse,struct pt_regs *regs);int (*reconnect)(struct psmouse *psmouse);void (*disconnect)(struct psmouse *psmouse); + +void (*pt_activate)(struct psmouse *psmouse); +void (*pt_deactivate)(struct psmouse *psmouse); };#define PSMOUSE_PS2 1
drivers/input/mouse/synaptics.c +11 -16
@@ -212,14 +212,14 @@/***************************************************************************** * Synaptics pass-through PS/2 port support ****************************************************************************/ -static int synaptics_pt_write (struct serio *port,unsigned char c) +static int synaptics_pt_write (struct serio *serio,unsigned char c) { -struct psmouse_ptport *ptport = port->port_data; +struct psmouse *parent = serio->parent->private;char rate_param =SYN_PS_CLIENT_CMD ;/* indicates that we want pass-through port */ -if (psmouse_sliced_command (ptport->parent, c)) +if (psmouse_sliced_command (parent, c))return -1 ; -if (psmouse_command (ptport->parent, &rate_param,PSMOUSE_CMD_SETRATE )) +if (psmouse_command (parent, &rate_param,PSMOUSE_CMD_SETRATE ))return -1 ;return 0 ; }
@@ -248,7 +248,7 @@static void synaptics_pt_activate (struct psmouse *psmouse) { -struct psmouse *child = psmouse->ptport->serio->private; +struct psmouse *child = psmouse->serio->child->private;/* adjust the touchpad to child's choice of protocol */ if (child && child->type >=PSMOUSE_GENPS ) {
@@ -259,30 +259,25 @@static void synaptics_pt_create (struct psmouse *psmouse) { -struct psmouse_ptport *port;struct serio *serio; - port =kmalloc (sizeof (struct psmouse_ptport ),GFP_KERNEL ); serio =kmalloc (sizeof (struct serio ),GFP_KERNEL ); -if (!port || !serio) { +if (!serio) {printk (KERN_ERR "synaptics: not enough memory to allocate pass-through port\n" );return ; } -memset (port,0 ,sizeof (struct psmouse_ptport ));memset (serio,0 ,sizeof (struct serio )); serio->type =SERIO_PS_PSTHRU ;strlcpy (serio->name,"Synaptics pass-through" ,sizeof (serio->name));strlcpy (serio->phys,"synaptics-pt/serio0" ,sizeof (serio->name)); serio->write = synaptics_pt_write; - serio->port_data = port; + serio->parent = psmouse->serio; - port->serio = serio; - port->parent = psmouse; - port->activate = synaptics_pt_activate; + psmouse->pt_activate = synaptics_pt_activate; - psmouse->ptport = port; + psmouse->serio->child = serio; }/*****************************************************************************
@@ -477,8 +472,8 @@if (unlikely (priv->pkt_type ==SYN_NEWABS )) priv->pkt_type =synaptics_detect_pkt_type (psmouse); -if (psmouse->ptport && psmouse->ptport->serio->drv &&synaptics_is_pt_packet (psmouse->packet)) -synaptics_pass_pt_packet (psmouse->ptport->serio, psmouse->packet); +if (psmouse->serio->child && psmouse->serio->child->drv &&synaptics_is_pt_packet (psmouse->packet)) +synaptics_pass_pt_packet (psmouse->serio->child, psmouse->packet);else synaptics_process_packet (psmouse);
drivers/input/serio/serio.c +166 -49
296 lines not on this page · raw message
include/linux/serio.h +2 -2
@@ -40,6 +40,8 @@int (*open)(struct serio *);void (*close)(struct serio *); +struct serio *parent, *child; +struct serio_driver *drv;/* Accessed from interrupt, writes must be protected by serio_lock */ struct list_head node;
@@ -68,10 +70,8 @@void serio_register_port (struct serio *serio);void serio_register_port_delayed (struct serio *serio); -void __serio_register_port (struct serio *serio);void serio_unregister_port (struct serio *serio);void serio_unregister_port_delayed (struct serio *serio); -void __serio_unregister_port (struct serio *serio);void serio_register_driver (struct serio_driver *drv);void serio_unregister_driver (struct serio_driver *drv);
PATCH 7/19 serio sysfs intergration
===================================================================
[email protected], 2004-06-27 15:55:37-05:00, [email protected]
Input: serio sysfs integration
drivers/Makefile | 2 drivers/input/joystick/iforce/iforce-serio.c | 12 ++- drivers/input/joystick/magellan.c | 14 ++-- drivers/input/joystick/spaceball.c | 14 ++-- drivers/input/joystick/spaceorb.c | 14 ++-- drivers/input/joystick/stinger.c | 14 ++-- drivers/input/joystick/twidjoy.c | 10 ++ drivers/input/joystick/warrior.c | 14 ++-- drivers/input/keyboard/atkbd.c | 18 +++-- drivers/input/keyboard/lkkbd.c | 14 ++-- drivers/input/keyboard/newtonkbd.c | 14 ++-- drivers/input/keyboard/sunkbd.c | 14 ++-- drivers/input/keyboard/xtkbd.c | 14 ++-- drivers/input/mouse/psmouse-base.c | 18 +++-- drivers/input/mouse/sermouse.c | 14 ++-- drivers/input/mouse/vsxxxaa.c | 14 ++-- drivers/input/serio/serio.c | 93 ++++++++++++++++++++++++--- drivers/input/touchscreen/gunze.c | 14 ++-- drivers/input/touchscreen/h3600_ts_input.c | 14 ++-- include/linux/serio.h | 9 ++ 20 files changed, 261 insertions(+), 83 deletions(-)
===================================================================
drivers/Makefile +1 -1
@@ -37,9 +37,9 @@ obj-$(CONFIG_TC) += tc/ obj-$(CONFIG_USB) += usb/ obj-$(CONFIG_USB_GADGET) += usb/gadget/ +obj-$(CONFIG_SERIO) += input/serio/ obj-$(CONFIG_INPUT) += input/ obj-$(CONFIG_GAMEPORT) += input/gameport/ -obj-$(CONFIG_SERIO) += input/serio/ obj-$(CONFIG_I2O) += message/ obj-$(CONFIG_I2C) += i2c/ obj-$(CONFIG_PHONE) += telephony/
drivers/input/joystick/iforce/iforce-serio.c +8 -4
@@ -159,8 +159,12 @@ }struct serio_driver iforce_serio_drv = { - .write_wakeup = iforce_serio_write_wakeup, - .interrupt = iforce_serio_irq, - .connect = iforce_serio_connect, - .disconnect = iforce_serio_disconnect, + .driver = { + .name ="iforce" , + }, + .description ="RS232 I-Force joysticks and wheels driver" , + .write_wakeup = iforce_serio_write_wakeup, + .interrupt = iforce_serio_irq, + .connect = iforce_serio_connect, + .disconnect = iforce_serio_disconnect, };
drivers/input/joystick/magellan.c +10 -4
@@ -35,8 +35,10 @@#include <linux/serio.h> #include <linux/init.h> +#define DRIVER_DESC "Magellan and SpaceMouse 6dof controller driver" +MODULE_AUTHOR ("Vojtech Pavlik <[email protected]>" ); -MODULE_DESCRIPTION ("Magellan and SpaceMouse 6dof controller driver" ); +MODULE_DESCRIPTION (DRIVER_DESC );MODULE_LICENSE ("GPL" );/*
@@ -200,9 +202,13 @@*/ static struct serio_driver magellan_drv = { - .interrupt = magellan_interrupt, - .connect = magellan_connect, - .disconnect = magellan_disconnect, + .driver = { + .name ="magellan" , + }, + .description =DRIVER_DESC , + .interrupt = magellan_interrupt, + .connect = magellan_connect, + .disconnect = magellan_disconnect, };/*
drivers/input/joystick/spaceball.c +10 -4
@@ -39,8 +39,10 @@#include <linux/input.h> #include <linux/serio.h> +#define DRIVER_DESC "SpaceTec SpaceBall 2003/3003/4000 FLX driver" +MODULE_AUTHOR ("Vojtech Pavlik <[email protected]>" ); -MODULE_DESCRIPTION ("SpaceTec SpaceBall 2003/3003/4000 FLX driver" ); +MODULE_DESCRIPTION (DRIVER_DESC );MODULE_LICENSE ("GPL" );/*
@@ -270,9 +272,13 @@*/ static struct serio_driver spaceball_drv = { - .interrupt = spaceball_interrupt, - .connect = spaceball_connect, - .disconnect = spaceball_disconnect, + .driver = { + .name ="spaceball" , + }, + .description =DRIVER_DESC , + .interrupt = spaceball_interrupt, + .connect = spaceball_connect, + .disconnect = spaceball_disconnect, };/*
drivers/input/joystick/spaceorb.c +10 -4
@@ -38,8 +38,10 @@#include <linux/input.h> #include <linux/serio.h> +#define DRIVER_DESC "SpaceTec SpaceOrb 360 and Avenger 6dof controller driver" +MODULE_AUTHOR ("Vojtech Pavlik <[email protected]>" ); -MODULE_DESCRIPTION ("SpaceTec SpaceOrb 360 and Avenger 6dof controller driver" ); +MODULE_DESCRIPTION (DRIVER_DESC );MODULE_LICENSE ("GPL" );/*
@@ -214,9 +216,13 @@*/ static struct serio_driver spaceorb_drv = { - .interrupt = spaceorb_interrupt, - .connect = spaceorb_connect, - .disconnect = spaceorb_disconnect, + .driver = { + .name ="spaceorb" , + }, + .description =DRIVER_DESC , + .interrupt = spaceorb_interrupt, + .connect = spaceorb_connect, + .disconnect = spaceorb_disconnect, };/*
drivers/input/joystick/stinger.c +10 -4
@@ -36,8 +36,10 @@#include <linux/serio.h> #include <linux/init.h> +#define DRIVER_DESC "Gravis Stinger gamepad driver" +MODULE_AUTHOR ("Vojtech Pavlik <[email protected]>" ); -MODULE_DESCRIPTION ("Gravis Stinger gamepad driver" ); +MODULE_DESCRIPTION (DRIVER_DESC );MODULE_LICENSE ("GPL" );/*
@@ -188,9 +190,13 @@*/ static struct serio_driver stinger_drv = { - .interrupt = stinger_interrupt, - .connect = stinger_connect, - .disconnect = stinger_disconnect, + .driver = { + .name ="stinger" , + }, + .description =DRIVER_DESC , + .interrupt = stinger_interrupt, + .connect = stinger_connect, + .disconnect = stinger_disconnect, };/*
drivers/input/joystick/twidjoy.c +7 -3
@@ -247,9 +247,13 @@*/ static struct serio_driver twidjoy_drv = { - .interrupt = twidjoy_interrupt, - .connect = twidjoy_connect, - .disconnect = twidjoy_disconnect, + .driver = { + .name ="twidjoy" , + }, + .description =DRIVER_DESC , + .interrupt = twidjoy_interrupt, + .connect = twidjoy_connect, + .disconnect = twidjoy_disconnect, };/*
drivers/input/joystick/warrior.c +10 -4
@@ -35,8 +35,10 @@#include <linux/serio.h> #include <linux/init.h> +#define DRIVER_DESC "Logitech WingMan Warrior joystick driver" +MODULE_AUTHOR ("Vojtech Pavlik <[email protected]>" ); -MODULE_DESCRIPTION ("Logitech WingMan Warrior joystick driver" ); +MODULE_DESCRIPTION (DRIVER_DESC );MODULE_LICENSE ("GPL" );/*
@@ -200,9 +202,13 @@*/ static struct serio_driver warrior_drv = { - .interrupt = warrior_interrupt, - .connect = warrior_connect, - .disconnect = warrior_disconnect, + .driver = { + .name ="warrior" , + }, + .description =DRIVER_DESC , + .interrupt = warrior_interrupt, + .connect = warrior_connect, + .disconnect = warrior_disconnect, };/*
drivers/input/keyboard/atkbd.c +12 -6
@@ -27,8 +27,10 @@#include <linux/serio.h> #include <linux/workqueue.h> +#define DRIVER_DESC "AT and PS/2 keyboard driver" +MODULE_AUTHOR ("Vojtech Pavlik <[email protected]>" ); -MODULE_DESCRIPTION ("AT and PS/2 keyboard driver" ); +MODULE_DESCRIPTION (DRIVER_DESC );MODULE_LICENSE ("GPL" );static int atkbd_set =2 ;
@@ -891,11 +893,15 @@ }static struct serio_driver atkbd_drv = { - .interrupt = atkbd_interrupt, - .connect = atkbd_connect, - .reconnect = atkbd_reconnect, - .disconnect = atkbd_disconnect, - .cleanup = atkbd_cleanup, + .driver = { + .name ="atkbd" , + }, + .description =DRIVER_DESC , + .interrupt = atkbd_interrupt, + .connect = atkbd_connect, + .reconnect = atkbd_reconnect, + .disconnect = atkbd_disconnect, + .cleanup = atkbd_cleanup, };int __init atkbd_init (void )
drivers/input/keyboard/lkkbd.c +10 -4
@@ -76,8 +76,10 @@#include <linux/serio.h> #include <linux/workqueue.h> +#define DRIVER_DESC "LK keyboard driver" +MODULE_AUTHOR ("Jan-Benedict Glaw <[email protected]>" ); -MODULE_DESCRIPTION ("LK keyboard driver" ); +MODULE_DESCRIPTION (DRIVER_DESC );MODULE_LICENSE ("GPL" );/*
@@ -704,9 +706,13 @@ }static struct serio_driver lkkbd_drv = { - .connect = lkkbd_connect, - .disconnect = lkkbd_disconnect, - .interrupt = lkkbd_interrupt, + .driver = { + .name ="lkkbd" , + }, + .description =DRIVER_DESC , + .connect = lkkbd_connect, + .disconnect = lkkbd_disconnect, + .interrupt = lkkbd_interrupt, };/*
drivers/input/keyboard/newtonkbd.c +10 -4
@@ -32,8 +32,10 @@#include <linux/init.h> #include <linux/serio.h> +#define DRIVER_DESC "Newton keyboard driver" +MODULE_AUTHOR ("Justin Cormack <[email protected]>" ); -MODULE_DESCRIPTION ("Newton keyboard driver" ); +MODULE_DESCRIPTION (DRIVER_DESC );MODULE_LICENSE ("GPL" );#define NKBD_KEY 0x7f
@@ -139,9 +141,13 @@ }struct serio_driver nkbd_drv = { - .interrupt = nkbd_interrupt, - .connect = nkbd_connect, - .disconnect = nkbd_disconnect + .driver = { + .name ="newtonkbd" , + }, + .description =DRIVER_DESC , + .interrupt = nkbd_interrupt, + .connect = nkbd_connect, + .disconnect = nkbd_disconnect, };int __init nkbd_init (void )
drivers/input/keyboard/sunkbd.c +10 -4
@@ -37,8 +37,10 @@#include <linux/serio.h> #include <linux/workqueue.h> +#define DRIVER_DESC "Sun keyboard driver" +MODULE_AUTHOR ("Vojtech Pavlik <[email protected]>" ); -MODULE_DESCRIPTION ("Sun keyboard driver" ); +MODULE_DESCRIPTION (DRIVER_DESC );MODULE_LICENSE ("GPL" );static unsigned char sunkbd_keycode[128 ] = {
@@ -302,9 +304,13 @@ }static struct serio_driver sunkbd_drv = { - .interrupt = sunkbd_interrupt, - .connect = sunkbd_connect, - .disconnect = sunkbd_disconnect + .driver = { + .name ="sunkbd" , + }, + .description =DRIVER_DESC , + .interrupt = sunkbd_interrupt, + .connect = sunkbd_connect, + .disconnect = sunkbd_disconnect, };/*
drivers/input/keyboard/xtkbd.c +10 -4
@@ -34,8 +34,10 @@#include <linux/init.h> #include <linux/serio.h> +#define DRIVER_DESC "XT keyboard driver" +MODULE_AUTHOR ("Vojtech Pavlik <[email protected]>" ); -MODULE_DESCRIPTION ("XT keyboard driver" ); +MODULE_DESCRIPTION (DRIVER_DESC );MODULE_LICENSE ("GPL" );#define XTKBD_EMUL0 0xe0
@@ -144,9 +146,13 @@ }struct serio_driver xtkbd_drv = { - .interrupt = xtkbd_interrupt, - .connect = xtkbd_connect, - .disconnect = xtkbd_disconnect + .driver = { + .name ="xtkbd" , + }, + .description =DRIVER_DESC , + .interrupt = xtkbd_interrupt, + .connect = xtkbd_connect, + .disconnect = xtkbd_disconnect, };int __init xtkbd_init (void )
drivers/input/mouse/psmouse-base.c +12 -6
@@ -22,8 +22,10 @@#include "synaptics.h" #include "logips2pp.h" +#define DRIVER_DESC "PS/2 mouse driver" +MODULE_AUTHOR ("Vojtech Pavlik <[email protected]>" ); -MODULE_DESCRIPTION ("PS/2 mouse driver" ); +MODULE_DESCRIPTION (DRIVER_DESC );MODULE_LICENSE ("GPL" );static char *psmouse_proto;
@@ -825,11 +827,15 @@static struct serio_driver psmouse_drv = { - .interrupt = psmouse_interrupt, - .connect = psmouse_connect, - .reconnect = psmouse_reconnect, - .disconnect = psmouse_disconnect, - .cleanup = psmouse_cleanup, + .driver = { + .name ="psmouse" , + }, + .description =DRIVER_DESC , + .interrupt = psmouse_interrupt, + .connect = psmouse_connect, + .reconnect = psmouse_reconnect, + .disconnect = psmouse_disconnect, + .cleanup = psmouse_cleanup, };static inline void psmouse_parse_proto (void )
drivers/input/mouse/sermouse.c +10 -4
@@ -37,8 +37,10 @@#include <linux/serio.h> #include <linux/init.h> +#define DRIVER_DESC "Serial mouse driver" +MODULE_AUTHOR ("Vojtech Pavlik <[email protected]>" ); -MODULE_DESCRIPTION ("Serial mouse driver" ); +MODULE_DESCRIPTION (DRIVER_DESC );MODULE_LICENSE ("GPL" );static char *sermouse_protocols[] = {"None" ,"Mouse Systems Mouse" ,"Sun Mouse" ,"Microsoft Mouse" ,
@@ -290,9 +292,13 @@ }static struct serio_driver sermouse_drv = { - .interrupt = sermouse_interrupt, - .connect = sermouse_connect, - .disconnect = sermouse_disconnect + .driver = { + .name ="sermouse" , + }, + .description =DRIVER_DESC , + .interrupt = sermouse_interrupt, + .connect = sermouse_connect, + .disconnect = sermouse_disconnect, };int __init sermouse_init (void )
drivers/input/mouse/vsxxxaa.c +10 -4
@@ -82,8 +82,10 @@#include <linux/serio.h> #include <linux/init.h> +#define DRIVER_DESC "Serial DEC VSXXX-AA/GA mouse / DEC tablet driver" +MODULE_AUTHOR ("Jan-Benedict Glaw <[email protected]>" ); -MODULE_DESCRIPTION ("Serial DEC VSXXX-AA/GA mouse / DEC tablet driver" ); +MODULE_DESCRIPTION (DRIVER_DESC );MODULE_LICENSE ("GPL" );#undef VSXXXAA_DEBUG
@@ -541,9 +543,13 @@ }static struct serio_driver vsxxxaa_drv = { - .connect = vsxxxaa_connect, - .interrupt = vsxxxaa_interrupt, - .disconnect = vsxxxaa_disconnect, + .driver = { + .name ="vsxxxaa" , + }, + .description =DRIVER_DESC , + .connect = vsxxxaa_connect, + .interrupt = vsxxxaa_interrupt, + .disconnect = vsxxxaa_disconnect, };int __init
drivers/input/serio/serio.c +83 -10
171 lines not on this page · raw message
drivers/input/touchscreen/gunze.c +10 -4
@@ -36,8 +36,10 @@#include <linux/serio.h> #include <linux/init.h> +#define DRIVER_DESC "Gunze AHL-51S touchscreen driver" +MODULE_AUTHOR ("Vojtech Pavlik <[email protected]>" ); -MODULE_DESCRIPTION ("Gunze AHL-51S touchscreen driver" ); +MODULE_DESCRIPTION (DRIVER_DESC );MODULE_LICENSE ("GPL" );/*
@@ -157,9 +159,13 @@*/ static struct serio_driver gunze_drv = { - .interrupt = gunze_interrupt, - .connect = gunze_connect, - .disconnect = gunze_disconnect, + .driver = { + .name ="gunze" , + }, + .description =DRIVER_DESC , + .interrupt = gunze_interrupt, + .connect = gunze_connect, + .disconnect = gunze_disconnect, };/*
drivers/input/touchscreen/h3600_ts_input.c +10 -4
@@ -45,8 +45,10 @@#include <asm/arch/hardware.h> #include <asm/arch/irqs.h> +#define DRIVER_DESC "H3600 touchscreen driver" +MODULE_AUTHOR ("James Simmons <[email protected]>" ); -MODULE_DESCRIPTION ("H3600 touchscreen driver" ); +MODULE_DESCRIPTION (DRIVER_DESC );MODULE_LICENSE ("GPL" );/*
@@ -479,9 +481,13 @@*/ static struct serio_driver h3600ts_drv = { - .interrupt = h3600ts_interrupt, - .connect = h3600ts_connect, - .disconnect = h3600ts_disconnect, + .driver = { + .name ="h3600ts" , + }, + .description =DRIVER_DESC , + .interrupt = h3600ts_interrupt, + .connect = h3600ts_connect, + .disconnect = h3600ts_disconnect, };/*
include/linux/serio.h +8 -1
@@ -18,6 +18,7 @@#include <linux/list.h> #include <linux/spinlock.h> +#include <linux/device.h> struct serio {void *private;
@@ -44,12 +45,15 @@struct serio_driver *drv;/* Accessed from interrupt, writes must be protected by serio_lock */ +struct device dev; +struct list_head node; }; +#define to_serio_port (d) container_of(d, struct serio, dev)struct serio_driver {void *private; -char *name; +char *description;void (*write_wakeup)(struct serio *); irqreturn_t (*interrupt)(struct serio *, unsigned char,
@@ -59,8 +63,11 @@void (*disconnect)(struct serio *);void (*cleanup)(struct serio *); +struct device_driver driver; +struct list_head node; }; +#define to_serio_driver (d) container_of(d, struct serio_driver, driver)int serio_open (struct serio *serio,struct serio_driver *drv);void serio_close (struct serio *serio);
PATCH 8/19 serio rebind
===================================================================
[email protected], 2004-06-27 15:56:07-05:00, [email protected]
Input: allow users manually rebind serio ports, like this:
echo -n "psmouse" > /sys/bus/serio/devices/serio0/driver echo -n "atkbd" > /sys/bus/serio/devices/serio1/driver echo -n "none" > /sys/bus/serio/devices/serio1/driver echo -n "reconnect" > /sys/bus/serio/devices/serio1/driver echo -n "rescan" > /sys/bus/serio/devices/serio1/driver
serio.c | 34 +++++++++++++++++++++++++++++++++- 1 files changed, 33 insertions(+), 1 deletion(-)
===================================================================
drivers/input/serio/serio.c +33 -1
@@ -257,7 +257,39 @@ {return sprintf (buf,"%s\n" , dev->driver ? dev->driver->name :"(none)" ); } -static DEVICE_ATTR(driver, S_IRUGO, serio_show_driver, NULL); + +static ssize_t serio_rebind_driver (struct device *dev,const char *buf,size_t count) +{ +struct serio *serio =to_serio_port (dev); +struct device_driver *drv; +struct kobject *k; +int retval; + + retval =down_interruptible (&serio_sem); +if (retval) +return retval; + + retval = count; +if (!strncmp (buf,"none" , count)) { +serio_disconnect_port (serio); + }else if (!strncmp (buf,"reconnect" , count)) { +serio_reconnect_port (serio); + }else if (!strncmp (buf,"rescan" , count)) { +serio_disconnect_port (serio); +serio_connect_port (serio,NULL ); + }else if ((k =kset_find_obj (&serio_bus.drivers, buf)) !=NULL ) { + drv = container_of(k, struct device_driver, kobj); +serio_disconnect_port (serio); +serio_connect_port (serio,to_serio_driver (drv)); + }else { + retval = -EINVAL ; + } + +up (&serio_sem); + +return retval; +} +static DEVICE_ATTR(driver, S_IWUSR | S_IRUGO, serio_show_driver, serio_rebind_driver);static void serio_release_port (struct device *dev) {
PATCH 9/19] serio manual bind
===================================================================
[email protected], 2004-06-27 15:56:35-05:00, [email protected]
Input: allow marking some drivers (that don't do HW autodetection)
as manual bind only. Such drivers will only be bound to a serio port if user requests it by echoing driver name into port's sysfs driver attribute.
drivers/input/serio/serio.c | 9 +++++++-- include/linux/serio.h | 2 ++ 2 files changed, 9 insertions(+), 2 deletions(-)
===================================================================
drivers/input/serio/serio.c +7 -2
@@ -92,8 +92,9 @@struct serio_driver *drv;list_for_each_entry (drv, &serio_driver_list, node) -if (serio_bind_driver (serio, drv)) -break ; +if (!drv->manual_bind) +if (serio_bind_driver (serio, drv)) +break ; }/*
@@ -502,6 +503,9 @@driver_register (&drv->driver);driver_create_file (&drv->driver, &driver_attr_description); +if (drv->manual_bind) + goto out; + start_over:list_for_each_entry (serio, &serio_list, node) {if (!serio->drv) {
@@ -515,6 +519,7 @@ } } +out:up (&serio_sem); }
include/linux/serio.h +2 -0
@@ -55,6 +55,8 @@void *private;char *description; +int manual_bind; +void (*write_wakeup)(struct serio *);irqreturn_t (*interrupt)(struct serio *,unsigned char ,unsigned int ,struct pt_regs *);
PATCH 10/19 serio_raw driver
===================================================================
[email protected], 2004-06-27 15:57:09-05:00, [email protected]
Input: Add serio_raw driver that binds to serio ports and provides
unobstructed access to the underlying serio port via a char device. The driver tries to register char device 10,1 (/dev/psaux) first and if it fails goes for dynamically allocated minor. To bind use sysfs interface:
echo -n "serio_raw" > /sys/bus/serio/devices/serioX/driver
Kconfig | 16 ++ Makefile | 1 serio_raw.c | 390 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 407 insertions(+)
===================================================================
drivers/input/serio/Kconfig +16 -0
@@ -130,3 +130,19 @@ To compile this driver as a module, choose M here: the module will be called maceps2. + +config SERIO_RAW + tristate "Raw access to serio ports" + depends on SERIO + help + Say Y here if you want to have raw access to serio ports, such as + AUX ports on i8042 keyboard controller. Each serio port that is + bound to this driver will be accessible via a char device with + major 10 and dynamically allocated minor. The driver will try + allocating minor 1 (that historically corresponds to /dev/psaux) + first. To bind this driver to a serio port use sysfs interface: + + echo -n "serio_raw" > /sys/bus/serio/devices/serioX/driver + + To compile this driver as a module, choose M here: the + module will be called serio_raw.
drivers/input/serio/Makefile +1 -0
@@ -17,3 +17,4 @@ obj-$(CONFIG_SERIO_GSCPS2) += gscps2.o obj-$(CONFIG_SERIO_PCIPS2) += pcips2.o obj-$(CONFIG_SERIO_MACEPS2) += maceps2.o +obj-$(CONFIG_SERIO_RAW) += serio_raw.o
drivers/input/serio/serio_raw.c new file +390 -0
390 lines not on this page · raw message
PATCH 11/19 add platform_device_register_simple
===================================================================
[email protected], 2004-06-27 15:57:46-05:00, [email protected]
sysfs: add platform_device_register_simple to register platform devices
requiring minimal resource and memory management. The device will have standard release function that just frees memory occupied by the platform device. By having release function in the driver core modules using such devices can be unloaded without waiting for the last reference to the device to be dropped.
Suggested by Russell King
drivers/base/platform.c | 68 ++++++++++++++++++++++++++++++++++++++++++++++++ include/linux/device.h | 2 + 2 files changed, 70 insertions(+)
===================================================================
drivers/base/platform.c +68 -0
@@ -13,6 +13,7 @@#include <linux/device.h> #include <linux/module.h> #include <linux/init.h> +#include <linux/err.h> struct device platform_bus = { .bus_id ="platform" ,
@@ -131,6 +132,13 @@return ret; } +/** +* platform_device_unregister - remove a platform-level device +* @dev: platform device we're removing +* +* Note that this function will also release all memory- and port-based +* resources owned by the device (@dev->resource). +*/ void platform_device_unregister (struct platform_device * pdev) {int i;
@@ -146,6 +154,65 @@ } } +struct platform_object { +struct platform_device pdev; +struct resource resources[0 ]; +}; + +static void platform_device_release_simple (struct device *dev) +{ +struct platform_device *pdev =to_platform_device (dev); + +kfree (container_of(pdev ,struct platform_object ,pdev )); +} + +/** +* platform_device_register_simple +* @name: base name of the device we're adding +* @id: instance id +* @res: set of resources that needs to be allocated for the device +* @num: number of resources +* +* This function creates a simple platform device that requires minimal +* resource and memory management. Canned release function freeing +* memory allocated for the device allows drivers using such devices +* to be unloaded iwithout waiting for the last reference to the device +* to be dropped. +*/ +struct platform_device *platform_device_register_simple (char *name,unsigned int id, +struct resource *res,unsigned int num) +{ +struct platform_object *pobj; +int retval; + + pobj =kmalloc (sizeof (struct platform_object ) +sizeof (struct resource ) * num,GFP_KERNEL ); +if (!pobj) { + retval = -ENOMEM ; + goto error; + } + +memset (pobj,0 ,sizeof (*pobj)); + pobj->pdev.name = name; + pobj->pdev.id = id; + pobj->pdev.dev.release = platform_device_release_simple; + +if (num) { +memcpy (pobj->resources, res,sizeof (struct resource ) * num); + pobj->pdev.resource = pobj->resources; + pobj->pdev.num_resources = num; + } + + retval =platform_device_register (&pobj->pdev); +if (retval) + goto error; + +return &pobj->pdev; + +error: +kfree (pobj); +return ERR_PTR (retval); +} +/** * platform_match - bind platform device to platform driver.
@@ -213,6 +280,7 @@EXPORT_SYMBOL (platform_bus);EXPORT_SYMBOL (platform_bus_type);EXPORT_SYMBOL (platform_device_register); +EXPORT_SYMBOL (platform_device_register_simple);EXPORT_SYMBOL (platform_device_unregister);EXPORT_SYMBOL (platform_get_irq);EXPORT_SYMBOL (platform_get_resource);
include/linux/device.h +2 -0
@@ -381,6 +381,8 @@extern int platform_get_irq (struct platform_device *,unsigned int );extern int platform_add_devices (struct platform_device **,int ); +extern struct platform_device *platform_device_register_simple (char *,unsigned int ,struct resource *,unsigned int ); +/* drivers/base/power.c */ extern void device_shutdown (void );
PATCH 12/19 convert i8042 into a platform device
===================================================================
[email protected], 2004-06-27 15:58:25-05:00, [email protected]
Input: make i8042 a platform device instead of system device so
its serio ports have proper parent
i8042.c | 60 ++++++++++++++++++++++++++++++++++-------------------------- 1 files changed, 34 insertions(+), 26 deletions(-)
===================================================================
drivers/input/serio/i8042.c +34 -26
@@ -21,6 +21,7 @@#include <linux/sysdev.h> #include <linux/pm.h> #include <linux/serio.h> +#include <linux/err.h> #include <asm/io.h>
@@ -101,9 +102,9 @@static unsigned char i8042_ctr;static unsigned char i8042_mux_open;static unsigned char i8042_mux_present; -static unsigned char i8042_sysdev_initialized;static struct pm_dev *i8042_pm_dev;static struct timer_list i8042_timer; +static struct platform_device *i8042_platform_device;/* * Shared IRQ's require a device pointer, but this driver doesn't support
@@ -855,7 +856,7 @@return NOTIFY_DONE ; } -static struct notifier_block i8042_notifier= +static struct notifier_block i8042_notifier = { i8042_notify_sys,NULL ,
@@ -865,25 +866,27 @@/* * Suspend/resume handlers for the new PM scheme (driver model) */ -static int i8042_suspend (struct sys_device *dev,u32 state) +static int i8042_suspend (struct device *dev,u32 state,u32 level) { -return i8042_controller_suspend (); +return level ==SUSPEND_DISABLE ?i8042_controller_suspend () :0 ; } -static int i8042_resume (struct sys_device *dev) +static int i8042_resume (struct device *dev,u32 level) { -return i8042_controller_resume (); +return level ==RESUME_ENABLE ?i8042_controller_resume () :0 ; } -static struct sysdev_class kbc_sysclass = { -set_kset_name ("i8042" ), - .suspend = i8042_suspend, - .resume = i8042_resume, -}; +static void i8042_shutdown (struct device *dev) +{ +i8042_controller_cleanup (); +} -static struct sys_device device_i8042 = { - .id =0 , - .cls = &kbc_sysclass, +static struct device_driver i8042_driver = { + .name ="i8042" , + .bus = &platform_bus_type, + .suspend = i8042_suspend, + .resume = i8042_resume, + .shutdown = i8042_shutdown, };/*
@@ -914,6 +917,7 @@ serio->open = i8042_open, serio->close = i8042_close, serio->port_data = &i8042_kbd_values, + serio->dev.parent = &i8042_platform_device->dev;strlcpy (serio->name,"i8042 Kbd Port" ,sizeof (serio->name));strlcpy (serio->phys,I8042_KBD_PHYS_DESC ,sizeof (serio->phys)); }
@@ -933,6 +937,7 @@ serio->open = i8042_open; serio->close = i8042_close; serio->port_data = &i8042_aux_values, + serio->dev.parent = &i8042_platform_device->dev;strlcpy (serio->name,"i8042 Aux Port" ,sizeof (serio->name));strlcpy (serio->phys,I8042_AUX_PHYS_DESC ,sizeof (serio->phys)); }
@@ -957,6 +962,7 @@ serio->open = i8042_open; serio->close = i8042_close; serio->port_data = values; + serio->dev.parent = &i8042_platform_device->dev;snprintf (serio->name,sizeof (serio->name),"i8042 Aux-%d Port" , index);snprintf (serio->phys,sizeof (serio->phys),I8042_MUX_PHYS_DESC , index +1 ); }
@@ -967,6 +973,7 @@int __init i8042_init (void ) {int i; +int err;dbg_init ();
@@ -989,6 +996,16 @@ }#endif + err =driver_register (&i8042_driver); +if (err) +return err; + + i8042_platform_device =platform_device_register_simple ("i8042" ,-1 ,NULL ,0 ); +if (IS_ERR (i8042_platform_device)) { +driver_unregister (&i8042_driver); +return PTR_ERR (i8042_platform_device); + } +if (!i8042_noaux && !i8042_check_aux (&i8042_aux_values)) {if (!i8042_nomux && !i8042_check_mux (&i8042_aux_values))for (i =0 ; i <I8042_NUM_MUX_PORTS ; i++) {
@@ -1009,13 +1026,6 @@mod_timer (&i8042_timer, jiffies +I8042_POLL_PERIOD ); -if (sysdev_class_register (&kbc_sysclass) ==0 ) { -if (sysdev_register (&device_i8042) ==0 ) - i8042_sysdev_initialized =1 ; -else -sysdev_class_unregister (&kbc_sysclass); - } - i8042_pm_dev =pm_register (PM_SYS_DEV ,PM_SYS_UNKNOWN , i8042_pm_callback);register_reboot_notifier (&i8042_notifier);
@@ -1032,11 +1042,6 @@if (i8042_pm_dev)pm_unregister (i8042_pm_dev); -if (i8042_sysdev_initialized) { -sysdev_unregister (&device_i8042); -sysdev_class_unregister (&kbc_sysclass); - } -i8042_controller_cleanup ();if (i8042_kbd_values.exists)
@@ -1050,6 +1055,9 @@serio_unregister_port (i8042_mux_port[i]);del_timer_sync (&i8042_timer); + +platform_device_unregister (i8042_platform_device); +driver_unregister (&i8042_driver);i8042_platform_exit (); }
PATCH 13/19 more platform device conversions
===================================================================
[email protected], 2004-06-27 15:58:55-05:00, [email protected]
Input: integrate ct82c710, maceps2, q40kbd and rpckbd with sysfs
as platform devices so their serio ports have proper parents
ct82c710.c | 50 ++++++++++++++++++++++++++++---------------------- maceps2.c | 19 ++++++++++++++----- q40kbd.c | 18 ++++++++++++++---- rpckbd.c | 20 +++++++++++++++----- 4 files changed, 71 insertions(+), 36 deletions(-)
===================================================================
drivers/input/serio/ct82c710.c +28 -22
@@ -36,6 +36,7 @@#include <linux/interrupt.h> #include <linux/serio.h> #include <linux/errno.h> +#include <linux/err.h> #include <asm/io.h>
@@ -58,10 +59,12 @@#define CT82C710_IRQ 12 -static struct serio *ct82c710_port; -static int ct82c710_data; -static int ct82c710_status; +#define CT82C710_DATA ct82c710_iores.start +#define CT82C710_STATUS (ct82c710_iores.start + 1) +static struct serio *ct82c710_port; +static struct platform_device *ct82c710_device; +static struct resource ct82c710_iores;/* * Interrupt handler for the 82C710 mouse port. A character
@@ -70,7 +73,7 @@static irqreturn_t ct82c710_interrupt (int cpl,void *dev_id,struct pt_regs * regs) { -return serio_interrupt (ct82c710_port,inb (ct82c710_data),0 , regs); +return serio_interrupt (ct82c710_port,inb (CT82C710_DATA ),0 , regs); }/*
@@ -81,10 +84,10 @@ {int timeout =60000 ; -while ((inb (ct82c710_status) & (CT82C710_RX_FULL |CT82C710_TX_IDLE |CT82C710_DEV_IDLE )) +while ((inb (CT82C710_STATUS ) & (CT82C710_RX_FULL |CT82C710_TX_IDLE |CT82C710_DEV_IDLE )) != (CT82C710_DEV_IDLE |CT82C710_TX_IDLE ) && timeout) { -if (inb_p (ct82c710_status) &CT82C710_RX_FULL )inb_p (ct82c710_data); +if (inb_p (CT82C710_STATUS ) &CT82C710_RX_FULL )inb_p (CT82C710_DATA );udelay (1 ); timeout--;
@@ -98,7 +101,7 @@if (ct82c170_wait ())printk (KERN_WARNING "ct82c710.c: Device busy in close()\n" ); -outb_p (inb_p (ct82c710_status) & ~(CT82C710_ENABLE |CT82C710_INTS_ON ), ct82c710_status); +outb_p (inb_p (CT82C710_STATUS ) & ~(CT82C710_ENABLE |CT82C710_INTS_ON ),CT82C710_STATUS );if (ct82c170_wait ())printk (KERN_WARNING "ct82c710.c: Device busy in close()\n" );
@@ -113,21 +116,21 @@if (request_irq (CT82C710_IRQ , ct82c710_interrupt,0 ,"ct82c710" ,NULL ))return -1 ; - status =inb_p (ct82c710_status); + status =inb_p (CT82C710_STATUS ); status |= (CT82C710_ENABLE |CT82C710_RESET ); -outb_p (status, ct82c710_status); +outb_p (status,CT82C710_STATUS ); status &= ~(CT82C710_RESET ); -outb_p (status, ct82c710_status); +outb_p (status,CT82C710_STATUS ); status |=CT82C710_INTS_ON ; -outb_p (status, ct82c710_status);/* Enable interrupts */ +outb_p (status,CT82C710_STATUS );/* Enable interrupts */ while (ct82c170_wait ()) {printk (KERN_ERR "ct82c710: Device busy in open()\n" ); status &= ~(CT82C710_ENABLE |CT82C710_INTS_ON ); -outb_p (status, ct82c710_status); +outb_p (status,CT82C710_STATUS );free_irq (CT82C710_IRQ ,NULL );return -1 ; }
@@ -142,7 +145,7 @@static int ct82c710_write (struct serio *port,unsigned char c) {if (ct82c170_wait ())return -1 ; -outb_p (c, ct82c710_data); +outb_p (c,CT82C710_DATA );return 0 ; }
@@ -162,8 +165,9 @@return -1 ;/* No: no 82C710 here */ outb_p (0x0d ,0x390 );/* Write index */ - ct82c710_data =inb_p (0x391 ) <<2 ;/* Get mouse I/O address */ - ct82c710_status = ct82c710_data +1 ; + ct82c710_iores.start =inb_p (0x391 ) <<2 ;/* Get mouse I/O address */ + ct82c710_iores.end = ct82c710_iores.start +1 ; + ct82c710_iores.flags =IORESOURCE_IO ;outb_p (0x0f ,0x390 );outb_p (0x0f ,0x391 );/* Close config mode */
@@ -181,8 +185,9 @@ serio->open = ct82c710_open; serio->close = ct82c710_close; serio->write = ct82c710_write; + serio->dev.parent = &ct82c710_device->dev;strlcpy (serio->name,"C&T 82c710 mouse port" ,sizeof (serio->name)); -snprintf (serio->phys,sizeof (serio->phys),"isa%04x/serio0" , ct82c710_data); +snprintf (serio->phys,sizeof (serio->phys),"isa%04lx/serio0" ,CT82C710_DATA ); }return serio;
@@ -193,18 +198,19 @@if (ct82c710_probe ())return -ENODEV ; -if (request_region (ct82c710_data,2 ,"ct82c710" )) -return -EBUSY ; + ct82c710_device =platform_device_register_simple ("ct82c710" ,-1 , &ct82c710_iores,1 ); +if (IS_ERR (ct82c710_device)) +return PTR_ERR (ct82c710_device);if (!(ct82c710_port =ct82c710_allocate_port ())) { -release_region (ct82c710_data,2 ); +platform_device_unregister (ct82c710_device);return -ENOMEM ; }serio_register_port (ct82c710_port); -printk (KERN_INFO "serio: C&T 82c710 mouse port at %#x irq %d\n" , - ct82c710_data,CT82C710_IRQ ); +printk (KERN_INFO "serio: C&T 82c710 mouse port at %#lx irq %d\n" , +CT82C710_DATA ,CT82C710_IRQ );return 0 ; }
@@ -212,7 +218,7 @@ void __exit ct82c710_exit(void) {serio_unregister_port (ct82c710_port); -release_region (ct82c710_data,2 ); +platform_device_unregister (ct82c710_device); }module_init (ct82c710_init);
drivers/input/serio/maceps2.c +14 -5
@@ -17,6 +17,7 @@#include <linux/device.h> #include <linux/slab.h> #include <linux/spinlock.h> +#include <linux/err.h> #include <asm/io.h> #include <asm/irq.h>
@@ -53,6 +54,7 @@static struct maceps2_data port_data[2 ];static struct serio *maceps2_port[2 ]; +static struct platform_device *maceps2_device;static int maceps2_write (struct serio *dev,unsigned char val) {
@@ -123,13 +125,14 @@ serio =kmalloc (sizeof (struct serio ),GFP_KERNEL );if (serio) {memset (serio,0 ,sizeof (struct serio )); - serio->type =SERIO_8042 ; - serio->write = maceps2_write; - serio->open = maceps2_open; - serio->close = maceps2_close; + serio->type =SERIO_8042 ; + serio->write = maceps2_write; + serio->open = maceps2_open; + serio->close = maceps2_close;snprintf (serio->name,sizeof (serio->name),"MACE PS/2 port%d" , idx);snprintf (serio->phys,sizeof (serio->phys),"mace/serio%d" , idx); - serio->port_data = &port_data[idx]; + serio->port_data = &port_data[idx]; + serio->dev.parent = &maceps2_device->dev; }return serio;
@@ -138,6 +141,10 @@static int __init maceps2_init (void ) { + maceps2_device =platform_device_register_simple ("maceps2" ,-1 ,NULL ,0 ); +if (IS_ERR (maceps2_device)) +return PTR_ERR (maceps2_device); + port_data[0 ].port = &mace->perif.ps2.keyb; port_data[0 ].irq =MACEISA_KEYB_IRQ ; port_data[1 ].port = &mace->perif.ps2.mouse;
@@ -148,6 +155,7 @@if (!maceps2_port[0 ] || !maceps2_port[1 ]) {kfree (maceps2_port[0 ]);kfree (maceps2_port[1 ]); +platform_device_unregister (maceps2_device);return -ENOMEM ; }
@@ -161,6 +169,7 @@ {serio_unregister_port (maceps2_port[0 ]);serio_unregister_port (maceps2_port[1 ]); +platform_device_unregister (maceps2_device); }module_init (maceps2_init);
drivers/input/serio/q40kbd.c +14 -4
@@ -35,6 +35,7 @@#include <linux/init.h> #include <linux/serio.h> #include <linux/interrupt.h> +#include <linux/err.h> #include <asm/bitops.h> #include <asm/io.h>
@@ -49,6 +50,7 @@spinlock_t q40kbd_lock =SPIN_LOCK_UNLOCKED ;static struct serio *q40kbd_port; +static struct platform_device *q40kbd_device;static irqreturn_t q40kbd_interrupt (int irq,void *dev_id,struct pt_regs *regs) {
@@ -120,9 +122,10 @@ serio =kmalloc (sizeof (struct serio ),GFP_KERNEL );if (serio) {memset (serio,0 ,sizeof (struct serio )); - serio->type =SERIO_8042 ; - serio->open = q40kbd_open; - serio->close = q40kbd_close; + serio->type =SERIO_8042 ; + serio->open = q40kbd_open; + serio->close = q40kbd_close; + serio->dev.parent = &q40kbd_device->dev;strlcpy (serio->name,"Q40 Kbd Port" ,sizeof (serio->name));strlcpy (serio->phys,"Q40" ,sizeof (serio->phys)); }
@@ -135,8 +138,14 @@if (!MACH_IS_Q40 )return -EIO ; -if (!(q40kbd_port =q40kbd_allocate_port ())) + q40kbd_device =platform_device_register_simple ("q40kbd" ,-1 ,NULL ,0 ); +if (IS_ERR (q40kbd_device)) +return PTR_ERR (q40kbd_device); + +if (!(q40kbd_port =q40kbd_allocate_port ())) { +platform_device_unregister (q40kbd_device);return -ENOMEM ; + }serio_register_port (q40kbd_port);printk (KERN_INFO "serio: Q40 kbd registered\n" );
@@ -147,6 +156,7 @@ static void __exit q40kbd_exit(void) {serio_unregister_port (q40kbd_port); +platform_device_unregister (q40kbd_device); }module_init (q40kbd_init);
drivers/input/serio/rpckbd.c +15 -5
@@ -33,6 +33,7 @@#include <linux/interrupt.h> #include <linux/init.h> #include <linux/serio.h> +#include <linux/err.h> #include <asm/irq.h> #include <asm/hardware.h>
@@ -45,6 +46,7 @@MODULE_LICENSE ("GPL" );static struct serio *rpckbd_port; +static struct platform_device *rpckbd_device;static int rpckbd_write (struct serio *port,unsigned char val) {
@@ -115,10 +117,11 @@ serio =kmalloc (sizeof (struct serio ),GFP_KERNEL );if (serio) {memset (serio,0 ,sizeof (struct serio )); - serio->type =SERIO_8042 ; - serio->write = rpckbd_write; - serio->open = rpckbd_open; - serio->close = rpckbd_close; + serio->type =SERIO_8042 ; + serio->write = rpckbd_write; + serio->open = rpckbd_open; + serio->close = rpckbd_close; + serio->dev.parent = &rpckbd_device->dev;strlcpy (serio->name,"RiscPC PS/2 kbd port" ,sizeof (serio->name));strlcpy (serio->phys,"rpckbd/serio0" ,sizeof (serio->phys)); }
@@ -128,8 +131,14 @@static int __init rpckbd_init (void ) { -if (!(rpckbd_port =rpckbd_allocate_port ())) + rpckbd_device =platform_device_register_simple ("rpckbd" ,-1 ,NULL ,0 ); +if (IS_ERR (rpckbd_device)) +return PTR_ERR (rpckbd_device); + +if (!(rpckbd_port =rpckbd_allocate_port ())) { +platform_device_unregister (rpckbd_device);return -ENOMEM ; + }serio_register_port (rpckbd_port);return 0 ;
@@ -138,6 +147,7 @@ static void __exit rpckbd_exit(void) {serio_unregister_port (rpckbd_port); +platform_device_unregister (rpckbd_device); }module_init (rpckbd_init);
PATCH 14/19 bind serio ports and their parents
===================================================================
[email protected], 2004-06-27 16:01:48-05:00, [email protected]
Input: link serio ports to their parent devices in ambakmi,
gscps2, pcips2 and sa1111ps2 drivers
ambakmi.c | 1 + gscps2.c | 1 + pcips2.c | 1 + sa1111ps2.c | 1 + 4 files changed, 4 insertions(+)
===================================================================
drivers/input/serio/ambakmi.c +1 -0
@@ -141,6 +141,7 @@strlcpy (io->name, dev->dev.bus_id,sizeof (io->name));strlcpy (io->phys, dev->dev.bus_id,sizeof (io->phys)); io->port_data = kmi; + io->dev.parent = &dev->dev; kmi->io = io; kmi->base =ioremap (dev->res.start,KMI_SIZE );
drivers/input/serio/gscps2.c +1 -0
@@ -385,6 +385,7 @@ serio->open = gscps2_open; serio->close = gscps2_close; serio->port_data = ps2port; + serio->dev.parent = &dev->dev;list_add_tail (&ps2port->node, &ps2port_list);
drivers/input/serio/pcips2.c +1 -0
@@ -159,6 +159,7 @@strlcpy (serio->name,pci_name (dev),sizeof (serio->name));strlcpy (serio->phys, dev->dev.bus_id,sizeof (serio->phys)); serio->port_data = ps2if; + serio->dev.parent = &dev->dev; ps2if->io = serio; ps2if->dev = dev; ps2if->base =pci_resource_start (dev,0 );
drivers/input/serio/sa1111ps2.c +1 -0
@@ -252,6 +252,7 @@strlcpy (serio->name, dev->dev.bus_id,sizeof (serio->name));strlcpy (serio->phys, dev->dev.bus_id,sizeof (serio->phys)); serio->port_data = ps2if; + serio->dev.parent = &dev->dev; ps2if->io = serio; ps2if->dev = dev;sa1111_set_drvdata (dev, ps2if);
PATCH 15/19 synaptics passthrough handling
===================================================================
[email protected], 2004-06-27 16:03:33-05:00, [email protected]
Input: synaptics - do not try to process packets from slave device
as if they were coming form the touchpad itself if pass-through port is disconnected
synaptics.c | 7 ++++--- 1 files changed, 4 insertions(+), 3 deletions(-)
===================================================================
drivers/input/mouse/synaptics.c +4 -3
@@ -472,9 +472,10 @@if (unlikely (priv->pkt_type ==SYN_NEWABS )) priv->pkt_type =synaptics_detect_pkt_type (psmouse); -if (psmouse->serio->child && psmouse->serio->child->drv &&synaptics_is_pt_packet (psmouse->packet)) -synaptics_pass_pt_packet (psmouse->serio->child, psmouse->packet); -else +if (SYN_CAP_PASS_THROUGH (priv->capabilities) &&synaptics_is_pt_packet (psmouse->packet)) { +if (psmouse->serio->child && psmouse->serio->child->drv) +synaptics_pass_pt_packet (psmouse->serio->child, psmouse->packet); + }else synaptics_process_packet (psmouse);return PSMOUSE_FULL_PACKET ;
PATCH 16/19 add bus' default driver attributes
===================================================================
[email protected], 2004-06-27 19:22:44-05:00, [email protected]
Driver core: add default driver attributes to struct bus_type
drivers/base/bus.c | 37 +++++++++++++++++++++++++++++++++++-- include/linux/device.h | 1 + 2 files changed, 36 insertions(+), 2 deletions(-)
===================================================================
drivers/base/bus.c +35 -2
@@ -415,7 +415,7 @@static void device_remove_attrs (struct bus_type * bus,struct device * dev) {int i; - +if (bus->dev_attrs) {for (i =0 ;attr_name (bus->dev_attrs[i]); i++)device_remove_file (dev,&bus->dev_attrs[i]);
@@ -471,6 +471,37 @@ } } +static int driver_add_attrs (struct bus_type * bus,struct device_driver * drv) +{ +int error =0 ; +int i; + +if (bus->drv_attrs) { +for (i =0 ;attr_name (bus->drv_attrs[i]); i++) { + error =driver_create_file (drv, &bus->drv_attrs[i]); +if (error) + goto Err; + } + } + Done: +return error; + Err: +while (--i >=0 ) +driver_remove_file (drv, &bus->drv_attrs[i]); + goto Done; +} + + +static void driver_remove_attrs (struct bus_type * bus,struct device_driver * drv) +{ +int i; + +if (bus->drv_attrs) { +for (i =0 ;attr_name (bus->drv_attrs[i]); i++) +driver_remove_file (drv, &bus->drv_attrs[i]); + } +} +/** * bus_add_driver - Add a driver to the bus.
@@ -499,6 +530,7 @@driver_attach (drv);up_write (&bus->subsys.rwsem); +driver_add_attrs (bus, drv); }return error; }
@@ -516,6 +548,7 @@void bus_remove_driver (struct device_driver * drv) {if (drv->bus) { +driver_remove_attrs (drv->bus, drv);down_write (&drv->bus->subsys.rwsem);pr_debug ("bus %s: remove driver %s\n" , drv->bus->name, drv->name);driver_detach (drv);
@@ -610,7 +643,7 @@static void bus_remove_attrs (struct bus_type * bus) {int i; - +if (bus->bus_attrs) {for (i =0 ;attr_name (bus->bus_attrs[i]); i++)bus_remove_file (bus,&bus->bus_attrs[i]);
include/linux/device.h +1 -0
@@ -56,6 +56,7 @@struct bus_attribute * bus_attrs;struct device_attribute * dev_attrs; +struct driver_attribute * drv_attrs;int (*match)(struct device * dev,struct device_driver * drv);struct device * (*add) (struct device * parent,char * bus_id);
PATCH 17/19 serio use bus' default driver/device attributes
===================================================================
[email protected], 2004-06-27 19:39:04-05:00, [email protected]
Input: Switch to use bus' default device and driver attributes to
manage serio sysfs attributes
serio.c | 23 +++++++++++++++-------- 1 files changed, 15 insertions(+), 8 deletions(-)
===================================================================
drivers/input/serio/serio.c +15 -8
@@ -245,14 +245,12 @@struct serio *serio =to_serio_port (dev);return sprintf (buf,"%s\n" , serio->name); } -static DEVICE_ATTR(description, S_IRUGO, serio_show_description, NULL);static ssize_t serio_show_legacy_position (struct device *dev,char *buf) {struct serio *serio =to_serio_port (dev);return sprintf (buf,"%s\n" , serio->phys); } -static DEVICE_ATTR(legacy_position, S_IRUGO, serio_show_legacy_position, NULL);static ssize_t serio_show_driver (struct device *dev,char *buf) {
@@ -290,7 +288,14 @@return retval; } -static DEVICE_ATTR(driver, S_IWUSR | S_IRUGO, serio_show_driver, serio_rebind_driver); + +static struct device_attribute serio_device_attrs[] = { +__ATTR (description,S_IRUGO , serio_show_description,NULL ), +__ATTR (legacy_position,S_IRUGO , serio_show_legacy_position,NULL ), +__ATTR (driver,S_IWUSR |S_IRUGO , serio_show_driver, serio_rebind_driver), + __ATTR_NULL +}; +static void serio_release_port (struct device *dev) {
@@ -312,9 +317,6 @@if (serio->parent) serio->dev.parent = &serio->parent->dev;device_register (&serio->dev); -device_create_file (&serio->dev, &dev_attr_description); -device_create_file (&serio->dev, &dev_attr_legacy_position); -device_create_file (&serio->dev, &dev_attr_driver); }/*
@@ -489,7 +491,11 @@struct serio_driver *driver =to_serio_driver (drv);return sprintf (buf,"%s\n" , driver->description ? driver->description :"(none)" ); } -static DRIVER_ATTR(description, S_IRUGO, serio_driver_show_description, NULL); + +static struct driver_attribute serio_driver_attrs[] = { +__ATTR (description,S_IRUGO , serio_driver_show_description,NULL ), + __ATTR_NULL +};void serio_register_driver (struct serio_driver *drv) {
@@ -501,7 +507,6 @@ drv->driver.bus = &serio_bus;driver_register (&drv->driver); -driver_create_file (&drv->driver, &driver_attr_description);if (drv->manual_bind) goto out;
@@ -607,6 +612,8 @@return -1 ; } + serio_bus.dev_attrs = serio_device_attrs; + serio_bus.drv_attrs = serio_driver_attrs;bus_register (&serio_bus);return 0 ;
PATCH 18/19 add driver_find
===================================================================
[email protected], 2004-06-27 20:49:01-05:00, [email protected]
Driver core: add driver_find helper to find a driver by its name
drivers/base/driver.c | 16 ++++++++++++++++ include/linux/device.h | 1 + 2 files changed, 17 insertions(+)
===================================================================
drivers/base/driver.c +16 -0
@@ -111,10 +111,26 @@up (&drv->unload_sem); } +/** +* driver_find - find driver on a given bus by its name. +* @name: name of the driver. +* @bus: bus to seatch for the driver +*/ + +struct device_driver *driver_find (const char *name,struct bus_type *bus) +{ +struct kobject *k =kset_find_obj (&bus->drivers, name); +if (k) +return to_drv (k); +return NULL ; +} + +EXPORT_SYMBOL (driver_register);EXPORT_SYMBOL (driver_unregister);EXPORT_SYMBOL (get_driver);EXPORT_SYMBOL (put_driver); +EXPORT_SYMBOL (driver_find);EXPORT_SYMBOL (driver_create_file);EXPORT_SYMBOL (driver_remove_file);
include/linux/device.h +1 -0
@@ -120,6 +120,7 @@extern struct device_driver *get_driver (struct device_driver * drv);extern void put_driver (struct device_driver * drv); +extern struct device_driver *driver_find (const char *name,struct bus_type *bus);/* driverfs interface for exporting driver attributes */
PATCH 19/19 serio use driver_find
===================================================================
[email protected], 2004-06-27 21:09:35-05:00, [email protected]
Input: serio - make use of driver_find instead of re-implementing it
serio.c | 4 +--- 1 files changed, 1 insertion(+), 3 deletions(-)
===================================================================
drivers/input/serio/serio.c +1 -3
@@ -261,7 +261,6 @@ {struct serio *serio =to_serio_port (dev);struct device_driver *drv; -struct kobject *k;int retval; retval =down_interruptible (&serio_sem);
@@ -276,8 +275,7 @@ }else if (!strncmp (buf,"rescan" , count)) {serio_disconnect_port (serio);serio_connect_port (serio,NULL ); - }else if ((k =kset_find_obj (&serio_bus.drivers, buf)) !=NULL ) { - drv = container_of(k, struct device_driver, kobj); + }else if ((drv =driver_find (buf, &serio_bus)) !=NULL ) {serio_disconnect_port (serio);serio_connect_port (serio,to_serio_driver (drv)); }else {
Quoted 10 lines · Dmitry Torokhov
Hi,
Here is the 2nd version of my set of input patches that mostly do serio sysfs integration. Among the changes - dropped psmouse KVM resync patch as it was bogus, added platform devices to those of serio providers that don't have proper parent device (i8042, q40kbd, etc).
01-psmouse-state-locking.patch
- Acquire underlying serio lock when changing psmouse state to prevent interrupt handler running on us
IMO drivers have no bussiness messing with the serio locks. We could use 'plug' and 'unplug' functions like the network driver use, or handle it inside the driver, but taking the lock is the wrong thing to do.
Quoted 5 lines
02-serio-connect-mandatory.patch
- Make serio driviers connect/disconnect methods mandatory as these methods open/close serio ports and link ports and drivers together. Presently if a driver does not implement connect method it will not be able to bind to a port anyway.
OK
Quoted 3 lines
03-serio-rename-1.patch
- Renameserio->drivertoserio->port_dataas with sysfs integration driver is not the best name for arbitrary data
OK
Quoted 2 lines
04-serio-rename-2.patch
- Renameserio_devtoserio_driveras they are drivers in sysfs sense
OK
Quoted 4 lines
05-serio-dynamic-alloc.patch
- Switch from static to dynamic serio port allocation so serio ports drivers can be freely unloaded even if not all references to ports are dropped (sysfs req.)
OK
Quoted 3 lines
06-serio-no-recursion.patch
- Do not do recursive discovery of children ports, needed for sysfs and generally better for stack usage.
Yes, this is very good.
Quoted 7 lines
07-serio-sysfs.patch
- sysfs integration. Register ports and drivers in driver model, link them all together under/sys/bus/serio. Every driver has a default attribute "descrip[tion" (fromserio_driver->description); serio ports have "decription", "driver" and "legacy_position".Legacy_positionporvides access toserio->physto allow matching with data in/proc/bus/input/devices
I'm not sure if we really need the 'legacy position' thing. We probably should drop the 'phys' stuff some time after we transition to sysfs, and exporting it through sysfs will make that harder.
Quoted 7 lines
08-serio-rebind.patch
- allow user to disconnect or rebind serio port by writing appropriate data to it's sysfs attribute:
echo -n "psmouse" >/sys/bus/serio/devices/serio0/driverecho -n "none" >/sys/bus/serio/devices/serio0/driverecho -n "reconnect" >/sys/bus/serio/devices/serio0/driverecho -n "rescan" >/sys/bus/serio/devices/serio0/driver
Very good idea.
Quoted 3 lines
09-serio-manual-bind.patch
- allow marking some drivers as requiring manual bind (to be used when driver does not do automatic HW discovery)
OK
Quoted 2 lines
10-serio_raw.patch
- raw access to serio data ala 2.4/dev/psaux
OK, finally those who insist on /dev/psaux can shut up
Quoted 10 lines
(*) 11-platform-device-simple.patch
- Addplatform_device_register_simpleto register platform devices requiring minimal resource and memory management. The release function resides in driver core and that allows drivers registering such devices be unloaded without waiting for the last reference to be dropped.12-i8042-to-platform-device.patch
- Convert i8042 to platform device instead of system device so its ports have proper parent.
OK
Quoted 2 lines
13-serio-add-platform-devices.patch
- Add platform devices to ct82c710, maceps2, q40kbd and rpckbd.
OK
Quoted 3 lines
14-serio-set-up-parents.patch
- Set up parent devices for serio ports in ambakmi, gscps2, pcips2 andsa1111ps2.c
OK
Quoted 4 lines
15-synaptics-passthrough-handling.patch
- If data looks like a pass-through packet and tuchpad has pass-through capability do not pass it to the main handler if child port is disconnected.
I'll have to look closer on this one - I think we want to pass the data to the serio layer even if there is no driver listening on the passthrough serio.
Quoted 8 lines
(*) 16-bus-default-drv-attrs.patch
- Add bus' default driver attributes (similar to defaulr device attributes)17-serio-use-bus-default-attrs.patch
- Use bus' default driver and device attributes to manage serio attributes
Quoted 7 lines
(*) 18-add-driver-find.patch
- Adddriver_findfunction, similar todevice_find, to search for a driver by its name.19-serio-use-driver-find.patch
- Usedriver_findinserio_rebind_driverinstead of implementing it locally.
Very good.
Quoted 1 line
(*) These patches have also been sent to Greg KH.
Did he accept them already?
Quoted 3 lines
This time I tried compiling the stuff using defconfing for SPACR64 and PPC64 (thanks to Andrew for pointing to me availability of cross-compile tools), so I should be a bit better now... Alpha failed on
cpumask.h...
Great! ;)
Quoted 5 lines
The patches are against today's Linus tree + recent pull form Vojtech's tree
+ recent pull from Greg KH's tree. I have patches against 2.6.7 that will bring it to my version of the tree at:http://www.geocities.com/dt_or/input/2_6_7/
Signature · 2 lines
Vojtech Pavlik SuSE Labs, SuSE CR
Quoted 8 lines · Vojtech Pavlik
Quoted 7 lines · Dmitry Torokhov
Hi,
Here is the 2nd version of my set of input patches that mostly do serio sysfs integration. Among the changes - dropped psmouse KVM resync patch as it was bogus, added platform devices to those of serio providers that don't have proper parent device (i8042, q40kbd, etc).
Quoted 7 lines
Quoted 3 lines
01-psmouse-state-locking.patch
- Acquire underlying serio lock when changing psmouse state to prevent interrupt handler running on usIMO drivers have no bussiness messing with the serio locks. We could use 'plug' and 'unplug' functions like the network driver use, or handle it inside the driver, but taking the lock is the wrong thing to do.
OK, I just don't want to introduce another lock just for that...
Quoted 5 lines
I'm not sure if we really need the 'legacy position' thing. We probably should drop the 'phys' stuff some time after we transition to sysfs, and exporting it through sysfs will make that harder.
I'll drop it then...
Quoted 5 lines
Quoted 3 lines
10-serio_raw.patch
- raw access to serio data ala 2.4/dev/psauxOK, finally those who insist on
/dev/psauxcan shut up
:)
Quoted 9 lines
Quoted 5 lines
15-synaptics-passthrough-handling.patch
- If data looks like a pass-through packet and tuchpad has pass-through capability do not pass it to the main handler if child port is disconnected.I'll have to look closer on this one - I think we want to pass the data to the serio layer even if there is no driver listening on the passthrough serio.
We probably should issue serio_interrupt on child port to force rescan but that packet has no business in parent's motion handling routine and that's what this patch tries to fix. Anyway, I will look at it more later.
Quoted 5 lines
Quoted 2 lines
(*) These patches have also been sent to Greg KH.
Did he accept them already?
No, not yet. He promised to take a look at platoform_device_register_simple by the end of the week but I guess kernel.bkbits.net troubles might intervene... And other 2 I just send out today.
Quoted 12 lines
Quoted 3 lines
This time I tried compiling the stuff using defconfing for SPACR64 and PPC64 (thanks to Andrew for pointing to me availability of cross-compile tools), so I should be a bit better now... Alpha failed on
cpumask.h...Great! ;)
Quoted 5 lines
The patches are against today's Linus tree + recent pull form Vojtech's tree
+ recent pull from Greg KH's tree. I have patches against 2.6.7 that will bring it to my version of the tree at:http://www.geocities.com/dt_or/input/2_6_7/
Signature · 1 line
Dmitry
Quoted 5 lines · Dmitry Torokhov
Quoted 3 lines
IMO drivers have no bussiness messing with the serio locks. We could use 'plug' and 'unplug' functions like the network driver use, or handle it inside the driver, but taking the lock is the wrong thing to do.
OK, I just don't want to introduce another lock just for that...
I think a bit in flags "PSMOUSE_ENABLED", like we have the "ATKBD_ENABLED" bit might be just fine - handle the interrupt, but throw away the data during the protocol switch. We aren't interested in the data anyway.
Quoted 5 lines
Quoted 5 lines
Quoted 4 lines
15-synaptics-passthrough-handling.patch
- If data looks like a pass-through packet and tuchpad has pass-through capability do not pass it to the main handler if child port is disconnected.
Quoted 7 lines
Quoted 3 lines
I'll have to look closer on this one - I think we want to pass the data to the serio layer even if there is no driver listening on the passthrough serio.
We probably should issue
serio_interrupton child port to force rescan but that packet has no business in parent's motion handling routine and that's what this patch tries to fix. Anyway, I will look at it more later.
Indeed, we need it for the rescan. It shouldn't be that hard to fix at once.
Quoted 8 lines
Quoted 4 lines
Quoted 2 lines
(*) These patches have also been sent to Greg KH.
Did he accept them already?
No, not yet. He promised to take a look at
platoform_device_register_simpleby the end of the week but I guess kernel.bkbits.net troubles might intervene... And other 2 I just send out today.
Ok. I'll wait then.
Signature · 2 lines
Vojtech Pavlik SuSE Labs, SuSE CR
Quoted 7 lines · On Monday June 28, [email protected] wrote:
Quoted 2 lines · Dmitry Torokhov
10-serio_raw.patch
- raw access to serio data ala 2.4/dev/psauxOK, finally those who insist on
/dev/psauxcan shut up
Alternatively, we could say thank you. So..
Thank you, very much!
NeilBrown
Quoted 6 lines · Neil Brown
Quoted 5 lines · On Monday June 28, [email protected] wrote:
Quoted 2 lines · Dmitry Torokhov
10-serio_raw.patch
- raw access to serio data ala 2.4/dev/psaux
Quoted 6 lines
Quoted 2 lines
OK, finally those who insist on
/dev/psauxcan shut upAlternatively, we could say thank you. So..
Thank you, very much!
You're welcome.
Signature · 2 lines
Vojtech Pavlik SuSE Labs, SuSE CR