2004-06-18 08:44:56

by Dmitry Torokhov

[permalink] [raw]
Subject: [PATCH 1/11] psmouse resync for KVM users


===================================================================


[email protected], 2004-06-16 18:13:33-05:00, [email protected]
Input: psmouse sync. changes
- when a partial packet is received (more than HZ/2 jiffies
has passed since last byte was received) increment
out-of-sync counter. It should help users with KVMs that
reset mice to bare PS/2 protocol but do not send 0xAA 0x00
init sequence - after 'resetafter' bad packets psmouse
will try reconnecting and reestablishing proper protcol.
- change default value for 'resetafter' parameter from
0 (never) to 20.

Signed-off-by: Dmitry Torokhov <[email protected]>


psmouse-base.c | 19 +++++++++++--------
1 files changed, 11 insertions(+), 8 deletions(-)


===================================================================



diff -Nru a/drivers/input/mouse/psmouse-base.c b/drivers/input/mouse/psmouse-base.c
--- a/drivers/input/mouse/psmouse-base.c 2004-06-18 03:14:22 -05:00
+++ b/drivers/input/mouse/psmouse-base.c 2004-06-18 03:14:22 -05:00
@@ -43,7 +43,7 @@
module_param_named(smartscroll, psmouse_smartscroll, bool, 0);
MODULE_PARM_DESC(smartscroll, "Logitech Smartscroll autorepeat, 1 = enabled (default), 0 = disabled.");

-static unsigned int psmouse_resetafter;
+static unsigned int psmouse_resetafter = 20;
module_param_named(resetafter, psmouse_resetafter, uint, 0);
MODULE_PARM_DESC(resetafter, "Reset device after so many bad packets (0 = never).");

@@ -189,6 +189,7 @@
printk(KERN_WARNING "psmouse.c: %s at %s lost synchronization, throwing %d bytes away.\n",
psmouse->name, psmouse->phys, psmouse->pktcnt);
psmouse->pktcnt = 0;
+ psmouse->out_of_sync++;
}

psmouse->last = jiffies;
@@ -221,12 +222,7 @@
printk(KERN_WARNING "psmouse.c: %s at %s lost sync at byte %d\n",
psmouse->name, psmouse->phys, psmouse->pktcnt);
psmouse->pktcnt = 0;
-
- if (++psmouse->out_of_sync == psmouse_resetafter) {
- psmouse->state = PSMOUSE_IGNORE;
- printk(KERN_NOTICE "psmouse.c: issuing reconnect request\n");
- serio_reconnect(psmouse->serio);
- }
+ psmouse->out_of_sync++;
break;

case PSMOUSE_FULL_PACKET:
@@ -241,6 +237,13 @@
case PSMOUSE_GOOD_DATA:
break;
}
+
+ if (psmouse->out_of_sync && psmouse->out_of_sync == psmouse_resetafter) {
+ psmouse->state = PSMOUSE_IGNORE;
+ printk(KERN_NOTICE "psmouse.c: issuing reconnect request\n");
+ serio_reconnect(psmouse->serio);
+ }
+
out:
return IRQ_HANDLED;
}
@@ -306,7 +309,7 @@
while (test_bit(PSMOUSE_FLAG_CMD, &psmouse->flags) && timeout--) {

if (!test_bit(PSMOUSE_FLAG_CMD1, &psmouse->flags)) {
-
+
if (command == PSMOUSE_CMD_RESET_BAT && timeout > 100000)
timeout = 100000;


2004-06-18 08:45:08

by Dmitry Torokhov

[permalink] [raw]
Subject: [PATCH 2/11] psmouse state locking


===================================================================


[email protected], 2004-06-17 18:15:07-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.

Signed-off-by: Dmitry Torokhov <[email protected]>


psmouse-base.c | 32 ++++++++++++++++++++++----------
1 files changed, 22 insertions(+), 10 deletions(-)


===================================================================



diff -Nru a/drivers/input/mouse/psmouse-base.c b/drivers/input/mouse/psmouse-base.c
--- a/drivers/input/mouse/psmouse-base.c 2004-06-18 03:14:47 -05:00
+++ b/drivers/input/mouse/psmouse-base.c 2004-06-18 03:14:47 -05:00
@@ -625,6 +625,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.
*/

@@ -633,7 +650,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);
}

/*
@@ -655,7 +672,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)
@@ -668,7 +685,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);
@@ -696,9 +713,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)) {
@@ -761,12 +778,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))

2004-06-18 08:47:52

by Dmitry Torokhov

[permalink] [raw]
Subject: [PATCH 4/11] serio renames 1


===================================================================


[email protected], 2004-06-17 18:18:43-05:00, [email protected]
Input: rename serio->driver to serio->port_data in preparation
to sysfs integration

Signed-off-by: Dmitry Torokhov <[email protected]>


drivers/input/mouse/synaptics.c | 4 ++--
drivers/input/serio/98kbd-io.c | 1 -
drivers/input/serio/ambakmi.c | 26 +++++++++++++-------------
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 +++---
include/linux/serio.h | 2 +-
10 files changed, 56 insertions(+), 57 deletions(-)


===================================================================



diff -Nru a/drivers/input/mouse/synaptics.c b/drivers/input/mouse/synaptics.c
--- a/drivers/input/mouse/synaptics.c 2004-06-18 03:15:34 -05:00
+++ b/drivers/input/mouse/synaptics.c 2004-06-18 03:15:34 -05:00
@@ -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;
}
diff -Nru a/drivers/input/serio/98kbd-io.c b/drivers/input/serio/98kbd-io.c
--- a/drivers/input/serio/98kbd-io.c 2004-06-18 03:15:34 -05:00
+++ b/drivers/input/serio/98kbd-io.c 2004-06-18 03:15:34 -05:00
@@ -132,7 +132,6 @@
.write = kbd98_write,
.open = kbd98_open,
.close = kbd98_close,
- .driver = NULL,
.name = "PC-9801 Kbd Port",
.phys = KBD98_PHYS_DESC,
};
diff -Nru a/drivers/input/serio/ambakmi.c b/drivers/input/serio/ambakmi.c
--- a/drivers/input/serio/ambakmi.c 2004-06-18 03:15:34 -05:00
+++ b/drivers/input/serio/ambakmi.c 2004-06-18 03:15:34 -05:00
@@ -52,7 +52,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--)
@@ -66,7 +66,7 @@

static int amba_kmi_open(struct serio *io)
{
- struct amba_kmi_port *kmi = io->driver;
+ struct amba_kmi_port *kmi = io->port_data;
int ret;

writeb(kmi->divisor, KMICLKDIV);
@@ -86,7 +86,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);

@@ -110,22 +110,22 @@

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;
}

- kmi->irq = dev->irq[0];
- kmi->divisor = 24 / 8 - 1;
+ kmi->irq = dev->irq[0];
+ kmi->divisor = 24 / 8 - 1;

amba_set_drvdata(dev, kmi);

diff -Nru a/drivers/input/serio/gscps2.c b/drivers/input/serio/gscps2.c
--- a/drivers/input/serio/gscps2.c 2004-06-18 03:15:34 -05:00
+++ b/drivers/input/serio/gscps2.c 2004-06-18 03:15:34 -05:00
@@ -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;

diff -Nru a/drivers/input/serio/i8042.c b/drivers/input/serio/i8042.c
--- a/drivers/input/serio/i8042.c 2004-06-18 03:15:34 -05:00
+++ b/drivers/input/serio/i8042.c 2004-06-18 03:15:34 -05:00
@@ -222,7 +222,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;

/*
@@ -250,7 +250,7 @@

static int i8042_activate_port(struct serio *port)
{
- struct i8042_values *values = port->driver;
+ struct i8042_values *values = port->port_data;

i8042_flush();

@@ -278,7 +278,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++)
@@ -317,7 +317,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)
@@ -352,7 +352,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,
};
@@ -370,7 +370,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,
};
@@ -940,7 +940,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;
}
diff -Nru a/drivers/input/serio/maceps2.c b/drivers/input/serio/maceps2.c
--- a/drivers/input/serio/maceps2.c 2004-06-18 03:15:34 -05:00
+++ b/drivers/input/serio/maceps2.c 2004-06-18 03:15:34 -05:00
@@ -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)
diff -Nru a/drivers/input/serio/pcips2.c b/drivers/input/serio/pcips2.c
--- a/drivers/input/serio/pcips2.c 2004-06-18 03:15:34 -05:00
+++ b/drivers/input/serio/pcips2.c 2004-06-18 03:15:34 -05:00
@@ -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);

diff -Nru a/drivers/input/serio/sa1111ps2.c b/drivers/input/serio/sa1111ps2.c
--- a/drivers/input/serio/sa1111ps2.c 2004-06-18 03:15:34 -05:00
+++ b/drivers/input/serio/sa1111ps2.c 2004-06-18 03:15:34 -05:00
@@ -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);

diff -Nru a/drivers/input/serio/serport.c b/drivers/input/serio/serport.c
--- a/drivers/input/serio/serport.c 2004-06-18 03:15:34 -05:00
+++ b/drivers/input/serio/serport.c 2004-06-18 03:15:34 -05:00
@@ -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);

diff -Nru a/include/linux/serio.h b/include/linux/serio.h
--- a/include/linux/serio.h 2004-06-18 03:15:34 -05:00
+++ b/include/linux/serio.h 2004-06-18 03:15:34 -05:00
@@ -21,7 +21,7 @@

struct serio {
void *private;
- void *driver;
+ void *port_data;
char *name;
char *phys;

2004-06-18 08:47:59

by Dmitry Torokhov

[permalink] [raw]
Subject: [PATCH 3/11] serio connect/disconnect mandatory


===================================================================


[email protected], 2004-06-17 18:16:15-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.

Signed-off-by: Dmitry Torokhov <[email protected]>


serio.c | 11 +++++------
1 files changed, 5 insertions(+), 6 deletions(-)


===================================================================



diff -Nru a/drivers/input/serio/serio.c b/drivers/input/serio/serio.c
--- a/drivers/input/serio/serio.c 2004-06-18 03:15:15 -05:00
+++ b/drivers/input/serio/serio.c 2004-06-18 03:15:15 -05:00
@@ -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);
}

2004-06-18 08:52:10

by Dmitry Torokhov

[permalink] [raw]
Subject: [PATCH 5/11] serio renames 2


===================================================================


[email protected], 2004-06-17 18:20:45-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

Signed-off-by: Dmitry Torokhov <[email protected]>


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/98kbd.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 ++++----
24 files changed, 144 insertions(+), 144 deletions(-)


===================================================================



diff -Nru a/drivers/input/joystick/iforce/iforce-main.c b/drivers/input/joystick/iforce/iforce-main.c
--- a/drivers/input/joystick/iforce/iforce-main.c 2004-06-18 03:15:51 -05:00
+++ b/drivers/input/joystick/iforce/iforce-main.c 2004-06-18 03:15:51 -05:00
@@ -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
}

diff -Nru a/drivers/input/joystick/iforce/iforce-serio.c b/drivers/input/joystick/iforce/iforce-serio.c
--- a/drivers/input/joystick/iforce/iforce-serio.c 2004-06-18 03:15:51 -05:00
+++ b/drivers/input/joystick/iforce/iforce-serio.c 2004-06-18 03:15:51 -05:00
@@ -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,
diff -Nru a/drivers/input/joystick/iforce/iforce.h b/drivers/input/joystick/iforce/iforce.h
--- a/drivers/input/joystick/iforce/iforce.h 2004-06-18 03:15:51 -05:00
+++ b/drivers/input/joystick/iforce/iforce.h 2004-06-18 03:15:51 -05:00
@@ -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;
diff -Nru a/drivers/input/joystick/magellan.c b/drivers/input/joystick/magellan.c
--- a/drivers/input/joystick/magellan.c 2004-06-18 03:15:51 -05:00
+++ b/drivers/input/joystick/magellan.c 2004-06-18 03:15:51 -05:00
@@ -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);
diff -Nru a/drivers/input/joystick/spaceball.c b/drivers/input/joystick/spaceball.c
--- a/drivers/input/joystick/spaceball.c 2004-06-18 03:15:51 -05:00
+++ b/drivers/input/joystick/spaceball.c 2004-06-18 03:15:51 -05:00
@@ -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);
diff -Nru a/drivers/input/joystick/spaceorb.c b/drivers/input/joystick/spaceorb.c
--- a/drivers/input/joystick/spaceorb.c 2004-06-18 03:15:51 -05:00
+++ b/drivers/input/joystick/spaceorb.c 2004-06-18 03:15:51 -05:00
@@ -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);
diff -Nru a/drivers/input/joystick/stinger.c b/drivers/input/joystick/stinger.c
--- a/drivers/input/joystick/stinger.c 2004-06-18 03:15:51 -05:00
+++ b/drivers/input/joystick/stinger.c 2004-06-18 03:15:51 -05:00
@@ -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);
diff -Nru a/drivers/input/joystick/twidjoy.c b/drivers/input/joystick/twidjoy.c
--- a/drivers/input/joystick/twidjoy.c 2004-06-18 03:15:51 -05:00
+++ b/drivers/input/joystick/twidjoy.c 2004-06-18 03:15:51 -05:00
@@ -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);
diff -Nru a/drivers/input/joystick/warrior.c b/drivers/input/joystick/warrior.c
--- a/drivers/input/joystick/warrior.c 2004-06-18 03:15:51 -05:00
+++ b/drivers/input/joystick/warrior.c 2004-06-18 03:15:51 -05:00
@@ -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);
diff -Nru a/drivers/input/keyboard/98kbd.c b/drivers/input/keyboard/98kbd.c
--- a/drivers/input/keyboard/98kbd.c 2004-06-18 03:15:51 -05:00
+++ b/drivers/input/keyboard/98kbd.c 2004-06-18 03:15:51 -05:00
@@ -309,7 +309,7 @@
return -1;
}

-void kbd98_connect(struct serio *serio, struct serio_dev *dev)
+void kbd98_connect(struct serio *serio, struct serio_driver *drv)
{
struct kbd98 *kbd98;
int i;
@@ -337,7 +337,7 @@

serio->private = kbd98;

- if (serio_open(serio, dev)) {
+ if (serio_open(serio, drv)) {
kfree(kbd98);
return;
}
@@ -370,7 +370,7 @@
kfree(kbd98);
}

-struct serio_dev kbd98_dev = {
+struct serio_driver kbd98_drv = {
.interrupt = kbd98_interrupt,
.connect = kbd98_connect,
.disconnect = kbd98_disconnect
@@ -378,13 +378,13 @@

int __init kbd98_init(void)
{
- serio_register_device(&kbd98_dev);
+ serio_register_driver(&kbd98_drv);
return 0;
}

void __exit kbd98_exit(void)
{
- serio_unregister_device(&kbd98_dev);
+ serio_unregister_driver(&kbd98_drv);
}

module_init(kbd98_init);
diff -Nru a/drivers/input/keyboard/atkbd.c b/drivers/input/keyboard/atkbd.c
--- a/drivers/input/keyboard/atkbd.c 2004-06-18 03:15:51 -05:00
+++ b/drivers/input/keyboard/atkbd.c 2004-06-18 03:15:51 -05:00
@@ -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);
diff -Nru a/drivers/input/keyboard/lkkbd.c b/drivers/input/keyboard/lkkbd.c
--- a/drivers/input/keyboard/lkkbd.c 2004-06-18 03:15:51 -05:00
+++ b/drivers/input/keyboard/lkkbd.c 2004-06-18 03:15:51 -05:00
@@ -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 __exit
lkkbd_exit (void)
{
- serio_unregister_device (&lkkbd_dev);
+ serio_unregister_driver(&lkkbd_drv);
}

module_init (lkkbd_init);
diff -Nru a/drivers/input/keyboard/newtonkbd.c b/drivers/input/keyboard/newtonkbd.c
--- a/drivers/input/keyboard/newtonkbd.c 2004-06-18 03:15:51 -05:00
+++ b/drivers/input/keyboard/newtonkbd.c 2004-06-18 03:15:51 -05:00
@@ -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);
diff -Nru a/drivers/input/keyboard/sunkbd.c b/drivers/input/keyboard/sunkbd.c
--- a/drivers/input/keyboard/sunkbd.c 2004-06-18 03:15:51 -05:00
+++ b/drivers/input/keyboard/sunkbd.c 2004-06-18 03:15:51 -05:00
@@ -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);
diff -Nru a/drivers/input/keyboard/xtkbd.c b/drivers/input/keyboard/xtkbd.c
--- a/drivers/input/keyboard/xtkbd.c 2004-06-18 03:15:51 -05:00
+++ b/drivers/input/keyboard/xtkbd.c 2004-06-18 03:15:51 -05:00
@@ -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);
diff -Nru a/drivers/input/mouse/psmouse-base.c b/drivers/input/mouse/psmouse-base.c
--- a/drivers/input/mouse/psmouse-base.c 2004-06-18 03:15:51 -05:00
+++ b/drivers/input/mouse/psmouse-base.c 2004-06-18 03:15:51 -05:00
@@ -696,7 +696,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;

@@ -718,7 +718,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;
@@ -771,9 +771,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;
}
@@ -806,7 +806,7 @@
}


-static struct serio_dev psmouse_dev = {
+static struct serio_driver psmouse_drv = {
.interrupt = psmouse_interrupt,
.connect = psmouse_connect,
.reconnect = psmouse_reconnect,
@@ -831,13 +831,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);
diff -Nru a/drivers/input/mouse/sermouse.c b/drivers/input/mouse/sermouse.c
--- a/drivers/input/mouse/sermouse.c 2004-06-18 03:15:51 -05:00
+++ b/drivers/input/mouse/sermouse.c 2004-06-18 03:15:51 -05:00
@@ -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);
diff -Nru a/drivers/input/mouse/synaptics.c b/drivers/input/mouse/synaptics.c
--- a/drivers/input/mouse/synaptics.c 2004-06-18 03:15:51 -05:00
+++ b/drivers/input/mouse/synaptics.c 2004-06-18 03:15:51 -05:00
@@ -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);
diff -Nru a/drivers/input/mouse/vsxxxaa.c b/drivers/input/mouse/vsxxxaa.c
--- a/drivers/input/mouse/vsxxxaa.c 2004-06-18 03:15:51 -05:00
+++ b/drivers/input/mouse/vsxxxaa.c 2004-06-18 03:15:51 -05:00
@@ -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 __exit
vsxxxaa_exit (void)
{
- serio_unregister_device (&vsxxxaa_dev);
+ serio_unregister_driver(&vsxxxaa_drv);
}

module_init (vsxxxaa_init);
diff -Nru a/drivers/input/serio/serio.c b/drivers/input/serio/serio.c
--- a/drivers/input/serio/serio.c 2004-06-18 03:15:51 -05:00
+++ b/drivers/input/serio/serio.c 2004-06-18 03:15:51 -05:00
@@ -48,27 +48,27 @@
EXPORT_SYMBOL(serio_unregister_port);
EXPORT_SYMBOL(serio_unregister_port_delayed);
EXPORT_SYMBOL(__serio_unregister_port);
-EXPORT_SYMBOL(serio_register_device);
-EXPORT_SYMBOL(serio_unregister_device);
+EXPORT_SYMBOL(serio_register_driver);
+EXPORT_SYMBOL(serio_unregister_driver);
EXPORT_SYMBOL(serio_open);
EXPORT_SYMBOL(serio_close);
EXPORT_SYMBOL(serio_rescan);
EXPORT_SYMBOL(serio_reconnect);

-static DECLARE_MUTEX(serio_sem); /* protects serio_list and serio_dev_list */
+static DECLARE_MUTEX(serio_sem); /* protects serio_list and serio_diriver_list */
static LIST_HEAD(serio_list);
-static LIST_HEAD(serio_dev_list);
+static LIST_HEAD(serio_driver_list);

