2004-11-24 07:14:57

by Dmitry Torokhov

[permalink] [raw]
Subject: [PATCH 0/11] New input patches

Hi Vojtech,

I have some more input patches that I'd like you to comment on.

01-atkbd-keycode-size.patch
Fix keycode table size initialization that got broken by my changes
that exported 'set' and other settings via sysfs.
setkeycodes should work again now.

02-psmouse-polling.patch
Trying to work around KVMs that suppress 0xAA 0x00 when switching
mouse off and on by periodically sending ENABLE command to the
mouse. The idea is that if KVM disconnects mouse the command will
time out or we get NAK. Next time we see data coming from the mouse
we will force reconnect. The advantages is that we can reconnect
even if mouse uses PS2++ kind of protocol.
Seems to work fine for several people.

03-serio-drvdata.patch
Remove serio->private in favor of using driver-specific data
in device structure, add serio_get_drvdata/serio_put_drvdata
to access it so serio bus code looks more like other buses.

04-twidjoy-build.patch
Make Kconfig and Makefile agree on the option name so twidjoy
can be built.

05-serio-id-match.patch
replace serio's type field with serio_id structure and
add ids table to serio drivers. This will allow splitting
initial matching and probing routines for better sysfs
integration.

06-serio-bus-cleanup.patch
make serio implementation more in line with standard
driver model implementations by removing explicit device
and driver list manipulations and introducing bus_match
function. serio_register_port is always asynchronous to
allow freely registering child ports. When deregistering
serio core still takes care of destroying children ports
first.

07-input-msecs-to-jiffies.patch
Use msecs_to_jiffies instead of homegrown ms_to_jiffies
so everything works when HZ != 1000

08-atkbd-msecs-to-jiffies.patch
Use msecs_to_jiffies instead of manually calculating
delay for Toshiba bouncing keys workaround.

09-gameport-rename1.patch
rename gameport->driver to gameport->port_data in preparation
to sysfs integration.

10-gameport-rename2.patch
more renames in serio in preparations to sysfs integration
- gameport_dev -> gameport_driver
- gameport_[un]register_device -> gameport_[un]register_driver

11-gameport-openclose-mandatory.patch
Make connect and disconnect methods mandatory for gameport
drivers since that's where gameport_{open|close} are called
from to actually bind driver to a port.

There are also patches from the previous batch that you have not pulled yet.
Please take a look. Thanks!

> 01-i8042-panicblink-cleanup.patch
> Move panicbkink parameter definition together with the rest of i8042
> module parameters, add description and entry in kernel-parameters.txt
>
> 02-serio-start-stop.patch
> Add serio start() and stop() methods to serio structure that are
> called when serio port is about to be fully registered and when
> serio port is about to be unregistered. These methods are useful
> for drivers that share interrupt among several serio ports. In this
> case interrupt can not be enabled/disabled in open/close methods
> and it is very hard to determine if interrupt shoudl be ignored or
> passed on.
>
> 03-i8042-use-start-stop.patch
> Make use of new serio start/stop methods to safely activate and
> deactivate ports. Also unify as much as possible port handling
> between KBD, AUX and MUX ports. Rename i8042_values into i8042_port.
>
> 04-serio-suppress-dup-events.patch
> Do not submit serio event into event queue if there is already one
> of the same type for the same port in front of it. Also look for
> duplicate events once event is processed. This should help with
> disconnected ports generating alot of data and consuming memory for
> events when kseriod gets behind and prevents constant rescans.
> This also allows to remove special check for 0xaa in reconnect path
> of interrupt handler known to cause problems with Toshibas keyboards.
>
> 05-evdev-buffer-size.patch
> Return -EINVAL from evdev_read when passed buffer is too small.
> Based on patch by James Lamanna.
>
> 06-ps2pp-mouse-name.patch
> Set mouse name to "Mouse" instead of leaving it NULL when using
> PS2++ protocol and don't have any other information (Wheel, Touchpad)
> about the mouse.
>
> 07-synaptics-toshiba-rate.patch
> Toshiba Satellite KBCs have trouble handling data stream coming from
> Synaptics at full rate (80 pps, 480 byte/sec) which causes keyboards
> to pause or even get stuck. Use DMI to detect Satellites and limit
> rate to 40 pps which cures keyboard.
>

--
Dmitry


2004-11-24 07:17:03

by Dmitry Torokhov

[permalink] [raw]
Subject: [PATCH 1/11] Atkbd keycodesize fix


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


[email protected], 2004-11-20 02:05:34-05:00, [email protected]
Input: atkbd - fix keycode table size initialization that got broken
by my changes that exported 'set' and other settings via sysfs.
setkeycodes should work again now.

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


atkbd.c | 8 ++++----
1 files changed, 4 insertions(+), 4 deletions(-)


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



diff -Nru a/drivers/input/keyboard/atkbd.c b/drivers/input/keyboard/atkbd.c
--- a/drivers/input/keyboard/atkbd.c 2004-11-24 01:40:49 -05:00
+++ b/drivers/input/keyboard/atkbd.c 2004-11-24 01:40:49 -05:00
@@ -757,6 +757,10 @@
set_bit(BTN_MIDDLE, atkbd->dev.keybit);
}

+ atkbd->dev.keycode = atkbd->keycode;
+ atkbd->dev.keycodesize = sizeof(unsigned char);
+ atkbd->dev.keycodemax = ARRAY_SIZE(atkbd_set2_keycode);
+
for (i = 0; i < 512; i++)
if (atkbd->keycode[i] && atkbd->keycode[i] < ATKBD_SPECIAL)
set_bit(atkbd->keycode[i], atkbd->dev.keybit);
@@ -798,10 +802,6 @@

if (atkbd->softrepeat)
atkbd->softraw = 1;
-
- atkbd->dev.keycode = atkbd->keycode;
- atkbd->dev.keycodesize = sizeof(unsigned char);
- atkbd->dev.keycodemax = ARRAY_SIZE(atkbd_set2_keycode);

serio_set_drvdata(serio, atkbd);

2004-11-24 07:17:07

by Dmitry Torokhov

[permalink] [raw]
Subject: [PATCH 2/11] Psmouse polling for KVMs


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


[email protected], 2004-11-14 02:02:02-05:00, [email protected]
Input: pmouse - periodically ping the mouse to verify that device
is still present. If there was no response assume that the
mouse was disconnected and next time data comes in force
reconnect to reinitialize the mouse. It is useful with KVM
swiches that supress new device announcements.

Pining is controlled via psmouse.ping_interval=<msec> module
parameter and through sysfs ping_interval per-device attribute.
Setting attribute to 0 disables polling (default).

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


Documentation/kernel-parameters.txt | 4 +
drivers/input/mouse/psmouse-base.c | 91 +++++++++++++++++++++++++++++++++++-
drivers/input/mouse/psmouse.h | 5 +
3 files changed, 99 insertions(+), 1 deletion(-)


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



diff -Nru a/Documentation/kernel-parameters.txt b/Documentation/kernel-parameters.txt
--- a/Documentation/kernel-parameters.txt 2004-11-24 01:44:52 -05:00
+++ b/Documentation/kernel-parameters.txt 2004-11-24 01:44:52 -05:00
@@ -1005,6 +1005,10 @@
before loading.
See Documentation/ramdisk.txt.

+ psmouse.ping_interval=
+ [HW,MOUSE] Controls how often the driver should ping
+ the mouse to verify that device is still connected.
+ Useful with KVM switches.
psmouse.proto= [HW,MOUSE] Highest PS2 mouse protocol extension to
probe for (bare|imps|exps).
psmouse.rate= [HW,MOUSE] Set desired mouse report rate, in reports
diff -Nru a/drivers/input/mouse/psmouse-base.c b/drivers/input/mouse/psmouse-base.c
--- a/drivers/input/mouse/psmouse-base.c 2004-11-24 01:44:52 -05:00
+++ b/drivers/input/mouse/psmouse-base.c 2004-11-24 01:44:52 -05:00
@@ -52,6 +52,11 @@
module_param_named(resetafter, psmouse_resetafter, uint, 0);
MODULE_PARM_DESC(resetafter, "Reset device after so many bad packets (0 = never).");

+static unsigned int psmouse_ping_interval;
+module_param_named(ping_interval, psmouse_ping_interval, uint, 0);
+MODULE_PARM_DESC(ping_interval, "Ping interval to verify presence of the device (0 to disable).");
+
+PSMOUSE_DEFINE_ATTR(ping_interval);
PSMOUSE_DEFINE_ATTR(rate);
PSMOUSE_DEFINE_ATTR(resolution);
PSMOUSE_DEFINE_ATTR(resetafter);
@@ -148,7 +153,28 @@
if (psmouse->state == PSMOUSE_IGNORE)
goto out;

- if (flags & (SERIO_PARITY|SERIO_TIMEOUT)) {
+ if (unlikely(psmouse->state == PSMOUSE_LOST_PING_ACK)) {
+ printk(KERN_INFO "psmouse: new data from %s at %s, reconnecting...\n",
+ psmouse->name, psmouse->phys);
+ psmouse->state = PSMOUSE_IGNORE;
+ serio_reconnect(serio);
+ goto out;
+ }
+
+ if (unlikely(psmouse->state == PSMOUSE_WAIT_PING_ACK)) {
+ if ((flags & (SERIO_PARITY|SERIO_TIMEOUT)) ||
+ data != PSMOUSE_RET_ACK) {
+ printk(KERN_INFO "psmouse.c: %s at %s not responding to pings\n",
+ psmouse->name, psmouse->phys);
+ psmouse->state = PSMOUSE_LOST_PING_ACK;
+ } else {
+ psmouse->state = PSMOUSE_ACTIVATED;
+ psmouse->pktcnt = 0;
+ }
+ goto out;
+ }
+
+ if (unlikely(flags & (SERIO_PARITY|SERIO_TIMEOUT))) {
if (psmouse->state == PSMOUSE_ACTIVATED)
printk(KERN_WARNING "psmouse.c: bad data from KBC -%s%s\n",
flags & SERIO_TIMEOUT ? " timeout" : "",
@@ -254,6 +280,29 @@
}


+static void psmouse_ping_device(unsigned long p)
+{
+ struct psmouse *psmouse = (struct psmouse *)p;
+
+ if (!psmouse->ping_interval || psmouse->state != PSMOUSE_ACTIVATED)
+ return;
+
+ serio_pause_rx(psmouse->ps2dev.serio);
+
+ if (time_before(jiffies, psmouse->last + msecs_to_jiffies(psmouse->ping_interval))) {
+ /* we recently had some data, just reschedule timer */
+ mod_timer(&psmouse->ping_timer, psmouse->last + msecs_to_jiffies(psmouse->ping_interval));
+ } else if (serio_write(psmouse->ps2dev.serio, PSMOUSE_CMD_ENABLE) < 0) {
+ psmouse->state = PSMOUSE_IGNORE;
+ serio_reconnect(psmouse->ps2dev.serio);
+ } else {
+ psmouse->state = PSMOUSE_WAIT_PING_ACK;
+ mod_timer(&psmouse->ping_timer, jiffies + msecs_to_jiffies(psmouse->ping_interval));
+ }
+
+ serio_continue_rx(psmouse->ps2dev.serio);
+}
+
/*
* psmouse_reset() resets the mouse into power-on state.
*/
@@ -608,6 +657,15 @@
psmouse->ps2dev.serio->phys);

psmouse_set_state(psmouse, PSMOUSE_ACTIVATED);
+
+ /*
+ * Only activate pinging on the device connected to parent port as
+ * children ports have complex write routines not suitable for
+ * calling from a tasklet. Also at least Synaptics slave responds
+ * to commands only if parent is command mode as well.
+ */
+ if (psmouse->ping_interval && !psmouse->ps2dev.serio->parent)
+ mod_timer(&psmouse->ping_timer, jiffies + msecs_to_jiffies(psmouse->ping_interval));
}


@@ -645,12 +703,16 @@
{
struct psmouse *psmouse, *parent;

+ if (!serio->parent)
+ device_remove_file(&serio->dev, &psmouse_attr_ping_interval);
device_remove_file(&serio->dev, &psmouse_attr_rate);
device_remove_file(&serio->dev, &psmouse_attr_resolution);
device_remove_file(&serio->dev, &psmouse_attr_resetafter);

psmouse = serio->private;
+
psmouse_set_state(psmouse, PSMOUSE_CMD_MODE);
+ del_timer_sync(&psmouse->ping_timer);

if (serio->parent && (serio->type & SERIO_TYPE) == SERIO_PS_PSTHRU) {
parent = serio->parent->private;
@@ -695,6 +757,9 @@
memset(psmouse, 0, sizeof(struct psmouse));

ps2_init(&psmouse->ps2dev, serio);
+ init_timer(&psmouse->ping_timer);
+ psmouse->ping_timer.data = (unsigned long)psmouse;
+ psmouse->ping_timer.function = psmouse_ping_device;
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);
@@ -716,6 +781,7 @@
goto out;
}

+ psmouse->ping_interval = psmouse_ping_interval;
psmouse->rate = psmouse_rate;
psmouse->resolution = psmouse_resolution;
psmouse->resetafter = psmouse_resetafter;
@@ -750,6 +816,8 @@
if (parent && parent->pt_activate)
parent->pt_activate(parent);

+ if (!parent)
+ device_create_file(&serio->dev, &psmouse_attr_ping_interval);
device_create_file(&serio->dev, &psmouse_attr_rate);
device_create_file(&serio->dev, &psmouse_attr_resolution);
device_create_file(&serio->dev, &psmouse_attr_resetafter);
@@ -884,6 +952,27 @@
out:
serio_unpin_driver(serio);
return retval;
+}
+
+static ssize_t psmouse_attr_show_ping_interval(struct psmouse *psmouse, char *buf)
+{
+ return sprintf(buf, "%d\n", psmouse->ping_interval);
+}
+
+static ssize_t psmouse_attr_set_ping_interval(struct psmouse *psmouse, const char *buf, size_t count)
+{
+ unsigned long value;
+ char *rest;
+
+ value = simple_strtoul(buf, &rest, 10);
+ if (*rest)
+ return -EINVAL;
+
+ del_timer_sync(&psmouse->ping_timer);
+ psmouse->ping_interval = value;
+ /* psmouse_activate will restart the timer */
+
+ return count;
}

static ssize_t psmouse_attr_show_rate(struct psmouse *psmouse, char *buf)
diff -Nru a/drivers/input/mouse/psmouse.h b/drivers/input/mouse/psmouse.h
--- a/drivers/input/mouse/psmouse.h 2004-11-24 01:44:52 -05:00
+++ b/drivers/input/mouse/psmouse.h 2004-11-24 01:44:52 -05:00
@@ -25,6 +25,8 @@
PSMOUSE_INITIALIZING,
PSMOUSE_CMD_MODE,
PSMOUSE_ACTIVATED,
+ PSMOUSE_WAIT_PING_ACK,
+ PSMOUSE_LOST_PING_ACK,
};

/* psmouse protocol handler return codes */
@@ -55,6 +57,9 @@
unsigned int resolution;
unsigned int resetafter;
unsigned int smartscroll; /* Logitech only */
+ unsigned int ping_interval;
+
+ struct timer_list ping_timer;

psmouse_ret_t (*protocol_handler)(struct psmouse *psmouse, struct pt_regs *regs);
void (*set_rate)(struct psmouse *psmouse, unsigned int rate);

2004-11-24 07:19:54

by Dmitry Torokhov

[permalink] [raw]
Subject: [PATCH 3/11] Addd serio_get/put_drvdata functions


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


[email protected], 2004-11-15 00:01:17-05:00, [email protected]
Input: remove serio->private in favor of using driver-specific data
in device structure, add serio_get_drvdata/serio_put_drvdata
to access it.

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


drivers/input/joystick/iforce/iforce-serio.c | 14 +++++++++----
drivers/input/joystick/magellan.c | 9 +++++---
drivers/input/joystick/spaceball.c | 9 +++++---
drivers/input/joystick/spaceorb.c | 9 +++++---
drivers/input/joystick/stinger.c | 10 ++++++---
drivers/input/joystick/warrior.c | 9 +++++---
drivers/input/keyboard/atkbd.c | 18 +++++++++-------
drivers/input/keyboard/lkkbd.c | 8 ++++---
drivers/input/keyboard/newtonkbd.c | 10 ++++++---
drivers/input/keyboard/sunkbd.c | 9 +++++---
drivers/input/keyboard/xtkbd.c | 9 +++++---
drivers/input/mouse/psmouse-base.c | 29 ++++++++++++++-------------
drivers/input/mouse/sermouse.c | 11 ++++++----
drivers/input/mouse/synaptics.c | 7 +++---
drivers/input/mouse/vsxxxaa.c | 9 +++++---
drivers/input/serio/serio_raw.c | 12 +++++------
drivers/input/touchscreen/gunze.c | 10 ++++++---
drivers/input/touchscreen/h3600_ts_input.c | 13 +++++++-----
include/linux/serio.h | 14 ++++++++++++-
19 files changed, 142 insertions(+), 77 deletions(-)


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



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-11-24 01:46:08 -05:00
+++ b/drivers/input/joystick/iforce/iforce-serio.c 2004-11-24 01:46:08 -05:00
@@ -75,13 +75,15 @@

static void iforce_serio_write_wakeup(struct serio *serio)
{
- iforce_serial_xmit((struct iforce *)serio->private);
+ struct iforce *iforce = serio_get_drvdata(serio);
+
+ iforce_serial_xmit(iforce);
}