-/* serio_find_dev() must be called with serio_sem down. */
+/* serio_find_driver() must be called with serio_sem down. */

-static void serio_find_dev(struct serio *serio)
+static void serio_find_driver(struct serio *serio)
{
- struct serio_dev *dev;
+ struct serio_driver *drv;

- list_for_each_entry(dev, &serio_dev_list, node) {
- if (serio->dev)
+ list_for_each_entry(drv, &serio_driver_list, node) {
+ if (serio->drv)
break;
- dev->connect(serio, dev);
+ drv->connect(serio, drv);
}
}

@@ -153,15 +153,15 @@
break;

case SERIO_RECONNECT :
- if (event->serio->dev && event->serio->dev->reconnect)
- if (event->serio->dev->reconnect(event->serio) == 0)
+ if (event->serio->drv && event->serio->drv->reconnect)
+ if (event->serio->drv->reconnect(event->serio) == 0)
break;
/* reconnect failed - fall through to rescan */

case SERIO_RESCAN :
- if (event->serio->dev)
- event->serio->dev->disconnect(event->serio);
- serio_find_dev(event->serio);
+ if (event->serio->drv)
+ event->serio->drv->disconnect(event->serio);
+ serio_find_driver(event->serio);
break;
default:
break;
@@ -252,7 +252,7 @@
{
spin_lock_init(&serio->lock);
list_add_tail(&serio->node, &serio_list);
- serio_find_dev(serio);
+ serio_find_driver(serio);
}

void serio_unregister_port(struct serio *serio)
@@ -281,58 +281,58 @@
{
serio_remove_pending_events(serio);
list_del_init(&serio->node);
- if (serio->dev)
- serio->dev->disconnect(serio);
+ if (serio->drv)
+ serio->drv->disconnect(serio);
}

/*
- * Serio device operations
+ * Serio driver operations
*/

-void serio_register_device(struct serio_dev *dev)
+void serio_register_driver(struct serio_driver *drv)
{
struct serio *serio;
down(&serio_sem);
- list_add_tail(&dev->node, &serio_dev_list);
+ list_add_tail(&drv->node, &serio_driver_list);
list_for_each_entry(serio, &serio_list, node)
- if (!serio->dev)
- dev->connect(serio, dev);
+ if (!serio->drv)
+ drv->connect(serio, drv);
up(&serio_sem);
}

-void serio_unregister_device(struct serio_dev *dev)
+void serio_unregister_driver(struct serio_driver *drv)
{
struct serio *serio;

down(&serio_sem);
- list_del_init(&dev->node);
+ list_del_init(&drv->node);

list_for_each_entry(serio, &serio_list, node) {
- if (serio->dev == dev)
- dev->disconnect(serio);
- serio_find_dev(serio);
+ if (serio->drv == drv)
+ drv->disconnect(serio);
+ serio_find_driver(serio);
}
up(&serio_sem);
}

-/* called from serio_dev->connect/disconnect methods under serio_sem */
-int serio_open(struct serio *serio, struct serio_dev *dev)
+/* called from serio_driver->connect/disconnect methods under serio_sem */
+int serio_open(struct serio *serio, struct serio_driver *drv)
{
unsigned long flags;

spin_lock_irqsave(&serio->lock, flags);
- serio->dev = dev;
+ serio->drv = drv;
spin_unlock_irqrestore(&serio->lock, flags);
if (serio->open && serio->open(serio)) {
spin_lock_irqsave(&serio->lock, flags);
- serio->dev = NULL;
+ serio->drv = NULL;
spin_unlock_irqrestore(&serio->lock, flags);
return -1;
}
return 0;
}

-/* called from serio_dev->connect/disconnect methods under serio_sem */
+/* called from serio_driver->connect/disconnect methods under serio_sem */
void serio_close(struct serio *serio)
{
unsigned long flags;
@@ -340,7 +340,7 @@
if (serio->close)
serio->close(serio);
spin_lock_irqsave(&serio->lock, flags);
- serio->dev = NULL;
+ serio->drv = NULL;
spin_unlock_irqrestore(&serio->lock, flags);
}

@@ -352,8 +352,8 @@

spin_lock_irqsave(&serio->lock, flags);

- if (likely(serio->dev)) {
- ret = serio->dev->interrupt(serio, data, dfl, regs);
+ if (likely(serio->drv)) {
+ ret = serio->drv->interrupt(serio, data, dfl, regs);
} else {
if (!dfl) {
if ((serio->type != SERIO_8042 &&
diff -Nru a/drivers/input/serio/serport.c b/drivers/input/serio/serport.c
--- a/drivers/input/serio/serport.c 2004-06-18 03:15:51 -05:00
+++ b/drivers/input/serio/serport.c 2004-06-18 03:15:51 -05:00
@@ -170,7 +170,7 @@
{
struct serport *sp = (struct serport *) tty->disc_data;

- serio_dev_write_wakeup(&sp->serio);
+ serio_drv_write_wakeup(&sp->serio);
}

/*
diff -Nru a/drivers/input/touchscreen/gunze.c b/drivers/input/touchscreen/gunze.c
--- a/drivers/input/touchscreen/gunze.c 2004-06-18 03:15:51 -05:00
+++ b/drivers/input/touchscreen/gunze.c 2004-06-18 03:15:51 -05:00
@@ -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);
diff -Nru a/drivers/input/touchscreen/h3600_ts_input.c b/drivers/input/touchscreen/h3600_ts_input.c
--- a/drivers/input/touchscreen/h3600_ts_input.c 2004-06-18 03:15:51 -05:00
+++ b/drivers/input/touchscreen/h3600_ts_input.c 2004-06-18 03:15:51 -05:00
@@ -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);
diff -Nru a/include/linux/serio.h b/include/linux/serio.h
--- a/include/linux/serio.h 2004-06-18 03:15:51 -05:00
+++ b/include/linux/serio.h 2004-06-18 03:15:51 -05:00
@@ -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

2004-06-18 08:57:25

by Dmitry Torokhov

[permalink] [raw]
Subject: [PATCH 6/11] serio dynamic allocation


===================================================================


[email protected], 2004-06-17 22:57:39-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.

Signed-off-by: Dmitry Torokhov <[email protected]>


drivers/input/mouse/psmouse-base.c | 12 +-
drivers/input/mouse/psmouse.h | 3
drivers/input/mouse/synaptics.c | 33 +++--
drivers/input/serio/98kbd-io.c | 76 ++++++-------
drivers/input/serio/ambakmi.c | 39 +++---
drivers/input/serio/ct82c710.c | 62 +++++-----
drivers/input/serio/gscps2.c | 53 +++++----
drivers/input/serio/i8042.c | 216 ++++++++++++++++++++-----------------
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 +++----
include/linux/serio.h | 5
18 files changed, 524 insertions(+), 353 deletions(-)


===================================================================



diff -Nru a/drivers/input/mouse/psmouse-base.c b/drivers/input/mouse/psmouse-base.c
--- a/drivers/input/mouse/psmouse-base.c 2004-06-18 03:16:29 -05:00
+++ b/drivers/input/mouse/psmouse-base.c 2004-06-18 03:16:29 -05:00
@@ -677,7 +677,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;
}
@@ -758,8 +758,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);
}
@@ -793,9 +793,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);
}
diff -Nru a/drivers/input/mouse/psmouse.h b/drivers/input/mouse/psmouse.h
--- a/drivers/input/mouse/psmouse.h 2004-06-18 03:16:29 -05:00
+++ b/drivers/input/mouse/psmouse.h 2004-06-18 03:16:29 -05:00
@@ -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);
diff -Nru a/drivers/input/mouse/synaptics.c b/drivers/input/mouse/synaptics.c
--- a/drivers/input/mouse/synaptics.c 2004-06-18 03:16:29 -05:00
+++ b/drivers/input/mouse/synaptics.c 2004-06-18 03:16:29 -05:00
@@ -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);

diff -Nru a/drivers/input/serio/98kbd-io.c b/drivers/input/serio/98kbd-io.c
--- a/drivers/input/serio/98kbd-io.c 2004-06-18 03:16:29 -05:00
+++ b/drivers/input/serio/98kbd-io.c 2004-06-18 03:16:29 -05:00
@@ -27,12 +27,6 @@
MODULE_LICENSE("GPL");

/*
- * Names.
- */
-
-#define KBD98_PHYS_DESC "isa0041/serio0"
-
-/*
* IRQs.
*/

@@ -47,11 +41,27 @@
#define KBD98_DATA_REG 0x41

spinlock_t kbd98io_lock = SPIN_LOCK_UNLOCKED;
+static struct serio *kbd98_port;
+
+
+/*
+ * kbd98io_interrupt() is the most important function in this driver -
+ * it handles the interrupts from keyboard, and sends incoming bytes
+ * to the upper layers.
+ */

-static struct serio kbd98_port;
-extern struct pt_regs *kbd_pt_regs;
+static irqreturn_t kbd98io_interrupt(int irq, void *dev_id, struct pt_regs *regs)
+{
+ unsigned long flags;
+ unsigned char data;

-static irqreturn_t kbd98io_interrupt(int irq, void *dev_id, struct pt_regs *regs);
+ spin_lock_irqsave(&kbd98io_lock, flags);
+ data = inb(KBD98_DATA_REG);
+ spin_unlock_irqrestore(&kbd98io_lock, flags);
+
+ serio_interrupt(kbd98_port, data, 0, regs);
+ return IRQ_HANDLED;
+}

/*
* kbd98_flush() flushes all data that may be in the keyboard buffers
@@ -123,42 +133,34 @@
}

/*
- * Structures for registering the devices in the serio.c module.
+ * Allocate and initialize serio structure for subsequent registration
+ * with serio core.
*/

-static struct serio kbd98_port =
+static struct serio * __init kbd98io_allocate_port(void)
{
- .type = SERIO_PC9800,
- .write = kbd98_write,
- .open = kbd98_open,
- .close = kbd98_close,
- .name = "PC-9801 Kbd Port",
- .phys = KBD98_PHYS_DESC,
-};
-
-/*
- * kbd98io_interrupt() is the most important function in this driver -
- * it handles the interrupts from keyboard, and sends incoming bytes
- * to the upper layers.
- */
+ struct serio *serio;

-static irqreturn_t kbd98io_interrupt(int irq, void *dev_id, struct pt_regs *regs)
-{
- unsigned long flags;
- unsigned char data;
-
- spin_lock_irqsave(&kbd98io_lock, flags);
-
- data = inb(KBD98_DATA_REG);
- spin_unlock_irqrestore(&kbd98io_lock, flags);
- serio_interrupt(&kbd98_port, data, 0, regs);
+ serio = kmalloc(sizeof(struct serio), GFP_KERNEL);
+ if (serio) {
+ memset(serio, 0, sizeof(struct serio));
+ serio->type = SERIO_PC9800;
+ serio->write = kbd98_write;
+ serio->open = kbd98_open;
+ serio->close = kbd98_close;
+ strlcpy(serio->name, "PC-9801 Kbd Port", sizeof(serio->name));
+ strlcpy(serio->phys, "isa0041/serio0", sizeof(serio->phys));
+ }

- return IRQ_HANDLED;
+ return serio;
}

int __init kbd98io_init(void)
{
- serio_register_port(&kbd98_port);
+ if (!(kbd98_port = kbd98io_allocate_port()))
+ return -ENOMEM;
+
+ serio_register_port(kbd98_port);

printk(KERN_INFO "serio: PC-9801 %s port at %#lx,%#lx irq %d\n",
"KBD",
@@ -171,7 +173,7 @@

void __exit kbd98io_exit(void)
{
- serio_unregister_port(&kbd98_port);
+ serio_unregister_port(kbd98_port);
}

module_init(kbd98io_init);
diff -Nru a/drivers/input/serio/ambakmi.c b/drivers/input/serio/ambakmi.c
--- a/drivers/input/serio/ambakmi.c 2004-06-18 03:16:29 -05:00
+++ b/drivers/input/serio/ambakmi.c 2004-06-18 03:16:29 -05:00
@@ -27,7 +27,7 @@
#define KMI_BASE (kmi->base)

struct amba_kmi_port {
- struct serio io;
+ struct serio *io;
struct amba_kmi_port *next;
unsigned char *base;
unsigned int irq;
@@ -42,7 +42,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;
}
@@ -96,6 +96,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);
@@ -103,37 +104,41 @@
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;
}

- kmi->irq = dev->irq[0];
- kmi->divisor = 24 / 8 - 1;
+ kmi->irq = dev->irq[0];
+ kmi->divisor = 24 / 8 - 1;

amba_set_drvdata(dev, kmi);

- serio_register_port(&kmi->io);
+ serio_register_port(kmi->io);
return 0;

out:
kfree(kmi);
+ kfree(io);
amba_release_regions(dev);
return ret;
}
@@ -144,7 +149,7 @@

amba_set_drvdata(dev, NULL);

- serio_unregister_port(&kmi->io);
+ serio_unregister_port(kmi->io);
iounmap(kmi->base);
kfree(kmi);
amba_release_regions(dev);
@@ -156,7 +161,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;
}
@@ -186,7 +191,7 @@

static void __exit amba_kmi_exit(void)
{
- return amba_driver_unregister(&ambakmi_driver);
+ amba_driver_unregister(&ambakmi_driver);
}

module_init(amba_kmi_init);
diff -Nru a/drivers/input/serio/ct82c710.c b/drivers/input/serio/ct82c710.c
--- a/drivers/input/serio/ct82c710.c 2004-06-18 03:16:29 -05:00
+++ b/drivers/input/serio/ct82c710.c 2004-06-18 03:16:29 -05:00
@@ -43,9 +43,6 @@
MODULE_DESCRIPTION("82C710 C&T mouse port chip driver");
MODULE_LICENSE("GPL");

-static char ct82c710_name[] = "C&T 82c710 mouse port";
-static char ct82c710_phys[16];
-
/*
* ct82c710 interface
*/
@@ -61,10 +58,20 @@

#define CT82C710_IRQ 12

+static struct serio *ct82c710_port;
static int ct82c710_data;
static int ct82c710_status;

-static irqreturn_t ct82c710_interrupt(int cpl, void *dev_id, struct pt_regs * regs);
+
+/*
+ * Interrupt handler for the 82C710 mouse port. A character
+ * is waiting in the 82C710.
+ */
+
+static irqreturn_t ct82c710_interrupt(int cpl, void *dev_id, struct pt_regs * regs)
+{
+ return serio_interrupt(ct82c710_port, inb(ct82c710_data), 0, regs);
+}

/*
* Wait for device to send output char and flush any input char.
@@ -139,26 +146,6 @@
return 0;
}

-static struct serio ct82c710_port =
-{
- .type = SERIO_8042,
- .name = ct82c710_name,
- .phys = ct82c710_phys,
- .write = ct82c710_write,
- .open = ct82c710_open,
- .close = ct82c710_close,
-};
-
-/*
- * Interrupt handler for the 82C710 mouse port. A character
- * is waiting in the 82C710.
- */
-
-static irqreturn_t ct82c710_interrupt(int cpl, void *dev_id, struct pt_regs * regs)
-{
- return serio_interrupt(&ct82c710_port, inb(ct82c710_data), 0, regs);
-}
-
/*
* See if we can find a 82C710 device. Read mouse address.
*/
@@ -183,6 +170,24 @@
return 0;
}

+static struct serio * __init ct82c710_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->open = ct82c710_open;
+ serio->close = ct82c710_close;
+ serio->write = ct82c710_write;
+ strlcpy(serio->name, "C&T 82c710 mouse port", sizeof(serio->name));
+ snprintf(serio->phys, sizeof(serio->phys), "isa%04x/serio0", ct82c710_data);
+ }
+
+ return serio;
+}
+
int __init ct82c710_init(void)
{
if (ct82c710_probe())
@@ -191,9 +196,12 @@
if (request_region(ct82c710_data, 2, "ct82c710"))
return -EBUSY;

- sprintf(ct82c710_phys, "isa%04x/serio0", ct82c710_data);
+ if (!(ct82c710_port = ct82c710_allocate_port())) {
+ release_region(ct82c710_data, 2);
+ return -ENOMEM;
+ }

- serio_register_port(&ct82c710_port);
+ serio_register_port(ct82c710_port);

printk(KERN_INFO "serio: C&T 82c710 mouse port at %#x irq %d\n",
ct82c710_data, CT82C710_IRQ);
@@ -203,7 +211,7 @@

void __exit ct82c710_exit(void)
{
- serio_unregister_port(&ct82c710_port);
+ serio_unregister_port(ct82c710_port);
release_region(ct82c710_data, 2);
}

diff -Nru a/drivers/input/serio/gscps2.c b/drivers/input/serio/gscps2.c
--- a/drivers/input/serio/gscps2.c 2004-06-18 03:16:29 -05:00
+++ b/drivers/input/serio/gscps2.c 2004-06-18 03:16:29 -05:00
@@ -91,7 +91,7 @@
struct gscps2port {
struct list_head node;
struct parisc_device *padev;
- struct serio port;
+ struct serio *port;
spinlock_t lock;
char *addr;
u8 act, append; /* position in buffer[] */
@@ -100,7 +100,6 @@
u8 str;
} buffer[BUFFER_SIZE+1];
int id;
- char name[32];
};

/*
@@ -272,7 +271,7 @@
rxflags = ((status & GSC_STAT_TERR) ? SERIO_TIMEOUT : 0 ) |
((status & GSC_STAT_PERR) ? SERIO_PARITY : 0 );

- serio_interrupt(&ps2port->port, data, rxflags, regs);
+ serio_interrupt(ps2port->port, data, rxflags, regs);

} /* while() */

@@ -344,6 +343,7 @@
static int __init gscps2_probe(struct parisc_device *dev)
{
struct gscps2port *ps2port;
+ struct serio *serio;
unsigned long hpa = dev->hpa;
int ret;

@@ -355,34 +355,44 @@
hpa += GSC_DINO_OFFSET;

ps2port = kmalloc(sizeof(struct gscps2port), GFP_KERNEL);
- if (!ps2port)
- return -ENOMEM;
+ serio = kmalloc(sizeof(struct serio), GFP_KERNEL);
+ if (!ps2port || !serio) {
+ ret = -ENOMEM;
+ goto fail_nomem;
+ }

dev_set_drvdata(&dev->dev, ps2port);

memset(ps2port, 0, sizeof(struct gscps2port));
+ memset(serio, 0, sizeof(struct serio));
+ ps2port->port = serio;
ps2port->padev = dev;
ps2port->addr = ioremap(hpa, GSC_STATUS + 4);
spin_lock_init(&ps2port->lock);

gscps2_reset(ps2port);
- ps2port->id = readb(ps2port->addr+GSC_ID) & 0x0f;
- snprintf(ps2port->name, sizeof(ps2port->name)-1, "%s %s",
- gscps2_serio_port.name,
- (ps2port->id == GSC_ID_KEYBOARD) ? "keyboard" : "mouse" );
-
- memcpy(&ps2port->port, &gscps2_serio_port, sizeof(gscps2_serio_port));
- ps2port->port.port_data = ps2port;
- ps2port->port.name = ps2port->name;
- ps2port->port.phys = dev->dev.bus_id;
+ ps2port->id = readb(ps2port->addr + GSC_ID) & 0x0f;
+
+ snprintf(serio->name, sizeof(serio->name), "GSC PS/2 %s",
+ (ps2port->id == GSC_ID_KEYBOARD) ? "keyboard" : "mouse");
+ strlcpy(serio->phys, dev->dev.bus_id, sizeof(serio->phys));
+ serio->idbus = BUS_GSC;
+ serio->idvendor = PCI_VENDOR_ID_HP;
+ serio->idproduct = 0x0001;
+ serio->idversion = 0x0010;
+ serio->type = SERIO_8042;
+ serio->write = gscps2_write;
+ serio->open = gscps2_open;
+ serio->close = gscps2_close;
+ serio->port_data = ps2port;

list_add_tail(&ps2port->node, &ps2port_list);

ret = -EBUSY;
- if (request_irq(dev->irq, gscps2_interrupt, SA_SHIRQ, ps2port->name, ps2port))
+ if (request_irq(dev->irq, gscps2_interrupt, SA_SHIRQ, ps2port->port->name, ps2port))
goto fail_miserably;

- if ( (ps2port->id != GSC_ID_KEYBOARD) && (ps2port->id != GSC_ID_MOUSE) ) {
+ if (ps2port->id != GSC_ID_KEYBOARD && ps2port->id != GSC_ID_MOUSE) {
printk(KERN_WARNING PFX "Unsupported PS/2 port at 0x%08lx (id=%d) ignored\n",
hpa, ps2port->id);
ret = -ENODEV;
@@ -395,12 +405,12 @@
#endif

printk(KERN_INFO "serio: %s port at 0x%p irq %d @ %s\n",
- ps2port->name,
+ ps2port->port->name,
ps2port->addr,
ps2port->padev->irq,
- ps2port->port.phys);
+ ps2port->port->phys);

- serio_register_port(&ps2port->port);
+ serio_register_port(ps2port->port);

return 0;

@@ -411,7 +421,10 @@
list_del(&ps2port->node);
iounmap(ps2port->addr);
release_mem_region(dev->hpa, GSC_STATUS + 4);
+
+fail_nomem:
kfree(ps2port);
+ kfree(serio);
return ret;
}

@@ -424,7 +437,7 @@
{
struct gscps2port *ps2port = dev_get_drvdata(&dev->dev);

- serio_unregister_port(&ps2port->port);
+ serio_unregister_port(ps2port->port);
free_irq(dev->irq, ps2port);
gscps2_flush(ps2port);
list_del(&ps2port->node);
diff -Nru a/drivers/input/serio/i8042.c b/drivers/input/serio/i8042.c
--- a/drivers/input/serio/i8042.c 2004-06-18 03:16:29 -05:00
+++ b/drivers/input/serio/i8042.c 2004-06-18 03:16:29 -05:00
@@ -24,6 +24,9 @@

#include <asm/io.h>

+#undef DEBUG
+#include "i8042.h"
+
MODULE_AUTHOR("Vojtech Pavlik <[email protected]>");
MODULE_DESCRIPTION("i8042 keyboard and mouse controller driver");
MODULE_LICENSE("GPL");
@@ -63,9 +66,6 @@
__obsolete_setup("i8042_direct");
__obsolete_setup("i8042_dumbkbd");

-#undef DEBUG
-#include "i8042.h"
-
spinlock_t i8042_lock = SPIN_LOCK_UNLOCKED;

struct i8042_values {
@@ -74,19 +74,37 @@
unsigned char irqen;
unsigned char exists;
signed char mux;
- unsigned char *name;
- unsigned char *phys;
+ char name[8];
};

-static struct serio i8042_kbd_port;
-static struct serio i8042_aux_port;
+static struct i8042_values i8042_kbd_values = {
+ .irq = I8042_KBD_IRQ,
+ .disable = I8042_CTR_KBDDIS,
+ .irqen = I8042_CTR_KBDINT,
+ .mux = -1,
+ .name = "KBD",
+};
+
+static struct i8042_values i8042_aux_values = {
+ .irq = I8042_AUX_IRQ,
+ .disable = I8042_CTR_AUXDIS,
+ .irqen = I8042_CTR_AUXINT,
+ .mux = -1,
+ .name = "AUX",
+};
+
+static struct i8042_values i8042_mux_values[I8042_NUM_MUX_PORTS];
+
+static struct serio *i8042_kbd_port;
+static struct serio *i8042_aux_port;
+static struct serio *i8042_mux_port[I8042_NUM_MUX_PORTS];
static unsigned char i8042_initial_ctr;
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;
-struct timer_list i8042_timer;
+static struct timer_list i8042_timer;

/*
* Shared IRQ's require a device pointer, but this driver doesn't support
@@ -336,52 +354,6 @@
}

/*
- * Structures for registering the devices in the serio.c module.
- */
-
-static struct i8042_values i8042_kbd_values = {
- .irqen = I8042_CTR_KBDINT,
- .disable = I8042_CTR_KBDDIS,
- .name = "KBD",
- .mux = -1,
-};
-
-static struct serio i8042_kbd_port =
-{
- .type = SERIO_8042_XL,
- .write = i8042_kbd_write,
- .open = i8042_open,
- .close = i8042_close,
- .port_data = &i8042_kbd_values,
- .name = "i8042 Kbd Port",
- .phys = I8042_KBD_PHYS_DESC,
-};
-
-static struct i8042_values i8042_aux_values = {
- .irqen = I8042_CTR_AUXINT,
- .disable = I8042_CTR_AUXDIS,
- .name = "AUX",
- .mux = -1,
-};
-
-static struct serio i8042_aux_port =
-{
- .type = SERIO_8042,
- .write = i8042_aux_write,
- .open = i8042_open,
- .close = i8042_close,
- .port_data = &i8042_aux_values,
- .name = "i8042 Aux Port",
- .phys = I8042_AUX_PHYS_DESC,
-};
-
-static struct i8042_values i8042_mux_values[4];
-static struct serio i8042_mux_port[4];
-static char i8042_mux_names[4][32];
-static char i8042_mux_short[4][16];
-static char i8042_mux_phys[4][32];
-
-/*
* i8042_interrupt() is the most important function in this driver -
* it handles the interrupts from the i8042, and sends incoming bytes
* to the upper layers.
@@ -427,7 +399,7 @@
dfl & SERIO_PARITY ? ", bad parity" : "",
dfl & SERIO_TIMEOUT ? ", timeout" : "");

- serio_interrupt(i8042_mux_port + ((str >> 6) & 3), data, dfl, regs);
+ serio_interrupt(i8042_mux_port[(str >> 6) & 3], data, dfl, regs);

goto irq_ret;
}
@@ -438,14 +410,14 @@
dfl & SERIO_TIMEOUT ? ", timeout" : "");

if (i8042_aux_values.exists && (str & I8042_STR_AUXDATA)) {
- serio_interrupt(&i8042_aux_port, data, dfl, regs);
+ serio_interrupt(i8042_aux_port, data, dfl, regs);
goto irq_ret;
}

if (!i8042_kbd_values.exists)
goto irq_ret;

- serio_interrupt(&i8042_kbd_port, data, dfl, regs);
+ serio_interrupt(i8042_kbd_port, data, dfl, regs);

irq_ret:
ret = 1;
@@ -638,8 +610,10 @@
* registers it, and reports to the user.
*/

-static int __init i8042_port_register(struct i8042_values *values, struct serio *port)
+static int __init i8042_port_register(struct serio *port)
{
+ struct i8042_values *values = port->port_data;
+
values->exists = 1;

i8042_ctr &= ~values->disable;
@@ -747,10 +721,8 @@
* BIOSes.
*/

- if (i8042_direct) {
+ if (i8042_direct)
i8042_ctr &= ~I8042_CTR_XLATE;
- i8042_kbd_port.type = SERIO_8042;
- }

/*
* Write CTR back.
@@ -804,14 +776,14 @@
*/

if (i8042_kbd_values.exists)
- serio_cleanup(&i8042_kbd_port);
+ serio_cleanup(i8042_kbd_port);

if (i8042_aux_values.exists)
- serio_cleanup(&i8042_aux_port);
+ serio_cleanup(i8042_aux_port);

- for (i = 0; i < 4; i++)
+ for (i = 0; i < I8042_NUM_MUX_PORTS; i++)
if (i8042_mux_values[i].exists)
- serio_cleanup(i8042_mux_port + i);
+ serio_cleanup(i8042_mux_port[i]);

i8042_controller_reset();
}
@@ -853,15 +825,15 @@
* Reconnect anything that was connected to the ports.
*/

- if (i8042_kbd_values.exists && i8042_activate_port(&i8042_kbd_port) == 0)
- serio_reconnect(&i8042_kbd_port);
+ if (i8042_kbd_values.exists && i8042_activate_port(i8042_kbd_port) == 0)
+ serio_reconnect(i8042_kbd_port);

- if (i8042_aux_values.exists && i8042_activate_port(&i8042_aux_port) == 0)
- serio_reconnect(&i8042_aux_port);
+ if (i8042_aux_values.exists && i8042_activate_port(i8042_aux_port) == 0)
+ serio_reconnect(i8042_aux_port);

- for (i = 0; i < 4; i++)
- if (i8042_mux_values[i].exists && i8042_activate_port(i8042_mux_port + i) == 0)
- serio_reconnect(i8042_mux_port + i);
+ for (i = 0; i < I8042_NUM_MUX_PORTS; i++)
+ if (i8042_mux_values[i].exists && i8042_activate_port(i8042_mux_port[i]) == 0)
+ serio_reconnect(i8042_mux_port[i]);
/*
* Restart timer (for polling "stuck" data)
*/
@@ -931,18 +903,66 @@
return 0;
}

-static void __init i8042_init_mux_values(struct i8042_values *values, struct serio *port, int index)
+static struct serio * __init i8042_allocate_kbd_port(void)
+{
+ struct serio *serio;
+
+ serio = kmalloc(sizeof(struct serio), GFP_KERNEL);
+ if (serio) {
+ memset(serio, 0, sizeof(struct serio));
+ serio->type = i8042_direct ? SERIO_8042 : SERIO_8042_XL,
+ serio->write = i8042_dumbkbd ? NULL : i8042_kbd_write,
+ serio->open = i8042_open,
+ serio->close = i8042_close,
+ serio->port_data = &i8042_kbd_values,
+ strlcpy(serio->name, "i8042 Kbd Port", sizeof(serio->name));
+ strlcpy(serio->phys, I8042_KBD_PHYS_DESC, sizeof(serio->phys));
+ }
+
+ return serio;
+}
+
+static struct serio * __init i8042_allocate_aux_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 = i8042_aux_write;
+ serio->open = i8042_open;
+ serio->close = i8042_close;
+ serio->port_data = &i8042_aux_values,
+ strlcpy(serio->name, "i8042 Aux Port", sizeof(serio->name));
+ strlcpy(serio->phys, I8042_AUX_PHYS_DESC, sizeof(serio->phys));
+ }
+
+ return serio;
+}
+
+static struct serio * __init i8042_allocate_mux_port(int index)
{
- memcpy(port, &i8042_aux_port, sizeof(struct serio));
- memcpy(values, &i8042_aux_values, sizeof(struct i8042_values));
- sprintf(i8042_mux_names[index], "i8042 Aux-%d Port", index);
- sprintf(i8042_mux_phys[index], I8042_MUX_PHYS_DESC, index + 1);
- sprintf(i8042_mux_short[index], "AUX%d", index);
- port->name = i8042_mux_names[index];
- port->phys = i8042_mux_phys[index];
- port->port_data = values;
- values->name = i8042_mux_short[index];
- values->mux = index;
+ struct serio *serio;
+ struct i8042_values *values = &i8042_mux_values[index];
+
+ serio = kmalloc(sizeof(struct serio), GFP_KERNEL);
+ if (serio) {
+ *values = i8042_aux_values;
+ snprintf(values->name, sizeof(values->name), "AUX%d", index);
+ values->mux = index;
+
+ memset(serio, 0, sizeof(struct serio));
+ serio->type = SERIO_8042;
+ serio->write = i8042_aux_write;
+ serio->open = i8042_open;
+ serio->close = i8042_close;
+ serio->port_data = values;
+ snprintf(serio->name, sizeof(serio->name), "i8042 Aux-%d Port", index);
+ snprintf(serio->phys, sizeof(serio->phys), I8042_MUX_PHYS_DESC, index + 1);
+ }
+
+ return serio;
}

int __init i8042_init(void)
@@ -963,9 +983,6 @@
if (i8042_controller_init())
return -ENODEV;

- if (i8042_dumbkbd)
- i8042_kbd_port.write = NULL;
-
#ifdef __i386__
if (i8042_dmi_noloop) {
printk(KERN_INFO "i8042.c: AUX LoopBack command disabled by DMI.\n");
@@ -975,15 +992,21 @@

if (!i8042_noaux && !i8042_check_aux(&i8042_aux_values)) {
if (!i8042_nomux && !i8042_check_mux(&i8042_aux_values))
- for (i = 0; i < 4; i++) {
- i8042_init_mux_values(i8042_mux_values + i, i8042_mux_port + i, i);
- i8042_port_register(i8042_mux_values + i, i8042_mux_port + i);
+ for (i = 0; i < I8042_NUM_MUX_PORTS; i++) {
+ i8042_mux_port[i] = i8042_allocate_mux_port(i);
+ if (i8042_mux_port[i])
+ i8042_port_register(i8042_mux_port[i]);
}
- else
- i8042_port_register(&i8042_aux_values, &i8042_aux_port);
+ else {
+ i8042_aux_port = i8042_allocate_aux_port();
+ if (i8042_aux_port)
+ i8042_port_register(i8042_aux_port);
+ }
}

- i8042_port_register(&i8042_kbd_values, &i8042_kbd_port);
+ i8042_kbd_port = i8042_allocate_kbd_port();
+ if (i8042_kbd_port)
+ i8042_port_register(i8042_kbd_port);

mod_timer(&i8042_timer, jiffies + I8042_POLL_PERIOD);

@@ -1018,14 +1041,15 @@
i8042_controller_cleanup();

if (i8042_kbd_values.exists)
- serio_unregister_port(&i8042_kbd_port);
+ serio_unregister_port(i8042_kbd_port);

if (i8042_aux_values.exists)
- serio_unregister_port(&i8042_aux_port);
+ serio_unregister_port(i8042_aux_port);

- for (i = 0; i < 4; i++)
+ for (i = 0; i < I8042_NUM_MUX_PORTS; i++)
if (i8042_mux_values[i].exists)
- serio_unregister_port(i8042_mux_port + i);
+ serio_unregister_port(i8042_mux_port[i]);
+
del_timer_sync(&i8042_timer);

i8042_platform_exit();
diff -Nru a/drivers/input/serio/i8042.h b/drivers/input/serio/i8042.h
--- a/drivers/input/serio/i8042.h 2004-06-18 03:16:29 -05:00
+++ b/drivers/input/serio/i8042.h 2004-06-18 03:16:29 -05:00
@@ -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.
*/

diff -Nru a/drivers/input/serio/maceps2.c b/drivers/input/serio/maceps2.c
--- a/drivers/input/serio/maceps2.c 2004-06-18 03:16:29 -05:00
+++ b/drivers/input/serio/maceps2.c 2004-06-18 03:16:29 -05:00
@@ -46,12 +46,14 @@
#define PS2_CONTROL_RX_CLOCK_ENABLE BIT(4) /* pause reception if set to 0 */
#define PS2_CONTROL_RESET BIT(5) /* reset */

-
struct maceps2_data {
struct mace_ps2port *port;
int irq;
};

+static struct maceps2_data port_data[2];
+static struct serio *maceps2_port[2];
+
static int maceps2_write(struct serio *dev, unsigned char val)
{
struct mace_ps2port *port = ((struct maceps2_data *)dev->port_data)->port;
@@ -68,8 +70,7 @@
return -1;
}

-static irqreturn_t maceps2_interrupt(int irq, void *dev_id,
- struct pt_regs *regs)
+static irqreturn_t maceps2_interrupt(int irq, void *dev_id, struct pt_regs *regs)
{
struct serio *dev = dev_id;
struct mace_ps2port *port = ((struct maceps2_data *)dev->port_data)->port;
@@ -114,46 +115,52 @@
free_irq(data->irq, dev);
}

-static struct maceps2_data port0_data, port1_data;

-static struct serio maceps2_port0 =
+static struct serio * __init maceps2_allocate_port(int idx)
{
- .type = SERIO_8042,
- .open = maceps2_open,
- .close = maceps2_close,
- .write = maceps2_write,
- .name = "MACE PS/2 port0",
- .phys = "mace/serio0",
- .port_data = &port0_data,
-};
+ struct serio *serio;
+
+ 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;
+ 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];
+ }
+
+ return serio;
+}