static irqreturn_t iforce_serio_irq(struct serio *serio,
unsigned char data, unsigned int flags, struct pt_regs *regs)
{
- struct iforce* iforce = serio->private;
+ struct iforce *iforce = serio_get_drvdata(serio);

if (!iforce->pkt) {
if (data == 0x2b)
@@ -135,15 +137,18 @@

iforce->bus = IFORCE_232;
iforce->serio = serio;
- serio->private = iforce;
+
+ serio_set_drvdata(serio, iforce);

if (serio_open(serio, drv)) {
+ serio_set_drvdata(serio, NULL);
kfree(iforce);
return;
}

if (iforce_init_device(iforce)) {
serio_close(serio);
+ serio_set_drvdata(serio, NULL);
kfree(iforce);
return;
}
@@ -151,10 +156,11 @@

static void iforce_serio_disconnect(struct serio *serio)
{
- struct iforce* iforce = serio->private;
+ struct iforce *iforce = serio_get_drvdata(serio);

input_unregister_device(&iforce->dev);
serio_close(serio);
+ serio_set_drvdata(serio, NULL);
kfree(iforce);
}

diff -Nru a/drivers/input/joystick/magellan.c b/drivers/input/joystick/magellan.c
--- a/drivers/input/joystick/magellan.c 2004-11-24 01:46:08 -05:00
+++ b/drivers/input/joystick/magellan.c 2004-11-24 01:46:08 -05:00
@@ -118,7 +118,7 @@
static irqreturn_t magellan_interrupt(struct serio *serio,
unsigned char data, unsigned int flags, struct pt_regs *regs)
{
- struct magellan* magellan = serio->private;
+ struct magellan* magellan = serio_get_drvdata(serio);

if (data == '\r') {
magellan_process_packet(magellan, regs);
@@ -136,9 +136,11 @@

static void magellan_disconnect(struct serio *serio)
{
- struct magellan* magellan = serio->private;
+ struct magellan* magellan = serio_get_drvdata(serio);
+
input_unregister_device(&magellan->dev);
serio_close(serio);
+ serio_set_drvdata(serio, NULL);
kfree(magellan);
}

@@ -185,9 +187,10 @@
magellan->dev.id.version = 0x0100;
magellan->dev.dev = &serio->dev;

- serio->private = magellan;
+ serio_set_drvdata(serio, magellan);

if (serio_open(serio, drv)) {
+ serio_set_drvdata(serio, NULL);
kfree(magellan);
return;
}
diff -Nru a/drivers/input/joystick/spaceball.c b/drivers/input/joystick/spaceball.c
--- a/drivers/input/joystick/spaceball.c 2004-11-24 01:46:08 -05:00
+++ b/drivers/input/joystick/spaceball.c 2004-11-24 01:46:08 -05:00
@@ -154,7 +154,7 @@
static irqreturn_t spaceball_interrupt(struct serio *serio,
unsigned char data, unsigned int flags, struct pt_regs *regs)
{
- struct spaceball *spaceball = serio->private;
+ struct spaceball *spaceball = serio_get_drvdata(serio);

switch (data) {
case 0xd:
@@ -191,9 +191,11 @@

static void spaceball_disconnect(struct serio *serio)
{
- struct spaceball* spaceball = serio->private;
+ struct spaceball* spaceball = serio_get_drvdata(serio);
+
input_unregister_device(&spaceball->dev);
serio_close(serio);
+ serio_set_drvdata(serio, NULL);
kfree(spaceball);
}

@@ -255,9 +257,10 @@
spaceball->dev.id.version = 0x0100;
spaceball->dev.dev = &serio->dev;

- serio->private = spaceball;
+ serio_set_drvdata(serio, spaceball);

if (serio_open(serio, drv)) {
+ serio_set_drvdata(serio, NULL);
kfree(spaceball);
return;
}
diff -Nru a/drivers/input/joystick/spaceorb.c b/drivers/input/joystick/spaceorb.c
--- a/drivers/input/joystick/spaceorb.c 2004-11-24 01:46:08 -05:00
+++ b/drivers/input/joystick/spaceorb.c 2004-11-24 01:46:08 -05:00
@@ -135,7 +135,7 @@
static irqreturn_t spaceorb_interrupt(struct serio *serio,
unsigned char data, unsigned int flags, struct pt_regs *regs)
{
- struct spaceorb* spaceorb = serio->private;
+ struct spaceorb* spaceorb = serio_get_drvdata(serio);

if (~data & 0x80) {
if (spaceorb->idx) spaceorb_process_packet(spaceorb, regs);
@@ -152,9 +152,11 @@

static void spaceorb_disconnect(struct serio *serio)
{
- struct spaceorb* spaceorb = serio->private;
+ struct spaceorb* spaceorb = serio_get_drvdata(serio);
+
input_unregister_device(&spaceorb->dev);
serio_close(serio);
+ serio_set_drvdata(serio, NULL);
kfree(spaceorb);
}

@@ -202,9 +204,10 @@
spaceorb->dev.id.version = 0x0100;
spaceorb->dev.dev = &serio->dev;

- serio->private = spaceorb;
+ serio_set_drvdata(serio, spaceorb);

if (serio_open(serio, drv)) {
+ serio_set_drvdata(serio, NULL);
kfree(spaceorb);
return;
}
diff -Nru a/drivers/input/joystick/stinger.c b/drivers/input/joystick/stinger.c
--- a/drivers/input/joystick/stinger.c 2004-11-24 01:46:08 -05:00
+++ b/drivers/input/joystick/stinger.c 2004-11-24 01:46:08 -05:00
@@ -103,7 +103,7 @@
static irqreturn_t stinger_interrupt(struct serio *serio,
unsigned char data, unsigned int flags, struct pt_regs *regs)
{
- struct stinger* stinger = serio->private;
+ struct stinger *stinger = serio_get_drvdata(serio);

/* All Stinger packets are 4 bytes */

@@ -124,9 +124,11 @@

static void stinger_disconnect(struct serio *serio)
{
- struct stinger* stinger = serio->private;
+ struct stinger *stinger = serio_get_drvdata(serio);
+
input_unregister_device(&stinger->dev);
serio_close(serio);
+ serio_set_drvdata(serio, NULL);
kfree(stinger);
}

@@ -173,9 +175,11 @@
}

stinger->dev.private = stinger;
- serio->private = stinger;
+
+ serio_set_drvdata(serio, stinger);

if (serio_open(serio, drv)) {
+ serio_set_drvdata(serio, NULL);
kfree(stinger);
return;
}
diff -Nru a/drivers/input/joystick/warrior.c b/drivers/input/joystick/warrior.c
--- a/drivers/input/joystick/warrior.c 2004-11-24 01:46:08 -05:00
+++ b/drivers/input/joystick/warrior.c 2004-11-24 01:46:08 -05:00
@@ -104,7 +104,7 @@
static irqreturn_t warrior_interrupt(struct serio *serio,
unsigned char data, unsigned int flags, struct pt_regs *regs)
{
- struct warrior* warrior = serio->private;
+ struct warrior *warrior = serio_get_drvdata(serio);

if (data & 0x80) {
if (warrior->idx) warrior_process_packet(warrior, regs);
@@ -129,9 +129,11 @@

static void warrior_disconnect(struct serio *serio)
{
- struct warrior* warrior = serio->private;
+ struct warrior *warrior = serio_get_drvdata(serio);
+
input_unregister_device(&warrior->dev);
serio_close(serio);
+ serio_set_drvdata(serio, NULL);
kfree(warrior);
}

@@ -186,9 +188,10 @@

warrior->dev.private = warrior;

- serio->private = warrior;
+ serio_set_drvdata(serio, warrior);

if (serio_open(serio, drv)) {
+ serio_set_drvdata(serio, NULL);
kfree(warrior);
return;
}
diff -Nru a/drivers/input/keyboard/atkbd.c b/drivers/input/keyboard/atkbd.c
--- a/drivers/input/keyboard/atkbd.c 2004-11-24 01:46:08 -05:00
+++ b/drivers/input/keyboard/atkbd.c 2004-11-24 01:46:08 -05:00
@@ -248,7 +248,7 @@
static irqreturn_t atkbd_interrupt(struct serio *serio, unsigned char data,
unsigned int flags, struct pt_regs *regs)
{
- struct atkbd *atkbd = serio->private;
+ struct atkbd *atkbd = serio_get_drvdata(serio);
unsigned int code = data;
int scroll = 0, click = -1;
int value;
@@ -645,7 +645,7 @@

static void atkbd_cleanup(struct serio *serio)
{
- struct atkbd *atkbd = serio->private;
+ struct atkbd *atkbd = serio_get_drvdata(serio);
ps2_command(&atkbd->ps2dev, NULL, ATKBD_CMD_RESET_BAT);
}

@@ -656,7 +656,7 @@

static void atkbd_disconnect(struct serio *serio)
{
- struct atkbd *atkbd = serio->private;
+ struct atkbd *atkbd = serio_get_drvdata(serio);

atkbd_disable(atkbd);

@@ -672,6 +672,7 @@

input_unregister_device(&atkbd->dev);
serio_close(serio);
+ serio_set_drvdata(serio, NULL);
kfree(atkbd);
}

@@ -808,9 +809,10 @@
atkbd->dev.keycodesize = sizeof(unsigned char);
atkbd->dev.keycodemax = ARRAY_SIZE(atkbd_set2_keycode);

- serio->private = atkbd;
+ serio_set_drvdata(serio, atkbd);

if (serio_open(serio, drv)) {
+ serio_set_drvdata(serio, NULL);
kfree(atkbd);
return;
}
@@ -819,7 +821,7 @@

if (atkbd_probe(atkbd)) {
serio_close(serio);
- serio->private = NULL;
+ serio_set_drvdata(serio, NULL);
kfree(atkbd);
return;
}
@@ -863,7 +865,7 @@

static int atkbd_reconnect(struct serio *serio)
{
- struct atkbd *atkbd = serio->private;
+ struct atkbd *atkbd = serio_get_drvdata(serio);
struct serio_driver *drv = serio->drv;
unsigned char param[1];

@@ -922,7 +924,7 @@
goto out;
}

- retval = handler((struct atkbd *)serio->private, buf);
+ retval = handler((struct atkbd *)serio_get_drvdata(serio), buf);

out:
serio_unpin_driver(serio);
@@ -945,7 +947,7 @@
goto out;
}

- atkbd = serio->private;
+ atkbd = serio_get_drvdata(serio);
atkbd_disable(atkbd);
retval = handler(atkbd, buf, count);
atkbd_enable(atkbd);
diff -Nru a/drivers/input/keyboard/lkkbd.c b/drivers/input/keyboard/lkkbd.c
--- a/drivers/input/keyboard/lkkbd.c 2004-11-24 01:46:08 -05:00
+++ b/drivers/input/keyboard/lkkbd.c 2004-11-24 01:46:08 -05:00
@@ -417,7 +417,7 @@
lkkbd_interrupt (struct serio *serio, unsigned char data, unsigned int flags,
struct pt_regs *regs)
{
- struct lkkbd *lk = serio->private;
+ struct lkkbd *lk = serio_get_drvdata (serio);
int i;

DBG (KERN_INFO "Got byte 0x%02x\n", data);
@@ -665,9 +665,10 @@
lk->dev.event = lkkbd_event;
lk->dev.private = lk;

- serio->private = lk;
+ serio_set_drvdata (serio, lk);

if (serio_open (serio, drv)) {
+ serio_set_drvdata (serio, NULL);
kfree (lk);
return;
}
@@ -699,10 +700,11 @@
static void
lkkbd_disconnect (struct serio *serio)
{
- struct lkkbd *lk = serio->private;
+ struct lkkbd *lk = serio_get_drvdata (serio);

input_unregister_device (&lk->dev);
serio_close (serio);
+ serio_set_drvdata (serio, NULL);
kfree (lk);
}

diff -Nru a/drivers/input/keyboard/newtonkbd.c b/drivers/input/keyboard/newtonkbd.c
--- a/drivers/input/keyboard/newtonkbd.c 2004-11-24 01:46:08 -05:00
+++ b/drivers/input/keyboard/newtonkbd.c 2004-11-24 01:46:08 -05:00
@@ -69,7 +69,7 @@
irqreturn_t nkbd_interrupt(struct serio *serio,
unsigned char data, unsigned int flags, struct pt_regs *regs)
{
- struct nkbd *nkbd = serio->private;
+ struct nkbd *nkbd = serio_get_drvdata(serio);

/* invalid scan codes are probably the init sequence, so we ignore them */
if (nkbd->keycode[data & NKBD_KEY]) {
@@ -106,9 +106,11 @@
nkbd->dev.keycodesize = sizeof(unsigned char);
nkbd->dev.keycodemax = ARRAY_SIZE(nkbd_keycode);
nkbd->dev.private = nkbd;
- serio->private = nkbd;
+
+ serio_set_drvdata(serio, nkbd);

if (serio_open(serio, drv)) {
+ serio_set_drvdata(serio, NULL);
kfree(nkbd);
return;
}
@@ -135,9 +137,11 @@

void nkbd_disconnect(struct serio *serio)
{
- struct nkbd *nkbd = serio->private;
+ struct nkbd *nkbd = serio_get_drvdata(serio);
+
input_unregister_device(&nkbd->dev);
serio_close(serio);
+ serio_set_drvdata(serio, NULL);
kfree(nkbd);
}

diff -Nru a/drivers/input/keyboard/sunkbd.c b/drivers/input/keyboard/sunkbd.c
--- a/drivers/input/keyboard/sunkbd.c 2004-11-24 01:46:08 -05:00
+++ b/drivers/input/keyboard/sunkbd.c 2004-11-24 01:46:08 -05:00
@@ -95,7 +95,7 @@
static irqreturn_t sunkbd_interrupt(struct serio *serio,
unsigned char data, unsigned int flags, struct pt_regs *regs)
{
- struct sunkbd* sunkbd = serio->private;
+ struct sunkbd* sunkbd = serio_get_drvdata(serio);

if (sunkbd->reset <= -1) { /* If cp[i] is 0xff, sunkbd->reset will stay -1. */
sunkbd->reset = data; /* The keyboard sends 0xff 0xff 0xID on powerup */
@@ -257,15 +257,17 @@
sunkbd->dev.event = sunkbd_event;
sunkbd->dev.private = sunkbd;

- serio->private = sunkbd;
+ serio_set_drvdata(serio, sunkbd);

if (serio_open(serio, drv)) {
+ serio_set_drvdata(serio, NULL);
kfree(sunkbd);
return;
}

if (sunkbd_initialize(sunkbd) < 0) {
serio_close(serio);
+ serio_set_drvdata(serio, NULL);
kfree(sunkbd);
return;
}
@@ -298,9 +300,10 @@

static void sunkbd_disconnect(struct serio *serio)
{
- struct sunkbd *sunkbd = serio->private;
+ struct sunkbd *sunkbd = serio_get_drvdata(serio);
input_unregister_device(&sunkbd->dev);
serio_close(serio);
+ serio_set_drvdata(serio, NULL);
kfree(sunkbd);
}

diff -Nru a/drivers/input/keyboard/xtkbd.c b/drivers/input/keyboard/xtkbd.c
--- a/drivers/input/keyboard/xtkbd.c 2004-11-24 01:46:08 -05:00
+++ b/drivers/input/keyboard/xtkbd.c 2004-11-24 01:46:08 -05:00
@@ -68,7 +68,7 @@
irqreturn_t xtkbd_interrupt(struct serio *serio,
unsigned char data, unsigned int flags, struct pt_regs *regs)
{
- struct xtkbd *xtkbd = serio->private;
+ struct xtkbd *xtkbd = serio_get_drvdata(serio);

switch (data) {
case XTKBD_EMUL0:
@@ -111,9 +111,10 @@
xtkbd->dev.keycodemax = ARRAY_SIZE(xtkbd_keycode);
xtkbd->dev.private = xtkbd;

- serio->private = xtkbd;
+ serio_set_drvdata(serio, xtkbd);

if (serio_open(serio, drv)) {
+ serio_set_drvdata(serio, NULL);
kfree(xtkbd);
return;
}
@@ -140,9 +141,11 @@

void xtkbd_disconnect(struct serio *serio)
{
- struct xtkbd *xtkbd = serio->private;
+ struct xtkbd *xtkbd = serio_get_drvdata(serio);
+
input_unregister_device(&xtkbd->dev);
serio_close(serio);
+ serio_set_drvdata(serio, NULL);
kfree(xtkbd);
}

diff -Nru a/drivers/input/mouse/psmouse-base.c b/drivers/input/mouse/psmouse-base.c
--- a/drivers/input/mouse/psmouse-base.c 2004-11-24 01:46:08 -05:00
+++ b/drivers/input/mouse/psmouse-base.c 2004-11-24 01:46:08 -05:00
@@ -147,7 +147,7 @@
static irqreturn_t psmouse_interrupt(struct serio *serio,
unsigned char data, unsigned int flags, struct pt_regs *regs)
{
- struct psmouse *psmouse = serio->private;
+ struct psmouse *psmouse = serio_get_drvdata(serio);
psmouse_ret_t rc;

if (psmouse->state == PSMOUSE_IGNORE)
@@ -690,7 +690,7 @@

static void psmouse_cleanup(struct serio *serio)
{
- struct psmouse *psmouse = serio->private;
+ struct psmouse *psmouse = serio_get_drvdata(serio);

psmouse_reset(psmouse);
}
@@ -709,13 +709,13 @@
device_remove_file(&serio->dev, &psmouse_attr_resolution);
device_remove_file(&serio->dev, &psmouse_attr_resetafter);

- psmouse = serio->private;
+ psmouse = serio_get_drvdata(serio);

psmouse_set_state(psmouse, PSMOUSE_CMD_MODE);
del_timer_sync(&psmouse->ping_timer);

if (serio->parent && (serio->type & SERIO_TYPE) == SERIO_PS_PSTHRU) {
- parent = serio->parent->private;
+ parent = serio_get_drvdata(serio->parent);
if (parent->pt_deactivate)
parent->pt_deactivate(parent);
}
@@ -727,6 +727,7 @@

input_unregister_device(&psmouse->dev);
serio_close(serio);
+ serio_set_drvdata(serio, NULL);
kfree(psmouse);
}

@@ -747,7 +748,7 @@
* connected to this port can be successfully identified
*/
if (serio->parent && (serio->type & SERIO_TYPE) == SERIO_PS_PSTHRU) {
- parent = serio->parent->private;
+ parent = serio_get_drvdata(serio->parent);
psmouse_deactivate(parent);
}

@@ -767,17 +768,18 @@
psmouse->dev.dev = &serio->dev;
psmouse_set_state(psmouse, PSMOUSE_INITIALIZING);

- serio->private = psmouse;
+ serio_set_drvdata(serio, psmouse);
+
if (serio_open(serio, drv)) {
+ serio_set_drvdata(serio, NULL);
kfree(psmouse);
- serio->private = NULL;
goto out;
}

if (psmouse_probe(psmouse) < 0) {
serio_close(serio);
+ serio_set_drvdata(serio, NULL);
kfree(psmouse);
- serio->private = NULL;
goto out;
}

@@ -841,7 +843,7 @@

static int psmouse_reconnect(struct serio *serio)
{
- struct psmouse *psmouse = serio->private;
+ struct psmouse *psmouse = serio_get_drvdata(serio);
struct psmouse *parent = NULL;
struct serio_driver *drv = serio->drv;
int rc = -1;
@@ -852,7 +854,7 @@
}

if (serio->parent && (serio->type & SERIO_TYPE) == SERIO_PS_PSTHRU) {
- parent = serio->parent->private;
+ parent = serio_get_drvdata(serio->parent);
psmouse_deactivate(parent);
}

@@ -914,7 +916,7 @@
goto out;
}

- retval = handler(serio->private, buf);
+ retval = handler(serio_get_drvdata(serio), buf);

out:
serio_unpin_driver(serio);
@@ -925,7 +927,8 @@
ssize_t (*handler)(struct psmouse *, const char *, size_t))
{
struct serio *serio = to_serio_port(dev);
- struct psmouse *psmouse = serio->private, *parent = NULL;
+ struct psmouse *psmouse = serio_get_drvdata(serio);
+ struct psmouse *parent = NULL;
int retval;

retval = serio_pin_driver(serio);
@@ -938,7 +941,7 @@
}

if (serio->parent && (serio->type & SERIO_TYPE) == SERIO_PS_PSTHRU) {
- parent = serio->parent->private;
+ parent = serio_get_drvdata(serio->parent);
psmouse_deactivate(parent);
}
psmouse_deactivate(psmouse);
diff -Nru a/drivers/input/mouse/sermouse.c b/drivers/input/mouse/sermouse.c
--- a/drivers/input/mouse/sermouse.c 2004-11-24 01:46:08 -05:00
+++ b/drivers/input/mouse/sermouse.c 2004-11-24 01:46:08 -05:00
@@ -209,7 +209,7 @@
static irqreturn_t sermouse_interrupt(struct serio *serio,
unsigned char data, unsigned int flags, struct pt_regs *regs)
{
- struct sermouse *sermouse = serio->private;
+ struct sermouse *sermouse = serio_get_drvdata(serio);

if (time_after(jiffies, sermouse->last + HZ/10)) sermouse->count = 0;
sermouse->last = jiffies;
@@ -228,9 +228,11 @@

static void sermouse_disconnect(struct serio *serio)
{
- struct sermouse *sermouse = serio->private;
+ struct sermouse *sermouse = serio_get_drvdata(serio);
+
input_unregister_device(&sermouse->dev);
serio_close(serio);
+ serio_set_drvdata(serio, NULL);
kfree(sermouse);
}

@@ -261,8 +263,6 @@
sermouse->dev.relbit[0] = BIT(REL_X) | BIT(REL_Y);
sermouse->dev.private = sermouse;

- serio->private = sermouse;
-
sermouse->type = serio->type & SERIO_PROTO;
c = (serio->type & SERIO_EXTRA) >> 16;

@@ -282,7 +282,10 @@
sermouse->dev.id.version = 0x0100;
sermouse->dev.dev = &serio->dev;

+ serio_set_drvdata(serio, sermouse);
+
if (serio_open(serio, drv)) {
+ serio_set_drvdata(serio, NULL);
kfree(sermouse);
return;
}
diff -Nru a/drivers/input/mouse/synaptics.c b/drivers/input/mouse/synaptics.c
--- a/drivers/input/mouse/synaptics.c 2004-11-24 01:46:08 -05:00
+++ b/drivers/input/mouse/synaptics.c 2004-11-24 01:46:08 -05:00
@@ -229,7 +229,7 @@
****************************************************************************/
static int synaptics_pt_write(struct serio *serio, unsigned char c)
{
- struct psmouse *parent = serio->parent->private;
+ struct psmouse *parent = serio_get_drvdata(serio->parent);
char rate_param = SYN_PS_CLIENT_CMD; /* indicates that we want pass-through port */

if (psmouse_sliced_command(parent, c))
@@ -246,7 +246,7 @@

static void synaptics_pass_pt_packet(struct serio *ptport, unsigned char *packet)
{
- struct psmouse *child = ptport->private;
+ struct psmouse *child = serio_get_drvdata(ptport);

if (child && child->state == PSMOUSE_ACTIVATED) {
serio_interrupt(ptport, packet[1], 0, NULL);
@@ -260,7 +260,8 @@

static void synaptics_pt_activate(struct psmouse *psmouse)
{
- struct psmouse *child = psmouse->ps2dev.serio->child->private;
+ struct serio *ptport = psmouse->ps2dev.serio->child;
+ struct psmouse *child = serio_get_drvdata(ptport);
struct synaptics_data *priv = psmouse->private;

/* adjust the touchpad to child's choice of protocol */
diff -Nru a/drivers/input/mouse/vsxxxaa.c b/drivers/input/mouse/vsxxxaa.c
--- a/drivers/input/mouse/vsxxxaa.c 2004-11-24 01:46:08 -05:00
+++ b/drivers/input/mouse/vsxxxaa.c 2004-11-24 01:46:08 -05:00
@@ -470,7 +470,7 @@
vsxxxaa_interrupt (struct serio *serio, unsigned char data, unsigned int flags,
struct pt_regs *regs)
{
- struct vsxxxaa *mouse = serio->private;
+ struct vsxxxaa *mouse = serio_get_drvdata (serio);

vsxxxaa_queue_byte (mouse, data);
vsxxxaa_parse_buffer (mouse, regs);
@@ -481,10 +481,11 @@
static void
vsxxxaa_disconnect (struct serio *serio)
{
- struct vsxxxaa *mouse = serio->private;
+ struct vsxxxaa *mouse = serio_get_drvdata (serio);

input_unregister_device (&mouse->dev);
serio_close (serio);
+ serio_set_drvdata (serio, NULL);
kfree (mouse);
}

@@ -522,7 +523,6 @@
mouse->dev.absmax[ABS_Y] = 1023;

mouse->dev.private = mouse;
- serio->private = mouse;

sprintf (mouse->name, "DEC VSXXX-AA/-GA mouse or VSXXX-AB digitizer");
sprintf (mouse->phys, "%s/input0", serio->phys);
@@ -532,7 +532,10 @@
mouse->dev.dev = &serio->dev;
mouse->serio = serio;

+ serio_set_drvdata (serio, mouse);
+
if (serio_open (serio, drv)) {
+ serio_set_drvdata (serio, NULL);
kfree (mouse);
return;
}
diff -Nru a/drivers/input/serio/serio_raw.c b/drivers/input/serio/serio_raw.c
--- a/drivers/input/serio/serio_raw.c 2004-11-24 01:46:08 -05:00
+++ b/drivers/input/serio/serio_raw.c 2004-11-24 01:46:08 -05:00
@@ -253,7 +253,7 @@
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 *serio_raw = serio_get_drvdata(serio);
struct serio_raw_list *list;
unsigned int head = serio_raw->head;

@@ -292,7 +292,7 @@
INIT_LIST_HEAD(&serio_raw->list);
init_waitqueue_head(&serio_raw->wait);

- serio->private = serio_raw;
+ serio_set_drvdata(serio, serio_raw);
if (serio_open(serio, drv))
goto out_free;

@@ -322,7 +322,7 @@
serio_close(serio);
list_del_init(&serio_raw->node);
out_free:
- serio->private = NULL;
+ serio_set_drvdata(serio, NULL);
kfree(serio_raw);
out:
up(&serio_raw_sem);
@@ -330,7 +330,7 @@

static int serio_raw_reconnect(struct serio *serio)
{
- struct serio_raw *serio_raw = serio->private;
+ struct serio_raw *serio_raw = serio_get_drvdata(serio);
struct serio_driver *drv = serio->drv;

if (!drv || !serio_raw) {
@@ -351,10 +351,10 @@

down(&serio_raw_sem);

- serio_raw = serio->private;
+ serio_raw = serio_get_drvdata(serio);

serio_close(serio);
- serio->private = NULL;
+ serio_set_drvdata(serio, NULL);

serio_raw->serio = NULL;
if (!serio_raw_cleanup(serio_raw))
diff -Nru a/drivers/input/touchscreen/gunze.c b/drivers/input/touchscreen/gunze.c
--- a/drivers/input/touchscreen/gunze.c 2004-11-24 01:46:08 -05:00
+++ b/drivers/input/touchscreen/gunze.c 2004-11-24 01:46:08 -05:00
@@ -83,7 +83,7 @@
static irqreturn_t gunze_interrupt(struct serio *serio,
unsigned char data, unsigned int flags, struct pt_regs *regs)
{
- struct gunze* gunze = serio->private;
+ struct gunze* gunze = serio_get_drvdata(serio);

if (data == '\r') {
gunze_process_packet(gunze, regs);
@@ -101,9 +101,11 @@

static void gunze_disconnect(struct serio *serio)
{
- struct gunze* gunze = serio->private;
+ struct gunze* gunze = serio_get_drvdata(serio);
+
input_unregister_device(&gunze->dev);
serio_close(serio);
+ serio_set_drvdata(serio, NULL);
kfree(gunze);
}

@@ -132,7 +134,6 @@
input_set_abs_params(&gunze->dev, ABS_Y, 72, 3000, 0, 0);

gunze->serio = serio;
- serio->private = gunze;

sprintf(gunze->phys, "%s/input0", serio->phys);

@@ -144,7 +145,10 @@
gunze->dev.id.product = 0x0051;
gunze->dev.id.version = 0x0100;

+ serio_set_drvdata(serio, gunze);
+
if (serio_open(serio, drv)) {
+ serio_set_drvdata(serio, NULL);
kfree(gunze);
return;
}
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-11-24 01:46:08 -05:00
+++ b/drivers/input/touchscreen/h3600_ts_input.c 2004-11-24 01:46:08 -05:00
@@ -331,7 +331,7 @@
static irqreturn_t h3600ts_interrupt(struct serio *serio, unsigned char data,
unsigned int flags, struct pt_regs *regs)
{
- struct h3600_dev *ts = serio->private;
+ struct h3600_dev *ts = serio_get_drvdata(serio);

/*
* We have a new frame coming in.
@@ -431,7 +431,6 @@
ts->dev.keybit[LONG(KEY_SUSPEND)] |= BIT(KEY_SUSPEND);

ts->serio = serio;
- serio->private = ts;

sprintf(ts->phys, "%s/input0", serio->phys);

@@ -444,9 +443,12 @@
ts->dev.id.product = 0x0666; /* FIXME !!! We can ask the hardware */
ts->dev.id.version = 0x0100;

+ serio_set_drvdata(serio, ts);
+
if (serio_open(serio, drv)) {
free_irq(IRQ_GPIO_BITSY_ACTION_BUTTON, ts);
free_irq(IRQ_GPIO_BITSY_NPOWER_BUTTON, ts);
+ serio_set_drvdata(serio, NULL);
kfree(ts);
return;
}
@@ -468,12 +470,13 @@

static void h3600ts_disconnect(struct serio *serio)
{
- struct h3600_dev *ts = serio->private;
+ struct h3600_dev *ts = serio_get_drvdata(serio);

- free_irq(IRQ_GPIO_BITSY_ACTION_BUTTON, &ts->dev);
- free_irq(IRQ_GPIO_BITSY_NPOWER_BUTTON, &ts->dev);
+ free_irq(IRQ_GPIO_BITSY_ACTION_BUTTON, &ts->dev);
+ free_irq(IRQ_GPIO_BITSY_NPOWER_BUTTON, &ts->dev);
input_unregister_device(&ts->dev);
serio_close(serio);
+ serio_set_drvdata(serio, NULL);
kfree(ts);
}

diff -Nru a/include/linux/serio.h b/include/linux/serio.h
--- a/include/linux/serio.h 2004-11-24 01:46:08 -05:00
+++ b/include/linux/serio.h 2004-11-24 01:46:08 -05:00
@@ -21,7 +21,6 @@
#include <linux/device.h>

struct serio {
- void *private;
void *port_data;

char name[32];
@@ -110,6 +109,19 @@
serio->drv->cleanup(serio);
}

+/*
+ * Use the following fucntions to manipulate serio's per-port
+ * driver-specific data.
+ */
+static __inline__ void *serio_get_drvdata(struct serio *serio)
+{
+ return dev_get_drvdata(&serio->dev);
+}
+
+static __inline__ void serio_set_drvdata(struct serio *serio, void *data)
+{
+ dev_set_drvdata(&serio->dev, data);
+}

/*
* Use the following fucntions to protect critical sections in

2004-11-24 07:19:54

by Dmitry Torokhov

[permalink] [raw]
Subject: [PATCH 4/11] Twidjoy build fix


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


[email protected], 2004-11-15 23:25:52-05:00, [email protected]
Input: twidjoy - apparently Kconfig and Makefile disagreed on the
name for config option so the module was never built.

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


Makefile | 2 +-
twidjoy.c | 14 ++++++++++----
2 files changed, 11 insertions(+), 5 deletions(-)


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



diff -Nru a/drivers/input/joystick/Makefile b/drivers/input/joystick/Makefile
--- a/drivers/input/joystick/Makefile 2004-11-24 01:47:17 -05:00
+++ b/drivers/input/joystick/Makefile 2004-11-24 01:47:17 -05:00
@@ -24,7 +24,7 @@
obj-$(CONFIG_JOYSTICK_STINGER) += stinger.o
obj-$(CONFIG_JOYSTICK_TMDC) += tmdc.o
obj-$(CONFIG_JOYSTICK_TURBOGRAFX) += turbografx.o
-obj-$(CONFIG_JOYSTICK_TWIDJOY) += twidjoy.o
+obj-$(CONFIG_JOYSTICK_TWIDDLER) += twidjoy.o
obj-$(CONFIG_JOYSTICK_WARRIOR) += warrior.o

obj-$(CONFIG_JOYSTICK_IFORCE) += iforce/
diff -Nru a/drivers/input/joystick/twidjoy.c b/drivers/input/joystick/twidjoy.c
--- a/drivers/input/joystick/twidjoy.c 2004-11-24 01:47:17 -05:00
+++ b/drivers/input/joystick/twidjoy.c 2004-11-24 01:47:17 -05:00
@@ -58,7 +58,9 @@
#include <linux/serio.h>
#include <linux/init.h>

-MODULE_DESCRIPTION("Handykey Twiddler keyboard as a joystick driver");
+#define DRIVER_DESC "Handykey Twiddler keyboard as a joystick driver"
+
+MODULE_DESCRIPTION(DRIVER_DESC);
MODULE_LICENSE("GPL");

/*
@@ -147,7 +149,7 @@

static irqreturn_t twidjoy_interrupt(struct serio *serio, unsigned char data, unsigned int flags, struct pt_regs *regs)
{
- struct twidjoy *twidjoy = serio->private;
+ struct twidjoy *twidjoy = serio_get_drvdata(serio);

/* All Twiddler packets are 5 bytes. The fact that the first byte
* has a MSB of 0 and all other bytes have a MSB of 1 can be used
@@ -175,9 +177,11 @@

static void twidjoy_disconnect(struct serio *serio)
{
- struct twidjoy *twidjoy = serio->private;
+ struct twidjoy *twidjoy = serio_get_drvdata(serio);
+
input_unregister_device(&twidjoy->dev);
serio_close(serio);
+ serio_set_drvdata(serio, NULL);
kfree(twidjoy);
}

@@ -231,9 +235,11 @@
}

twidjoy->dev.private = twidjoy;
- serio->private = twidjoy;
+
+ serio_set_drvdata(serio, twidjoy);

if (serio_open(serio, drv)) {
+ serio_set_drvdata(serio, NULL);
kfree(twidjoy);
return;
}

2004-11-24 07:28:31

by Dmitry Torokhov

[permalink] [raw]
Subject: [PATCH 5/11] serio - use id matching


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


[email protected], 2004-11-16 01:08:10-05:00, [email protected]
Input: replace serio's type field with serio_id structure and
add ids table to serio drivers. This will allow split
initial matching and probing routines for better sysfs
integration.

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


drivers/input/joystick/iforce/iforce-serio.c | 16 ++++++++--
drivers/input/joystick/magellan.c | 20 +++++++++---
drivers/input/joystick/spaceball.c | 22 +++++++++-----
drivers/input/joystick/spaceorb.c | 18 ++++++++---
drivers/input/joystick/stinger.c | 20 +++++++++---
drivers/input/joystick/twidjoy.c | 17 ++++++++--
drivers/input/joystick/warrior.c | 16 +++++++---
drivers/input/keyboard/atkbd.c | 31 +++++++++++++++----
drivers/input/keyboard/lkkbd.c | 16 +++++++---
drivers/input/keyboard/newtonkbd.c | 14 +++++++--
drivers/input/keyboard/sunkbd.c | 23 ++++++++++----
drivers/input/keyboard/xtkbd.c | 14 +++++++--
drivers/input/mouse/psmouse-base.c | 28 ++++++++++++------
drivers/input/mouse/sermouse.c | 20 +++++++++---
drivers/input/mouse/synaptics.c | 2 -
drivers/input/mouse/vsxxxaa.c | 16 +++++++---
drivers/input/serio/ambakmi.c | 2 -
drivers/input/serio/ct82c710.c | 2 -
drivers/input/serio/gscps2.c | 6 ---
drivers/input/serio/i8042.c | 6 +--
drivers/input/serio/maceps2.c | 2 -
drivers/input/serio/parkbd.c | 2 -
drivers/input/serio/pcips2.c | 2 -
drivers/input/serio/q40kbd.c | 2 -
drivers/input/serio/rpckbd.c | 2 -
drivers/input/serio/sa1111ps2.c | 2 -
drivers/input/serio/serio.c | 30 ++++++++++++++-----
drivers/input/serio/serio_raw.c | 14 +++++++--
drivers/input/serio/serport.c | 18 ++++++++---
drivers/input/touchscreen/gunze.c | 20 +++++++++---
drivers/input/touchscreen/h3600_ts_input.c | 21 +++++++++----
drivers/serial/sunsu.c | 7 ++--
drivers/serial/sunzilog.c | 7 ++--
include/linux/serio.h | 42 +++++++++++++++------------
34 files changed, 334 insertions(+), 146 deletions(-)


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



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-11-24 01:48:30 -05:00
+++ b/drivers/input/joystick/iforce/iforce-serio.c 2004-11-24 01:48:30 -05:00
@@ -129,10 +129,9 @@
static void iforce_serio_connect(struct serio *serio, struct serio_driver *drv)
{
struct iforce *iforce;
- if (serio->type != (SERIO_RS232 | SERIO_IFORCE))
- return;

- if (!(iforce = kmalloc(sizeof(struct iforce), GFP_KERNEL))) return;
+ if (!(iforce = kmalloc(sizeof(struct iforce), GFP_KERNEL)))
+ return;
memset(iforce, 0, sizeof(struct iforce));

iforce->bus = IFORCE_232;
@@ -164,11 +163,22 @@
kfree(iforce);
}

+static struct serio_id iforce_serio_ids[] = {
+ {
+ .type = SERIO_RS232,
+ .proto = SERIO_IFORCE,
+ .id = SERIO_ANY,
+ .extra = SERIO_ANY,
+ },
+ { 0 }
+};
+
struct serio_driver iforce_serio_drv = {
.driver = {
.name = "iforce",
},
.description = "RS232 I-Force joysticks and wheels driver",
+ .ids = iforce_serio_ids,
.write_wakeup = iforce_serio_write_wakeup,
.interrupt = iforce_serio_irq,
.connect = iforce_serio_connect,
diff -Nru a/drivers/input/joystick/magellan.c b/drivers/input/joystick/magellan.c
--- a/drivers/input/joystick/magellan.c 2004-11-24 01:48:30 -05:00
+++ b/drivers/input/joystick/magellan.c 2004-11-24 01:48:30 -05:00
@@ -146,8 +146,8 @@

/*
* magellan_connect() is the routine that is called when someone adds a
- * new serio device. It looks for the Magellan, and if found, registers
- * it as an input device.
+ * new serio device that supports Magellan protocol and registers it as
+ * an input device.
*/

static void magellan_connect(struct serio *serio, struct serio_driver *drv)
@@ -155,9 +155,6 @@
struct magellan *magellan;
int i, t;

- if (serio->type != (SERIO_RS232 | SERIO_MAGELLAN))
- return;
-
if (!(magellan = kmalloc(sizeof(struct magellan), GFP_KERNEL)))
return;

@@ -202,14 +199,25 @@
}

/*
- * The serio device structure.
+ * The serio driver structure.
*/

+static struct serio_id magellan_serio_ids[] = {
+ {
+ .type = SERIO_RS232,
+ .proto = SERIO_MAGELLAN,
+ .id = SERIO_ANY,
+ .extra = SERIO_ANY,
+ },
+ { 0 }
+};
+
static struct serio_driver magellan_drv = {
.driver = {
.name = "magellan",
},
.description = DRIVER_DESC,
+ .ids = magellan_serio_ids,
.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-11-24 01:48:30 -05:00
+++ b/drivers/input/joystick/spaceball.c 2004-11-24 01:48:30 -05:00
@@ -201,8 +201,8 @@

/*
* spaceball_connect() is the routine that is called when someone adds a
- * new serio device. It looks for the Magellan, and if found, registers
- * it as an input device.
+ * new serio device that supports Spaceball protocol and registers it as
+ * an input device.
*/

static void spaceball_connect(struct serio *serio, struct serio_driver *drv)
@@ -210,10 +210,7 @@
struct spaceball *spaceball;
int i, t, id;

- if ((serio->type & ~SERIO_ID) != (SERIO_RS232 | SERIO_SPACEBALL))
- return;
-
- if ((id = (serio->type & SERIO_ID) >> 8) > SPACEBALL_MAX_ID)
+ if ((id = serio->id.id) > SPACEBALL_MAX_ID)
return;

if (!(spaceball = kmalloc(sizeof(struct spaceball), GFP_KERNEL)))
@@ -272,14 +269,25 @@
}

/*
- * The serio device structure.
+ * The serio driver structure.
*/

+static struct serio_id spaceball_serio_ids[] = {
+ {
+ .type = SERIO_RS232,
+ .proto = SERIO_SPACEBALL,
+ .id = SERIO_ANY,
+ .extra = SERIO_ANY,
+ },
+ { 0 }
+};
+
static struct serio_driver spaceball_drv = {
.driver = {
.name = "spaceball",
},
.description = DRIVER_DESC,
+ .ids = spaceball_serio_ids,
.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-11-24 01:48:30 -05:00
+++ b/drivers/input/joystick/spaceorb.c 2004-11-24 01:48:30 -05:00
@@ -162,7 +162,7 @@

/*
* spaceorb_connect() is the routine that is called when someone adds a
- * new serio device. It looks for the SpaceOrb/Avenger, and if found, registers
+ * new serio device that supports SpaceOrb/Avenger protocol and registers
* it as an input device.
*/

@@ -171,9 +171,6 @@
struct spaceorb *spaceorb;
int i, t;

- if (serio->type != (SERIO_RS232 | SERIO_SPACEORB))
- return;
-
if (!(spaceorb = kmalloc(sizeof(struct spaceorb), GFP_KERNEL)))
return;
memset(spaceorb, 0, sizeof(struct spaceorb));
@@ -216,14 +213,25 @@
}

/*
- * The serio device structure.
+ * The serio driver structure.
*/

+static struct serio_id spaceorb_serio_ids[] = {
+ {
+ .type = SERIO_RS232,
+ .proto = SERIO_SPACEORB,
+ .id = SERIO_ANY,
+ .extra = SERIO_ANY,
+ },
+ { 0 }
+};
+
static struct serio_driver spaceorb_drv = {
.driver = {
.name = "spaceorb",
},
.description = DRIVER_DESC,
+ .ids = spaceorb_serio_ids,
.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-11-24 01:48:30 -05:00
+++ b/drivers/input/joystick/stinger.c 2004-11-24 01:48:30 -05:00
@@ -134,8 +134,8 @@

/*
* stinger_connect() is the routine that is called when someone adds a
- * new serio device. It looks for the Stinger, and if found, registers
- * it as an input device.
+ * new serio device that supports Stinger protocol and registers it as
+ * an input device.
*/

static void stinger_connect(struct serio *serio, struct serio_driver *drv)
@@ -143,9 +143,6 @@
struct stinger *stinger;
int i;

- if (serio->type != (SERIO_RS232 | SERIO_STINGER))
- return;
-
if (!(stinger = kmalloc(sizeof(struct stinger), GFP_KERNEL)))
return;

@@ -191,14 +188,25 @@
}

/*
- * The serio device structure.
+ * The serio driver structure.
*/

+static struct serio_id stinger_serio_ids[] = {
+ {
+ .type = SERIO_RS232,
+ .proto = SERIO_STINGER,
+ .id = SERIO_ANY,
+ .extra = SERIO_ANY,
+ },
+ { 0 }
+};
+
static struct serio_driver stinger_drv = {
.driver = {
.name = "stinger",
},
.description = DRIVER_DESC,
+ .ids = stinger_serio_ids,
.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-11-24 01:48:30 -05:00
+++ b/drivers/input/joystick/twidjoy.c 2004-11-24 01:48:30 -05:00
@@ -197,9 +197,6 @@
struct twidjoy *twidjoy;
int i;

- if (serio->type != (SERIO_RS232 | SERIO_TWIDJOY))
- return;
-
if (!(twidjoy = kmalloc(sizeof(struct twidjoy), GFP_KERNEL)))
return;

@@ -250,14 +247,26 @@
}

/*
- * The serio device structure.
+ * The serio driver structure.
*/

+static struct serio_id twidjoy_serio_ids[] = {
+ {
+ .type = SERIO_RS232,
+ .proto = SERIO_TWIDJOY,
+ .id = SERIO_ANY,
+ .extra = SERIO_ANY,
+ },
+ { 0 }
+};
+
+
static struct serio_driver twidjoy_drv = {
.driver = {
.name = "twidjoy",
},
.description = DRIVER_DESC,
+ .ids = twidjoy_serio_ids,
.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-11-24 01:48:30 -05:00
+++ b/drivers/input/joystick/warrior.c 2004-11-24 01:48:30 -05:00
@@ -148,9 +148,6 @@
struct warrior *warrior;
int i;

- if (serio->type != (SERIO_RS232 | SERIO_WARRIOR))
- return;
-
if (!(warrior = kmalloc(sizeof(struct warrior), GFP_KERNEL)))
return;

@@ -202,14 +199,25 @@
}

/*
- * The serio device structure.
+ * The serio driver structure.
*/

+static struct serio_id warrior_serio_ids[] = {
+ {
+ .type = SERIO_RS232,
+ .proto = SERIO_WARRIOR,
+ .id = SERIO_ANY,
+ .extra = SERIO_ANY,
+ },
+ { 0 }
+};
+
static struct serio_driver warrior_drv = {
.driver = {
.name = "warrior",
},
.description = DRIVER_DESC,
+ .ids = warrior_serio_ids,
.interrupt = warrior_interrupt,
.connect = warrior_connect,
.disconnect = warrior_disconnect,
diff -Nru a/drivers/input/keyboard/atkbd.c b/drivers/input/keyboard/atkbd.c
--- a/drivers/input/keyboard/atkbd.c 2004-11-24 01:48:30 -05:00
+++ b/drivers/input/keyboard/atkbd.c 2004-11-24 01:48:30 -05:00
@@ -779,7 +779,7 @@

ps2_init(&atkbd->ps2dev, serio);

- switch (serio->type & SERIO_TYPE) {
+ switch (serio->id.type) {

case SERIO_8042_XL:
atkbd->translated = 1;
@@ -787,12 +787,6 @@
if (serio->write)
atkbd->write = 1;
break;
- case SERIO_RS232:
- if ((serio->type & SERIO_PROTO) == SERIO_PS2SER)
- break;
- default:
- kfree(atkbd);
- return;
}

atkbd->softraw = atkbd_softraw;
@@ -897,11 +891,34 @@
return 0;
}

+static struct serio_id atkbd_serio_ids[] = {
+ {
+ .type = SERIO_8042,
+ .proto = SERIO_ANY,
+ .id = SERIO_ANY,
+ .extra = SERIO_ANY,
+ },
+ {
+ .type = SERIO_8042_XL,
+ .proto = SERIO_ANY,
+ .id = SERIO_ANY,
+ .extra = SERIO_ANY,
+ },
+ {
+ .type = SERIO_RS232,
+ .proto = SERIO_PS2SER,
+ .id = SERIO_ANY,
+ .extra = SERIO_ANY,
+ },
+ { 0 }
+};
+
static struct serio_driver atkbd_drv = {
.driver = {
.name = "atkbd",
},
.description = DRIVER_DESC,
+ .ids = atkbd_serio_ids,
.interrupt = atkbd_interrupt,
.connect = atkbd_connect,
.reconnect = atkbd_reconnect,
diff -Nru a/drivers/input/keyboard/lkkbd.c b/drivers/input/keyboard/lkkbd.c
--- a/drivers/input/keyboard/lkkbd.c 2004-11-24 01:48:30 -05:00
+++ b/drivers/input/keyboard/lkkbd.c 2004-11-24 01:48:30 -05:00
@@ -629,11 +629,6 @@
struct lkkbd *lk;
int i;

- if ((serio->type & SERIO_TYPE) != SERIO_RS232)
- return;
- if ((serio->type & SERIO_PROTO) != SERIO_LKKBD)
- return;
-
if (!(lk = kmalloc (sizeof (struct lkkbd), GFP_KERNEL)))
return;
memset (lk, 0, sizeof (struct lkkbd));
@@ -708,11 +703,22 @@
kfree (lk);
}

+static struct serio_id lkkbd_serio_ids[] = {
+ {
+ .type = SERIO_RS232,
+ .proto = SERIO_LKKBD,
+ .id = SERIO_ANY,
+ .extra = SERIO_ANY,
+ },
+ { 0 }
+};
+
static struct serio_driver lkkbd_drv = {
.driver = {
.name = "lkkbd",
},
.description = DRIVER_DESC,
+ .ids = lkkbd_serio_ids,
.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-11-24 01:48:30 -05:00
+++ b/drivers/input/keyboard/newtonkbd.c 2004-11-24 01:48:30 -05:00
@@ -89,9 +89,6 @@
struct nkbd *nkbd;
int i;

- if (serio->type != (SERIO_RS232 | SERIO_NEWTON))
- return;
-
if (!(nkbd = kmalloc(sizeof(struct nkbd), GFP_KERNEL)))
return;

@@ -145,11 +142,22 @@
kfree(nkbd);
}

+static struct serio_id nkbd_serio_ids[] = {
+ {
+ .type = SERIO_RS232,
+ .proto = SERIO_NEWTON,
+ .id = SERIO_ANY,
+ .extra = SERIO_ANY,
+ },
+ { 0 }
+};
+
struct serio_driver nkbd_drv = {
.driver = {
.name = "newtonkbd",
},
.description = DRIVER_DESC,
+ .ids = nkbd_serio_ids,
.interrupt = nkbd_interrupt,
.connect = nkbd_connect,
.disconnect = nkbd_disconnect,
diff -Nru a/drivers/input/keyboard/sunkbd.c b/drivers/input/keyboard/sunkbd.c
--- a/drivers/input/keyboard/sunkbd.c 2004-11-24 01:48:30 -05:00
+++ b/drivers/input/keyboard/sunkbd.c 2004-11-24 01:48:30 -05:00
@@ -228,12 +228,6 @@
struct sunkbd *sunkbd;
int i;

- if ((serio->type & SERIO_TYPE) != SERIO_RS232)
- return;
-
- if ((serio->type & SERIO_PROTO) && (serio->type & SERIO_PROTO) != SERIO_SUNKBD)
- return;
-
if (!(sunkbd = kmalloc(sizeof(struct sunkbd), GFP_KERNEL)))
return;

@@ -307,11 +301,28 @@
kfree(sunkbd);
}

+static struct serio_id sunkbd_serio_ids[] = {
+ {
+ .type = SERIO_RS232,
+ .proto = SERIO_SUNKBD,
+ .id = SERIO_ANY,
+ .extra = SERIO_ANY,
+ },
+ {
+ .type = SERIO_RS232,
+ .proto = SERIO_UNKNOWN, /* sunkbd does probe */
+ .id = SERIO_ANY,
+ .extra = SERIO_ANY,
+ },
+ { 0 }
+};
+
static struct serio_driver sunkbd_drv = {
.driver = {
.name = "sunkbd",
},
.description = DRIVER_DESC,
+ .ids = sunkbd_serio_ids,
.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-11-24 01:48:30 -05:00
+++ b/drivers/input/keyboard/xtkbd.c 2004-11-24 01:48:30 -05:00
@@ -93,9 +93,6 @@
struct xtkbd *xtkbd;
int i;

- if ((serio->type & SERIO_TYPE) != SERIO_XT)
- return;
-
if (!(xtkbd = kmalloc(sizeof(struct xtkbd), GFP_KERNEL)))
return;

@@ -149,11 +146,22 @@
kfree(xtkbd);
}

+static struct serio_id xtkbd_serio_ids[] = {
+ {
+ .type = SERIO_XT,
+ .proto = SERIO_ANY,
+ .id = SERIO_ANY,
+ .extra = SERIO_ANY,
+ },
+ { 0 }
+};
+
struct serio_driver xtkbd_drv = {
.driver = {
.name = "xtkbd",
},
.description = DRIVER_DESC,
+ .ids = xtkbd_serio_ids,
.interrupt = xtkbd_interrupt,
.connect = xtkbd_connect,
.disconnect = xtkbd_disconnect,
diff -Nru a/drivers/input/mouse/psmouse-base.c b/drivers/input/mouse/psmouse-base.c
--- a/drivers/input/mouse/psmouse-base.c 2004-11-24 01:48:30 -05:00
+++ b/drivers/input/mouse/psmouse-base.c 2004-11-24 01:48:30 -05:00
@@ -714,7 +714,7 @@
psmouse_set_state(psmouse, PSMOUSE_CMD_MODE);
del_timer_sync(&psmouse->ping_timer);

- if (serio->parent && (serio->type & SERIO_TYPE) == SERIO_PS_PSTHRU) {
+ if (serio->parent && serio->id.type == SERIO_PS_PSTHRU) {
parent = serio_get_drvdata(serio->parent);
if (parent->pt_deactivate)
parent->pt_deactivate(parent);
@@ -739,15 +739,11 @@
{
struct psmouse *psmouse, *parent = NULL;

- if ((serio->type & SERIO_TYPE) != SERIO_8042 &&
- (serio->type & SERIO_TYPE) != SERIO_PS_PSTHRU)
- return;
-
/*
* If this is a pass-through port deactivate parent so the device
* connected to this port can be successfully identified
*/
- if (serio->parent && (serio->type & SERIO_TYPE) == SERIO_PS_PSTHRU) {
+ if (serio->parent && serio->id.type == SERIO_PS_PSTHRU) {
parent = serio_get_drvdata(serio->parent);
psmouse_deactivate(parent);
}
@@ -853,7 +849,7 @@
return -1;
}

- if (serio->parent && (serio->type & SERIO_TYPE) == SERIO_PS_PSTHRU) {
+ if (serio->parent && serio->id.type == SERIO_PS_PSTHRU) {
parent = serio_get_drvdata(serio->parent);
psmouse_deactivate(parent);
}
@@ -888,12 +884,28 @@
return rc;
}

+static struct serio_id psmouse_serio_ids[] = {
+ {
+ .type = SERIO_8042,
+ .proto = SERIO_ANY,
+ .id = SERIO_ANY,
+ .extra = SERIO_ANY,
+ },
+ {
+ .type = SERIO_PS_PSTHRU,
+ .proto = SERIO_ANY,
+ .id = SERIO_ANY,
+ .extra = SERIO_ANY,
+ },
+ { 0 }
+};

static struct serio_driver psmouse_drv = {
.driver = {
.name = "psmouse",
},
.description = DRIVER_DESC,
+ .ids = psmouse_serio_ids,
.interrupt = psmouse_interrupt,
.connect = psmouse_connect,
.reconnect = psmouse_reconnect,
@@ -940,7 +952,7 @@
goto out;
}

- if (serio->parent && (serio->type & SERIO_TYPE) == SERIO_PS_PSTHRU) {
+ if (serio->parent && serio->id.type == SERIO_PS_PSTHRU) {
parent = serio_get_drvdata(serio->parent);
psmouse_deactivate(parent);
}
diff -Nru a/drivers/input/mouse/sermouse.c b/drivers/input/mouse/sermouse.c
--- a/drivers/input/mouse/sermouse.c 2004-11-24 01:48:30 -05:00
+++ b/drivers/input/mouse/sermouse.c 2004-11-24 01:48:30 -05:00
@@ -246,10 +246,7 @@
struct sermouse *sermouse;
unsigned char c;

- if ((serio->type & SERIO_TYPE) != SERIO_RS232)
- return;
-
- if (!(serio->type & SERIO_PROTO) || ((serio->type & SERIO_PROTO) > SERIO_MZPP))
+ if (!serio->id.proto || serio->id.proto > SERIO_MZPP)
return;

if (!(sermouse = kmalloc(sizeof(struct sermouse), GFP_KERNEL)))
@@ -263,8 +260,8 @@
sermouse->dev.relbit[0] = BIT(REL_X) | BIT(REL_Y);
sermouse->dev.private = sermouse;

- sermouse->type = serio->type & SERIO_PROTO;
- c = (serio->type & SERIO_EXTRA) >> 16;
+ sermouse->type = serio->id.proto;
+ c = serio->id.extra;

if (c & 0x01) set_bit(BTN_MIDDLE, sermouse->dev.keybit);
if (c & 0x02) set_bit(BTN_SIDE, sermouse->dev.keybit);
@@ -295,11 +292,22 @@
printk(KERN_INFO "input: %s on %s\n", sermouse_protocols[sermouse->type], serio->phys);
}

+static struct serio_id sermouse_serio_ids[] = {
+ {
+ .type = SERIO_RS232,
+ .proto = SERIO_ANY,
+ .id = SERIO_ANY,
+ .extra = SERIO_ANY,
+ },
+ { 0 }
+};
+
static struct serio_driver sermouse_drv = {
.driver = {
.name = "sermouse",
},
.description = DRIVER_DESC,
+ .ids = sermouse_serio_ids,
.interrupt = sermouse_interrupt,
.connect = sermouse_connect,
.disconnect = sermouse_disconnect,
diff -Nru a/drivers/input/mouse/synaptics.c b/drivers/input/mouse/synaptics.c
--- a/drivers/input/mouse/synaptics.c 2004-11-24 01:48:30 -05:00
+++ b/drivers/input/mouse/synaptics.c 2004-11-24 01:48:30 -05:00
@@ -288,7 +288,7 @@

memset(serio, 0, sizeof(struct serio));

- serio->type = SERIO_PS_PSTHRU;
+ serio->id.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;
diff -Nru a/drivers/input/mouse/vsxxxaa.c b/drivers/input/mouse/vsxxxaa.c
--- a/drivers/input/mouse/vsxxxaa.c 2004-11-24 01:48:30 -05:00
+++ b/drivers/input/mouse/vsxxxaa.c 2004-11-24 01:48:30 -05:00
@@ -494,11 +494,6 @@
{
struct vsxxxaa *mouse;

- if ((serio->type & SERIO_TYPE) != SERIO_RS232)
- return;
- if ((serio->type & SERIO_PROTO) != SERIO_VSXXXAA)
- return;
-
if (!(mouse = kmalloc (sizeof (struct vsxxxaa), GFP_KERNEL)))
return;

@@ -551,11 +546,22 @@
printk (KERN_INFO "input: %s on %s\n", mouse->name, mouse->phys);
}

+static struct serio_id vsxxaa_serio_ids[] = {
+ {
+ .type = SERIO_RS232,
+ .proto = SERIO_VSXXXAA,
+ .id = SERIO_ANY,
+ .extra = SERIO_ANY,
+ },
+ { 0 }
+};
+
static struct serio_driver vsxxxaa_drv = {
.driver = {
.name = "vsxxxaa",
},
.description = DRIVER_DESC,
+ .ids = vsxxaa_serio_ids,
.connect = vsxxxaa_connect,
.interrupt = vsxxxaa_interrupt,
.disconnect = vsxxxaa_disconnect,
diff -Nru a/drivers/input/serio/ambakmi.c b/drivers/input/serio/ambakmi.c
--- a/drivers/input/serio/ambakmi.c 2004-11-24 01:48:30 -05:00
+++ b/drivers/input/serio/ambakmi.c 2004-11-24 01:48:30 -05:00
@@ -134,7 +134,7 @@
memset(kmi, 0, sizeof(struct amba_kmi_port));
memset(io, 0, sizeof(struct serio));

- io->type = SERIO_8042;
+ io->id.type = SERIO_8042;
io->write = amba_kmi_write;
io->open = amba_kmi_open;
io->close = amba_kmi_close;
diff -Nru a/drivers/input/serio/ct82c710.c b/drivers/input/serio/ct82c710.c
--- a/drivers/input/serio/ct82c710.c 2004-11-24 01:48:30 -05:00
+++ b/drivers/input/serio/ct82c710.c 2004-11-24 01:48:30 -05:00
@@ -181,7 +181,7 @@
serio = kmalloc(sizeof(struct serio), GFP_KERNEL);
if (serio) {
memset(serio, 0, sizeof(struct serio));
- serio->type = SERIO_8042;
+ serio->id.type = SERIO_8042;
serio->open = ct82c710_open;
serio->close = ct82c710_close;
serio->write = ct82c710_write;
diff -Nru a/drivers/input/serio/gscps2.c b/drivers/input/serio/gscps2.c
--- a/drivers/input/serio/gscps2.c 2004-11-24 01:48:30 -05:00
+++ b/drivers/input/serio/gscps2.c 2004-11-24 01:48:30 -05:00
@@ -363,11 +363,7 @@
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->id.type = SERIO_8042;
serio->write = gscps2_write;
serio->open = gscps2_open;
serio->close = gscps2_close;
diff -Nru a/drivers/input/serio/i8042.c b/drivers/input/serio/i8042.c
--- a/drivers/input/serio/i8042.c 2004-11-24 01:48:30 -05:00
+++ b/drivers/input/serio/i8042.c 2004-11-24 01:48:30 -05:00
@@ -960,7 +960,7 @@
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->id.type = i8042_direct ? SERIO_8042 : SERIO_8042_XL,
serio->write = i8042_dumbkbd ? NULL : i8042_kbd_write,
serio->open = i8042_open,
serio->close = i8042_close,
@@ -984,7 +984,7 @@
serio = kmalloc(sizeof(struct serio), GFP_KERNEL);
if (serio) {
memset(serio, 0, sizeof(struct serio));
- serio->type = SERIO_8042;
+ serio->id.type = SERIO_8042;
serio->write = i8042_aux_write;
serio->open = i8042_open;
serio->close = i8042_close;
@@ -1008,7 +1008,7 @@
serio = kmalloc(sizeof(struct serio), GFP_KERNEL);
if (serio) {
memset(serio, 0, sizeof(struct serio));
- serio->type = SERIO_8042;
+ serio->id.type = SERIO_8042;
serio->write = i8042_aux_write;
serio->open = i8042_open;
serio->close = i8042_close;
diff -Nru a/drivers/input/serio/maceps2.c b/drivers/input/serio/maceps2.c
--- a/drivers/input/serio/maceps2.c 2004-11-24 01:48:30 -05:00
+++ b/drivers/input/serio/maceps2.c 2004-11-24 01:48:30 -05:00
@@ -125,7 +125,7 @@
serio = kmalloc(sizeof(struct serio), GFP_KERNEL);
if (serio) {
memset(serio, 0, sizeof(struct serio));
- serio->type = SERIO_8042;
+ serio->id.type = SERIO_8042;
serio->write = maceps2_write;
serio->open = maceps2_open;
serio->close = maceps2_close;
diff -Nru a/drivers/input/serio/parkbd.c b/drivers/input/serio/parkbd.c
--- a/drivers/input/serio/parkbd.c 2004-11-24 01:48:30 -05:00
+++ b/drivers/input/serio/parkbd.c 2004-11-24 01:48:30 -05:00
@@ -158,7 +158,7 @@
serio = kmalloc(sizeof(struct serio), GFP_KERNEL);
if (serio) {
memset(serio, 0, sizeof(struct serio));
- serio->type = parkbd_mode;
+ serio->id.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);
diff -Nru a/drivers/input/serio/pcips2.c b/drivers/input/serio/pcips2.c
--- a/drivers/input/serio/pcips2.c 2004-11-24 01:48:30 -05:00
+++ b/drivers/input/serio/pcips2.c 2004-11-24 01:48:30 -05:00
@@ -150,7 +150,7 @@
memset(ps2if, 0, sizeof(struct pcips2_data));
memset(serio, 0, sizeof(struct serio));

- serio->type = SERIO_8042;
+ serio->id.type = SERIO_8042;
serio->write = pcips2_write;
serio->open = pcips2_open;
serio->close = pcips2_close;
diff -Nru a/drivers/input/serio/q40kbd.c b/drivers/input/serio/q40kbd.c
--- a/drivers/input/serio/q40kbd.c 2004-11-24 01:48:30 -05:00
+++ b/drivers/input/serio/q40kbd.c 2004-11-24 01:48:30 -05:00
@@ -122,7 +122,7 @@
serio = kmalloc(sizeof(struct serio), GFP_KERNEL);
if (serio) {
memset(serio, 0, sizeof(struct serio));
- serio->type = SERIO_8042;
+ serio->id.type = SERIO_8042;
serio->open = q40kbd_open;
serio->close = q40kbd_close;
serio->dev.parent = &q40kbd_device->dev;
diff -Nru a/drivers/input/serio/rpckbd.c b/drivers/input/serio/rpckbd.c
--- a/drivers/input/serio/rpckbd.c 2004-11-24 01:48:30 -05:00
+++ b/drivers/input/serio/rpckbd.c 2004-11-24 01:48:30 -05:00
@@ -115,7 +115,7 @@
return -ENOMEM;

memset(serio, 0, sizeof(struct serio));
- serio->type = SERIO_8042;
+ serio->id.type = SERIO_8042;
serio->write = rpckbd_write;
serio->open = rpckbd_open;
serio->close = rpckbd_close;
diff -Nru a/drivers/input/serio/sa1111ps2.c b/drivers/input/serio/sa1111ps2.c
--- a/drivers/input/serio/sa1111ps2.c 2004-11-24 01:48:30 -05:00
+++ b/drivers/input/serio/sa1111ps2.c 2004-11-24 01:48:30 -05:00
@@ -245,7 +245,7 @@
memset(ps2if, 0, sizeof(struct ps2if));
memset(serio, 0, sizeof(struct serio));

- serio->type = SERIO_8042;
+ serio->id.type = SERIO_8042;
serio->write = ps2_write;
serio->open = ps2_open;
serio->close = ps2_close;
diff -Nru a/drivers/input/serio/serio.c b/drivers/input/serio/serio.c
--- a/drivers/input/serio/serio.c 2004-11-24 01:48:30 -05:00
+++ b/drivers/input/serio/serio.c 2004-11-24 01:48:30 -05:00
@@ -69,17 +69,33 @@
static void serio_reconnect_port(struct serio *serio);
static void serio_disconnect_port(struct serio *serio);

+static int serio_match_port(const struct serio_id *ids, struct serio *serio)
+{
+ while (ids->type || ids->proto) {
+ if ((ids->type == SERIO_ANY || ids->type == serio->id.type) ||
+ (ids->proto == SERIO_ANY || ids->proto == serio->id.proto) ||
+ (ids->extra == SERIO_ANY || ids->extra == serio->id.extra) ||
+ (ids->id == SERIO_ANY || ids->id == serio->id.id))
+ return 1;
+ ids++;
+ }
+ return 0;
+}
+
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;
+ if (serio_match_port(drv->ids, serio)) {
+ 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;
+ }
}

put_driver(&drv->driver);
diff -Nru a/drivers/input/serio/serio_raw.c b/drivers/input/serio/serio_raw.c
--- a/drivers/input/serio/serio_raw.c 2004-11-24 01:48:30 -05:00
+++ b/drivers/input/serio/serio_raw.c 2004-11-24 01:48:30 -05:00
@@ -275,9 +275,6 @@
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;
@@ -363,11 +360,22 @@
up(&serio_raw_sem);
}

+static struct serio_id serio_raw_serio_ids[] = {
+ {
+ .type = SERIO_8042,
+ .proto = SERIO_ANY,
+ .id = SERIO_ANY,
+ .extra = SERIO_ANY,
+ },
+ { 0 }
+};
+
static struct serio_driver serio_raw_drv = {
.driver = {
.name = "serio_raw",
},
.description = DRIVER_DESC,
+ .ids = serio_raw_serio_ids,
.interrupt = serio_raw_interrupt,
.connect = serio_raw_connect,
.reconnect = serio_raw_reconnect,
diff -Nru a/drivers/input/serio/serport.c b/drivers/input/serio/serport.c
--- a/drivers/input/serio/serport.c 2004-11-24 01:48:30 -05:00
+++ b/drivers/input/serio/serport.c 2004-11-24 01:48:30 -05:00
@@ -49,7 +49,7 @@
{
struct serport *serport = serio->port_data;

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

@@ -81,7 +81,7 @@
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->id.type = SERIO_RS232;
serio->write = serport_serio_write;
serio->close = serport_serio_close;
serio->port_data = serport;
@@ -145,7 +145,7 @@

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);
+ wait_event_interruptible(serport->wait, !serport->serio->id.type);
serio_unregister_port(serport->serio);

clear_bit(SERPORT_BUSY, &serport->flags);
@@ -160,9 +160,17 @@
static int serport_ldisc_ioctl(struct tty_struct * tty, struct file * file, unsigned int cmd, unsigned long arg)
{
struct serport *serport = (struct serport*) tty->disc_data;
+ struct serio *serio = serport->serio;
+ unsigned long type;

- if (cmd == SPIOCSTYPE)
- return get_user(serport->serio->type, (unsigned long __user *) arg);
+ if (cmd == SPIOCSTYPE) {
+ if (get_user(type, (unsigned long __user *) arg))
+ return -EFAULT;
+
+ serio->id.proto = type & 0x000000ff;
+ serio->id.id = (type & 0x0000ff00) >> 8;
+ serio->id.extra = (type & 0x00ff0000) >> 16;
+ }

return -EINVAL;
}
diff -Nru a/drivers/input/touchscreen/gunze.c b/drivers/input/touchscreen/gunze.c
--- a/drivers/input/touchscreen/gunze.c 2004-11-24 01:48:30 -05:00
+++ b/drivers/input/touchscreen/gunze.c 2004-11-24 01:48:30 -05:00
@@ -111,17 +111,14 @@

/*
* gunze_connect() is the routine that is called when someone adds a
- * new serio device. It looks whether it was registered as a Gunze touchscreen
- * and if yes, registers it as an input device.
+ * new serio device that supports Gunze protocol and registers it as
+ * an input device.
*/

static void gunze_connect(struct serio *serio, struct serio_driver *drv)
{
struct gunze *gunze;

- if (serio->type != (SERIO_RS232 | SERIO_GUNZE))
- return;
-
if (!(gunze = kmalloc(sizeof(struct gunze), GFP_KERNEL)))
return;

@@ -159,14 +156,25 @@
}

/*
- * The serio device structure.
+ * The serio driver structure.
*/

+static struct serio_id gunze_serio_ids[] = {
+ {
+ .type = SERIO_RS232,
+ .proto = SERIO_GUNZE,
+ .id = SERIO_ANY,
+ .extra = SERIO_ANY,
+ },
+ { 0 }
+};
+
static struct serio_driver gunze_drv = {
.driver = {
.name = "gunze",
},
.description = DRIVER_DESC,
+ .ids = gunze_serio_ids,
.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-11-24 01:48:30 -05:00
+++ b/drivers/input/touchscreen/h3600_ts_input.c 2004-11-24 01:48:30 -05:00
@@ -102,6 +102,7 @@
struct input_dev dev;
struct pm_dev *pm_dev;
struct serio *serio;
+ struct pm_dev *pm_dev;
unsigned char event; /* event ID from packet */
unsigned char chksum;
unsigned char len;
@@ -373,16 +374,13 @@

/*
* h3600ts_connect() is the routine that is called when someone adds a
- * new serio device. It looks whether it was registered as a H3600 touchscreen
- * and if yes, registers it as an input device.
+ * new serio device that supports H3600 protocol and registers it as
+ * an input device.
*/
static void h3600ts_connect(struct serio *serio, struct serio_driver *drv)
{
struct h3600_dev *ts;

- if (serio->type != (SERIO_RS232 | SERIO_H3600))
- return;
-
if (!(ts = kmalloc(sizeof(struct h3600_dev), GFP_KERNEL)))
return;

@@ -481,14 +479,25 @@
}

/*
- * The serio device structure.
+ * The serio driver structure.
*/

+static struct serio_id h3600ts_serio_ids[] = {
+ {
+ .type = SERIO_RS232,
+ .proto = SERIO_H3600,
+ .id = SERIO_ANY,
+ .extra = SERIO_ANY,
+ },
+ { 0 }
+};
+
static struct serio_driver h3600ts_drv = {
.driver = {
.name = "h3600ts",
},
.description = DRIVER_DESC,
+ .ids = h3600ts_serio_ids,
.interrupt = h3600ts_interrupt,
.connect = h3600ts_connect,
.disconnect = h3600ts_disconnect,
diff -Nru a/drivers/serial/sunsu.c b/drivers/serial/sunsu.c
--- a/drivers/serial/sunsu.c 2004-11-24 01:48:30 -05:00
+++ b/drivers/serial/sunsu.c 2004-11-24 01:48:30 -05:00
@@ -1312,12 +1312,13 @@

serio->port_data = up;

- serio->type = SERIO_RS232;
+ serio->id.type = SERIO_RS232;
if (up->su_type == SU_PORT_KBD) {
- serio->type |= SERIO_SUNKBD;
+ serio->id.proto = SERIO_SUNKBD;
strlcpy(serio->name, "sukbd", sizeof(serio->name));
} else {
- serio->type |= (SERIO_SUN | (1 << 16));
+ serio->id.proto = SERIO_SUN;
+ serio->id.extra = 1;
strlcpy(serio->name, "sums", sizeof(serio->name));
}
strlcpy(serio->phys, (channel == 0 ? "su/serio0" : "su/serio1"),
diff -Nru a/drivers/serial/sunzilog.c b/drivers/serial/sunzilog.c
--- a/drivers/serial/sunzilog.c 2004-11-24 01:48:30 -05:00
+++ b/drivers/serial/sunzilog.c 2004-11-24 01:48:30 -05:00
@@ -1560,12 +1560,13 @@

serio->port_data = up;

- serio->type = SERIO_RS232;
+ serio->id.type = SERIO_RS232;
if (channel == KEYBOARD_LINE) {
- serio->type |= SERIO_SUNKBD;
+ serio->id.proto = SERIO_SUNKBD;
strlcpy(serio->name, "zskbd", sizeof(serio->name));
} else {
- serio->type |= (SERIO_SUN | (1 << 16));
+ serio->id.proto = SERIO_SUN;
+ serio->id.extra = 1;
strlcpy(serio->name, "zsms", sizeof(serio->name));
}
strlcpy(serio->phys,
diff -Nru a/include/linux/serio.h b/include/linux/serio.h
--- a/include/linux/serio.h 2004-11-24 01:48:30 -05:00
+++ b/include/linux/serio.h 2004-11-24 01:48:30 -05:00
@@ -20,6 +20,13 @@
#include <linux/spinlock.h>
#include <linux/device.h>

+struct serio_id {
+ unsigned char type;
+ unsigned char extra;
+ unsigned char id;
+ unsigned char proto;
+};
+
struct serio {
void *port_data;

@@ -28,13 +35,7 @@

unsigned int manual_bind;

- unsigned short idbus;
- unsigned short idvendor;
- unsigned short idproduct;
- unsigned short idversion;
-
- unsigned long type;
- unsigned long event;
+ struct serio_id id;

spinlock_t lock; /* protects critical sections from port's interrupt handler */

@@ -59,6 +60,7 @@
void *private;
char *description;

+ struct serio_id *ids;
unsigned int manual_bind;

void (*write_wakeup)(struct serio *);
@@ -160,15 +162,22 @@
#define SERIO_PARITY 2
#define SERIO_FRAME 4

-#define SERIO_TYPE 0xff000000UL
-#define SERIO_XT 0x00000000UL
-#define SERIO_8042 0x01000000UL
-#define SERIO_RS232 0x02000000UL
-#define SERIO_HIL_MLC 0x03000000UL
-#define SERIO_PS_PSTHRU 0x05000000UL
-#define SERIO_8042_XL 0x06000000UL
+#define SERIO_ANY 0xff

-#define SERIO_PROTO 0xFFUL
+/*
+ * Serio types
+ */
+#define SERIO_XT 0x00
+#define SERIO_8042 0x01
+#define SERIO_RS232 0x02
+#define SERIO_HIL_MLC 0x03
+#define SERIO_PS_PSTHRU 0x05
+#define SERIO_8042_XL 0x06
+
+/*
+ * Serio types
+ */
+#define SERIO_UNKNOWN 0x00
#define SERIO_MSC 0x01
#define SERIO_SUN 0x02
#define SERIO_MS 0x03
@@ -195,8 +204,5 @@
#define SERIO_SNES232 0x26
#define SERIO_SEMTECH 0x27
#define SERIO_LKKBD 0x28
-
-#define SERIO_ID 0xff00UL
-#define SERIO_EXTRA 0xff0000UL

#endif

2004-11-24 07:31:20

by Dmitry Torokhov

[permalink] [raw]
Subject: [PATCH 7/11] input: use msecs_to_jiffies


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


[email protected], 2004-11-24 00:41:39-05:00, [email protected]
Input: use msecs_to_jiffies instead of homegrown ms_to_jiffies
when setting timer for autorepeat handling. This will
make sure that autorepeat is scheduled correctly when
HZ != 1000.

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


input.c | 15 ++++-----------
1 files changed, 4 insertions(+), 11 deletions(-)


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



diff -Nru a/drivers/input/input.c b/drivers/input/input.c
--- a/drivers/input/input.c 2004-11-24 01:52:55 -05:00
+++ b/drivers/input/input.c 2004-11-24 01:52:55 -05:00
@@ -54,14 +54,6 @@
static int input_devices_state;
#endif

-static inline unsigned int ms_to_jiffies(unsigned int ms)
-{
- unsigned int j;
- j = (ms * HZ + 500) / 1000;
- return (j > 0) ? j : 1;
-}
-
-
void input_event(struct input_dev *dev, unsigned int type, unsigned int code, int value)
{
struct input_handle *handle;
@@ -96,9 +88,9 @@

change_bit(code, dev->key);

- if (test_bit(EV_REP, dev->evbit) && dev->rep[REP_PERIOD] && dev->timer.data && value) {
+ if (test_bit(EV_REP, dev->evbit) && dev->rep[REP_PERIOD] && dev->rep[REP_DELAY] && dev->timer.data && value) {
dev->repeat_key = code;
- mod_timer(&dev->timer, jiffies + ms_to_jiffies(dev->rep[REP_DELAY]));
+ mod_timer(&dev->timer, jiffies + msecs_to_jiffies(dev->rep[REP_DELAY]));
}

break;
@@ -198,7 +190,8 @@
input_event(dev, EV_KEY, dev->repeat_key, 2);
input_sync(dev);

- mod_timer(&dev->timer, jiffies + ms_to_jiffies(dev->rep[REP_PERIOD]));
+ if (dev->rep[REP_PERIOD])
+ mod_timer(&dev->timer, jiffies + msecs_to_jiffies(dev->rep[REP_PERIOD]));
}

int input_accept_process(struct input_handle *handle, struct file *file)

2004-11-24 07:31:21

by Dmitry Torokhov

[permalink] [raw]
Subject: [PATCH 6/11] serio bus code cleanup


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


[email protected], 2004-11-24 00:33:25-05:00, [email protected]
Input: make serio implementation more in line with standard
driver model implementations. serio_register_port is
always asynchronous to allow freely registering child
ports. When deregistering serio core still takes care
of destroying children ports first.

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


drivers/input/mouse/psmouse-base.c | 11 -
drivers/input/mouse/synaptics.c | 10 -
drivers/input/serio/serio.c | 350 +++++++++++++++++++------------------
include/linux/serio.h | 17 +
4 files changed, 208 insertions(+), 180 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-11-24 01:51:14 -05:00
+++ b/drivers/input/mouse/psmouse-base.c 2004-11-24 01:51:14 -05:00
@@ -754,6 +754,7 @@
memset(psmouse, 0, sizeof(struct psmouse));

ps2_init(&psmouse->ps2dev, serio);
+ sprintf(psmouse->phys, "%s/input0", serio->phys);
init_timer(&psmouse->ping_timer);
psmouse->ping_timer.data = (unsigned long)psmouse;
psmouse->ping_timer.function = psmouse_ping_device;
@@ -793,8 +794,6 @@

sprintf(psmouse->devname, "%s %s %s",
psmouse_protocols[psmouse->type], psmouse->vendor, psmouse->name);
- sprintf(psmouse->phys, "%s/input0",
- serio->phys);

psmouse->dev.name = psmouse->devname;
psmouse->dev.phys = psmouse->phys;
@@ -819,14 +818,6 @@
device_create_file(&serio->dev, &psmouse_attr_rate);
device_create_file(&serio->dev, &psmouse_attr_resolution);
device_create_file(&serio->dev, &psmouse_attr_resetafter);
-
- 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);
- }

psmouse_activate(psmouse);

diff -Nru a/drivers/input/mouse/synaptics.c b/drivers/input/mouse/synaptics.c
--- a/drivers/input/mouse/synaptics.c 2004-11-24 01:51:14 -05:00
+++ b/drivers/input/mouse/synaptics.c 2004-11-24 01:51:14 -05:00
@@ -296,7 +296,8 @@

psmouse->pt_activate = synaptics_pt_activate;

- psmouse->ps2dev.serio->child = serio;
+ printk(KERN_INFO "serio: %s port at %s\n", serio->name, psmouse->phys);
+ serio_register_port(serio);
}

/*****************************************************************************
@@ -552,6 +553,7 @@
{
synaptics_reset(psmouse);
kfree(psmouse->private);
+ psmouse->private = NULL;
}

static int synaptics_reconnect(struct psmouse *psmouse)
@@ -640,9 +642,6 @@

priv->pkt_type = SYN_MODEL_NEWABS(priv->model_id) ? SYN_NEWABS : SYN_OLDABS;

- if (SYN_CAP_PASS_THROUGH(priv->capabilities))
- synaptics_pt_create(psmouse);
-
print_ident(priv);
set_input_params(&psmouse->dev, priv);

@@ -651,6 +650,9 @@
psmouse->disconnect = synaptics_disconnect;
psmouse->reconnect = synaptics_reconnect;
psmouse->pktsize = 6;
+
+ if (SYN_CAP_PASS_THROUGH(priv->capabilities))
+ synaptics_pt_create(psmouse);

#if defined(__i386__)
/*
diff -Nru a/drivers/input/serio/serio.c b/drivers/input/serio/serio.c
--- a/drivers/input/serio/serio.c 2004-11-24 01:51:14 -05:00
+++ b/drivers/input/serio/serio.c 2004-11-24 01:51:14 -05:00
@@ -42,10 +42,9 @@
MODULE_LICENSE("GPL");

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_delayed);
EXPORT_SYMBOL(serio_register_driver);
EXPORT_SYMBOL(serio_unregister_driver);
EXPORT_SYMBOL(serio_open);
@@ -53,19 +52,20 @@
EXPORT_SYMBOL(serio_rescan);
EXPORT_SYMBOL(serio_reconnect);

-static DECLARE_MUTEX(serio_sem); /* protects serio_list and serio_diriver_list */
+/*
+ * serio_sem protects entire serio subsystem and is taken every time
+ * serio port or driver registrered or unregistered.
+ */
+static DECLARE_MUTEX(serio_sem);
+
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);
+static void serio_add_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);

@@ -82,37 +82,37 @@
return 0;
}

-static int serio_bind_driver(struct serio *serio, struct serio_driver *drv)
-{
- get_driver(&drv->driver);
+/*
+ * Basic serio -> driver core mappings
+ */

+static void serio_bind_driver(struct serio *serio, struct serio_driver *drv)
+{
+ down_write(&serio_bus.subsys.rwsem);
if (serio_match_port(drv->ids, serio)) {
+ serio->dev.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;
- }
+ if (!serio->drv)
+ serio->dev.driver = NULL;
}
+ up_write(&serio_bus.subsys.rwsem);
+}

- put_driver(&drv->driver);
- return 0;
+static void serio_release_driver(struct serio *serio)
+{
+ down_write(&serio_bus.subsys.rwsem);
+ device_release_driver(&serio->dev);
+ up_write(&serio_bus.subsys.rwsem);
}

-/* 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 (!drv->manual_bind)
- if (serio_bind_driver(serio, drv))
- break;
+ down_write(&serio_bus.subsys.rwsem);
+ device_attach(&serio->dev);
+ up_write(&serio_bus.subsys.rwsem);
}

+
/*
* Serio event processing.
*/
@@ -120,6 +120,7 @@
struct serio_event {
int type;
struct serio *serio;
+ struct module *owner;
struct list_head node;
};

@@ -136,7 +137,8 @@
static DECLARE_COMPLETION(serio_exited);
static int serio_pid;

-static void serio_queue_event(struct serio *serio, enum serio_event_type event_type)
+static void serio_queue_event(struct serio *serio, struct module *owner,
+ enum serio_event_type event_type)
{
unsigned long flags;
struct serio_event *event;
@@ -159,17 +161,27 @@
}

if ((event = kmalloc(sizeof(struct serio_event), GFP_ATOMIC))) {
+ __module_get(owner);
+
event->type = event_type;
event->serio = serio;
+ event->owner = owner;

list_add_tail(&event->node, &serio_event_list);
wake_up(&serio_wait);
+ } else {
+ printk(KERN_ERR "serio: Not enough memory to queue event %d\n", event_type);
}
-
out:
spin_unlock_irqrestore(&serio_event_lock, flags);
}

+static void serio_free_event(struct serio_event *event)
+{
+ module_put(event->owner);
+ kfree(event);
+}
+
static void serio_remove_duplicate_events(struct serio_event *event)
{
struct list_head *node, *next;
@@ -179,7 +191,7 @@
spin_lock_irqsave(&serio_event_lock, flags);

list_for_each_safe(node, next, &serio_event_list) {
- e = container_of(node, struct serio_event, node);
+ e = list_entry(node, struct serio_event, node);
if (event->serio == e->serio) {
/*
* If this event is of different type we should not
@@ -187,9 +199,10 @@
* that were sent back-to-back.
*/
if (event->type != e->type)
- break; /* Stop, when need to preserve event flow */
+ break;
+
list_del_init(node);
- kfree(e);
+ serio_free_event(e);
}
}

@@ -211,7 +224,7 @@
}

node = serio_event_list.next;
- event = container_of(node, struct serio_event, node);
+ event = list_entry(node, struct serio_event, node);
list_del_init(node);

spin_unlock_irqrestore(&serio_event_lock, flags);
@@ -223,14 +236,14 @@
{
struct serio_event *event;

- while ((event = serio_get_event())) {
+ down(&serio_sem);

- down(&serio_sem);
+ while ((event = serio_get_event())) {

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

case SERIO_UNREGISTER_PORT :
@@ -244,18 +257,22 @@

case SERIO_RESCAN :
serio_disconnect_port(event->serio);
- serio_connect_port(event->serio, NULL);
+ serio_find_driver(event->serio);
break;
default:
break;
}

- up(&serio_sem);
serio_remove_duplicate_events(event);
- kfree(event);
+ serio_free_event(event);
}
+
+ up(&serio_sem);
}

+/*
+ * Remove all events that have been submitted for a given serio port.
+ */
static void serio_remove_pending_events(struct serio *serio)
{
struct list_head *node, *next;
@@ -265,16 +282,42 @@
spin_lock_irqsave(&serio_event_lock, flags);

list_for_each_safe(node, next, &serio_event_list) {
- event = container_of(node, struct serio_event, node);
+ event = list_entry(node, struct serio_event, node);
if (event->serio == serio) {
list_del_init(node);
- kfree(event);
+ serio_free_event(event);
}
}

spin_unlock_irqrestore(&serio_event_lock, flags);
}

+/*
+ * Destroy child serio port (if any) that has not been fully registered yet.
+ *
+ * Note that we rely on the fact that port can have only one child and therefore
+ * only one child registration request can be pending. Additionally, children
+ * are registered by driver's connect() handler so there can't be a grandchild
+ * pending registration together with a child.
+ */
+static struct serio *serio_get_pending_child(struct serio *parent)
+{
+ struct serio_event *event;
+ struct serio *serio = NULL;
+ unsigned long flags;
+
+ spin_lock_irqsave(&serio_event_lock, flags);
+
+ list_for_each_entry(event, &serio_event_list, node) {
+ if (event->type == SERIO_REGISTER_PORT && event->serio->parent == parent) {
+ serio = event->serio;
+ break;
+ }
+ }
+
+ spin_unlock_irqrestore(&serio_event_lock, flags);
+ return serio;
+}

static int serio_thread(void *nothing)
{
@@ -323,10 +366,10 @@
serio_reconnect_port(serio);
} else if (!strncmp(buf, "rescan", count)) {
serio_disconnect_port(serio);
- serio_connect_port(serio, NULL);
+ serio_find_driver(serio);
} else if ((drv = driver_find(buf, &serio_bus)) != NULL) {
serio_disconnect_port(serio);
- serio_connect_port(serio, to_serio_driver(drv));
+ serio_bind_driver(serio, to_serio_driver(drv));
put_driver(drv);
} else {
retval = -EINVAL;
@@ -376,22 +419,43 @@
module_put(THIS_MODULE);
}

-static void serio_create_port(struct serio *serio)
+/*
+ * Prepare serio port for registration.
+ */
+static void serio_init_port(struct serio *serio)
{
- try_module_get(THIS_MODULE);
+ static atomic_t serio_no = ATOMIC_INIT(0);
+
+ __module_get(THIS_MODULE);

spin_lock_init(&serio->lock);
init_MUTEX(&serio->drv_sem);
- list_add_tail(&serio->node, &serio_list);
- snprintf(serio->dev.bus_id, sizeof(serio->dev.bus_id), "serio%d", serio_no++);
+ device_initialize(&serio->dev);
+ snprintf(serio->dev.bus_id, sizeof(serio->dev.bus_id),
+ "serio%d", atomic_inc_return(&serio_no) - 1);
serio->dev.bus = &serio_bus;
serio->dev.release = serio_release_port;
if (serio->parent)
serio->dev.parent = &serio->parent->dev;
- device_initialize(&serio->dev);
+}
+
+/*
+ * Complete serio port registration.
+ * Driver core will attempt to find appropriate driver for the port.
+ */
+static void serio_add_port(struct serio *serio)
+{
+ if (serio->parent) {
+ serio_pause_rx(serio->parent);
+ serio->parent->child = serio;
+ serio_continue_rx(serio->parent);
+ }
+
+ list_add_tail(&serio->node, &serio_list);
if (serio->start)
serio->start(serio);
device_add(&serio->dev);
+ serio->registered = 1;
}

/*
@@ -400,77 +464,43 @@
*/
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);
+ struct serio *child;

- 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);
+ child = serio_get_pending_child(serio);
+ if (child) {
+ serio_remove_pending_events(child);
+ put_device(&child->dev);
}

if (serio->stop)
serio->stop(serio);

if (serio->parent) {
- spin_lock_irqsave(&serio->parent->lock, flags);
+ serio_pause_rx(serio->parent);
serio->parent->child = NULL;
- spin_unlock_irqrestore(&serio->parent->lock, flags);
+ serio->parent = NULL;
+ serio_continue_rx(serio->parent);
}

- device_unregister(&serio->dev);
-}
-
-/*
- * 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 if (!serio->manual_bind)
- 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);
-
- if (!serio->manual_bind) {
- /*
- * 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);
- }
+ if (serio->registered) {
+ device_del(&serio->dev);
+ list_del_init(&serio->node);
+ serio->registered = 0;
}
+
+ serio_remove_pending_events(serio);
+ put_device(&serio->dev);
}

/*
- *
+ * Reconnect serio port and all its children (re-initialize attached devices)
*/
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);
+ serio_find_driver(serio);
/* Ok, old children are now gone, we are done */
break;
}
@@ -484,8 +514,7 @@
*/
static void serio_disconnect_port(struct serio *serio)
{
- struct serio_driver *drv = serio->drv;
- struct serio *s;
+ struct serio *s, *parent;

if (serio->child) {
/*
@@ -493,56 +522,46 @@
* first, staring with the leaf one, since we don't want
* to do recursion
*/
+ for (s = serio; s->child; s = s->child)
+ /* empty */;
+
do {
- s = serio->child;
- } while (s->child);
+ parent = s->parent;

- while (s != serio) {
- s = s->parent;
- serio_destroy_port(s->child);
- }
+ serio_release_driver(s);
+ serio_destroy_port(s);
+ } while ((s = parent) != serio);
}

/*
* Ok, no children left, now disconnect this port
*/
- 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);
- }
+ serio_release_driver(serio);
}

void serio_rescan(struct serio *serio)
{
- serio_queue_event(serio, SERIO_RESCAN);
+ serio_queue_event(serio, NULL, SERIO_RESCAN);
}

void serio_reconnect(struct serio *serio)
{
- serio_queue_event(serio, SERIO_RECONNECT);
-}
-
-void serio_register_port(struct serio *serio)
-{
- down(&serio_sem);
- serio_create_port(serio);
- serio_connect_port(serio, NULL);
- up(&serio_sem);
+ serio_queue_event(serio, NULL, SERIO_RECONNECT);
}

/*
* Submits register request to kseriod for subsequent execution.
- * Can be used when it is not obvious whether the serio_sem is
- * taken or not and when delayed execution is feasible.
+ * Note that port registration is always asynchronous.
*/
-void serio_register_port_delayed(struct serio *serio)
+void __serio_register_port(struct serio *serio, struct module *owner)
{
- serio_queue_event(serio, SERIO_REGISTER_PORT);
+ serio_init_port(serio);
+ serio_queue_event(serio, owner, SERIO_REGISTER_PORT);
}

+/*
+ * Synchronously unregisters serio port.
+ */
void serio_unregister_port(struct serio *serio)
{
down(&serio_sem);
@@ -552,13 +571,13 @@
}

/*
- * Submits unregister request to kseriod for subsequent execution.
+ * Submits register request to kseriod for subsequent execution.
* Can be used when it is not obvious whether the serio_sem is
* taken or not and when delayed execution is feasible.
*/
-void serio_unregister_port_delayed(struct serio *serio)
+void __serio_unregister_port_delayed(struct serio *serio, struct module *owner)
{
- serio_queue_event(serio, SERIO_UNREGISTER_PORT);
+ serio_queue_event(serio, owner, SERIO_UNREGISTER_PORT);
}


@@ -603,34 +622,33 @@
__ATTR_NULL
};

-void serio_register_driver(struct serio_driver *drv)
+static int serio_driver_probe(struct device *dev)
{
- struct serio *serio;
+ struct serio *serio = to_serio_port(dev);
+ struct serio_driver *drv = to_serio_driver(dev->driver);

- down(&serio_sem);
+ drv->connect(serio, drv);
+ return serio->drv ? 0 : -ENODEV;
+}

- list_add_tail(&drv->node, &serio_driver_list);
+static int serio_driver_remove(struct device *dev)
+{
+ struct serio *serio = to_serio_port(dev);
+ struct serio_driver *drv = to_serio_driver(dev->driver);

- drv->driver.bus = &serio_bus;
- driver_register(&drv->driver);
+ drv->disconnect(serio);
+ return 0;
+}

- if (drv->manual_bind)
- goto out;
+void serio_register_driver(struct serio_driver *drv)
+{
+ down(&serio_sem);

-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;
- }
- }
+ drv->driver.bus = &serio_bus;
+ drv->driver.probe = serio_driver_probe;
+ drv->driver.remove = serio_driver_remove;
+ driver_register(&drv->driver);

-out:
up(&serio_sem);
}

@@ -639,21 +657,19 @@
struct serio *serio;

down(&serio_sem);
-
- list_del_init(&drv->node);
+ drv->manual_bind = 1; /* so serio_find_driver ignores it */

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

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

@@ -666,6 +682,17 @@
up(&serio->drv_sem);
}

+static int serio_bus_match(struct device *dev, struct device_driver *drv)
+{
+ struct serio *serio = to_serio_port(dev);
+ struct serio_driver *serio_drv = to_serio_driver(drv);
+
+ if (serio->manual_bind || serio_drv->manual_bind)
+ return 0;
+
+ return serio_match_port(serio_drv->ids, serio);
+}
+
/* called from serio_driver->connect/disconnect methods under serio_sem */
int serio_open(struct serio *serio, struct serio_driver *drv)
{
@@ -697,7 +724,7 @@

if (likely(serio->drv)) {
ret = serio->drv->interrupt(serio, data, dfl, regs);
- } else if (!dfl) {
+ } else if (!dfl && serio->registered) {
serio_rescan(serio);
ret = IRQ_HANDLED;
}
@@ -710,12 +737,13 @@
static int __init serio_init(void)
{
if (!(serio_pid = kernel_thread(serio_thread, NULL, CLONE_KERNEL))) {
- printk(KERN_WARNING "serio: Failed to start kseriod\n");
+ printk(KERN_ERR "serio: Failed to start kseriod\n");
return -1;
}

serio_bus.dev_attrs = serio_device_attrs;
serio_bus.drv_attrs = serio_driver_attrs;
+ serio_bus.match = serio_bus_match;
bus_register(&serio_bus);

return 0;
diff -Nru a/include/linux/serio.h b/include/linux/serio.h
--- a/include/linux/serio.h 2004-11-24 01:51:14 -05:00
+++ b/include/linux/serio.h 2004-11-24 01:51:14 -05:00
@@ -51,6 +51,7 @@
struct semaphore drv_sem; /* protects serio->drv so attributes can pin driver */

struct device dev;
+ unsigned int registered; /* port has been fully registered with driver core */

struct list_head node;
};
@@ -72,8 +73,6 @@
void (*cleanup)(struct serio *);

struct device_driver driver;
-
- struct list_head node;
};
#define to_serio_driver(d) container_of(d, struct serio_driver, driver)

@@ -83,10 +82,18 @@
void serio_reconnect(struct serio *serio);
irqreturn_t serio_interrupt(struct serio *serio, unsigned char data, unsigned int flags, struct pt_regs *regs);

-void serio_register_port(struct serio *serio);
-void serio_register_port_delayed(struct serio *serio);
+void __serio_register_port(struct serio *serio, struct module *owner);
+static inline void serio_register_port(struct serio *serio)
+{
+ __serio_register_port(serio, THIS_MODULE);
+}
+
void serio_unregister_port(struct serio *serio);
-void serio_unregister_port_delayed(struct serio *serio);
+void __serio_unregister_port_delayed(struct serio *serio, struct module *owner);
+static inline void serio_unregister_port_delayed(struct serio *serio)
+{
+ __serio_unregister_port_delayed(serio, THIS_MODULE);
+}

void serio_register_driver(struct serio_driver *drv);
void serio_unregister_driver(struct serio_driver *drv);

2004-11-24 07:34:39

by Dmitry Torokhov

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


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


[email protected], 2004-11-24 01:28:49-05:00, [email protected]
Input: make connect and disconnect methods mandatory for gameport
drivers since that's where gameport_{open|close} are called
from to actually bind driver to a port.

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


gameport.c | 9 ++++-----
1 files changed, 4 insertions(+), 5 deletions(-)


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



diff -Nru a/drivers/input/gameport/gameport.c b/drivers/input/gameport/gameport.c
--- a/drivers/input/gameport/gameport.c 2004-11-24 01:58:30 -05:00
+++ b/drivers/input/gameport/gameport.c 2004-11-24 01:58:30 -05:00
@@ -107,8 +107,7 @@
list_for_each_entry(drv, &gameport_driver_list, node) {
if (gameport->drv)
break;
- if (drv->connect)
- drv->connect(gameport, drv);
+ drv->connect(gameport, drv);
}
}

@@ -128,7 +127,7 @@
void gameport_unregister_port(struct gameport *gameport)
{
list_del_init(&gameport->node);
- if (gameport->drv && gameport->drv->disconnect)
+ if (gameport->drv)
gameport->drv->disconnect(gameport);
}

@@ -138,7 +137,7 @@

list_add_tail(&drv->node, &gameport_driver_list);
list_for_each_entry(gameport, &gameport_list, node)
- if (!gameport->drv && drv->connect)
+ if (!gameport->drv)
drv->connect(gameport, drv);
}

@@ -148,7 +147,7 @@

list_del_init(&drv->node);
list_for_each_entry(gameport, &gameport_list, node) {
- if (gameport->drv == drv && drv->disconnect)
+ if (gameport->drv == drv)
drv->disconnect(gameport);
gameport_find_driver(gameport);
}

2004-11-24 07:44:50

by Dmitry Torokhov

[permalink] [raw]
Subject: [PATCH 9/11] gameport renames part 1


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


[email protected], 2004-11-24 01:20:17-05:00, [email protected]
Input: rename gameport->driver to gameport->port_data in preparation
to sysfs integration.

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


drivers/input/gameport/lightning.c | 8 ++++----
drivers/input/gameport/vortex.c | 10 +++++-----
drivers/input/joystick/a3d.c | 8 ++++----
include/linux/gameport.h | 4 ++--
sound/oss/trident.c | 10 +++++-----
sound/pci/au88x0/au88x0_game.c | 15 +++++++--------
6 files changed, 27 insertions(+), 28 deletions(-)


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



diff -Nru a/drivers/input/gameport/lightning.c b/drivers/input/gameport/lightning.c
--- a/drivers/input/gameport/lightning.c 2004-11-24 01:55:49 -05:00
+++ b/drivers/input/gameport/lightning.c 2004-11-24 01:55:49 -05:00
@@ -79,7 +79,7 @@

static int l4_cooked_read(struct gameport *gameport, int *axes, int *buttons)
{
- struct l4 *l4 = gameport->driver;
+ struct l4 *l4 = gameport->port_data;
unsigned char status;
int i, result = -1;

@@ -112,7 +112,7 @@

static int l4_open(struct gameport *gameport, int mode)
{
- struct l4 *l4 = gameport->driver;
+ struct l4 *l4 = gameport->port_data;
if (l4->port != 0 && mode != GAMEPORT_MODE_COOKED)
return -1;
outb(L4_SELECT_ANALOG, L4_PORT);
@@ -190,7 +190,7 @@
{
int i, t;
int cal[4];
- struct l4 *l4 = gameport->driver;
+ struct l4 *l4 = gameport->port_data;

if (l4_getcal(l4->port, cal))
return -1;
@@ -252,7 +252,7 @@
sprintf(l4->phys, "isa%04x/gameport%d", L4_PORT, 4 * i + j);

gameport = &l4->gameport;
- gameport->driver = l4;
+ gameport->port_data = l4;
gameport->open = l4_open;
gameport->cooked_read = l4_cooked_read;
gameport->calibrate = l4_calibrate;
diff -Nru a/drivers/input/gameport/vortex.c b/drivers/input/gameport/vortex.c
--- a/drivers/input/gameport/vortex.c 2004-11-24 01:55:49 -05:00
+++ b/drivers/input/gameport/vortex.c 2004-11-24 01:55:49 -05:00
@@ -62,19 +62,19 @@

static unsigned char vortex_read(struct gameport *gameport)
{
- struct vortex *vortex = gameport->driver;
+ struct vortex *vortex = gameport->port_data;
return readb(vortex->io + VORTEX_LEG);
}

static void vortex_trigger(struct gameport *gameport)
{
- struct vortex *vortex = gameport->driver;
+ struct vortex *vortex = gameport->port_data;
writeb(0xff, vortex->io + VORTEX_LEG);
}

static int vortex_cooked_read(struct gameport *gameport, int *axes, int *buttons)
{
- struct vortex *vortex = gameport->driver;
+ struct vortex *vortex = gameport->port_data;
int i;

*buttons = (~readb(vortex->base + VORTEX_LEG) >> 4) & 0xf;
@@ -89,7 +89,7 @@

static int vortex_open(struct gameport *gameport, int mode)
{
- struct vortex *vortex = gameport->driver;
+ struct vortex *vortex = gameport->port_data;

switch (mode) {
case GAMEPORT_MODE_COOKED:
@@ -120,7 +120,7 @@

pci_set_drvdata(dev, vortex);

- vortex->gameport.driver = vortex;
+ vortex->gameport.port_data = vortex;
vortex->gameport.fuzz = 64;

vortex->gameport.read = vortex_read;
diff -Nru a/drivers/input/joystick/a3d.c b/drivers/input/joystick/a3d.c
--- a/drivers/input/joystick/a3d.c 2004-11-24 01:55:49 -05:00
+++ b/drivers/input/joystick/a3d.c 2004-11-24 01:55:49 -05:00
@@ -197,7 +197,7 @@

int a3d_adc_cooked_read(struct gameport *gameport, int *axes, int *buttons)
{
- struct a3d *a3d = gameport->driver;
+ struct a3d *a3d = gameport->port_data;
int i;
for (i = 0; i < 4; i++)
axes[i] = (a3d->axes[i] < 254) ? a3d->axes[i] : -1;
@@ -212,7 +212,7 @@

int a3d_adc_open(struct gameport *gameport, int mode)
{
- struct a3d *a3d = gameport->driver;
+ struct a3d *a3d = gameport->port_data;
if (mode != GAMEPORT_MODE_COOKED)
return -1;
if (!a3d->used++)
@@ -226,7 +226,7 @@

static void a3d_adc_close(struct gameport *gameport)
{
- struct a3d *a3d = gameport->driver;
+ struct a3d *a3d = gameport->port_data;
if (!--a3d->used)
del_timer(&a3d->timer);
}
@@ -336,7 +336,7 @@
a3d->dev.relbit[0] |= BIT(REL_X) | BIT(REL_Y);
a3d->dev.keybit[LONG(BTN_MOUSE)] |= BIT(BTN_RIGHT) | BIT(BTN_LEFT) | BIT(BTN_MIDDLE);

- a3d->adc.driver = a3d;
+ a3d->adc.port_data = a3d;
a3d->adc.open = a3d_adc_open;
a3d->adc.close = a3d_adc_close;
a3d->adc.cooked_read = a3d_adc_cooked_read;
diff -Nru a/include/linux/gameport.h b/include/linux/gameport.h
--- a/include/linux/gameport.h 2004-11-24 01:55:49 -05:00
+++ b/include/linux/gameport.h 2004-11-24 01:55:49 -05:00
@@ -17,8 +17,8 @@

struct gameport {

- void *private; /* Private pointer for joystick drivers */
- void *driver; /* Private pointer for gameport drivers */
+ void *private; /* Private pointer for joystick drivers */
+ void *port_data; /* Private pointer for gameport drivers */
char *name;
char *phys;

diff -Nru a/sound/oss/trident.c b/sound/oss/trident.c
--- a/sound/oss/trident.c 2004-11-24 01:55:49 -05:00
+++ b/sound/oss/trident.c 2004-11-24 01:55:49 -05:00
@@ -4256,21 +4256,21 @@
static unsigned char
trident_game_read(struct gameport *gameport)
{
- struct trident_card *card = gameport->driver;
+ struct trident_card *card = gameport->port_data;
return inb(TRID_REG(card, T4D_GAME_LEG));
}

static void
trident_game_trigger(struct gameport *gameport)
{
- struct trident_card *card = gameport->driver;
+ struct trident_card *card = gameport->port_data;
outb(0xff, TRID_REG(card, T4D_GAME_LEG));
}

static int
trident_game_cooked_read(struct gameport *gameport, int *axes, int *buttons)
{
- struct trident_card *card = gameport->driver;
+ struct trident_card *card = gameport->port_data;
int i;

*buttons = (~inb(TRID_REG(card, T4D_GAME_LEG)) >> 4) & 0xf;
@@ -4287,7 +4287,7 @@
static int
trident_game_open(struct gameport *gameport, int mode)
{
- struct trident_card *card = gameport->driver;
+ struct trident_card *card = gameport->port_data;

switch (mode) {
case GAMEPORT_MODE_COOKED:
@@ -4367,7 +4367,7 @@
card->banks[BANK_B].addresses = &bank_b_addrs;
card->banks[BANK_B].bitmap = 0UL;

- card->gameport.driver = card;
+ card->gameport.port_data = card;
card->gameport.fuzz = 64;
card->gameport.read = trident_game_read;
card->gameport.trigger = trident_game_trigger;
diff -Nru a/sound/pci/au88x0/au88x0_game.c b/sound/pci/au88x0/au88x0_game.c
--- a/sound/pci/au88x0/au88x0_game.c 2004-11-24 01:55:49 -05:00
+++ b/sound/pci/au88x0/au88x0_game.c 2004-11-24 01:55:49 -05:00
@@ -44,20 +44,20 @@

static unsigned char vortex_game_read(struct gameport *gameport)
{
- vortex_t *vortex = gameport->driver;
+ vortex_t *vortex = gameport->port_data;
return hwread(vortex->mmio, VORTEX_GAME_LEGACY);
}

static void vortex_game_trigger(struct gameport *gameport)
{
- vortex_t *vortex = gameport->driver;
+ vortex_t *vortex = gameport->port_data;
hwwrite(vortex->mmio, VORTEX_GAME_LEGACY, 0xff);
}

static int
vortex_game_cooked_read(struct gameport *gameport, int *axes, int *buttons)
{
- vortex_t *vortex = gameport->driver;
+ vortex_t *vortex = gameport->port_data;
int i;

*buttons = (~hwread(vortex->mmio, VORTEX_GAME_LEGACY) >> 4) & 0xf;
@@ -73,7 +73,7 @@

static int vortex_game_open(struct gameport *gameport, int mode)
{
- vortex_t *vortex = gameport->driver;
+ vortex_t *vortex = gameport->port_data;

switch (mode) {
case GAMEPORT_MODE_COOKED:
@@ -96,11 +96,10 @@

static int vortex_gameport_register(vortex_t * vortex)
{
- if ((vortex->gameport = kcalloc(1, sizeof(struct gameport), GFP_KERNEL)) == NULL) {
+ if ((vortex->gameport = kcalloc(1, sizeof(struct gameport), GFP_KERNEL)) == NULL)
return -1;
- };
-
- vortex->gameport->driver = vortex;
+
+ vortex->gameport->port_data = vortex;
vortex->gameport->fuzz = 64;

vortex->gameport->read = vortex_game_read;

2004-11-24 07:34:38

by Dmitry Torokhov

[permalink] [raw]
Subject: [PATCH 10/11] gameport renames part 2


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


[email protected], 2004-11-24 01:27:02-05:00, [email protected]
nput: more renames in serio in preparations to sysfs integration
- gameport_dev -> gameport_driver
- gameport_[un]register_device -> gameport_[un]register_driver

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


drivers/input/gameport/gameport.c | 52 ++++++++++++++++++------------------
drivers/input/joystick/a3d.c | 10 +++---
drivers/input/joystick/adi.c | 10 +++---
drivers/input/joystick/analog.c | 18 ++++++------
drivers/input/joystick/cobra.c | 10 +++---
drivers/input/joystick/gf2k.c | 10 +++---
drivers/input/joystick/grip.c | 10 +++---
drivers/input/joystick/grip_mp.c | 10 +++---
drivers/input/joystick/guillemot.c | 10 +++---
drivers/input/joystick/interact.c | 10 +++---
drivers/input/joystick/joydump.c | 10 +++---
drivers/input/joystick/sidewinder.c | 10 +++---
drivers/input/joystick/tmdc.c | 10 +++---
include/linux/gameport.h | 12 ++++----
14 files changed, 96 insertions(+), 96 deletions(-)


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



diff -Nru a/drivers/input/gameport/gameport.c b/drivers/input/gameport/gameport.c
--- a/drivers/input/gameport/gameport.c 2004-11-24 02:03:16 -05:00
+++ b/drivers/input/gameport/gameport.c 2004-11-24 02:03:16 -05:00
@@ -25,15 +25,15 @@

EXPORT_SYMBOL(gameport_register_port);
EXPORT_SYMBOL(gameport_unregister_port);
-EXPORT_SYMBOL(gameport_register_device);
-EXPORT_SYMBOL(gameport_unregister_device);
+EXPORT_SYMBOL(gameport_register_driver);
+EXPORT_SYMBOL(gameport_unregister_driver);
EXPORT_SYMBOL(gameport_open);
EXPORT_SYMBOL(gameport_close);
EXPORT_SYMBOL(gameport_rescan);
EXPORT_SYMBOL(gameport_cooked_read);

static LIST_HEAD(gameport_list);
-static LIST_HEAD(gameport_dev_list);
+static LIST_HEAD(gameport_driver_list);

#ifdef __i386__

@@ -100,61 +100,61 @@
#endif
}

-static void gameport_find_dev(struct gameport *gameport)
+static void gameport_find_driver(struct gameport *gameport)
{
- struct gameport_dev *dev;
+ struct gameport_driver *drv;

- list_for_each_entry(dev, &gameport_dev_list, node) {
- if (gameport->dev)
+ list_for_each_entry(drv, &gameport_driver_list, node) {
+ if (gameport->drv)
break;
- if (dev->connect)
- dev->connect(gameport, dev);
+ if (drv->connect)
+ drv->connect(gameport, drv);
}
}

void gameport_rescan(struct gameport *gameport)
{
gameport_close(gameport);
- gameport_find_dev(gameport);
+ gameport_find_driver(gameport);
}

void gameport_register_port(struct gameport *gameport)
{
list_add_tail(&gameport->node, &gameport_list);
gameport->speed = gameport_measure_speed(gameport);
- gameport_find_dev(gameport);
+ gameport_find_driver(gameport);
}

void gameport_unregister_port(struct gameport *gameport)
{
list_del_init(&gameport->node);
- if (gameport->dev && gameport->dev->disconnect)
- gameport->dev->disconnect(gameport);
+ if (gameport->drv && gameport->drv->disconnect)
+ gameport->drv->disconnect(gameport);
}

-void gameport_register_device(struct gameport_dev *dev)
+void gameport_register_driver(struct gameport_driver *drv)
{
struct gameport *gameport;

- list_add_tail(&dev->node, &gameport_dev_list);
+ list_add_tail(&drv->node, &gameport_driver_list);
list_for_each_entry(gameport, &gameport_list, node)
- if (!gameport->dev && dev->connect)
- dev->connect(gameport, dev);
+ if (!gameport->drv && drv->connect)
+ drv->connect(gameport, drv);
}

-void gameport_unregister_device(struct gameport_dev *dev)
+void gameport_unregister_driver(struct gameport_driver *drv)
{
struct gameport *gameport;

- list_del_init(&dev->node);
+ list_del_init(&drv->node);
list_for_each_entry(gameport, &gameport_list, node) {
- if (gameport->dev == dev && dev->disconnect)
- dev->disconnect(gameport);
- gameport_find_dev(gameport);
+ if (gameport->drv == drv && drv->disconnect)
+ drv->disconnect(gameport);
+ gameport_find_driver(gameport);
}
}

-int gameport_open(struct gameport *gameport, struct gameport_dev *dev, int mode)
+int gameport_open(struct gameport *gameport, struct gameport_driver *drv, int mode)
{
if (gameport->open) {
if (gameport->open(gameport, mode))
@@ -164,17 +164,17 @@
return -1;
}

- if (gameport->dev)
+ if (gameport->drv)
return -1;

- gameport->dev = dev;
+ gameport->drv = drv;

return 0;
}

void gameport_close(struct gameport *gameport)
{
- gameport->dev = NULL;
+ gameport->drv = NULL;
if (gameport->close)
gameport->close(gameport);
}
diff -Nru a/drivers/input/joystick/a3d.c b/drivers/input/joystick/a3d.c
--- a/drivers/input/joystick/a3d.c 2004-11-24 02:03:16 -05:00
+++ b/drivers/input/joystick/a3d.c 2004-11-24 02:03:16 -05:00
@@ -258,7 +258,7 @@
* a3d_connect() probes for A3D joysticks.
*/

-static void a3d_connect(struct gameport *gameport, struct gameport_dev *dev)
+static void a3d_connect(struct gameport *gameport, struct gameport_driver *drv)
{
struct a3d *a3d;
unsigned char data[A3D_MAX_LENGTH];
@@ -275,7 +275,7 @@
a3d->timer.data = (long) a3d;
a3d->timer.function = a3d_timer;

- if (gameport_open(gameport, dev, GAMEPORT_MODE_RAW))
+ if (gameport_open(gameport, drv, GAMEPORT_MODE_RAW))
goto fail1;

i = a3d_read_packet(gameport, A3D_MAX_LENGTH, data);
@@ -385,20 +385,20 @@
kfree(a3d);
}

-static struct gameport_dev a3d_dev = {
+static struct gameport_driver a3d_drv = {
.connect = a3d_connect,
.disconnect = a3d_disconnect,
};

int __init a3d_init(void)
{
- gameport_register_device(&a3d_dev);
+ gameport_register_driver(&a3d_drv);
return 0;
}

void __exit a3d_exit(void)
{
- gameport_unregister_device(&a3d_dev);
+ gameport_unregister_driver(&a3d_drv);
}

module_init(a3d_init);
diff -Nru a/drivers/input/joystick/adi.c b/drivers/input/joystick/adi.c
--- a/drivers/input/joystick/adi.c 2004-11-24 02:03:16 -05:00
+++ b/drivers/input/joystick/adi.c 2004-11-24 02:03:16 -05:00
@@ -475,7 +475,7 @@
* adi_connect() probes for Logitech ADI joysticks.
*/

-static void adi_connect(struct gameport *gameport, struct gameport_dev *dev)
+static void adi_connect(struct gameport *gameport, struct gameport_driver *drv)
{
struct adi_port *port;
int i;
@@ -491,7 +491,7 @@
port->timer.data = (long) port;
port->timer.function = adi_timer;

- if (gameport_open(gameport, dev, GAMEPORT_MODE_RAW)) {
+ if (gameport_open(gameport, drv, GAMEPORT_MODE_RAW)) {
kfree(port);
return;
}
@@ -544,20 +544,20 @@
* The gameport device structure.
*/

-static struct gameport_dev adi_dev = {
+static struct gameport_driver adi_drv = {
.connect = adi_connect,
.disconnect = adi_disconnect,
};

int __init adi_init(void)
{
- gameport_register_device(&adi_dev);
+ gameport_register_driver(&adi_drv);
return 0;
}

void __exit adi_exit(void)
{
- gameport_unregister_device(&adi_dev);
+ gameport_unregister_driver(&adi_drv);
}

module_init(adi_init);
diff -Nru a/drivers/input/joystick/analog.c b/drivers/input/joystick/analog.c
--- a/drivers/input/joystick/analog.c 2004-11-24 02:03:16 -05:00
+++ b/drivers/input/joystick/analog.c 2004-11-24 02:03:16 -05:00
@@ -587,7 +587,7 @@
return -!(analog[0].mask || analog[1].mask);
}

-static int analog_init_port(struct gameport *gameport, struct gameport_dev *dev, struct analog_port *port)
+static int analog_init_port(struct gameport *gameport, struct gameport_driver *drv, struct analog_port *port)
{
int i, t, u, v;

@@ -597,7 +597,7 @@
port->timer.data = (long) port;
port->timer.function = analog_timer;

- if (!gameport_open(gameport, dev, GAMEPORT_MODE_RAW)) {
+ if (!gameport_open(gameport, drv, GAMEPORT_MODE_RAW)) {

analog_calibrate_timer(port);

@@ -632,7 +632,7 @@
gameport_close(gameport);
}

- if (!gameport_open(gameport, dev, GAMEPORT_MODE_COOKED)) {
+ if (!gameport_open(gameport, drv, GAMEPORT_MODE_COOKED)) {

for (i = 0; i < ANALOG_INIT_RETRIES; i++)
if (!gameport_cooked_read(gameport, port->axes, &port->buttons))
@@ -645,13 +645,13 @@
return 0;
}

- if (!gameport_open(gameport, dev, GAMEPORT_MODE_RAW))
+ if (!gameport_open(gameport, drv, GAMEPORT_MODE_RAW))
return 0;

return -1;
}

-static void analog_connect(struct gameport *gameport, struct gameport_dev *dev)
+static void analog_connect(struct gameport *gameport, struct gameport_driver *drv)
{
struct analog_port *port;
int i;
@@ -660,7 +660,7 @@
return;
memset(port, 0, sizeof(struct analog_port));

- if (analog_init_port(gameport, dev, port)) {
+ if (analog_init_port(gameport, drv, port)) {
kfree(port);
return;
}
@@ -741,7 +741,7 @@
* The gameport device structure.
*/

-static struct gameport_dev analog_dev = {
+static struct gameport_driver analog_drv = {
.connect = analog_connect,
.disconnect = analog_disconnect,
};
@@ -749,13 +749,13 @@
int __init analog_init(void)
{
analog_parse_options();
- gameport_register_device(&analog_dev);
+ gameport_register_driver(&analog_drv);
return 0;
}

void __exit analog_exit(void)
{
- gameport_unregister_device(&analog_dev);
+ gameport_unregister_driver(&analog_drv);
}

module_init(analog_init);
diff -Nru a/drivers/input/joystick/cobra.c b/drivers/input/joystick/cobra.c
--- a/drivers/input/joystick/cobra.c 2004-11-24 02:03:16 -05:00
+++ b/drivers/input/joystick/cobra.c 2004-11-24 02:03:16 -05:00
@@ -158,7 +158,7 @@
del_timer(&cobra->timer);
}

-static void cobra_connect(struct gameport *gameport, struct gameport_dev *dev)
+static void cobra_connect(struct gameport *gameport, struct gameport_driver *drv)
{
struct cobra *cobra;
unsigned int data[2];
@@ -175,7 +175,7 @@
cobra->timer.data = (long) cobra;
cobra->timer.function = cobra_timer;

- if (gameport_open(gameport, dev, GAMEPORT_MODE_RAW))
+ if (gameport_open(gameport, drv, GAMEPORT_MODE_RAW))
goto fail1;

cobra->exists = cobra_read_packet(gameport, data);
@@ -236,20 +236,20 @@
kfree(cobra);
}

-static struct gameport_dev cobra_dev = {
+static struct gameport_driver cobra_drv = {
.connect = cobra_connect,
.disconnect = cobra_disconnect,
};

int __init cobra_init(void)
{
- gameport_register_device(&cobra_dev);
+ gameport_register_driver(&cobra_drv);
return 0;
}

void __exit cobra_exit(void)
{
- gameport_unregister_device(&cobra_dev);
+ gameport_unregister_driver(&cobra_drv);
}

module_init(cobra_init);
diff -Nru a/drivers/input/joystick/gf2k.c b/drivers/input/joystick/gf2k.c
--- a/drivers/input/joystick/gf2k.c 2004-11-24 02:03:16 -05:00
+++ b/drivers/input/joystick/gf2k.c 2004-11-24 02:03:16 -05:00
@@ -238,7 +238,7 @@
* gf2k_connect() probes for Genius id joysticks.
*/

-static void gf2k_connect(struct gameport *gameport, struct gameport_dev *dev)
+static void gf2k_connect(struct gameport *gameport, struct gameport_driver *drv)
{
struct gf2k *gf2k;
unsigned char data[GF2K_LENGTH];
@@ -255,7 +255,7 @@
gf2k->timer.data = (long) gf2k;
gf2k->timer.function = gf2k_timer;

- if (gameport_open(gameport, dev, GAMEPORT_MODE_RAW))
+ if (gameport_open(gameport, drv, GAMEPORT_MODE_RAW))
goto fail1;

gf2k_trigger_seq(gameport, gf2k_seq_reset);
@@ -346,20 +346,20 @@
kfree(gf2k);
}

-static struct gameport_dev gf2k_dev = {
+static struct gameport_driver gf2k_drv = {
.connect = gf2k_connect,
.disconnect = gf2k_disconnect,
};

int __init gf2k_init(void)
{
- gameport_register_device(&gf2k_dev);
+ gameport_register_driver(&gf2k_drv);
return 0;
}

void __exit gf2k_exit(void)
{
- gameport_unregister_device(&gf2k_dev);
+ gameport_unregister_driver(&gf2k_drv);
}

module_init(gf2k_init);
diff -Nru a/drivers/input/joystick/grip.c b/drivers/input/joystick/grip.c
--- a/drivers/input/joystick/grip.c 2004-11-24 02:03:16 -05:00
+++ b/drivers/input/joystick/grip.c 2004-11-24 02:03:16 -05:00
@@ -298,7 +298,7 @@
del_timer(&grip->timer);
}

-static void grip_connect(struct gameport *gameport, struct gameport_dev *dev)
+static void grip_connect(struct gameport *gameport, struct gameport_driver *drv)
{
struct grip *grip;
unsigned int data[GRIP_LENGTH_XT];
@@ -315,7 +315,7 @@
grip->timer.data = (long) grip;
grip->timer.function = grip_timer;

- if (gameport_open(gameport, dev, GAMEPORT_MODE_RAW))
+ if (gameport_open(gameport, drv, GAMEPORT_MODE_RAW))
goto fail1;

for (i = 0; i < 2; i++) {
@@ -409,20 +409,20 @@
kfree(grip);
}

-static struct gameport_dev grip_dev = {
+static struct gameport_driver grip_drv = {
.connect = grip_connect,
.disconnect = grip_disconnect,
};

int __init grip_init(void)
{
- gameport_register_device(&grip_dev);
+ gameport_register_driver(&grip_drv);
return 0;
}

void __exit grip_exit(void)
{
- gameport_unregister_device(&grip_dev);
+ gameport_unregister_driver(&grip_drv);
}

module_init(grip_init);
diff -Nru a/drivers/input/joystick/grip_mp.c b/drivers/input/joystick/grip_mp.c
--- a/drivers/input/joystick/grip_mp.c 2004-11-24 02:03:16 -05:00
+++ b/drivers/input/joystick/grip_mp.c 2004-11-24 02:03:16 -05:00
@@ -616,7 +616,7 @@
mod_timer(&grip->timer, jiffies + GRIP_REFRESH_TIME);
}

-static void grip_connect(struct gameport *gameport, struct gameport_dev *dev)
+static void grip_connect(struct gameport *gameport, struct gameport_driver *drv)
{
struct grip_mp *grip;

@@ -629,7 +629,7 @@
grip->timer.data = (long) grip;
grip->timer.function = grip_timer;

- if (gameport_open(gameport, dev, GAMEPORT_MODE_RAW))
+ if (gameport_open(gameport, drv, GAMEPORT_MODE_RAW))
goto fail1;
if (!multiport_init(grip))
goto fail2;
@@ -654,20 +654,20 @@
kfree(grip);
}

-static struct gameport_dev grip_dev = {
+static struct gameport_driver grip_drv = {
.connect = grip_connect,
.disconnect = grip_disconnect,
};

static int grip_init(void)
{
- gameport_register_device(&grip_dev);
+ gameport_register_driver(&grip_drv);
return 0;
}

static void grip_exit(void)
{
- gameport_unregister_device(&grip_dev);
+ gameport_unregister_driver(&grip_drv);
}

module_init(grip_init);
diff -Nru a/drivers/input/joystick/guillemot.c b/drivers/input/joystick/guillemot.c
--- a/drivers/input/joystick/guillemot.c 2004-11-24 02:03:16 -05:00
+++ b/drivers/input/joystick/guillemot.c 2004-11-24 02:03:16 -05:00
@@ -179,7 +179,7 @@
* guillemot_connect() probes for Guillemot joysticks.
*/

-static void guillemot_connect(struct gameport *gameport, struct gameport_dev *dev)
+static void guillemot_connect(struct gameport *gameport, struct gameport_driver *drv)
{
struct guillemot *guillemot;
u8 data[GUILLEMOT_MAX_LENGTH];
@@ -196,7 +196,7 @@
guillemot->timer.data = (long) guillemot;
guillemot->timer.function = guillemot_timer;

- if (gameport_open(gameport, dev, GAMEPORT_MODE_RAW))
+ if (gameport_open(gameport, drv, GAMEPORT_MODE_RAW))
goto fail1;

i = guillemot_read_packet(gameport, data);
@@ -266,20 +266,20 @@
kfree(guillemot);
}

-static struct gameport_dev guillemot_dev = {
+static struct gameport_driver guillemot_drv = {
.connect = guillemot_connect,
.disconnect = guillemot_disconnect,
};

int __init guillemot_init(void)
{
- gameport_register_device(&guillemot_dev);
+ gameport_register_driver(&guillemot_drv);
return 0;
}

void __exit guillemot_exit(void)
{
- gameport_unregister_device(&guillemot_dev);
+ gameport_unregister_driver(&guillemot_drv);
}

module_init(guillemot_init);
diff -Nru a/drivers/input/joystick/interact.c b/drivers/input/joystick/interact.c
--- a/drivers/input/joystick/interact.c 2004-11-24 02:03:16 -05:00
+++ b/drivers/input/joystick/interact.c 2004-11-24 02:03:16 -05:00
@@ -209,7 +209,7 @@
* interact_connect() probes for InterAct joysticks.
*/

-static void interact_connect(struct gameport *gameport, struct gameport_dev *dev)
+static void interact_connect(struct gameport *gameport, struct gameport_driver *drv)
{
struct interact *interact;
__u32 data[3];
@@ -226,7 +226,7 @@
interact->timer.data = (long) interact;
interact->timer.function = interact_timer;

- if (gameport_open(gameport, dev, GAMEPORT_MODE_RAW))
+ if (gameport_open(gameport, drv, GAMEPORT_MODE_RAW))
goto fail1;

i = interact_read_packet(gameport, INTERACT_MAX_LENGTH * 2, data);
@@ -294,20 +294,20 @@
kfree(interact);
}

-static struct gameport_dev interact_dev = {
+static struct gameport_driver interact_drv = {
.connect = interact_connect,
.disconnect = interact_disconnect,
};

int __init interact_init(void)
{
- gameport_register_device(&interact_dev);
+ gameport_register_driver(&interact_drv);
return 0;
}

void __exit interact_exit(void)
{
- gameport_unregister_device(&interact_dev);
+ gameport_unregister_driver(&interact_drv);
}

module_init(interact_init);
diff -Nru a/drivers/input/joystick/joydump.c b/drivers/input/joystick/joydump.c
--- a/drivers/input/joystick/joydump.c 2004-11-24 02:03:16 -05:00
+++ b/drivers/input/joystick/joydump.c 2004-11-24 02:03:16 -05:00
@@ -46,7 +46,7 @@
unsigned char data;
};

-static void __devinit joydump_connect(struct gameport *gameport, struct gameport_dev *dev)
+static void __devinit joydump_connect(struct gameport *gameport, struct gameport_driver *drv)
{
struct joydump buf[BUF_SIZE];
int axes[4], buttons;
@@ -58,7 +58,7 @@
printk(KERN_INFO "joydump: | Dumping gameport%s.\n", gameport->phys);
printk(KERN_INFO "joydump: | Speed: %4d kHz. |\n", gameport->speed);

- if (gameport_open(gameport, dev, GAMEPORT_MODE_RAW)) {
+ if (gameport_open(gameport, drv, GAMEPORT_MODE_RAW)) {

printk(KERN_INFO "joydump: | Raw mode not available - trying cooked. |\n");

@@ -131,20 +131,20 @@
gameport_close(gameport);
}

-static struct gameport_dev joydump_dev = {
+static struct gameport_driver joydump_drv = {
.connect = joydump_connect,
.disconnect = joydump_disconnect,
};

static int __init joydump_init(void)
{
- gameport_register_device(&joydump_dev);
+ gameport_register_driver(&joydump_drv);
return 0;
}

static void __exit joydump_exit(void)
{
- gameport_unregister_device(&joydump_dev);
+ gameport_unregister_driver(&joydump_drv);
}

module_init(joydump_init);
diff -Nru a/drivers/input/joystick/sidewinder.c b/drivers/input/joystick/sidewinder.c
--- a/drivers/input/joystick/sidewinder.c 2004-11-24 02:03:16 -05:00
+++ b/drivers/input/joystick/sidewinder.c 2004-11-24 02:03:16 -05:00
@@ -569,7 +569,7 @@
* sw_connect() probes for SideWinder type joysticks.
*/

-static void sw_connect(struct gameport *gameport, struct gameport_dev *dev)
+static void sw_connect(struct gameport *gameport, struct gameport_driver *drv)
{
struct sw *sw;
int i, j, k, l;
@@ -595,7 +595,7 @@
sw->timer.data = (long) sw;
sw->timer.function = sw_timer;

- if (gameport_open(gameport, dev, GAMEPORT_MODE_RAW))
+ if (gameport_open(gameport, drv, GAMEPORT_MODE_RAW))
goto fail1;

dbg("Init 0: Opened %s, io %#x, speed %d",
@@ -760,20 +760,20 @@
kfree(sw);
}

-static struct gameport_dev sw_dev = {
+static struct gameport_driver sw_drv = {
.connect = sw_connect,
.disconnect = sw_disconnect,
};

int __init sw_init(void)
{
- gameport_register_device(&sw_dev);
+ gameport_register_driver(&sw_drv);
return 0;
}

void __exit sw_exit(void)
{
- gameport_unregister_device(&sw_dev);
+ gameport_unregister_driver(&sw_drv);
}

module_init(sw_init);
diff -Nru a/drivers/input/joystick/tmdc.c b/drivers/input/joystick/tmdc.c
--- a/drivers/input/joystick/tmdc.c 2004-11-24 02:03:16 -05:00
+++ b/drivers/input/joystick/tmdc.c 2004-11-24 02:03:16 -05:00
@@ -242,7 +242,7 @@
* tmdc_probe() probes for ThrustMaster type joysticks.
*/

-static void tmdc_connect(struct gameport *gameport, struct gameport_dev *dev)
+static void tmdc_connect(struct gameport *gameport, struct gameport_driver *drv)
{
struct models {
unsigned char id;
@@ -275,7 +275,7 @@
tmdc->timer.data = (long) tmdc;
tmdc->timer.function = tmdc_timer;

- if (gameport_open(gameport, dev, GAMEPORT_MODE_RAW))
+ if (gameport_open(gameport, drv, GAMEPORT_MODE_RAW))
goto fail1;

if (!(tmdc->exists = tmdc_read_packet(gameport, data)))
@@ -362,20 +362,20 @@
kfree(tmdc);
}

-static struct gameport_dev tmdc_dev = {
+static struct gameport_driver tmdc_drv = {
.connect = tmdc_connect,
.disconnect = tmdc_disconnect,
};

int __init tmdc_init(void)
{
- gameport_register_device(&tmdc_dev);
+ gameport_register_driver(&tmdc_drv);
return 0;
}

void __exit tmdc_exit(void)
{
- gameport_unregister_device(&tmdc_dev);
+ gameport_unregister_driver(&tmdc_drv);
}

module_init(tmdc_init);
diff -Nru a/include/linux/gameport.h b/include/linux/gameport.h
--- a/include/linux/gameport.h 2004-11-24 02:03:16 -05:00
+++ b/include/linux/gameport.h 2004-11-24 02:03:16 -05:00
@@ -35,23 +35,23 @@
int (*open)(struct gameport *, int);
void (*close)(struct gameport *);

- struct gameport_dev *dev;
+ struct gameport_driver *drv;

struct list_head node;
};

-struct gameport_dev {
+struct gameport_driver {

void *private;
char *name;

- void (*connect)(struct gameport *, struct gameport_dev *dev);
+ void (*connect)(struct gameport *, struct gameport_driver *drv);
void (*disconnect)(struct gameport *);

struct list_head node;
};

-int gameport_open(struct gameport *gameport, struct gameport_dev *dev, int mode);
+int gameport_open(struct gameport *gameport, struct gameport_driver *drv, int mode);
void gameport_close(struct gameport *gameport);
void gameport_rescan(struct gameport *gameport);

@@ -63,8 +63,8 @@
static inline void gameport_unregister_port(struct gameport *gameport) { return; }
#endif

-void gameport_register_device(struct gameport_dev *dev);
-void gameport_unregister_device(struct gameport_dev *dev);
+void gameport_register_driver(struct gameport_driver *drv);
+void gameport_unregister_driver(struct gameport_driver *drv);

#define GAMEPORT_MODE_DISABLED 0
#define GAMEPORT_MODE_RAW 1

2004-11-24 07:34:38

by Dmitry Torokhov

[permalink] [raw]
Subject: [PATCH 8/11] atkbd: use msecs_to_jiffies


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


[email protected], 2004-11-24 00:47:02-05:00, [email protected]
Input: use msecs_to_jiffies instead of manually calculating
delay for Toshiba bouncing keys workaround to the code
works with HZ != 1000.

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


atkbd.c | 2 +-
1 files changed, 1 insertion(+), 1 deletion(-)


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



diff -Nru a/drivers/input/keyboard/atkbd.c b/drivers/input/keyboard/atkbd.c
--- a/drivers/input/keyboard/atkbd.c 2004-11-24 01:53:21 -05:00
+++ b/drivers/input/keyboard/atkbd.c 2004-11-24 01:53:21 -05:00
@@ -378,7 +378,7 @@
break;
case 1:
atkbd->last = code;
- atkbd->time = jiffies + (atkbd->dev.rep[REP_DELAY] * HZ + 500) / 1000 / 2;
+ atkbd->time = jiffies + msecs_to_jiffies(atkbd->dev.rep[REP_DELAY]) / 2;
break;
case 2:
if (!time_after(jiffies, atkbd->time) && atkbd->last == code)