-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",
- .port_data = &port1_data,
-};

static int __init maceps2_init(void)
{
- port0_data.port = &mace->perif.ps2.keyb;
- port0_data.irq = MACEISA_KEYB_IRQ;
- port1_data.port = &mace->perif.ps2.mouse;
- port1_data.irq = MACEISA_MOUSE_IRQ;
- serio_register_port(&maceps2_port0);
- serio_register_port(&maceps2_port1);
+ port_data[0].port = &mace->perif.ps2.keyb;
+ port_data[0].irq = MACEISA_KEYB_IRQ;
+ port_data[1].port = &mace->perif.ps2.mouse;
+ port_data[1].irq = MACEISA_MOUSE_IRQ;
+
+ maceps2_port[0] = maceps2_allocate_port(0);
+ maceps2_port[1] = maceps2_allocate_port(1);
+ if (!maceps2_port[0] || !maceps2_port[1]) {
+ kfree(maceps2_port[0]);
+ kfree(maceps2_port[1]);
+ return -ENOMEM;
+ }
+
+ serio_register_port(maceps2_port[0]);
+ serio_register_port(maceps2_port[1]);

return 0;
}

static void __exit maceps2_exit(void)
{
- serio_unregister_port(&maceps2_port0);
- serio_unregister_port(&maceps2_port1);
+ serio_unregister_port(maceps2_port[0]);
+ serio_unregister_port(maceps2_port[1]);
}

module_init(maceps2_init);
diff -Nru a/drivers/input/serio/parkbd.c b/drivers/input/serio/parkbd.c
--- a/drivers/input/serio/parkbd.c 2004-06-18 03:16:29 -05:00
+++ b/drivers/input/serio/parkbd.c 2004-06-18 03:16:29 -05:00
@@ -53,9 +53,7 @@
static unsigned long parkbd_start;

static struct pardevice *parkbd_dev;
-
-static char parkbd_name[] = "PARKBD AT/XT keyboard adapter";
-static char parkbd_phys[32];
+static struct serio *parkbd_port;

static int parkbd_readlines(void)
{
@@ -86,13 +84,6 @@
return 0;
}

-static struct serio parkbd_port =
-{
- .write = parkbd_write,
- .name = parkbd_name,
- .phys = parkbd_phys,
-};
-
static void parkbd_interrupt(int irq, void *dev_id, struct pt_regs *regs)
{

@@ -125,7 +116,7 @@
parkbd_buffer |= (parkbd_readlines() >> 1) << parkbd_counter++;

if (parkbd_counter == parkbd_mode + 10)
- serio_interrupt(&parkbd_port, (parkbd_buffer >> (2 - parkbd_mode)) & 0xff, 0, regs);
+ serio_interrupt(parkbd_port, (parkbd_buffer >> (2 - parkbd_mode)) & 0xff, 0, regs);
}

parkbd_last = jiffies;
@@ -163,16 +154,38 @@
return 0;
}

+static struct serio * __init parkbd_allocate_serio(void)
+{
+ struct serio *serio;
+
+ serio = kmalloc(sizeof(struct serio), GFP_KERNEL);
+ if (serio) {
+ serio->type = parkbd_mode;
+ serio->write = parkbd_write,
+ strlcpy(serio->name, "PARKBD AT/XT keyboard adapter", sizeof(serio->name));
+ snprintf(serio->phys, sizeof(serio->phys), "%s/serio0", parkbd_dev->port->name);
+ }
+
+ return serio;
+}

int __init parkbd_init(void)
{
- if (parkbd_getport()) return -1;
- parkbd_writelines(3);
- parkbd_port.type = parkbd_mode;
+ int err;

- sprintf(parkbd_phys, "%s/serio0", parkbd_dev->port->name);
+ err = parkbd_getport();
+ if (err)
+ return err;
+
+ parkbd_port = parkbd_allocate_serio();
+ if (!parkbd_port) {
+ parport_release(parkbd_dev);
+ return -ENOMEM;
+ }
+
+ parkbd_writelines(3);

- serio_register_port(&parkbd_port);
+ serio_register_port(parkbd_port);

printk(KERN_INFO "serio: PARKBD %s adapter on %s\n",
parkbd_mode ? "AT" : "XT", parkbd_dev->port->name);
@@ -183,7 +196,7 @@
void __exit parkbd_exit(void)
{
parport_release(parkbd_dev);
- serio_unregister_port(&parkbd_port);
+ serio_unregister_port(parkbd_port);
parport_unregister_device(parkbd_dev);
}

diff -Nru a/drivers/input/serio/pcips2.c b/drivers/input/serio/pcips2.c
--- a/drivers/input/serio/pcips2.c 2004-06-18 03:16:29 -05:00
+++ b/drivers/input/serio/pcips2.c 2004-06-18 03:16:29 -05:00
@@ -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);
diff -Nru a/drivers/input/serio/q40kbd.c b/drivers/input/serio/q40kbd.c
--- a/drivers/input/serio/q40kbd.c 2004-06-18 03:16:29 -05:00
+++ b/drivers/input/serio/q40kbd.c 2004-06-18 03:16:29 -05:00
@@ -47,43 +47,98 @@
MODULE_DESCRIPTION("Q40 PS/2 keyboard controller driver");
MODULE_LICENSE("GPL");

-static struct serio q40kbd_port =
-{
- .type = SERIO_8042,
- .name = "Q40 kbd port",
- .phys = "Q40",
- .write = NULL,
-};
+spinlock_t q40kbd_lock = SPIN_LOCK_UNLOCKED;
+static struct serio *q40kbd_port;

-static irqreturn_t q40kbd_interrupt(int irq, void *dev_id,
- struct pt_regs *regs)
+static irqreturn_t q40kbd_interrupt(int irq, void *dev_id, struct pt_regs *regs)
{
+ unsigned long flags;
+
+ spin_lock_irqsave(&q40kbd_lock, flags);
+
if (Q40_IRQ_KEYB_MASK & master_inb(INTERRUPT_REG))
- serio_interrupt(&q40kbd_port, master_inb(KEYCODE_REG), 0, regs);
+ serio_interrupt(q40kbd_port, master_inb(KEYCODE_REG), 0, regs);

master_outb(-1, KEYBOARD_UNLOCK_REG);
+
+ spin_unlock_irqrestore(&q40kbd_lock, flags);
+
return IRQ_HANDLED;
}

-static int __init q40kbd_init(void)
+/*
+ * q40kbd_flush() flushes all data that may be in the keyboard buffers
+ */
+
+static void q40kbd_flush(void)
{
- int maxread = 100;
+ int maxread = 100;
+ unsigned long flags;
+
+ spin_lock_irqsave(&q40kbd_lock, flags);
+
+ while (maxread-- && (Q40_IRQ_KEYB_MASK & master_inb(INTERRUPT_REG)))
+ master_inb(KEYCODE_REG);
+
+ spin_unlock_irqrestore(&q40kbd_lock, flags);
+}
+
+/*
+ * q40kbd_open() is called when a port is open by the higher layer.
+ * It allocates the interrupt and enables in in the chip.
+ */
+
+static int q40kbd_open(struct serio *port)
+{
+ q40kbd_flush();
+
+ if (request_irq(Q40_IRQ_KEYBOARD, q40kbd_interrupt, 0, "q40kbd", NULL)) {
+ printk(KERN_ERR "q40kbd.c: Can't get irq %d.\n", Q40_IRQ_KEYBOARD);
+ return -1;
+ }
+
+ /* off we go */
+ master_outb(-1, KEYBOARD_UNLOCK_REG);
+ master_outb(1, KEY_IRQ_ENABLE_REG);
+
+ return 0;
+}

+static void q40kbd_close(struct serio *port)
+{
+ master_outb(0, KEY_IRQ_ENABLE_REG);
+ master_outb(-1, KEYBOARD_UNLOCK_REG);
+ free_irq(Q40_IRQ_KEYBOARD, NULL);
+
+ q40kbd_flush();
+}
+
+static struct serio * __init q40kbd_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->open = q40kbd_open;
+ serio->close = q40kbd_close;
+ strlcpy(serio->name, "Q40 Kbd Port", sizeof(serio->name));
+ strlcpy(serio->phys, "Q40", sizeof(serio->phys));
+ }
+
+ return serio;
+}
+
+static int __init q40kbd_init(void)
+{
if (!MACH_IS_Q40)
return -EIO;

- /* allocate the IRQ */
- request_irq(Q40_IRQ_KEYBOARD, q40kbd_interrupt, 0, "q40kbd", NULL);
-
- /* flush any pending input */
- while (maxread-- && (Q40_IRQ_KEYB_MASK & master_inb(INTERRUPT_REG)))
- master_inb(KEYCODE_REG);
-
- /* off we go */
- master_outb(-1,KEYBOARD_UNLOCK_REG);
- master_outb(1,KEY_IRQ_ENABLE_REG);
+ if (!(q40kbd_port = q40kbd_allocate_port()))
+ return -ENOMEM;

- serio_register_port(&q40kbd_port);
+ serio_register_port(q40kbd_port);
printk(KERN_INFO "serio: Q40 kbd registered\n");

return 0;
@@ -91,11 +146,7 @@

static void __exit q40kbd_exit(void)
{
- master_outb(0,KEY_IRQ_ENABLE_REG);
- master_outb(-1,KEYBOARD_UNLOCK_REG);
-
- serio_unregister_port(&q40kbd_port);
- free_irq(Q40_IRQ_KEYBOARD, NULL);
+ serio_unregister_port(q40kbd_port);
}

module_init(q40kbd_init);
diff -Nru a/drivers/input/serio/rpckbd.c b/drivers/input/serio/rpckbd.c
--- a/drivers/input/serio/rpckbd.c 2004-06-18 03:16:29 -05:00
+++ b/drivers/input/serio/rpckbd.c 2004-06-18 03:16:29 -05:00
@@ -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);
diff -Nru a/drivers/input/serio/sa1111ps2.c b/drivers/input/serio/sa1111ps2.c
--- a/drivers/input/serio/sa1111ps2.c 2004-06-18 03:16:29 -05:00
+++ b/drivers/input/serio/sa1111ps2.c 2004-06-18 03:16:29 -05:00
@@ -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);
diff -Nru a/drivers/input/serio/serio.c b/drivers/input/serio/serio.c
--- a/drivers/input/serio/serio.c 2004-06-18 03:16:29 -05:00
+++ b/drivers/input/serio/serio.c 2004-06-18 03:16:29 -05:00
@@ -283,6 +283,7 @@
list_del_init(&serio->node);
if (serio->drv)
serio->drv->disconnect(serio);
+ kfree(serio);
}

/*
diff -Nru a/drivers/input/serio/serport.c b/drivers/input/serio/serport.c
--- a/drivers/input/serio/serport.c 2004-06-18 03:16:29 -05:00
+++ b/drivers/input/serio/serport.c 2004-06-18 03:16:29 -05:00
@@ -31,13 +31,10 @@
struct serport {
struct tty_struct *tty;
wait_queue_head_t wait;
- struct serio serio;
+ struct serio *serio;
unsigned long flags;
- char phys[32];
};

-char serport_name[] = "Serial port";
-
/*
* Callback functions from the serio code.
*/
@@ -52,7 +49,7 @@
{
struct serport *serport = serio->port_data;

- serport->serio.type = 0;
+ serport->serio->type = 0;
wake_up_interruptible(&serport->wait);
}

@@ -64,26 +61,30 @@
static int serport_ldisc_open(struct tty_struct *tty)
{
struct serport *serport;
+ struct serio *serio;
char name[64];

serport = kmalloc(sizeof(struct serport), GFP_KERNEL);
- if (unlikely(!serport))
+ serio = kmalloc(sizeof(struct serio), GFP_KERNEL);
+ if (unlikely(!serport || !serio)) {
+ kfree(serport);
+ kfree(serio);
return -ENOMEM;
- memset(serport, 0, sizeof(struct serport));
+ }

+ memset(serport, 0, sizeof(struct serport));
+ serport->serio = serio;
set_bit(TTY_DO_WRITE_WAKEUP, &tty->flags);
serport->tty = tty;
tty->disc_data = serport;

- snprintf(serport->phys, sizeof(serport->phys), "%s/serio0", tty_name(tty, name));
-
- serport->serio.name = serport_name;
- serport->serio.phys = serport->phys;
-
- serport->serio.type = SERIO_RS232;
- serport->serio.write = serport_serio_write;
- serport->serio.close = serport_serio_close;
- serport->serio.port_data = serport;
+ memset(serio, 0, sizeof(struct serio));
+ strlcpy(serio->name, "Serial port", sizeof(serio->name));
+ snprintf(serio->phys, sizeof(serio->phys), "%s/serio0", tty_name(tty, name));
+ serio->type = SERIO_RS232;
+ serio->write = serport_serio_write;
+ serio->close = serport_serio_close;
+ serio->port_data = serport;

init_waitqueue_head(&serport->wait);

@@ -114,7 +115,7 @@
struct serport *serport = (struct serport*) tty->disc_data;
int i;
for (i = 0; i < count; i++)
- serio_interrupt(&serport->serio, cp[i], 0, NULL);
+ serio_interrupt(serport->serio, cp[i], 0, NULL);
}

/*
@@ -142,10 +143,10 @@
if (test_and_set_bit(SERPORT_BUSY, &serport->flags))
return -EBUSY;

- serio_register_port(&serport->serio);
+ serio_register_port(serport->serio);
printk(KERN_INFO "serio: Serial port %s\n", tty_name(tty, name));
- wait_event_interruptible(serport->wait, !serport->serio.type);
- serio_unregister_port(&serport->serio);
+ wait_event_interruptible(serport->wait, !serport->serio->type);
+ serio_unregister_port(serport->serio);

clear_bit(SERPORT_BUSY, &serport->flags);

@@ -161,7 +162,7 @@
struct serport *serport = (struct serport*) tty->disc_data;

if (cmd == SPIOCSTYPE)
- return get_user(serport->serio.type, (unsigned long __user *) arg);
+ return get_user(serport->serio->type, (unsigned long __user *) arg);

return -EINVAL;
}
@@ -170,7 +171,7 @@
{
struct serport *sp = (struct serport *) tty->disc_data;

- serio_drv_write_wakeup(&sp->serio);
+ serio_drv_write_wakeup(sp->serio);
}

/*
diff -Nru a/include/linux/serio.h b/include/linux/serio.h
--- a/include/linux/serio.h 2004-06-18 03:16:29 -05:00
+++ b/include/linux/serio.h 2004-06-18 03:16:29 -05:00
@@ -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;

2004-06-18 08:58:52

by Dmitry Torokhov

[permalink] [raw]
Subject: [PATCH 7/11] serio no recursion


===================================================================


[email protected], 2004-06-18 00:09:46-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.

Signed-off-by: Dmitry Torokhov <[email protected]>


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(-)


===================================================================



diff -Nru a/drivers/input/mouse/psmouse-base.c b/drivers/input/mouse/psmouse-base.c
--- a/drivers/input/mouse/psmouse-base.c 2004-06-18 03:16:50 -05:00
+++ b/drivers/input/mouse/psmouse-base.c 2004-06-18 03:16:50 -05:00
@@ -670,16 +670,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)
@@ -698,14 +697,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));

@@ -721,14 +723,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);
@@ -757,20 +759,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) {
@@ -792,16 +810,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;
}

diff -Nru a/drivers/input/mouse/psmouse.h b/drivers/input/mouse/psmouse.h
--- a/drivers/input/mouse/psmouse.h 2004-06-18 03:16:50 -05:00
+++ b/drivers/input/mouse/psmouse.h 2004-06-18 03:16:50 -05:00
@@ -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
diff -Nru a/drivers/input/mouse/synaptics.c b/drivers/input/mouse/synaptics.c
--- a/drivers/input/mouse/synaptics.c 2004-06-18 03:16:50 -05:00
+++ b/drivers/input/mouse/synaptics.c 2004-06-18 03:16:50 -05:00
@@ -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);

diff -Nru a/drivers/input/serio/serio.c b/drivers/input/serio/serio.c
--- a/drivers/input/serio/serio.c 2004-06-18 03:16:50 -05:00
+++ b/drivers/input/serio/serio.c 2004-06-18 03:16:50 -05:00
@@ -44,10 +44,8 @@
EXPORT_SYMBOL(serio_interrupt);
EXPORT_SYMBOL(serio_register_port);
EXPORT_SYMBOL(serio_register_port_delayed);
-EXPORT_SYMBOL(__serio_register_port);
EXPORT_SYMBOL(serio_unregister_port);
EXPORT_SYMBOL(serio_unregister_port_delayed);
-EXPORT_SYMBOL(__serio_unregister_port);
EXPORT_SYMBOL(serio_register_driver);
EXPORT_SYMBOL(serio_unregister_driver);
EXPORT_SYMBOL(serio_open);
@@ -59,17 +57,28 @@
static LIST_HEAD(serio_list);
static LIST_HEAD(serio_driver_list);

-/* serio_find_driver() must be called with serio_sem down. */
+static void serio_find_driver(struct serio *serio);
+static void serio_create_port(struct serio *serio);
+static void serio_destroy_port(struct serio *serio);
+static void serio_connect_port(struct serio *serio, struct serio_driver *drv);
+static void serio_reconnect_port(struct serio *serio);
+static void serio_disconnect_port(struct serio *serio);
+
+static int serio_bind_driver(struct serio *serio, struct serio_driver *drv)
+{
+ drv->connect(serio, drv);
+
+ return serio->drv != NULL;
+}

+/* serio_find_driver() must be called with serio_sem down. */
static void serio_find_driver(struct serio *serio)
{
struct serio_driver *drv;

- list_for_each_entry(drv, &serio_driver_list, node) {
- if (serio->drv)
+ list_for_each_entry(drv, &serio_driver_list, node)
+ if (serio_bind_driver(serio, drv))
break;
- drv->connect(serio, drv);
- }
}

/*
@@ -145,23 +154,22 @@

switch (event->type) {
case SERIO_REGISTER_PORT :
- __serio_register_port(event->serio);
+ serio_create_port(event->serio);
+ serio_connect_port(event->serio, NULL);
break;

case SERIO_UNREGISTER_PORT :
- __serio_unregister_port(event->serio);
+ serio_disconnect_port(event->serio);
+ serio_destroy_port(event->serio);
break;

case SERIO_RECONNECT :
- if (event->serio->drv && event->serio->drv->reconnect)
- if (event->serio->drv->reconnect(event->serio) == 0)
- break;
- /* reconnect failed - fall through to rescan */
+ serio_reconnect_port(event->serio);
+ break;

case SERIO_RESCAN :
- if (event->serio->drv)
- event->serio->drv->disconnect(event->serio);
- serio_find_driver(event->serio);
+ serio_disconnect_port(event->serio);
+ serio_connect_port(event->serio, NULL);
break;
default:
break;
@@ -216,6 +224,118 @@
* Serio port operations
*/

+static void serio_create_port(struct serio *serio)
+{
+ spin_lock_init(&serio->lock);
+ list_add_tail(&serio->node, &serio_list);
+}
+
+/*
+ * serio_destroy_port() completes deregistration process and removes
+ * port from the system
+ */
+static void serio_destroy_port(struct serio *serio)
+{
+ struct serio_driver *drv = serio->drv;
+ unsigned long flags;
+
+ serio_remove_pending_events(serio);
+ list_del_init(&serio->node);
+
+ if (drv)
+ drv->disconnect(serio);
+
+ if (serio->parent) {
+ spin_lock_irqsave(&serio->parent->lock, flags);
+ serio->parent->child = NULL;
+ spin_unlock_irqrestore(&serio->parent->lock, flags);
+ }
+
+ kfree(serio);
+}
+
+/*
+ * serio_connect_port() tries to bind the port and possible all its
+ * children to appropriate drivers. If driver passed in the function will not
+ * try otehr drivers when binding parent port.
+ */
+static void serio_connect_port(struct serio *serio, struct serio_driver *drv)
+{
+ WARN_ON(serio->drv);
+ WARN_ON(serio->child);
+
+ if (drv)
+ serio_bind_driver(serio, drv);
+ else
+ serio_find_driver(serio);
+
+ /* Ok, now bind children, if any */
+ while (serio->child) {
+ serio = serio->child;
+
+ WARN_ON(serio->drv);
+ WARN_ON(serio->child);
+
+ serio_create_port(serio);
+
+ /*
+ * With children we just _prefer_ passed in driver,
+ * but we will try other options in case preferred
+ * is not the one
+ */
+ if (!drv || !serio_bind_driver(serio, drv))
+ serio_find_driver(serio);
+ }
+}
+
+/*
+ *
+ */
+static void serio_reconnect_port(struct serio *serio)
+{
+ do {
+ if (!serio->drv || !serio->drv->reconnect || serio->drv->reconnect(serio)) {
+ serio_disconnect_port(serio);
+ serio_connect_port(serio, NULL);
+ /* Ok, old children are now gone, we are done */
+ break;
+ }
+ serio = serio->child;
+ } while (serio);
+}
+
+/*
+ * serio_disconnect_port() unbinds a port from its driver. As a side effect
+ * all child ports are unbound and destroyed.
+ */
+static void serio_disconnect_port(struct serio *serio)
+{
+ struct serio_driver *drv = serio->drv;
+ struct serio *s;
+
+ if (serio->child) {
+ /*
+ * Children ports should be disconnected and destroyed
+ * first, staring with the leaf one, since we don't want
+ * to do recursion
+ */
+ do {
+ s = serio->child;
+ } while (s->child);
+
+ while (s != serio) {
+ s = s->parent;
+ serio_destroy_port(s->child);
+ }
+ }
+
+ /*
+ * Ok, no children left, now disconnect this port
+ */
+ if (drv)
+ drv->disconnect(serio);
+}
+
void serio_rescan(struct serio *serio)
{
serio_queue_event(serio, SERIO_RESCAN);
@@ -229,7 +349,8 @@
void serio_register_port(struct serio *serio)
{
down(&serio_sem);
- __serio_register_port(serio);
+ serio_create_port(serio);
+ serio_connect_port(serio, NULL);
up(&serio_sem);
}

@@ -243,22 +364,11 @@
serio_queue_event(serio, SERIO_REGISTER_PORT);
}

-/*
- * Should only be called directly if serio_sem has already been taken,
- * for example when unregistering a serio from other input device's
- * connect() function.
- */
-void __serio_register_port(struct serio *serio)
-{
- spin_lock_init(&serio->lock);
- list_add_tail(&serio->node, &serio_list);
- serio_find_driver(serio);
-}
-
void serio_unregister_port(struct serio *serio)
{
down(&serio_sem);
- __serio_unregister_port(serio);
+ serio_disconnect_port(serio);
+ serio_destroy_port(serio);
up(&serio_sem);
}

@@ -272,32 +382,33 @@
serio_queue_event(serio, SERIO_UNREGISTER_PORT);
}

-/*
- * Should only be called directly if serio_sem has already been taken,
- * for example when unregistering a serio from other input device's
- * disconnect() function.
- */
-void __serio_unregister_port(struct serio *serio)
-{
- serio_remove_pending_events(serio);
- list_del_init(&serio->node);
- if (serio->drv)
- serio->drv->disconnect(serio);
- kfree(serio);
-}

/*
* Serio driver operations
*/

+
void serio_register_driver(struct serio_driver *drv)
{
struct serio *serio;
+
down(&serio_sem);
+
list_add_tail(&drv->node, &serio_driver_list);
- list_for_each_entry(serio, &serio_list, node)
- if (!serio->drv)
- drv->connect(serio, drv);
+
+start_over:
+ list_for_each_entry(serio, &serio_list, node) {
+ if (!serio->drv) {
+ serio_connect_port(serio, drv);
+ /*
+ * if new child appeared then the list is changed,
+ * we need to start over
+ */
+ if (serio->child)
+ goto start_over;
+ }
+ }
+
up(&serio_sem);
}

@@ -306,13 +417,19 @@
struct serio *serio;

down(&serio_sem);
+
list_del_init(&drv->node);

+start_over:
list_for_each_entry(serio, &serio_list, node) {
- if (serio->drv == drv)
- drv->disconnect(serio);
- serio_find_driver(serio);
+ if (serio->drv == drv) {
+ serio_disconnect_port(serio);
+ serio_connect_port(serio, NULL);
+ /* we could've deleted some ports, restart */
+ goto start_over;
+ }
}
+
up(&serio_sem);
}

diff -Nru a/include/linux/serio.h b/include/linux/serio.h
--- a/include/linux/serio.h 2004-06-18 03:16:50 -05:00
+++ b/include/linux/serio.h 2004-06-18 03:16:50 -05:00
@@ -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);

2004-06-18 09:02:30

by Dmitry Torokhov

[permalink] [raw]
Subject: [PATCH 8/11] serio sysfs integration


===================================================================


[email protected], 2004-06-18 01:28:22-05:00, [email protected]
Input: serio sysfs integration

Signed-off-by: Dmitry Torokhov <[email protected]>


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/98kbd.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 ++
21 files changed, 271 insertions(+), 87 deletions(-)


===================================================================



diff -Nru a/drivers/Makefile b/drivers/Makefile
--- a/drivers/Makefile 2004-06-18 03:17:09 -05:00
+++ b/drivers/Makefile 2004-06-18 03:17:09 -05:00
@@ -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/
diff -Nru a/drivers/input/joystick/iforce/iforce-serio.c b/drivers/input/joystick/iforce/iforce-serio.c
--- a/drivers/input/joystick/iforce/iforce-serio.c 2004-06-18 03:17:09 -05:00
+++ b/drivers/input/joystick/iforce/iforce-serio.c 2004-06-18 03:17:09 -05:00
@@ -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,
};
diff -Nru a/drivers/input/joystick/magellan.c b/drivers/input/joystick/magellan.c
--- a/drivers/input/joystick/magellan.c 2004-06-18 03:17:09 -05:00
+++ b/drivers/input/joystick/magellan.c 2004-06-18 03:17:09 -05:00
@@ -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,
};

/*
diff -Nru a/drivers/input/joystick/spaceball.c b/drivers/input/joystick/spaceball.c
--- a/drivers/input/joystick/spaceball.c 2004-06-18 03:17:09 -05:00
+++ b/drivers/input/joystick/spaceball.c 2004-06-18 03:17:09 -05:00
@@ -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,
};

/*
diff -Nru a/drivers/input/joystick/spaceorb.c b/drivers/input/joystick/spaceorb.c
--- a/drivers/input/joystick/spaceorb.c 2004-06-18 03:17:09 -05:00
+++ b/drivers/input/joystick/spaceorb.c 2004-06-18 03:17:09 -05:00
@@ -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,
};

/*
diff -Nru a/drivers/input/joystick/stinger.c b/drivers/input/joystick/stinger.c
--- a/drivers/input/joystick/stinger.c 2004-06-18 03:17:09 -05:00
+++ b/drivers/input/joystick/stinger.c 2004-06-18 03:17:09 -05:00
@@ -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,
};

/*
diff -Nru a/drivers/input/joystick/twidjoy.c b/drivers/input/joystick/twidjoy.c
--- a/drivers/input/joystick/twidjoy.c 2004-06-18 03:17:09 -05:00
+++ b/drivers/input/joystick/twidjoy.c 2004-06-18 03:17:09 -05:00
@@ -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,
};

/*
diff -Nru a/drivers/input/joystick/warrior.c b/drivers/input/joystick/warrior.c
--- a/drivers/input/joystick/warrior.c 2004-06-18 03:17:09 -05:00
+++ b/drivers/input/joystick/warrior.c 2004-06-18 03:17:09 -05:00
@@ -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,
};

/*
diff -Nru a/drivers/input/keyboard/98kbd.c b/drivers/input/keyboard/98kbd.c
--- a/drivers/input/keyboard/98kbd.c 2004-06-18 03:17:09 -05:00
+++ b/drivers/input/keyboard/98kbd.c 2004-06-18 03:17:09 -05:00
@@ -36,8 +36,10 @@
#include <asm/io.h>
#include <asm/pc9800.h>

+#define DRIVER_DESC "PC-9801 keyboard driver";
+
MODULE_AUTHOR("Osamu Tomita <[email protected]>");
-MODULE_DESCRIPTION("PC-9801 keyboard driver");
+MODULE_DESCRIPTION(DRIVER_DESC);
MODULE_LICENSE("GPL");

#define KBD98_KEY 0x7f
@@ -371,9 +373,13 @@
}

struct serio_driver kbd98_drv = {
- .interrupt = kbd98_interrupt,
- .connect = kbd98_connect,
- .disconnect = kbd98_disconnect
+ .driver = {
+ .name = "98kbd",
+ },
+ .description = DRIVER_DESC,
+ .interrupt = kbd98_interrupt,
+ .connect = kbd98_connect,
+ .disconnect = kbd98_disconnect,
};

int __init kbd98_init(void)
diff -Nru a/drivers/input/keyboard/atkbd.c b/drivers/input/keyboard/atkbd.c
--- a/drivers/input/keyboard/atkbd.c 2004-06-18 03:17:09 -05:00
+++ b/drivers/input/keyboard/atkbd.c 2004-06-18 03:17:09 -05:00
@@ -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)
diff -Nru a/drivers/input/keyboard/lkkbd.c b/drivers/input/keyboard/lkkbd.c
--- a/drivers/input/keyboard/lkkbd.c 2004-06-18 03:17:09 -05:00
+++ b/drivers/input/keyboard/lkkbd.c 2004-06-18 03:17:09 -05:00
@@ -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,
};

/*
diff -Nru a/drivers/input/keyboard/newtonkbd.c b/drivers/input/keyboard/newtonkbd.c
--- a/drivers/input/keyboard/newtonkbd.c 2004-06-18 03:17:09 -05:00
+++ b/drivers/input/keyboard/newtonkbd.c 2004-06-18 03:17:09 -05:00
@@ -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)
diff -Nru a/drivers/input/keyboard/sunkbd.c b/drivers/input/keyboard/sunkbd.c
--- a/drivers/input/keyboard/sunkbd.c 2004-06-18 03:17:09 -05:00
+++ b/drivers/input/keyboard/sunkbd.c 2004-06-18 03:17:09 -05:00
@@ -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,
};

/*
diff -Nru a/drivers/input/keyboard/xtkbd.c b/drivers/input/keyboard/xtkbd.c
--- a/drivers/input/keyboard/xtkbd.c 2004-06-18 03:17:09 -05:00
+++ b/drivers/input/keyboard/xtkbd.c 2004-06-18 03:17:09 -05:00
@@ -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)
diff -Nru a/drivers/input/mouse/psmouse-base.c b/drivers/input/mouse/psmouse-base.c
--- a/drivers/input/mouse/psmouse-base.c 2004-06-18 03:17:09 -05:00
+++ b/drivers/input/mouse/psmouse-base.c 2004-06-18 03:17:09 -05:00
@@ -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;
@@ -828,11 +830,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)
diff -Nru a/drivers/input/mouse/sermouse.c b/drivers/input/mouse/sermouse.c
--- a/drivers/input/mouse/sermouse.c 2004-06-18 03:17:09 -05:00
+++ b/drivers/input/mouse/sermouse.c 2004-06-18 03:17:09 -05:00
@@ -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)
diff -Nru a/drivers/input/mouse/vsxxxaa.c b/drivers/input/mouse/vsxxxaa.c
--- a/drivers/input/mouse/vsxxxaa.c 2004-06-18 03:17:09 -05:00
+++ b/drivers/input/mouse/vsxxxaa.c 2004-06-18 03:17:09 -05:00
@@ -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
diff -Nru a/drivers/input/serio/serio.c b/drivers/input/serio/serio.c
--- a/drivers/input/serio/serio.c 2004-06-18 03:17:09 -05:00
+++ b/drivers/input/serio/serio.c 2004-06-18 03:17:09 -05:00
@@ -56,6 +56,11 @@
static DECLARE_MUTEX(serio_sem); /* protects serio_list and serio_diriver_list */
static LIST_HEAD(serio_list);
static LIST_HEAD(serio_driver_list);
+static unsigned int serio_no;
+
+struct bus_type serio_bus = {
+ .name = "serio",
+};

static void serio_find_driver(struct serio *serio);
static void serio_create_port(struct serio *serio);
@@ -66,9 +71,19 @@

static int serio_bind_driver(struct serio *serio, struct serio_driver *drv)
{
+ get_driver(&drv->driver);
+
drv->connect(serio, drv);
+ if (serio->drv) {
+ down_write(&serio_bus.subsys.rwsem);
+ serio->dev.driver = &drv->driver;
+ device_bind_driver(&serio->dev);
+ up_write(&serio_bus.subsys.rwsem);
+ return 1;
+ }

- return serio->drv != NULL;
+ put_driver(&drv->driver);
+ return 0;
}

/* serio_find_driver() must be called with serio_sem down. */
@@ -224,10 +239,49 @@
* Serio port operations
*/

+static ssize_t serio_show_description(struct device *dev, char *buf)
+{
+ 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)
+{
+ return sprintf(buf, "%s\n", dev->driver ? dev->driver->name : "(none)");
+}
+static DEVICE_ATTR(driver, S_IRUGO, serio_show_driver, NULL);
+
+static void serio_release_port(struct device *dev)
+{
+ struct serio *serio = to_serio_port(dev);
+
+ kfree(serio);
+ module_put(THIS_MODULE);
+}
+
static void serio_create_port(struct serio *serio)
{
+ try_module_get(THIS_MODULE);
+
spin_lock_init(&serio->lock);
list_add_tail(&serio->node, &serio_list);
+ snprintf(serio->dev.bus_id, sizeof(serio->dev.bus_id), "serio%d", serio_no++);
+ serio->dev.bus = &serio_bus;
+ serio->dev.release = serio_release_port;
+ 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);
}

/*
@@ -242,8 +296,13 @@
serio_remove_pending_events(serio);
list_del_init(&serio->node);

- if (drv)
+ if (drv) {
drv->disconnect(serio);
+ down_write(&serio_bus.subsys.rwsem);
+ device_release_driver(&serio->dev);
+ up_write(&serio_bus.subsys.rwsem);
+ put_driver(&drv->driver);
+ }

if (serio->parent) {
spin_lock_irqsave(&serio->parent->lock, flags);
@@ -251,7 +310,7 @@
spin_unlock_irqrestore(&serio->parent->lock, flags);
}

- kfree(serio);
+ device_unregister(&serio->dev);
}

/*
@@ -332,8 +391,13 @@
/*
* Ok, no children left, now disconnect this port
*/
- if (drv)
+ if (drv) {
drv->disconnect(serio);
+ down_write(&serio_bus.subsys.rwsem);
+ device_release_driver(&serio->dev);
+ up_write(&serio_bus.subsys.rwsem);
+ put_driver(&drv->driver);
+ }
}

void serio_rescan(struct serio *serio)
@@ -387,6 +451,12 @@
* Serio driver operations
*/

+static ssize_t serio_driver_show_description(struct device_driver *drv, char *buf)
+{
+ 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);

void serio_register_driver(struct serio_driver *drv)
{
@@ -396,6 +466,10 @@

list_add_tail(&drv->node, &serio_driver_list);

+ drv->driver.bus = &serio_bus;
+ driver_register(&drv->driver);
+ driver_create_file(&drv->driver, &driver_attr_description);
+
start_over:
list_for_each_entry(serio, &serio_list, node) {
if (!serio->drv) {
@@ -430,6 +504,8 @@
}
}

+ driver_unregister(&drv->driver);
+
up(&serio_sem);
}

@@ -489,22 +565,19 @@

static int __init serio_init(void)
{
- int pid;
-
- pid = kernel_thread(serio_thread, NULL, CLONE_KERNEL);
-
- if (!pid) {
+ if (!(serio_pid = kernel_thread(serio_thread, NULL, CLONE_KERNEL))) {
printk(KERN_WARNING "serio: Failed to start kseriod\n");
return -1;
}

- serio_pid = pid;
+ bus_register(&serio_bus);

return 0;
}

static void __exit serio_exit(void)
{
+ bus_unregister(&serio_bus);
kill_proc(serio_pid, SIGTERM, 1);
wait_for_completion(&serio_exited);
}
diff -Nru a/drivers/input/touchscreen/gunze.c b/drivers/input/touchscreen/gunze.c
--- a/drivers/input/touchscreen/gunze.c 2004-06-18 03:17:09 -05:00
+++ b/drivers/input/touchscreen/gunze.c 2004-06-18 03:17:09 -05:00
@@ -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,
};

/*
diff -Nru a/drivers/input/touchscreen/h3600_ts_input.c b/drivers/input/touchscreen/h3600_ts_input.c
--- a/drivers/input/touchscreen/h3600_ts_input.c 2004-06-18 03:17:09 -05:00
+++ b/drivers/input/touchscreen/h3600_ts_input.c 2004-06-18 03:17:09 -05:00
@@ -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,
};

/*
diff -Nru a/include/linux/serio.h b/include/linux/serio.h
--- a/include/linux/serio.h 2004-06-18 03:17:09 -05:00
+++ b/include/linux/serio.h 2004-06-18 03:17:09 -05:00
@@ -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);

2004-06-18 09:02:34

by Dmitry Torokhov

[permalink] [raw]
Subject: [PATCH 9/11] serio allow rebinding


===================================================================


[email protected], 2004-06-18 02:31:47-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/devices/serio1/driver

Signed-off-by: Dmitry Torokhov <[email protected]>


serio.c | 30 +++++++++++++++++++++++++++++-
1 files changed, 29 insertions(+), 1 deletion(-)


===================================================================



diff -Nru a/drivers/input/serio/serio.c b/drivers/input/serio/serio.c
--- a/drivers/input/serio/serio.c 2004-06-18 03:17:30 -05:00
+++ b/drivers/input/serio/serio.c 2004-06-18 03:17:30 -05:00
@@ -257,7 +257,35 @@
{
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;
+
+ if (!strncmp(buf, "none", count)) {
+ serio_disconnect_port(serio);
+ retval = count;
+ } else if (!(k = kset_find_obj(&serio_bus.drivers, buf))) {
+ retval = -EINVAL;
+ } else {
+ serio_disconnect_port(serio);
+ drv = container_of(k, struct device_driver, kobj);
+ serio_connect_port(serio, to_serio_driver(drv));
+ retval = count;
+ }
+
+ 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)
{

2004-06-18 09:17:30

by Dmitry Torokhov

[permalink] [raw]
Subject: [PATCH 11/11] serio_raw driver


===================================================================


[email protected], 2004-06-18 03:11:02-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

Signed-off-by: Dmitry Torokhov <[email protected]>


Kconfig | 16 ++
Makefile | 1
serio_raw.c | 390 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
3 files changed, 407 insertions(+)


===================================================================



diff -Nru a/drivers/input/serio/Kconfig b/drivers/input/serio/Kconfig
--- a/drivers/input/serio/Kconfig 2004-06-18 03:18:24 -05:00
+++ b/drivers/input/serio/Kconfig 2004-06-18 03:18:24 -05:00
@@ -140,3 +140,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.
diff -Nru a/drivers/input/serio/Makefile b/drivers/input/serio/Makefile
--- a/drivers/input/serio/Makefile 2004-06-18 03:18:24 -05:00
+++ b/drivers/input/serio/Makefile 2004-06-18 03:18:24 -05:00
@@ -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
diff -Nru a/drivers/input/serio/serio_raw.c b/drivers/input/serio/serio_raw.c
--- /dev/null Wed Dec 31 16:00:00 196900
+++ b/drivers/input/serio/serio_raw.c 2004-06-18 03:18:24 -05:00
@@ -0,0 +1,390 @@
+/*
+ * Raw serio device providing access to a raw byte stream from underlying
+ * serio port. Closely emulates behavior of pre-2.6 /dev/psaux device
+ *
+ * Copyright (c) 2004 Dmitry Torokhov
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 as published by
+ * the Free Software Foundation.
+ */
+
+#include <linux/slab.h>
+#include <linux/poll.h>
+#include <linux/module.h>
+#include <linux/serio.h>
+#include <linux/init.h>
+#include <linux/major.h>
+#include <linux/device.h>
+#include <linux/devfs_fs_kernel.h>
+#include <linux/miscdevice.h>
+#include <linux/wait.h>
+
+#define DRIVER_DESC "Raw serio driver"
+
+MODULE_AUTHOR("Dmitry Torokhov <[email protected]>");
+MODULE_DESCRIPTION(DRIVER_DESC);
+MODULE_LICENSE("GPL");
+
+#define SERIO_RAW_QUEUE_LEN 64
+struct serio_raw {
+ unsigned char queue[SERIO_RAW_QUEUE_LEN];
+ unsigned int tail, head;
+
+ char name[16];
+ unsigned int refcnt;
+ struct serio *serio;
+ struct miscdevice dev;
+ wait_queue_head_t wait;
+ struct list_head list;
+ struct list_head node;
+};
+
+struct serio_raw_list {
+ struct fasync_struct *fasync;
+ struct serio_raw *serio_raw;
+ struct list_head node;
+};
+
+static DECLARE_MUTEX(serio_raw_sem);
+static LIST_HEAD(serio_raw_list);
+static unsigned int serio_raw_no;
+
+/*********************************************************************
+ * Interface with userspace (file operations) *
+ *********************************************************************/
+
+static int serio_raw_fasync(int fd, struct file *file, int on)
+{
+ struct serio_raw_list *list = file->private_data;
+ int retval;
+
+ retval = fasync_helper(fd, file, on, &list->fasync);
+ return retval < 0 ? retval : 0;
+}
+
+static struct serio_raw *serio_raw_locate(int minor)
+{
+ struct serio_raw *serio_raw;
+
+ list_for_each_entry(serio_raw, &serio_raw_list, node) {
+ if (serio_raw->dev.minor == minor)
+ return serio_raw;
+ }
+
+ return NULL;
+}
+
+static int serio_raw_open(struct inode *inode, struct file *file)
+{
+ struct serio_raw *serio_raw;
+ struct serio_raw_list *list;
+ int retval = 0;
+
+ retval = down_interruptible(&serio_raw_sem);
+ if (retval)
+ return retval;
+
+ if (!(serio_raw = serio_raw_locate(iminor(inode)))) {
+ retval = -ENODEV;
+ goto out;
+ }
+
+ if (!serio_raw->serio) {
+ retval = -ENODEV;
+ goto out;
+ }
+
+ if (!(list = kmalloc(sizeof(struct serio_raw_list), GFP_KERNEL))) {
+ retval = -ENOMEM;
+ goto out;
+ }
+
+ memset(list, 0, sizeof(struct serio_raw_list));
+ list->serio_raw = serio_raw;
+ file->private_data = list;
+
+ serio_raw->refcnt++;
+ list_add_tail(&list->node, &serio_raw->list);
+
+out:
+ up(&serio_raw_sem);
+ return retval;
+}
+
+static int serio_raw_cleanup(struct serio_raw *serio_raw)
+{
+ if (--serio_raw->refcnt == 0) {
+ misc_deregister(&serio_raw->dev);
+ list_del_init(&serio_raw->node);
+ kfree(serio_raw);
+
+ return 1;
+ }
+
+ return 0;
+}
+
+static int serio_raw_release(struct inode *inode, struct file *file)
+{
+ struct serio_raw_list *list = file->private_data;
+ struct serio_raw *serio_raw = list->serio_raw;
+
+ down(&serio_raw_sem);
+
+ serio_raw_fasync(-1, file, 0);
+ serio_raw_cleanup(serio_raw);
+
+ up(&serio_raw_sem);
+ return 0;
+}
+
+static int serio_raw_fetch_byte(struct serio_raw *serio_raw, char *c)
+{
+ unsigned long flags;
+ int empty;
+
+ spin_lock_irqsave(&serio_raw->serio->lock, flags);
+
+ empty = serio_raw->head == serio_raw->tail;
+ if (!empty) {
+ *c = serio_raw->queue[serio_raw->tail];
+ serio_raw->tail = (serio_raw->tail + 1) % SERIO_RAW_QUEUE_LEN;
+ }
+
+ spin_unlock_irqrestore(&serio_raw->serio->lock, flags);
+
+ return !empty;
+}
+
+static ssize_t serio_raw_read(struct file *file, char *buffer, size_t count, loff_t *ppos)
+{
+ struct serio_raw_list *list = file->private_data;
+ struct serio_raw *serio_raw = list->serio_raw;
+ char c;
+ ssize_t retval = 0;
+
+ if (!serio_raw->serio)
+ return -ENODEV;
+
+ if (serio_raw->head == serio_raw->tail && (file->f_flags & O_NONBLOCK))
+ return -EAGAIN;
+
+ retval = wait_event_interruptible(list->serio_raw->wait,
+ serio_raw->head != serio_raw->tail || !serio_raw->serio);
+ if (retval)
+ return retval;
+
+ if (!serio_raw->serio)
+ return -ENODEV;
+
+ while (retval < count && serio_raw_fetch_byte(serio_raw, &c)) {
+ if (put_user(c, buffer++))
+ return -EFAULT;
+ retval++;
+ }
+
+ return retval;
+}
+
+static ssize_t serio_raw_write(struct file *file, const char *buffer, size_t count, loff_t *ppos)
+{
+ struct serio_raw_list *list = file->private_data;
+ ssize_t written = 0;
+ int retval;
+ unsigned char c;
+
+ retval = down_interruptible(&serio_raw_sem);
+ if (retval)
+ return retval;
+
+ if (!list->serio_raw->serio) {
+ retval = -ENODEV;
+ goto out;
+ }
+
+ if (count > 32)
+ count = 32;
+
+ while (count--) {
+ if (get_user(c, buffer++)) {
+ retval = -EFAULT;
+ goto out;
+ }
+ if (serio_write(list->serio_raw->serio, c)) {
+ retval = -EIO;
+ goto out;
+ }
+ written++;
+ };
+
+out:
+ up(&serio_raw_sem);
+ return written;
+}
+
+static unsigned int serio_raw_poll(struct file *file, poll_table *wait)
+{
+ struct serio_raw_list *list = file->private_data;
+
+ poll_wait(file, &list->serio_raw->wait, wait);
+
+ if (list->serio_raw->head != list->serio_raw->tail)
+ return POLLIN | POLLRDNORM;
+
+ return 0;
+}
+
+struct file_operations serio_raw_fops = {
+ .owner = THIS_MODULE,
+ .open = serio_raw_open,
+ .release = serio_raw_release,
+ .read = serio_raw_read,
+ .write = serio_raw_write,
+ .poll = serio_raw_poll,
+ .fasync = serio_raw_fasync,
+};
+
+
+/*********************************************************************
+ * Interface with serio port *
+ *********************************************************************/
+
+static irqreturn_t serio_raw_interrupt(struct serio *serio, unsigned char data,
+ unsigned int dfl, struct pt_regs *regs)
+{
+ struct serio_raw *serio_raw = serio->private;
+ struct serio_raw_list *list;
+ unsigned int head = serio_raw->head;
+
+ /* we are holding serio->lock here so we are prootected */
+ serio_raw->queue[head] = data;
+ head = (head + 1) % SERIO_RAW_QUEUE_LEN;
+ if (likely(head != serio_raw->tail)) {
+ serio_raw->head = head;
+ list_for_each_entry(list, &serio_raw->list, node)
+ kill_fasync(&list->fasync, SIGIO, POLL_IN);
+ wake_up_interruptible(&serio_raw->wait);
+ }
+
+ return IRQ_HANDLED;
+}
+
+static void serio_raw_connect(struct serio *serio, struct serio_driver *drv)
+{
+ struct serio_raw *serio_raw;
+ int err;
+
+ if ((serio->type & SERIO_TYPE) != SERIO_8042)
+ return;
+
+ if (!(serio_raw = kmalloc(sizeof(struct serio_raw), GFP_KERNEL))) {
+ printk(KERN_ERR "serio_raw.c: can't allocate memory for a device\n");
+ return;
+ }
+
+ down(&serio_raw_sem);
+
+ memset(serio_raw, 0, sizeof(struct serio_raw));
+ snprintf(serio_raw->name, sizeof(serio_raw->name), "serio_raw%d", serio_raw_no++);
+ serio_raw->refcnt = 1;
+ serio_raw->serio = serio;
+ INIT_LIST_HEAD(&serio_raw->list);
+ init_waitqueue_head(&serio_raw->wait);
+
+ serio->private = serio_raw;
+ if (serio_open(serio, drv))
+ goto out_free;
+
+ list_add_tail(&serio_raw->node, &serio_raw_list);
+
+ serio_raw->dev.minor = PSMOUSE_MINOR;
+ serio_raw->dev.name = serio_raw->name;
+ serio_raw->dev.fops = &serio_raw_fops;
+
+ err = misc_register(&serio_raw->dev);
+ if (err) {
+ serio_raw->dev.minor = MISC_DYNAMIC_MINOR;
+ err = misc_register(&serio_raw->dev);
+ }
+
+ if (err) {
+ printk(KERN_INFO "serio_raw: failed to register raw access device for %s\n",
+ serio->phys);
+ goto out_close;
+ }
+
+ printk(KERN_INFO "serio_raw: raw access enabled on %s (%s, minor %d)\n",
+ serio->phys, serio_raw->name, serio_raw->dev.minor);
+ goto out;
+
+out_close:
+ serio_close(serio);
+ list_del_init(&serio_raw->node);
+out_free:
+ serio->private = NULL;
+ kfree(serio_raw);
+out:
+ up(&serio_raw_sem);
+}
+
+static int serio_raw_reconnect(struct serio *serio)
+{
+ struct serio_raw *serio_raw = serio->private;
+ struct serio_driver *drv = serio->drv;
+
+ if (!drv || !serio_raw) {
+ printk(KERN_DEBUG "serio_raw: reconnect request, but serio is disconnected, ignoring...\n");
+ return -1;
+ }
+
+ /*
+ * Nothing needs to be done here, we just need this method to
+ * keep the same device.
+ */
+ return 0;
+}
+
+static void serio_raw_disconnect(struct serio *serio)
+{
+ struct serio_raw *serio_raw;
+
+ down(&serio_raw_sem);
+
+ serio_raw = serio->private;
+
+ serio_close(serio);
+ serio->private = NULL;
+
+ serio_raw->serio = NULL;
+ if (!serio_raw_cleanup(serio_raw))
+ wake_up_interruptible(&serio_raw->wait);
+
+ up(&serio_raw_sem);
+}
+
+static struct serio_driver serio_raw_drv = {
+ .driver = {
+ .name = "serio_raw",
+ },
+ .description = DRIVER_DESC,
+ .interrupt = serio_raw_interrupt,
+ .connect = serio_raw_connect,
+ .reconnect = serio_raw_reconnect,
+ .disconnect = serio_raw_disconnect,
+ .manual_bind = 1,
+};
+
+int __init serio_raw_init(void)
+{
+ serio_register_driver(&serio_raw_drv);
+ return 0;
+}
+
+void __exit serio_raw_exit(void)
+{
+ serio_unregister_driver(&serio_raw_drv);
+}
+
+module_init(serio_raw_init);
+module_exit(serio_raw_exit);

2004-06-18 09:02:35

by Dmitry Torokhov

[permalink] [raw]
Subject: [PATCH 10/11] serio manual bind


===================================================================


[email protected], 2004-06-18 02:59:36-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.

Signed-off-by: Dmitry Torokhov <[email protected]>


drivers/input/serio/serio.c | 9 +++++++--
include/linux/serio.h | 2 ++
2 files changed, 9 insertions(+), 2 deletions(-)


===================================================================



diff -Nru a/drivers/input/serio/serio.c b/drivers/input/serio/serio.c
--- a/drivers/input/serio/serio.c 2004-06-18 03:18:00 -05:00
+++ b/drivers/input/serio/serio.c 2004-06-18 03:18:00 -05:00
@@ -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;
}

/*
@@ -498,6 +499,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) {
@@ -511,6 +515,7 @@
}
}

+out:
up(&serio_sem);
}

diff -Nru a/include/linux/serio.h b/include/linux/serio.h
--- a/include/linux/serio.h 2004-06-18 03:18:00 -05:00
+++ b/include/linux/serio.h 2004-06-18 03:18:00 -05:00
@@ -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 *);

2004-06-18 09:25:40

by Jan-Benedict Glaw

[permalink] [raw]
Subject: Re: [PATCH 9/11] serio allow rebinding

On Fri, 2004-06-18 03:42:39 -0500, Dmitry Torokhov <[email protected]>
wrote in message <[email protected]>:
> [email protected], 2004-06-18 02:31:47-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/devices/serio1/driver
> Signed-off-by: Dmitry Torokhov <[email protected]>

I specifically like this one.

MfG, JBG

--
Jan-Benedict Glaw [email protected] . +49-172-7608481
"Eine Freie Meinung in einem Freien Kopf | Gegen Zensur | Gegen Krieg
fuer einen Freien Staat voll Freier B?rger" | im Internet! | im Irak!
ret = do_actions((curr | FREE_SPEECH) & ~(NEW_COPYRIGHT_LAW | DRM | TCPA));


Attachments:
(No filename) (857.00 B)
signature.asc (189.00 B)
Digital signature
Download all attachments

2004-06-18 09:39:56

by Andrew Morton

[permalink] [raw]
Subject: Re: [PATCH 8/11] serio sysfs integration

Dmitry Torokhov <[email protected]> wrote:
>
> Input: serio sysfs integration

What is the sysfs directory layout, and what do the chosen nodes do?

What design decisions were made when choosing that layout?

Is it so trivial that users don't need any documentation?

2004-06-18 12:50:34

by Dmitry Torokhov

[permalink] [raw]
Subject: Re: [PATCH 8/11] serio sysfs integration

On Friday 18 June 2004 04:38 am, Andrew Morton wrote:
> Dmitry Torokhov <[email protected]> wrote:
> >
> > Input: serio sysfs integration
>
> What is the sysfs directory layout, and what do the chosen nodes do?
>
> What design decisions were made when choosing that layout?
>
> Is it so trivial that users don't need any documentation?
>

I do consider it trivial for now as the only thing that user can do is
"echo" desired driver into serioX/driver to rebind it. The typical node
looks like this:

[dtor@core dtor]$ ls -la /sys/bus/serio/devices/serio0/
total 0
-r--r--r-- 1 root root 4096 Jun 17 21:49 description
-rw-r--r-- 1 root root 4096 Jun 17 21:49 detach_state
-rw-r--r-- 1 root root 0 Jun 18 02:52 driver
-r--r--r-- 1 root root 4096 Jun 17 21:49 legacy_position
drwxr-xr-x 2 root root 0 Jun 17 21:49 power
drwxr-xr-x 3 root root 0 Jun 18 02:52 serio3

description - i8042 Aux Port
driver - psmouse
legacy_position - isa0060/serio1 (take from serio's phys, can be used
to match with /proc/bus/input/devices).

Every driver will have a set of custom attributes that will be documented
on one by one basis. Btw, where would you document it? Documentation
directory entry? Something else?

--
Dmitry

[dtor@core dtor]$ ls -laR /sys/bus/serio/
/sys/bus/serio/:
total 0
drwxr-xr-x 2 root root 0 Jun 18 02:52 devices
drwxr-xr-x 5 root root 0 Jun 18 02:52 drivers

/sys/bus/serio/devices:
total 0
lrwxrwxrwx 1 root root 0 Jun 17 21:49 serio0 -> ../../../devices/serio0
lrwxrwxrwx 1 root root 0 Jun 17 21:49 serio1 -> ../../../devices/serio1
lrwxrwxrwx 1 root root 0 Jun 18 02:52 serio3 -> ../../../devices/serio0/serio3

/sys/bus/serio/drivers:
total 0
drwxr-xr-x 2 root root 0 Jun 17 21:49 atkbd
drwxr-xr-x 2 root root 0 Jun 18 02:52 psmouse
drwxr-xr-x 2 root root 0 Jun 18 02:52 serio_raw

/sys/bus/serio/drivers/atkbd:
total 0
-r--r--r-- 1 root root 4096 Jun 17 21:49 description
lrwxrwxrwx 1 root root 0 Jun 17 21:49 serio1 -> ../../../../devices/serio1

/sys/bus/serio/drivers/psmouse:
total 0
-r--r--r-- 1 root root 4096 Jun 18 02:52 description
lrwxrwxrwx 1 root root 0 Jun 18 02:52 serio0 -> ../../../../devices/serio0
lrwxrwxrwx 1 root root 0 Jun 18 02:52 serio3 -> ../../../../devices/serio0/serio3

/sys/bus/serio/drivers/serio_raw:
total 0
-r--r--r-- 1 root root 4096 Jun 18 02:50 description

2004-06-18 19:48:30

by Andrew Morton

[permalink] [raw]
Subject: Re: [PATCH 8/11] serio sysfs integration

Dmitry Torokhov <[email protected]> wrote:
>
> description - i8042 Aux Port
> driver - psmouse
> legacy_position - isa0060/serio1 (take from serio's phys, can be used
> to match with /proc/bus/input/devices).
>
> Every driver will have a set of custom attributes that will be documented
> on one by one basis. Btw, where would you document it? Documentation
> directory entry? Something else?

Conceivably one could attempt to document it via module_parm_desc in each
driver, but I presume that won't work for a host of reasons.

So yup, a succinct description in Documentation/input/ would be great.

2004-06-20 05:08:00

by Andrew Morton

[permalink] [raw]
Subject: Re: [PATCH 6/11] serio dynamic allocation

Dmitry Torokhov <[email protected]> wrote:
>
> 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.

This patch causes problems on sparc64:

drivers/input/serio/i8042-sparcio.h: In function `i8042_platform_init':
drivers/input/serio/i8042-sparcio.h:103: error: `i8042_reset' undeclared (first use in this function)
drivers/input/serio/i8042-sparcio.h:103: error: (Each undeclared identifier is reported only once
drivers/input/serio/i8042-sparcio.h:103: error: for each function it appears in.)
drivers/input/serio/i8042.c: At top level:
drivers/input/serio/i8042.c:46: error: `i8042_reset' used prior to declaration

Which will be fixed by this patch:

--- 25-sparc64/drivers/input/serio/i8042.c~input-serio-dynamic-allocation-fix 2004-06-19 21:56:11.972974984 -0700
+++ 25-sparc64-akpm/drivers/input/serio/i8042.c 2004-06-19 21:57:15.454324352 -0700
@@ -25,7 +25,6 @@
#include <asm/io.h>

#undef DEBUG
-#include "i8042.h"

MODULE_AUTHOR("Vojtech Pavlik <[email protected]>");
MODULE_DESCRIPTION("i8042 keyboard and mouse controller driver");
@@ -55,6 +54,8 @@ static unsigned int i8042_dumbkbd;
module_param_named(dumbkbd, i8042_dumbkbd, bool, 0);
MODULE_PARM_DESC(dumbkbd, "Pretend that controller can only read data from keyboard");

+#include "i8042.h"
+
extern unsigned int i8042_dmi_noloop;
static unsigned int i8042_noloop;
extern unsigned int i8042_dmi_noloop;
_


However we still have this:

drivers/input/serio/i8042.c:81: error: initializer element is not constant
drivers/input/serio/i8042.c:81: error: (near initialization for `i8042_kbd_values.irq')
drivers/input/serio/i8042.c:89: error: initializer element is not constant
drivers/input/serio/i8042.c:89: error: (near initialization for `i8042_aux_values.irq')

due to:

static struct i8042_values i8042_kbd_values = {
.irq = I8042_KBD_IRQ,


I8042_KBD_IRQ is not a constant on sparc64.

It seems that simply removing that static initialiser will fix
it up, but I assume it was added for some reason, so I'll leave
you to ponder that.

2004-06-20 05:32:11

by Dmitry Torokhov

[permalink] [raw]
Subject: Re: [PATCH 6/11] serio dynamic allocation

On Sunday 20 June 2004 12:07 am, Andrew Morton wrote:
> Dmitry Torokhov <[email protected]> wrote:
> >
>
> I8042_KBD_IRQ is not a constant on sparc64.

Yes, what you see are leftovers from me missing that fact...

>
> It seems that simply removing that static initialiser will fix
> it up, but I assume it was added for some reason, so I'll leave
> you to ponder that.
>

No, removing the initialization is the correct way to fix it. We can
only assign these values after platform init is done.

Sorry about the breakage.

--
Dmitry

2004-06-20 06:28:18

by Andrew Morton

[permalink] [raw]
Subject: Re: [PATCH 6/11] serio dynamic allocation

Dmitry Torokhov <[email protected]> wrote:
>
> >
> > It seems that simply removing that static initialiser will fix
> > it up, but I assume it was added for some reason, so I'll leave
> > you to ponder that.
> >
>
> No, removing the initialization is the correct way to fix it. We can
> only assign these values after platform init is done.

Ok..

You'll be needing this...

25-sparc64-akpm/drivers/serial/sunsu.c | 8 ++++----
25-sparc64-akpm/drivers/serial/sunzilog.c | 8 ++++----
2 files changed, 8 insertions(+), 8 deletions(-)

diff -puN drivers/serial/sunzilog.c~input-serio-renames-1-fix drivers/serial/sunzilog.c
--- 25-sparc64/drivers/serial/sunzilog.c~input-serio-renames-1-fix 2004-06-19 23:12:14.764325264 -0700
+++ 25-sparc64-akpm/drivers/serial/sunzilog.c 2004-06-19 23:15:09.411774816 -0700
@@ -1295,7 +1295,7 @@ static spinlock_t sunzilog_serio_lock =

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_write(struct s

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 int sunzilog_serio_open(struct se

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 @@ static void __init sunzilog_init_kbdms(s
#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) {
diff -puN drivers/serial/sunsu.c~input-serio-renames-1-fix drivers/serial/sunsu.c
--- 25-sparc64/drivers/serial/sunsu.c~input-serio-renames-1-fix 2004-06-19 23:12:14.780322832 -0700
+++ 25-sparc64-akpm/drivers/serial/sunsu.c 2004-06-19 23:16:11.737299896 -0700
@@ -994,7 +994,7 @@ static spinlock_t sunsu_serio_lock = SPI

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_write(struct seri

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 int sunsu_serio_open(struct serio

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 @@ static int __init sunsu_kbd_ms_init(void
#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) {
_

2004-06-20 06:29:56

by Andrew Morton

[permalink] [raw]
Subject: Re: [PATCH 6/11] serio dynamic allocation

Andrew Morton <[email protected]> wrote:
>
> You'll be needing this...

And this

25-sparc64-akpm/drivers/serial/sunsu.c | 9 ++++++---
25-sparc64-akpm/drivers/serial/sunzilog.c | 9 +++++----
2 files changed, 11 insertions(+), 7 deletions(-)

diff -puN drivers/serial/sunsu.c~input-serio-dynamic-allocation-fix-3 drivers/serial/sunsu.c
--- 25-sparc64/drivers/serial/sunsu.c~input-serio-dynamic-allocation-fix-3 2004-06-19 23:20:15.415255216 -0700
+++ 25-sparc64-akpm/drivers/serial/sunsu.c 2004-06-19 23:23:02.148907848 -0700
@@ -1316,12 +1316,15 @@ static int __init sunsu_kbd_ms_init(void
up->serio.type = SERIO_RS232;
if (up->su_type == SU_PORT_KBD) {
up->serio.type |= SERIO_SUNKBD;
- up->serio.name = "sukbd";
+ strlcpy(up->serio.name, "sukbd",
+ sizeof(up->serio.name));
} else {
up->serio.type |= (SERIO_SUN | (1 << 16));
- up->serio.name = "sums";
+ strlcpy(up->serio.name, "sums",
+ sizeof(up->serio.name));
}
- up->serio.phys = (i == 0 ? "su/serio0" : "su/serio1");
+ strlcpy(up->serio.phys, (i == 0 ? "su/serio0" : "su/serio1"),
+ sizeof(up->serio.phys));

up->serio.write = sunsu_serio_write;
up->serio.open = sunsu_serio_open;
diff -puN drivers/serial/sunzilog.c~input-serio-dynamic-allocation-fix-3 drivers/serial/sunzilog.c
--- 25-sparc64/drivers/serial/sunzilog.c~input-serio-dynamic-allocation-fix-3 2004-06-19 23:20:15.432252632 -0700
+++ 25-sparc64-akpm/drivers/serial/sunzilog.c 2004-06-19 23:24:48.002815608 -0700
@@ -1554,13 +1554,14 @@ static void __init sunzilog_init_kbdms(s
up->serio.type = SERIO_RS232;
if (channel == KEYBOARD_LINE) {
up->serio.type |= SERIO_SUNKBD;
- up->serio.name = "zskbd";
+ strlcpy(up->serio.name, "zskbd", sizeof(up->serio.name));
} else {
up->serio.type |= (SERIO_SUN | (1 << 16));
- up->serio.name = "zsms";
+ strlcpy(up->serio.name, "zsms", sizeof(up->serio.name));
}
- up->serio.phys = (channel == KEYBOARD_LINE ?
- "zs/serio0" : "zs/serio1");
+ strlcpy(up->serio.phys,
+ (channel == KEYBOARD_LINE ? "zs/serio0" : "zs/serio1"),
+ sizeof(up->serio.phys));

up->serio.write = sunzilog_serio_write;
up->serio.open = sunzilog_serio_open;
_