2005-10-28 06:29:57

by Greg KH

[permalink] [raw]
Subject: [GIT PATCH] Driver Core patches for 2.6.14

Here are a lot of driver core patches for 2.6.14. They have all been in
the past few -mm releases with no problems. They contain the following
things:
- 2 small aoe driver updates
- create hotplug events directly from the sysfs tree so that
"coldplug" work at boot time is much simpler.
- add the ability to nest class devices in the driver model
- move the input drivers to have dynamic structures
- move the input subsystem to use the nested class devices
- remove the input core from calling /sbin/hotplug on its own.
- some driver core pm changes
- stop the i2o abuse of the driver model
- some other small things (documentation, bugfixes, etc.)

These patches are needed so that the different distros don't keep trying
to keep their own set of "fix up the input subsystem to play nice with
/sbin/hotplug" patches that they have been, in order to rely only on
udev to handle their hotplug needs. With these changes, they no longer
need to do that.

Please pull from:
rsync://rsync.kernel.org/pub/scm/linux/kernel/git/gregkh/driver-2.6.git/
or if master.kernel.org hasn't synced up yet:
master.kernel.org:/pub/scm/linux/kernel/git/gregkh/driver-2.6.git/

The full patch set will be sent to the linux-kernel mailing lists, if
anyone wants to see them.

thanks,

greg k-h

Documentation/Changes | 2
Documentation/DocBook/writing_usb_driver.tmpl | 3
Documentation/driver-model/driver.txt | 60 --
Documentation/driver-model/porting.txt | 2
arch/arm/common/locomo.c | 10
arch/arm/common/sa1111.c | 11
arch/arm/common/scoop.c | 24 -
arch/arm/mach-pxa/corgi_ssp.c | 24 -
arch/arm/mach-sa1100/neponset.c | 28 -
arch/i386/kernel/cpuid.c | 2
arch/i386/kernel/msr.c | 2
drivers/base/attribute_container.c | 2
drivers/base/base.h | 12
drivers/base/class.c | 152 ++++--
drivers/base/core.c | 21
drivers/base/cpu.c | 1
drivers/base/driver.c | 3
drivers/base/firmware.c | 3
drivers/base/init.c | 10
drivers/base/platform.c | 22
drivers/base/power/sysfs.c | 73 +++
drivers/block/aoe/aoe.h | 2
drivers/block/aoe/aoechr.c | 2
drivers/block/aoe/aoecmd.c | 15
drivers/block/genhd.c | 25 +
drivers/block/paride/pg.c | 2
drivers/block/paride/pt.c | 4
drivers/char/dsp56k.c | 2
drivers/char/ftape/zftape/zftape-init.c | 12
drivers/char/ip2main.c | 10
drivers/char/ipmi/ipmi_devintf.c | 2
drivers/char/istallion.c | 3
drivers/char/lp.c | 2
drivers/char/mem.c | 3
drivers/char/misc.c | 2
drivers/char/ppdev.c | 2
drivers/char/raw.c | 4
drivers/char/s3c2410-rtc.c | 20
drivers/char/snsc.c | 2
drivers/char/sonypi.c | 106 ++--
drivers/char/stallion.c | 4
drivers/char/tipar.c | 2
drivers/char/tty_io.c | 10
drivers/char/vc_screen.c | 10
drivers/char/viotape.c | 4
drivers/char/watchdog/s3c2410_wdt.c | 34 -
drivers/hwmon/hdaps.c | 6
drivers/hwmon/hwmon.c | 2
drivers/i2c/busses/i2c-s3c2410.c | 8
drivers/i2c/i2c-core.c | 4
drivers/ide/ide-tape.c | 42 +
drivers/ieee1394/dv1394.c | 2
drivers/ieee1394/nodemgr.c | 4
drivers/ieee1394/raw1394.c | 2
drivers/ieee1394/video1394.c | 2
drivers/infiniband/core/ucm.c | 2
drivers/input/evdev.c | 26 -
drivers/input/input.c | 555 +++++++++++++++----------
drivers/input/joydev.c | 26 -
drivers/input/joystick/adi.c | 93 ++--
drivers/input/joystick/amijoy.c | 87 ++-
drivers/input/joystick/analog.c | 100 ++--
drivers/input/joystick/cobra.c | 70 +--
drivers/input/joystick/db9.c | 292 +++++++------
drivers/input/joystick/gamecon.c | 396 +++++++++--------
drivers/input/joystick/gf2k.c | 71 +--
drivers/input/joystick/grip.c | 85 ++-
drivers/input/joystick/grip_mp.c | 149 +++---
drivers/input/joystick/guillemot.c | 53 +-
drivers/input/joystick/iforce/iforce-main.c | 106 ++--
drivers/input/joystick/iforce/iforce-packets.c | 5
drivers/input/joystick/iforce/iforce-serio.c | 10
drivers/input/joystick/iforce/iforce-usb.c | 22
drivers/input/joystick/iforce/iforce.h | 2
drivers/input/joystick/interact.c | 55 +-
drivers/input/joystick/magellan.c | 71 +--
drivers/input/joystick/sidewinder.c | 72 +--
drivers/input/joystick/spaceball.c | 82 +--
drivers/input/joystick/spaceorb.c | 78 +--
drivers/input/joystick/stinger.c | 75 +--
drivers/input/joystick/tmdc.c | 324 ++++++++------
drivers/input/joystick/turbografx.c | 223 ++++++----
drivers/input/joystick/twidjoy.c | 118 ++---
drivers/input/joystick/warrior.c | 83 +--
drivers/input/keyboard/amikbd.c | 59 +-
drivers/input/keyboard/atkbd.c | 188 ++++----
drivers/input/keyboard/corgikbd.c | 96 ++--
drivers/input/keyboard/lkkbd.c | 126 ++---
drivers/input/keyboard/maple_keyb.c | 76 +--
drivers/input/keyboard/newtonkbd.c | 83 +--
drivers/input/keyboard/spitzkbd.c | 121 ++---
drivers/input/keyboard/sunkbd.c | 117 ++---
drivers/input/keyboard/xtkbd.c | 82 +--
drivers/input/misc/m68kspkr.c | 40 -
drivers/input/misc/pcspkr.c | 34 -
drivers/input/misc/sparcspkr.c | 45 --
drivers/input/mouse/alps.c | 67 +--
drivers/input/mouse/alps.h | 2
drivers/input/mouse/amimouse.c | 51 +-
drivers/input/mouse/inport.c | 96 ++--
drivers/input/mouse/lifebook.c | 16
drivers/input/mouse/logibm.c | 88 ++-
drivers/input/mouse/logips2pp.c | 20
drivers/input/mouse/maplemouse.c | 10
drivers/input/mouse/pc110pad.c | 70 +--
drivers/input/mouse/psmouse-base.c | 99 ++--
drivers/input/mouse/psmouse.h | 2
drivers/input/mouse/rpcmouse.c | 43 -
drivers/input/mouse/sermouse.c | 84 +--
drivers/input/mouse/synaptics.c | 6
drivers/input/mouse/vsxxxaa.c | 84 +--
drivers/input/mousedev.c | 41 -
drivers/input/serio/i8042.c | 13
drivers/input/touchscreen/corgi_ts.c | 131 ++---
drivers/input/touchscreen/elo.c | 89 +---
drivers/input/touchscreen/gunze.c | 66 +-
drivers/input/touchscreen/h3600_ts_input.c | 149 ++----
drivers/input/touchscreen/hp680_ts_input.c | 58 +-
drivers/input/touchscreen/mk712.c | 80 +--
drivers/input/touchscreen/mtouch.c | 64 +-
drivers/input/tsdev.c | 29 -
drivers/isdn/capi/capi.c | 2
drivers/macintosh/adb.c | 2
drivers/macintosh/adbhid.c | 220 +++++----
drivers/macintosh/mac_hid.c | 44 +
drivers/media/common/ir-common.c | 1
drivers/media/dvb/cinergyT2/cinergyT2.c | 108 +++-
drivers/media/dvb/dvb-core/dvbdev.c | 2
drivers/media/dvb/dvb-usb/dvb-usb-remote.c | 50 +-
drivers/media/dvb/dvb-usb/dvb-usb.h | 3
drivers/media/dvb/ttpci/av7110_ir.c | 37 -
drivers/media/dvb/ttpci/budget-ci.c | 24 -
drivers/media/dvb/ttusb-dec/ttusb_dec.c | 51 +-
drivers/media/video/bttvp.h | 2
drivers/media/video/cx88/cx88-input.c | 58 +-
drivers/media/video/ir-kbd-gpio.c | 52 +-
drivers/media/video/ir-kbd-i2c.c | 33 -
drivers/media/video/msp3400.c | 8
drivers/media/video/saa7134/saa7134-input.c | 39 -
drivers/media/video/saa7134/saa7134.h | 2
drivers/media/video/tda9887.c | 4
drivers/media/video/tuner-core.c | 4
drivers/message/i2o/core.h | 3
drivers/message/i2o/device.c | 326 ++++++--------
drivers/message/i2o/driver.c | 3
drivers/message/i2o/iop.c | 34 -
drivers/mfd/mcp-sa11x0.c | 20
drivers/mfd/ucb1x00-ts.c | 45 +-
drivers/mmc/pxamci.c | 8
drivers/mmc/wbsd.c | 4
drivers/mtd/maps/sa1100-flash.c | 8
drivers/mtd/mtdchar.c | 4
drivers/net/dm9000.c | 8
drivers/net/irda/sa1100_ir.c | 8
drivers/net/irda/smsc-ircc2.c | 12
drivers/net/phy/mdio_bus.c | 20
drivers/net/ppp_generic.c | 2
drivers/net/smc91x.c | 8
drivers/net/wan/cosa.c | 2
drivers/pci/pci.c | 4
drivers/pci/pcie/portdrv_core.c | 4
drivers/pci/probe.c | 16
drivers/pcmcia/au1000_generic.c | 21
drivers/pcmcia/ds.c | 6
drivers/pcmcia/hd64465_ss.c | 20
drivers/pcmcia/i82365.c | 20
drivers/pcmcia/m32r_cfc.c | 21
drivers/pcmcia/m32r_pcc.c | 21
drivers/pcmcia/omap_cf.c | 18
drivers/pcmcia/pxa2xx_base.c | 26 -
drivers/pcmcia/rsrc_nonstatic.c | 6
drivers/pcmcia/sa1100_generic.c | 20
drivers/pcmcia/socket_sysfs.c | 6
drivers/pcmcia/tcic.c | 20
drivers/pcmcia/vrc4171_card.c | 24 -
drivers/s390/char/tape_class.c | 1
drivers/s390/char/vmlogrdr.c | 1
drivers/scsi/ch.c | 2
drivers/scsi/osst.c | 2
drivers/scsi/sg.c | 10
drivers/scsi/st.c | 2
drivers/serial/8250.c | 10
drivers/serial/imx.c | 8
drivers/serial/mpc52xx_uart.c | 8
drivers/serial/pxa.c | 8
drivers/serial/s3c2410.c | 9
drivers/serial/sa1100.c | 8
drivers/serial/vr41xx_siu.c | 10
drivers/usb/core/devio.c | 2
drivers/usb/core/file.c | 4
drivers/usb/core/hcd.c | 3
drivers/usb/core/hub.c | 16
drivers/usb/gadget/dummy_hcd.c | 22
drivers/usb/gadget/omap_udc.c | 9
drivers/usb/gadget/pxa2xx_udc.c | 17
drivers/usb/host/isp116x-hcd.c | 14
drivers/usb/host/ohci-omap.c | 10
drivers/usb/host/ohci-pxa27x.c | 4
drivers/usb/host/sl811-hcd.c | 10
drivers/usb/input/acecad.c | 78 +--
drivers/usb/input/aiptek.c | 209 ++++-----
drivers/usb/input/appletouch.c | 130 +++--
drivers/usb/input/ati_remote.c | 173 ++++---
drivers/usb/input/hid-core.c | 51 +-
drivers/usb/input/hid-input.c | 58 +-
drivers/usb/input/hid-lgff.c | 17
drivers/usb/input/hid-tmff.c | 11
drivers/usb/input/hid.h | 2
drivers/usb/input/itmtouch.c | 72 +--
drivers/usb/input/kbtab.c | 86 +--
drivers/usb/input/keyspan_remote.c | 214 ++++-----
drivers/usb/input/mtouchusb.c | 111 ++---
drivers/usb/input/pid.c | 12
drivers/usb/input/powermate.c | 136 +++---
drivers/usb/input/touchkitusb.c | 116 ++---
drivers/usb/input/usbkbd.c | 105 ++--
drivers/usb/input/usbmouse.c | 97 ++--
drivers/usb/input/wacom.c | 142 ++----
drivers/usb/input/xpad.c | 97 +---
drivers/usb/input/yealink.c | 66 +-
drivers/usb/media/konicawc.c | 89 ++--
drivers/usb/storage/onetouch.c | 105 ++--
drivers/video/backlight/corgi_bl.c | 10
drivers/video/fbmem.c | 2
drivers/video/imxfb.c | 10
drivers/video/pxafb.c | 10
drivers/video/s1d13xxxfb.c | 7
drivers/video/s3c2410fb.c | 29 -
drivers/video/sa1100fb.c | 10
drivers/video/w100fb.c | 48 +-
fs/coda/psdev.c | 4
fs/partitions/check.c | 27 +
include/linux/device.h | 115 ++---
include/linux/genhd.h | 1
include/linux/i2o.h | 4
include/linux/input.h | 28 +
include/linux/kobject.h | 2
include/linux/pm.h | 26 +
lib/kobject.c | 2
lib/kobject_uevent.c | 8
net/bluetooth/hidp/core.c | 13
sound/arm/pxa2xx-ac97.c | 8
sound/core/init.c | 14
sound/core/sound.c | 2
sound/oss/soundcard.c | 4
sound/pci/ac97/ac97_bus.c | 6
sound/ppc/beep.c | 68 +--
sound/sound_core.c | 2
248 files changed, 5702 insertions(+), 5318 deletions(-)


Ben Dooks:
drivers/base - fix sparse warnings

David Brownell:
pci device wakeup flags
driver model wakeup flags
usb device wakeup flags

Dmitry Torokhov:
Driver core: pass interface to class interface methods
Driver core: send hotplug event before adding class interfaces
I2O: remove i2o_device_class
I2O: remove class interface
Input: prepare to sysfs integration
drivers/input/mouse: convert to dynamic input_dev allocation
Input: kill devfs references
Input: convert sonypi to dynamic input_dev allocation
Input: convert ucb1x00-ts to dynamic input_dev allocation
drivers/input/keyboard: convert to dynamic input_dev allocation
Input: convert onetouch to dynamic input_dev allocation
drivers/input/touchscreen: convert to dynamic input_dev allocation
drivers/usb/input: convert to dynamic input_dev allocation
Input: convert driver/input/misc to dynamic input_dev allocation
Input: convert net/bluetooth to dynamic input_dev allocation
Input: convert konicawc to dynamic input_dev allocation
drivers/input/joystick: convert to dynamic input_dev allocation
Input: convert drivers/macintosh to dynamic input_dev allocation
Input: convert sound/ppc/beep to dynamic input_dev allocation
drivers/media: convert to dynamic input_dev allocation
Input: show sysfs path in /proc/bus/input/devices
Input: export input_dev data via sysfs attributes
input core: remove custom-made hotplug handler

Ed L Cashin:
aoe: update to version 14
aoe: use get_unaligned for accesses in ATA id buffer

Erik Hovland:
kobject_uevent.c has a typo in a comment
changes device to driver in porting.txt

Greg Kroah-Hartman:
I2O: Clean up some pretty bad driver model abuses in the i2o code
Driver Core: add the ability for class_device structures to be nested
Driver Core: fix up all callers of class_device_create()
Driver Core: document struct class_device properly
INPUT: remove the input_class structure, as it is unused.
INPUT: export input_dev_class so that input drivers can use it.
INPUT: Fix oops when accessing sysfs files of nested input devices
INPUT: register the input class device sooner
INPUT: move the input class devices under their new input_dev devices
INPUT: rename input_dev_class to input_class to be correct.
update required version of udev
INPUT: Create symlinks for backwards compatibility

Jesper Juhl:
Driver Core: Big kfree NULL check cleanup - Documentation

Kay Sievers:
add sysfs attr to re-emit device hotplug event

Randy Dunlap:
kobject: fix gfp flags type
kernel-doc: drivers/base fixes

Russell King:
DRIVER MODEL: Get rid of the obsolete tri-level suspend/resume callbacks

Will Dyson:
add sysfs support for ide tape


2005-10-28 06:31:04

by Greg KH

[permalink] [raw]
Subject: [PATCH] kobject_uevent.c has a typo in a comment

[PATCH] kobject_uevent.c has a typo in a comment

This patch changes trough to through in a comment in kobject_uevent.c.

Signed-off-by: Greg Kroah-Hartman <[email protected]>

---
commit 3ab05c2cd849f4fdee6e79cc9f63d11de6ad63d9
tree 4b60b003d447d63a370564a7059ed2b91b7f119f
parent e801e49d1ca90da1ab0286a3688f2465cb1e45e4
author Erik Hovland <[email protected]> Thu, 06 Oct 2005 10:45:30 -0700
committer Greg Kroah-Hartman <[email protected]> Thu, 27 Oct 2005 22:47:59 -0700

lib/kobject_uevent.c | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/lib/kobject_uevent.c b/lib/kobject_uevent.c
index 04ca442..a318330 100644
--- a/lib/kobject_uevent.c
+++ b/lib/kobject_uevent.c
@@ -54,7 +54,7 @@ static char *action_to_string(enum kobje
static struct sock *uevent_sock;

/**
- * send_uevent - notify userspace by sending event trough netlink socket
+ * send_uevent - notify userspace by sending event through netlink socket
*
* @signal: signal name
* @obj: object path (kobject)

2005-10-28 06:31:44

by Greg KH

[permalink] [raw]
Subject: [PATCH] changes device to driver in porting.txt

[PATCH] changes device to driver in porting.txt

The document porting.txt in Documentation/driver-model says:
When a device is successfully bound to a device

I think it should say:
When a device is successfully bound to a driver

Signed-off-by: Greg Kroah-Hartman <[email protected]>

---
commit 3da2cf413a832ae4f7691d299f2d7dab30654ce5
tree 1808e0383651b708d22038756f87796b5806a9fc
parent 3ab05c2cd849f4fdee6e79cc9f63d11de6ad63d9
author Erik Hovland <[email protected]> Thu, 06 Oct 2005 10:47:49 -0700
committer Greg Kroah-Hartman <[email protected]> Thu, 27 Oct 2005 22:47:59 -0700

Documentation/driver-model/porting.txt | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/Documentation/driver-model/porting.txt b/Documentation/driver-model/porting.txt
index ff2fef2..98b233c 100644
--- a/Documentation/driver-model/porting.txt
+++ b/Documentation/driver-model/porting.txt
@@ -350,7 +350,7 @@ When a driver is registered, the bus's l
over. bus->match() is called for each device that is not already
claimed by a driver.

-When a device is successfully bound to a device, device->driver is
+When a device is successfully bound to a driver, device->driver is
set, the device is added to a per-driver list of devices, and a
symlink is created in the driver's sysfs directory that points to the
device's physical directory:

2005-10-28 06:32:58

by Greg KH

[permalink] [raw]
Subject: [PATCH] kobject: fix gfp flags type

[PATCH] kobject: fix gfp flags type

Fix implicit nocast warnings in kobject_uevent code, including __nocast:
lib/kobject_uevent.c:78:37: warning: implicit cast to nocast type
lib/kobject_uevent.c:97:51: warning: implicit cast to nocast type
lib/kobject_uevent.c:120:27: warning: implicit cast to nocast type

Signed-off-by: Randy Dunlap <[email protected]>
Signed-off-by: Greg Kroah-Hartman <[email protected]>

---
commit 409d93787e8cfec603d512c2925f8580c32a9d0a
tree 7ee455a735b293d329e1921f5dd6e565644817c7
parent 3da2cf413a832ae4f7691d299f2d7dab30654ce5
author Randy Dunlap <[email protected]> Tue, 04 Oct 2005 00:45:34 -0700
committer Greg Kroah-Hartman <[email protected]> Thu, 27 Oct 2005 22:47:59 -0700

include/linux/kobject.h | 2 +-
lib/kobject.c | 2 +-
lib/kobject_uevent.c | 6 +++---
3 files changed, 5 insertions(+), 5 deletions(-)

diff --git a/include/linux/kobject.h b/include/linux/kobject.h
index 3b22304..9c52805 100644
--- a/include/linux/kobject.h
+++ b/include/linux/kobject.h
@@ -65,7 +65,7 @@ extern void kobject_unregister(struct ko
extern struct kobject * kobject_get(struct kobject *);
extern void kobject_put(struct kobject *);

-extern char * kobject_get_path(struct kobject *, int);
+extern char * kobject_get_path(struct kobject *, unsigned int __nocast);

struct kobj_type {
void (*release)(struct kobject *);
diff --git a/lib/kobject.c b/lib/kobject.c
index dd0917d..97ad4c6 100644
--- a/lib/kobject.c
+++ b/lib/kobject.c
@@ -100,7 +100,7 @@ static void fill_kobj_path(struct kobjec
* @kobj: kobject in question, with which to build the path
* @gfp_mask: the allocation type used to allocate the path
*/
-char *kobject_get_path(struct kobject *kobj, int gfp_mask)
+char *kobject_get_path(struct kobject *kobj, unsigned int __nocast gfp_mask)
{
char *path;
int len;
diff --git a/lib/kobject_uevent.c b/lib/kobject_uevent.c
index a318330..7be1769 100644
--- a/lib/kobject_uevent.c
+++ b/lib/kobject_uevent.c
@@ -62,7 +62,7 @@ static struct sock *uevent_sock;
* @gfp_mask:
*/
static int send_uevent(const char *signal, const char *obj,
- char **envp, int gfp_mask)
+ char **envp, unsigned int __nocast gfp_mask)
{
struct sk_buff *skb;
char *pos;
@@ -98,7 +98,7 @@ static int send_uevent(const char *signa
}

static int do_kobject_uevent(struct kobject *kobj, enum kobject_action action,
- struct attribute *attr, int gfp_mask)
+ struct attribute *attr, unsigned int __nocast gfp_mask)
{
char *path;
char *attrpath;
@@ -170,7 +170,7 @@ postcore_initcall(kobject_uevent_init);

#else
static inline int send_uevent(const char *signal, const char *obj,
- char **envp, int gfp_mask)
+ char **envp, unsigned int __nocast gfp_mask)
{
return 0;
}

2005-10-28 06:32:23

by Greg KH

[permalink] [raw]
Subject: [PATCH] Input: convert sonypi to dynamic input_dev allocation

[PATCH] Input: convert sonypi to dynamic input_dev allocation

Input: convert sonypi to dynamic input_dev allocation

This is required for input_dev sysfs integration

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

---
commit 218e51d8b7c75a09e156696c037e6e3383a7808b
tree 5ac0471cac3b7fe7214d5d94d1017b9be81c0416
parent a7827f4a9186387c432f3c802ea6330396d83eb9
author Dmitry Torokhov <[email protected]> Thu, 15 Sep 2005 02:01:50 -0500
committer Greg Kroah-Hartman <[email protected]> Thu, 27 Oct 2005 22:48:04 -0700

drivers/char/sonypi.c | 92 ++++++++++++++++++++++++++++---------------------
1 files changed, 53 insertions(+), 39 deletions(-)

diff --git a/drivers/char/sonypi.c b/drivers/char/sonypi.c
index 36ae9ad..a487368 100644
--- a/drivers/char/sonypi.c
+++ b/drivers/char/sonypi.c
@@ -424,10 +424,6 @@ static struct sonypi_eventtypes {

#define SONYPI_BUF_SIZE 128

-/* The name of the devices for the input device drivers */
-#define SONYPI_JOG_INPUTNAME "Sony Vaio Jogdial"
-#define SONYPI_KEY_INPUTNAME "Sony Vaio Keys"
-
/* Correspondance table between sonypi events and input layer events */
static struct {
int sonypiev;
@@ -490,8 +486,8 @@ static struct sonypi_device {
struct fasync_struct *fifo_async;
int open_count;
int model;
- struct input_dev input_jog_dev;
- struct input_dev input_key_dev;
+ struct input_dev *input_jog_dev;
+ struct input_dev *input_key_dev;
struct work_struct input_work;
struct kfifo *input_fifo;
spinlock_t input_fifo_lock;
@@ -779,8 +775,8 @@ static void input_keyrelease(void *data)

static void sonypi_report_input_event(u8 event)
{
- struct input_dev *jog_dev = &sonypi_device.input_jog_dev;
- struct input_dev *key_dev = &sonypi_device.input_key_dev;
+ struct input_dev *jog_dev = sonypi_device.input_jog_dev;
+ struct input_dev *key_dev = sonypi_device.input_key_dev;
struct sonypi_keypress kp = { NULL };
int i;

@@ -1203,6 +1199,47 @@ static struct device_driver sonypi_drive
.shutdown = sonypi_shutdown,
};

+static int __devinit sonypi_create_input_devices(void)
+{
+ struct input_dev *jog_dev;
+ struct input_dev *key_dev;
+ int i;
+
+ sonypi_device.input_jog_dev = jog_dev = input_allocate_device();
+ if (!jog_dev)
+ return -ENOMEM;
+
+ jog_dev->name = "Sony Vaio Jogdial";
+ jog_dev->id.bustype = BUS_ISA;
+ jog_dev->id.vendor = PCI_VENDOR_ID_SONY;
+
+ jog_dev->evbit[0] = BIT(EV_KEY) | BIT(EV_REL);
+ jog_dev->keybit[LONG(BTN_MOUSE)] = BIT(BTN_MIDDLE);
+ jog_dev->relbit[0] = BIT(REL_WHEEL);
+
+ sonypi_device.input_key_dev = key_dev = input_allocate_device();
+ if (!key_dev) {
+ input_free_device(jog_dev);
+ sonypi_device.input_jog_dev = NULL;
+ return -ENOMEM;
+ }
+
+ key_dev->name = "Sony Vaio Keys";
+ key_dev->id.bustype = BUS_ISA;
+ key_dev->id.vendor = PCI_VENDOR_ID_SONY;
+
+ /* Initialize the Input Drivers: special keys */
+ key_dev->evbit[0] = BIT(EV_KEY);
+ for (i = 0; sonypi_inputkeys[i].sonypiev; i++)
+ if (sonypi_inputkeys[i].inputev)
+ set_bit(sonypi_inputkeys[i].inputev, key_dev->keybit);
+
+ input_register_device(jog_dev);
+ input_register_device(key_dev);
+
+ return 0;
+}
+
static int __devinit sonypi_probe(void)
{
int i, ret;
@@ -1298,34 +1335,10 @@ static int __devinit sonypi_probe(void)
}

if (useinput) {
- /* Initialize the Input Drivers: jogdial */
- int i;
- sonypi_device.input_jog_dev.evbit[0] =
- BIT(EV_KEY) | BIT(EV_REL);
- sonypi_device.input_jog_dev.keybit[LONG(BTN_MOUSE)] =
- BIT(BTN_MIDDLE);
- sonypi_device.input_jog_dev.relbit[0] = BIT(REL_WHEEL);
- sonypi_device.input_jog_dev.name = SONYPI_JOG_INPUTNAME;
- sonypi_device.input_jog_dev.id.bustype = BUS_ISA;
- sonypi_device.input_jog_dev.id.vendor = PCI_VENDOR_ID_SONY;
-
- input_register_device(&sonypi_device.input_jog_dev);
- printk(KERN_INFO "%s input method installed.\n",
- sonypi_device.input_jog_dev.name);

- /* Initialize the Input Drivers: special keys */
- sonypi_device.input_key_dev.evbit[0] = BIT(EV_KEY);
- for (i = 0; sonypi_inputkeys[i].sonypiev; i++)
- if (sonypi_inputkeys[i].inputev)
- set_bit(sonypi_inputkeys[i].inputev,
- sonypi_device.input_key_dev.keybit);
- sonypi_device.input_key_dev.name = SONYPI_KEY_INPUTNAME;
- sonypi_device.input_key_dev.id.bustype = BUS_ISA;
- sonypi_device.input_key_dev.id.vendor = PCI_VENDOR_ID_SONY;
-
- input_register_device(&sonypi_device.input_key_dev);
- printk(KERN_INFO "%s input method installed.\n",
- sonypi_device.input_key_dev.name);
+ ret = sonypi_create_input_devices();
+ if (ret)
+ goto out_inputdevices;

spin_lock_init(&sonypi_device.input_fifo_lock);
sonypi_device.input_fifo =
@@ -1375,8 +1388,9 @@ static int __devinit sonypi_probe(void)
out_platformdev:
kfifo_free(sonypi_device.input_fifo);
out_infifo:
- input_unregister_device(&sonypi_device.input_key_dev);
- input_unregister_device(&sonypi_device.input_jog_dev);
+ input_unregister_device(sonypi_device.input_key_dev);
+ input_unregister_device(sonypi_device.input_jog_dev);
+out_inputdevices:
free_irq(sonypi_device.irq, sonypi_irq);
out_reqirq:
release_region(sonypi_device.ioport1, sonypi_device.region_size);
@@ -1402,8 +1416,8 @@ static void __devexit sonypi_remove(void
platform_device_unregister(sonypi_device.pdev);

if (useinput) {
- input_unregister_device(&sonypi_device.input_key_dev);
- input_unregister_device(&sonypi_device.input_jog_dev);
+ input_unregister_device(sonypi_device.input_key_dev);
+ input_unregister_device(sonypi_device.input_jog_dev);
kfifo_free(sonypi_device.input_fifo);
}


2005-10-28 06:32:23

by Greg KH

[permalink] [raw]
Subject: [PATCH] Input: kill devfs references

[PATCH] Input: kill devfs references

Input: remove references to devfs from input subsystem

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

---
commit f2e28e004f12e0e3fd1edf3ca1f35b42ab45988f
tree c460ec846a36705836ba7f641a610a161f3a7996
parent e9a873633c67dd048c9d53f3e934e83df10312d1
author Dmitry Torokhov <[email protected]> Thu, 15 Sep 2005 02:01:38 -0500
committer Greg Kroah-Hartman <[email protected]> Thu, 27 Oct 2005 22:48:03 -0700

drivers/input/evdev.c | 4 ----
drivers/input/input.c | 7 -------
drivers/input/joydev.c | 4 ----
drivers/input/mousedev.c | 9 +--------
drivers/input/tsdev.c | 7 -------
5 files changed, 1 insertions(+), 30 deletions(-)

diff --git a/drivers/input/evdev.c b/drivers/input/evdev.c
index 83b694c..14ea57f 100644
--- a/drivers/input/evdev.c
+++ b/drivers/input/evdev.c
@@ -20,7 +20,6 @@
#include <linux/major.h>
#include <linux/smp_lock.h>
#include <linux/device.h>
-#include <linux/devfs_fs_kernel.h>
#include <linux/compat.h>

struct evdev {
@@ -687,8 +686,6 @@ static struct input_handle *evdev_connec

evdev_table[minor] = evdev;

- devfs_mk_cdev(MKDEV(INPUT_MAJOR, EVDEV_MINOR_BASE + minor),
- S_IFCHR|S_IRUGO|S_IWUSR, "input/event%d", minor);
class_device_create(input_class, NULL,
MKDEV(INPUT_MAJOR, EVDEV_MINOR_BASE + minor),
dev->dev, "event%d", minor);
@@ -703,7 +700,6 @@ static void evdev_disconnect(struct inpu

class_device_destroy(input_class,
MKDEV(INPUT_MAJOR, EVDEV_MINOR_BASE + evdev->minor));
- devfs_remove("input/event%d", evdev->minor);
evdev->exist = 0;

if (evdev->open) {
diff --git a/drivers/input/input.c b/drivers/input/input.c
index 14ae558..072bbf5 100644
--- a/drivers/input/input.c
+++ b/drivers/input/input.c
@@ -22,7 +22,6 @@
#include <linux/interrupt.h>
#include <linux/poll.h>
#include <linux/device.h>
-#include <linux/devfs_fs_kernel.h>

MODULE_AUTHOR("Vojtech Pavlik <[email protected]>");
MODULE_DESCRIPTION("Input core");
@@ -770,13 +769,8 @@ static int __init input_init(void)
goto fail2;
}

- err = devfs_mk_dir("input");
- if (err)
- goto fail3;
-
return 0;

- fail3: unregister_chrdev(INPUT_MAJOR, "input");
fail2: input_proc_exit();
fail1: class_destroy(input_class);
return err;
@@ -785,7 +779,6 @@ static int __init input_init(void)
static void __exit input_exit(void)
{
input_proc_exit();
- devfs_remove("input");
unregister_chrdev(INPUT_MAJOR, "input");
class_destroy(input_class);
}
diff --git a/drivers/input/joydev.c b/drivers/input/joydev.c
index c696fb2..40d2b46 100644
--- a/drivers/input/joydev.c
+++ b/drivers/input/joydev.c
@@ -26,7 +26,6 @@
#include <linux/init.h>
#include <linux/smp_lock.h>
#include <linux/device.h>
-#include <linux/devfs_fs_kernel.h>

MODULE_AUTHOR("Vojtech Pavlik <[email protected]>");
MODULE_DESCRIPTION("Joystick device interfaces");
@@ -514,8 +513,6 @@ static struct input_handle *joydev_conne

joydev_table[minor] = joydev;

- devfs_mk_cdev(MKDEV(INPUT_MAJOR, JOYDEV_MINOR_BASE + minor),
- S_IFCHR|S_IRUGO|S_IWUSR, "input/js%d", minor);
class_device_create(input_class, NULL,
MKDEV(INPUT_MAJOR, JOYDEV_MINOR_BASE + minor),
dev->dev, "js%d", minor);
@@ -529,7 +526,6 @@ static void joydev_disconnect(struct inp
struct joydev_list *list;

class_device_destroy(input_class, MKDEV(INPUT_MAJOR, JOYDEV_MINOR_BASE + joydev->minor));
- devfs_remove("input/js%d", joydev->minor);
joydev->exist = 0;

if (joydev->open) {
diff --git a/drivers/input/mousedev.c b/drivers/input/mousedev.c
index d7144e1..89c3e49 100644
--- a/drivers/input/mousedev.c
+++ b/drivers/input/mousedev.c
@@ -9,7 +9,7 @@
* the Free Software Foundation.
*/

-#define MOUSEDEV_MINOR_BASE 32
+#define MOUSEDEV_MINOR_BASE 32
#define MOUSEDEV_MINORS 32
#define MOUSEDEV_MIX 31

@@ -24,7 +24,6 @@
#include <linux/random.h>
#include <linux/major.h>
#include <linux/device.h>
-#include <linux/devfs_fs_kernel.h>
#ifdef CONFIG_INPUT_MOUSEDEV_PSAUX
#include <linux/miscdevice.h>
#endif
@@ -649,8 +648,6 @@ static struct input_handle *mousedev_con

mousedev_table[minor] = mousedev;

- devfs_mk_cdev(MKDEV(INPUT_MAJOR, MOUSEDEV_MINOR_BASE + minor),
- S_IFCHR|S_IRUGO|S_IWUSR, "input/mouse%d", minor);
class_device_create(input_class, NULL,
MKDEV(INPUT_MAJOR, MOUSEDEV_MINOR_BASE + minor),
dev->dev, "mouse%d", minor);
@@ -665,7 +662,6 @@ static void mousedev_disconnect(struct i

class_device_destroy(input_class,
MKDEV(INPUT_MAJOR, MOUSEDEV_MINOR_BASE + mousedev->minor));
- devfs_remove("input/mouse%d", mousedev->minor);
mousedev->exist = 0;

if (mousedev->open) {
@@ -738,8 +734,6 @@ static int __init mousedev_init(void)
mousedev_mix.exist = 1;
mousedev_mix.minor = MOUSEDEV_MIX;

- devfs_mk_cdev(MKDEV(INPUT_MAJOR, MOUSEDEV_MINOR_BASE + MOUSEDEV_MIX),
- S_IFCHR|S_IRUGO|S_IWUSR, "input/mice");
class_device_create(input_class, NULL,
MKDEV(INPUT_MAJOR, MOUSEDEV_MINOR_BASE + MOUSEDEV_MIX), NULL, "mice");

@@ -759,7 +753,6 @@ static void __exit mousedev_exit(void)
if (psaux_registered)
misc_deregister(&psaux_mouse);
#endif
- devfs_remove("input/mice");
class_device_destroy(input_class,
MKDEV(INPUT_MAJOR, MOUSEDEV_MINOR_BASE + MOUSEDEV_MIX));
input_unregister_handler(&mousedev_handler);
diff --git a/drivers/input/tsdev.c b/drivers/input/tsdev.c
index fbb35c9..2d45e4d 100644
--- a/drivers/input/tsdev.c
+++ b/drivers/input/tsdev.c
@@ -53,7 +53,6 @@
#include <linux/random.h>
#include <linux/time.h>
#include <linux/device.h>
-#include <linux/devfs_fs_kernel.h>

#ifndef CONFIG_INPUT_TSDEV_SCREEN_X
#define CONFIG_INPUT_TSDEV_SCREEN_X 240
@@ -410,10 +409,6 @@ static struct input_handle *tsdev_connec

tsdev_table[minor] = tsdev;

- devfs_mk_cdev(MKDEV(INPUT_MAJOR, TSDEV_MINOR_BASE + minor),
- S_IFCHR|S_IRUGO|S_IWUSR, "input/ts%d", minor);
- devfs_mk_cdev(MKDEV(INPUT_MAJOR, TSDEV_MINOR_BASE + minor + TSDEV_MINORS/2),
- S_IFCHR|S_IRUGO|S_IWUSR, "input/tsraw%d", minor);
class_device_create(input_class, NULL,
MKDEV(INPUT_MAJOR, TSDEV_MINOR_BASE + minor),
dev->dev, "ts%d", minor);
@@ -428,8 +423,6 @@ static void tsdev_disconnect(struct inpu

class_device_destroy(input_class,
MKDEV(INPUT_MAJOR, TSDEV_MINOR_BASE + tsdev->minor));
- devfs_remove("input/ts%d", tsdev->minor);
- devfs_remove("input/tsraw%d", tsdev->minor);
tsdev->exist = 0;

if (tsdev->open) {

2005-10-28 06:33:40

by Greg KH

[permalink] [raw]
Subject: [PATCH] Driver core: send hotplug event before adding class interfaces

[PATCH] Driver core: send hotplug event before adding class interfaces

Move call to kobject_hotplug() above code that adds interfaces
to a class device, otherwise children's hotplug events may reach
userspace first.

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

---
commit 85a44726f49989a2647cd850d55ec5be75727c5b
tree f9d837c5fb3f70626ea55bbb522c485be79b2039
parent 454a289c5bc26384c2bdc40c0d232cf47bcf0a5d
author Dmitry Torokhov <[email protected]> Thu, 15 Sep 2005 02:01:37 -0500
committer Greg Kroah-Hartman <[email protected]> Thu, 27 Oct 2005 22:48:00 -0700

drivers/base/class.c | 3 ++-
1 files changed, 2 insertions(+), 1 deletions(-)

diff --git a/drivers/base/class.c b/drivers/base/class.c
index ce23dc8..8df58c5 100644
--- a/drivers/base/class.c
+++ b/drivers/base/class.c
@@ -524,6 +524,8 @@ int class_device_add(struct class_device
class_name);
}

+ kobject_hotplug(&class_dev->kobj, KOBJ_ADD);
+
/* notify any interfaces this device is now here */
if (parent) {
down(&parent->sem);
@@ -533,7 +535,6 @@ int class_device_add(struct class_device
class_intf->add(class_dev);
up(&parent->sem);
}
- kobject_hotplug(&class_dev->kobj, KOBJ_ADD);

register_done:
if (error && parent)

2005-10-28 06:34:11

by Greg KH

[permalink] [raw]
Subject: [PATCH] pci device wakeup flags

[PATCH] pci device wakeup flags

This patch teaches "pci_dev" about the new driver model wakeup support:

- It marks devices as supporting wakeup when "can issue PME#" is
listed in its PCI PM capability.

- pci_enable_wake() refuses to enable wake if that's been disabled
(e.g. through sysfs).

NOTE that a recent patch changed PCI probing, and this reverts part
of that change ... so that driver model initialization is again done
before the PCI setup.

(One issue is that the driver model "init + add == register" pattern isn't
being used inside PCI ... and that probe change worsened the problem by
making "add" do some "init" too. Maybe PCI should match the driver model
more closely, and just grow a new "pci_dev_init" function.)

Signed-off-by: David Brownell <[email protected]>
Signed-off-by: Greg Kroah-Hartman <[email protected]>

---
commit 454a289c5bc26384c2bdc40c0d232cf47bcf0a5d
tree e012cb9ddae22f2bb7fba37b6834e2123070eaa0
parent f69079c91f8ade0bb306d137d60cc9892e89f35a
author David Brownell <[email protected]> Mon, 12 Sep 2005 19:48:14 -0700
committer Greg Kroah-Hartman <[email protected]> Thu, 27 Oct 2005 22:47:59 -0700

drivers/pci/pci.c | 4 ++++
drivers/pci/probe.c | 16 +++++++++++++++-
2 files changed, 19 insertions(+), 1 deletions(-)

diff --git a/drivers/pci/pci.c b/drivers/pci/pci.c
index 259d247..6c1c56b 100644
--- a/drivers/pci/pci.c
+++ b/drivers/pci/pci.c
@@ -539,6 +539,10 @@ int pci_enable_wake(struct pci_dev *dev,
if (!pm)
return enable ? -EIO : 0;

+ /* don't enable unless policy set through driver core allows it */
+ if (!device_may_wakeup(&dev->dev) && enable)
+ return -EROFS;
+
/* Check device's ability to generate PME# */
pci_read_config_word(dev,pm+PCI_PM_PMC,&value);

diff --git a/drivers/pci/probe.c b/drivers/pci/probe.c
index 0057864..0a7eec1 100644
--- a/drivers/pci/probe.c
+++ b/drivers/pci/probe.c
@@ -589,6 +589,7 @@ static void pci_read_irq(struct pci_dev
static int pci_setup_device(struct pci_dev * dev)
{
u32 class;
+ u16 pm;

sprintf(pci_name(dev), "%04x:%02x:%02x.%d", pci_domain_nr(dev->bus),
dev->bus->number, PCI_SLOT(dev->devfn), PCI_FUNC(dev->devfn));
@@ -616,6 +617,19 @@ static int pci_setup_device(struct pci_d
pci_read_bases(dev, 6, PCI_ROM_ADDRESS);
pci_read_config_word(dev, PCI_SUBSYSTEM_VENDOR_ID, &dev->subsystem_vendor);
pci_read_config_word(dev, PCI_SUBSYSTEM_ID, &dev->subsystem_device);
+
+ /* PCI PM capable devices may be able to issue PME# (wakeup) */
+ pm = pci_find_capability(dev, PCI_CAP_ID_PM);
+ if (pm) {
+ pci_read_config_word(dev, pm + PCI_PM_PMC, &pm);
+ if (pm & PCI_PM_CAP_PME_MASK)
+ device_init_wakeup(&dev->dev, 1);
+
+ /* REVISIT: if (pm & PCI_PM_CAP_PME_D3cold) then
+ * pci pm spec 1.2, section 3.2.4 says we should
+ * init PCI_PM_CTRL_PME_{STATUS,ENABLE} ...
+ */
+ }
break;

case PCI_HEADER_TYPE_BRIDGE: /* bridge header */
@@ -755,6 +769,7 @@ pci_scan_device(struct pci_bus *bus, int
memset(dev, 0, sizeof(struct pci_dev));
dev->bus = bus;
dev->sysdata = bus->sysdata;
+ device_initialize(&dev->dev);
dev->dev.parent = bus->bridge;
dev->dev.bus = &pci_bus_type;
dev->devfn = devfn;
@@ -777,7 +792,6 @@ pci_scan_device(struct pci_bus *bus, int

void __devinit pci_device_add(struct pci_dev *dev, struct pci_bus *bus)
{
- device_initialize(&dev->dev);
dev->dev.release = pci_release_dev;
pci_dev_get(dev);


2005-10-28 06:34:11

by Greg KH

[permalink] [raw]
Subject: [PATCH] usb device wakeup flags

[PATCH] usb device wakeup flags

This patch teaches "usb_device" about the new driver model wakeup support:

- It updates device wakeup capabilities when entering a configuration
with the WAKEUP attribute;

- During suspend processing it consults the policy bit to see
whether it should enable wakeup for that device. (This resolves
a FIXME to not assume the answer is always "yes"; some devices
lie about supporting remote wakeup.)

Support for root hubs and the HCDs is separate (and more complex).

Signed-off-by: David Brownell <[email protected]>
Signed-off-by: Greg Kroah-Hartman <[email protected]>

---
commit f69079c91f8ade0bb306d137d60cc9892e89f35a
tree 40b0e76157521b9c422267c7c6d693be16e93e77
parent 79eef3cfd105168a2115fff06971af8efa27db82
author David Brownell <[email protected]> Mon, 12 Sep 2005 19:39:39 -0700
committer Greg Kroah-Hartman <[email protected]> Thu, 27 Oct 2005 22:47:59 -0700

drivers/usb/core/hub.c | 16 +++++++++-------
1 files changed, 9 insertions(+), 7 deletions(-)

diff --git a/drivers/usb/core/hub.c b/drivers/usb/core/hub.c
index a12cab5..c3e2024 100644
--- a/drivers/usb/core/hub.c
+++ b/drivers/usb/core/hub.c
@@ -1020,9 +1020,15 @@ void usb_set_device_state(struct usb_dev
spin_lock_irqsave(&device_state_lock, flags);
if (udev->state == USB_STATE_NOTATTACHED)
; /* do nothing */
- else if (new_state != USB_STATE_NOTATTACHED)
+ else if (new_state != USB_STATE_NOTATTACHED) {
udev->state = new_state;
- else
+ if (new_state == USB_STATE_CONFIGURED)
+ device_init_wakeup(&udev->dev,
+ (udev->actconfig->desc.bmAttributes
+ & USB_CONFIG_ATT_WAKEUP));
+ else if (new_state != USB_STATE_SUSPENDED)
+ device_init_wakeup(&udev->dev, 0);
+ } else
recursively_mark_NOTATTACHED(udev);
spin_unlock_irqrestore(&device_state_lock, flags);
}
@@ -1546,11 +1552,7 @@ static int hub_port_suspend(struct usb_h
* NOTE: OTG devices may issue remote wakeup (or SRP) even when
* we don't explicitly enable it here.
*/
- if (udev->actconfig
- // && FIXME (remote wakeup enabled on this bus)
- // ... currently assuming it's always appropriate
- && (udev->actconfig->desc.bmAttributes
- & USB_CONFIG_ATT_WAKEUP) != 0) {
+ if (device_may_wakeup(&udev->dev)) {
status = usb_control_msg(udev, usb_sndctrlpipe(udev, 0),
USB_REQ_SET_FEATURE, USB_RECIP_DEVICE,
USB_DEVICE_REMOTE_WAKEUP, 0,

2005-10-28 06:35:33

by Greg KH

[permalink] [raw]
Subject: [PATCH] Input: convert ucb1x00-ts to dynamic input_dev allocation

[PATCH] Input: convert ucb1x00-ts to dynamic input_dev allocation

Input: convert ucb1x00-ts to dynamic input_dev allocation

This is required for input_dev sysfs integration

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

---
commit 61ae45fa4a9d1637a430965ee3743c1c42f07268
tree 95ecb6c67d8ebcbab9f2f8113472d7a6b0483c9d
parent b991fee057c50e098677f57b49c848f81b697b14
author Dmitry Torokhov <[email protected]> Thu, 15 Sep 2005 02:01:48 -0500
committer Greg Kroah-Hartman <[email protected]> Thu, 27 Oct 2005 22:48:04 -0700

drivers/mfd/ucb1x00-ts.c | 45 +++++++++++++++++++++++++--------------------
1 files changed, 25 insertions(+), 20 deletions(-)

diff --git a/drivers/mfd/ucb1x00-ts.c b/drivers/mfd/ucb1x00-ts.c
index a260f83..585cded 100644
--- a/drivers/mfd/ucb1x00-ts.c
+++ b/drivers/mfd/ucb1x00-ts.c
@@ -40,7 +40,7 @@


struct ucb1x00_ts {
- struct input_dev idev;
+ struct input_dev *idev;
struct ucb1x00 *ucb;

wait_queue_head_t irq_wait;
@@ -56,16 +56,16 @@ static int adcsync;

static inline void ucb1x00_ts_evt_add(struct ucb1x00_ts *ts, u16 pressure, u16 x, u16 y)
{
- input_report_abs(&ts->idev, ABS_X, x);
- input_report_abs(&ts->idev, ABS_Y, y);
- input_report_abs(&ts->idev, ABS_PRESSURE, pressure);
- input_sync(&ts->idev);
+ input_report_abs(ts->idev, ABS_X, x);
+ input_report_abs(ts->idev, ABS_Y, y);
+ input_report_abs(ts->idev, ABS_PRESSURE, pressure);
+ input_sync(ts->idev);
}

static inline void ucb1x00_ts_event_release(struct ucb1x00_ts *ts)
{
- input_report_abs(&ts->idev, ABS_PRESSURE, 0);
- input_sync(&ts->idev);
+ input_report_abs(ts->idev, ABS_PRESSURE, 0);
+ input_sync(ts->idev);
}

/*
@@ -341,26 +341,30 @@ static int ucb1x00_ts_add(struct ucb1x00
{
struct ucb1x00_ts *ts;

- ts = kmalloc(sizeof(struct ucb1x00_ts), GFP_KERNEL);
+ ts = kzalloc(sizeof(struct ucb1x00_ts), GFP_KERNEL);
if (!ts)
return -ENOMEM;

- memset(ts, 0, sizeof(struct ucb1x00_ts));
+ ts->idev = input_allocate_device();
+ if (!ts->idev) {
+ kfree(ts);
+ return -ENOMEM;
+ }

ts->ucb = dev->ucb;
ts->adcsync = adcsync ? UCB_SYNC : UCB_NOSYNC;

- ts->idev.name = "Touchscreen panel";
- ts->idev.id.product = ts->ucb->id;
- ts->idev.open = ucb1x00_ts_open;
- ts->idev.close = ucb1x00_ts_close;
-
- __set_bit(EV_ABS, ts->idev.evbit);
- __set_bit(ABS_X, ts->idev.absbit);
- __set_bit(ABS_Y, ts->idev.absbit);
- __set_bit(ABS_PRESSURE, ts->idev.absbit);
+ ts->idev->name = "Touchscreen panel";
+ ts->idev->id.product = ts->ucb->id;
+ ts->idev->open = ucb1x00_ts_open;
+ ts->idev->close = ucb1x00_ts_close;
+
+ __set_bit(EV_ABS, ts->idev->evbit);
+ __set_bit(ABS_X, ts->idev->absbit);
+ __set_bit(ABS_Y, ts->idev->absbit);
+ __set_bit(ABS_PRESSURE, ts->idev->absbit);

- input_register_device(&ts->idev);
+ input_register_device(ts->idev);

dev->priv = ts;

@@ -370,7 +374,8 @@ static int ucb1x00_ts_add(struct ucb1x00
static void ucb1x00_ts_remove(struct ucb1x00_dev *dev)
{
struct ucb1x00_ts *ts = dev->priv;
- input_unregister_device(&ts->idev);
+
+ input_unregister_device(ts->idev);
kfree(ts);
}


2005-10-28 06:31:45

by Greg KH

[permalink] [raw]
Subject: [PATCH] aoe: update to version 14

[PATCH] aoe: update to version 14

Signed-off-by: "Ed L. Cashin" <[email protected]>
Signed-off-by: Greg Kroah-Hartman <[email protected]>

Update driver version number to 14.

---
commit 271c0df6e700b3f208b1802a1e96bb9eeeaa880c
tree 9ef2a3d1fff7584bf8ffc4513500e4af580d2fb7
parent 786fbf6c1eb91e7e70a1ef42ff2523aff0f09850
author Ed L. Cashin <[email protected]> Thu, 29 Sep 2005 12:47:55 -0400
committer Greg Kroah-Hartman <[email protected]> Thu, 27 Oct 2005 22:47:58 -0700

drivers/block/aoe/aoe.h | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/drivers/block/aoe/aoe.h b/drivers/block/aoe/aoe.h
index 0e9e586..881c48d 100644
--- a/drivers/block/aoe/aoe.h
+++ b/drivers/block/aoe/aoe.h
@@ -1,5 +1,5 @@
/* Copyright (c) 2004 Coraid, Inc. See COPYING for GPL terms. */
-#define VERSION "12"
+#define VERSION "14"
#define AOE_MAJOR 152
#define DEVICE_NAME "aoe"


2005-10-28 06:38:14

by Greg KH

[permalink] [raw]
Subject: [PATCH] driver model wakeup flags

[PATCH] driver model wakeup flags

This is a refresh of an earlier patch to add "wakeup" support to the
PM core model. This provides per-device bus-neutral control of the
use of wakeup events.

* "struct device_pm_info" has two bits that are initialized as
part of setting up the enclosing struct device:
- "can_wakeup", reflecting hardware capabilities
- "may_wakeup", the policy setting (when CONFIG_PM)

* There's a writeable sysfs "wakeup" file, with one of two values:
- "enabled", when the policy is to allow wakeup
- "disabled", when the policy is not to allow it
- "" if the device can't currently issue wakeups

By default, wakeup is enabled on all devices that support it. If its
driver doesn't support it ... treat it as a bug. :)

Signed-off-by: David Brownell <[email protected]>
Signed-off-by: Greg Kroah-Hartman <[email protected]>

---
commit 79eef3cfd105168a2115fff06971af8efa27db82
tree 078336166c58694cab5086cc6b69443226985445
parent 409d93787e8cfec603d512c2925f8580c32a9d0a
author David Brownell <[email protected]> Mon, 12 Sep 2005 19:39:34 -0700
committer Greg Kroah-Hartman <[email protected]> Thu, 27 Oct 2005 22:47:59 -0700

drivers/base/core.c | 1 +
drivers/base/power/sysfs.c | 73 ++++++++++++++++++++++++++++++++++++++++++++
include/linux/pm.h | 26 +++++++++++++++-
3 files changed, 99 insertions(+), 1 deletions(-)

diff --git a/drivers/base/core.c b/drivers/base/core.c
index 6ab73f5..3110919 100644
--- a/drivers/base/core.c
+++ b/drivers/base/core.c
@@ -225,6 +225,7 @@ void device_initialize(struct device *de
klist_children_put);
INIT_LIST_HEAD(&dev->dma_pools);
init_MUTEX(&dev->sem);
+ device_init_wakeup(dev, 0);
}

/**
diff --git a/drivers/base/power/sysfs.c b/drivers/base/power/sysfs.c
index 8d04fb4..89c5787 100644
--- a/drivers/base/power/sysfs.c
+++ b/drivers/base/power/sysfs.c
@@ -48,8 +48,81 @@ static ssize_t state_store(struct device
static DEVICE_ATTR(state, 0644, state_show, state_store);


+/*
+ * wakeup - Report/change current wakeup option for device
+ *
+ * Some devices support "wakeup" events, which are hardware signals
+ * used to activate devices from suspended or low power states. Such
+ * devices have one of three values for the sysfs power/wakeup file:
+ *
+ * + "enabled\n" to issue the events;
+ * + "disabled\n" not to do so; or
+ * + "\n" for temporary or permanent inability to issue wakeup.
+ *
+ * (For example, unconfigured USB devices can't issue wakeups.)
+ *
+ * Familiar examples of devices that can issue wakeup events include
+ * keyboards and mice (both PS2 and USB styles), power buttons, modems,
+ * "Wake-On-LAN" Ethernet links, GPIO lines, and more. Some events
+ * will wake the entire system from a suspend state; others may just
+ * wake up the device (if the system as a whole is already active).
+ * Some wakeup events use normal IRQ lines; other use special out
+ * of band signaling.
+ *
+ * It is the responsibility of device drivers to enable (or disable)
+ * wakeup signaling as part of changing device power states, respecting
+ * the policy choices provided through the driver model.
+ *
+ * Devices may not be able to generate wakeup events from all power
+ * states. Also, the events may be ignored in some configurations;
+ * for example, they might need help from other devices that aren't
+ * active, or which may have wakeup disabled. Some drivers rely on
+ * wakeup events internally (unless they are disabled), keeping
+ * their hardware in low power modes whenever they're unused. This
+ * saves runtime power, without requiring system-wide sleep states.
+ */
+
+static const char enabled[] = "enabled";
+static const char disabled[] = "disabled";
+
+static ssize_t
+wake_show(struct device * dev, struct device_attribute *attr, char * buf)
+{
+ return sprintf(buf, "%s\n", device_can_wakeup(dev)
+ ? (device_may_wakeup(dev) ? enabled : disabled)
+ : "");
+}
+
+static ssize_t
+wake_store(struct device * dev, struct device_attribute *attr,
+ const char * buf, size_t n)
+{
+ char *cp;
+ int len = n;
+
+ if (!device_can_wakeup(dev))
+ return -EINVAL;
+
+ cp = memchr(buf, '\n', n);
+ if (cp)
+ len = cp - buf;
+ if (len == sizeof enabled - 1
+ && strncmp(buf, enabled, sizeof enabled - 1) == 0)
+ device_set_wakeup_enable(dev, 1);
+ else if (len == sizeof disabled - 1
+ && strncmp(buf, disabled, sizeof disabled - 1) == 0)
+ device_set_wakeup_enable(dev, 0);
+ else
+ return -EINVAL;
+ return n;
+}
+
+static DEVICE_ATTR(wakeup, 0644, wake_show, wake_store);
+
+
static struct attribute * power_attrs[] = {
&dev_attr_state.attr,
+ &dev_attr_wakeup.attr,
NULL,
};
static struct attribute_group pm_attr_group = {
diff --git a/include/linux/pm.h b/include/linux/pm.h
index 5cfb076..7897cf5 100644
--- a/include/linux/pm.h
+++ b/include/linux/pm.h
@@ -219,7 +219,9 @@ typedef struct pm_message {

struct dev_pm_info {
pm_message_t power_state;
+ unsigned can_wakeup:1;
#ifdef CONFIG_PM
+ unsigned should_wakeup:1;
pm_message_t prev_state;
void * saved_state;
atomic_t pm_users;
@@ -236,13 +238,35 @@ extern void device_resume(void);

#ifdef CONFIG_PM
extern int device_suspend(pm_message_t state);
-#else
+
+#define device_set_wakeup_enable(dev,val) \
+ ((dev)->power.should_wakeup = !!(val))
+#define device_may_wakeup(dev) \
+ (device_can_wakeup(dev) && (dev)->power.should_wakeup)
+
+#else /* !CONFIG_PM */
+
static inline int device_suspend(pm_message_t state)
{
return 0;
}
+
+#define device_set_wakeup_enable(dev,val) do{}while(0)
+#define device_may_wakeup(dev) (0)
+
#endif

+/* changes to device_may_wakeup take effect on the next pm state change.
+ * by default, devices should wakeup if they can.
+ */
+#define device_can_wakeup(dev) \
+ ((dev)->power.can_wakeup)
+#define device_init_wakeup(dev,val) \
+ do { \
+ device_can_wakeup(dev) = !!(val); \
+ device_set_wakeup_enable(dev,val); \
+ } while(0)
+
#endif /* __KERNEL__ */

#endif /* _LINUX_PM_H */

2005-10-28 06:38:22

by Greg KH

[permalink] [raw]
Subject: [PATCH] drivers/input/touchscreen: convert to dynamic input_dev allocation

[PATCH] drivers/input/touchscreen: convert to dynamic input_dev allocation

Input: convert drivers/input/touchscreen to dynamic input_dev allocation

This is required for input_dev sysfs integration

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

---
commit a7827f4a9186387c432f3c802ea6330396d83eb9
tree ffe7249d34b35003a0fac1882cfedd5edb0ae02e
parent 61ae45fa4a9d1637a430965ee3743c1c42f07268
author Dmitry Torokhov <[email protected]> Thu, 15 Sep 2005 02:01:46 -0500
committer Greg Kroah-Hartman <[email protected]> Thu, 27 Oct 2005 22:48:04 -0700

drivers/input/touchscreen/corgi_ts.c | 93 +++++++++--------
drivers/input/touchscreen/elo.c | 89 ++++++++---------
drivers/input/touchscreen/gunze.c | 66 ++++++------
drivers/input/touchscreen/h3600_ts_input.c | 149 +++++++++++-----------------
drivers/input/touchscreen/hp680_ts_input.c | 58 +++++------
drivers/input/touchscreen/mk712.c | 80 ++++++++-------
drivers/input/touchscreen/mtouch.c | 64 ++++++------
7 files changed, 285 insertions(+), 314 deletions(-)

diff --git a/drivers/input/touchscreen/corgi_ts.c b/drivers/input/touchscreen/corgi_ts.c
index 4c7fbe5..40ae183 100644
--- a/drivers/input/touchscreen/corgi_ts.c
+++ b/drivers/input/touchscreen/corgi_ts.c
@@ -41,8 +41,7 @@ struct ts_event {
};

struct corgi_ts {
- char phys[32];
- struct input_dev input;
+ struct input_dev *input;
struct timer_list timer;
struct ts_event tc;
int pendown;
@@ -182,14 +181,12 @@ static void new_data(struct corgi_ts *co
if (!corgi_ts->tc.pressure && corgi_ts->pendown == 0)
return;

- if (regs)
- input_regs(&corgi_ts->input, regs);
-
- input_report_abs(&corgi_ts->input, ABS_X, corgi_ts->tc.x);
- input_report_abs(&corgi_ts->input, ABS_Y, corgi_ts->tc.y);
- input_report_abs(&corgi_ts->input, ABS_PRESSURE, corgi_ts->tc.pressure);
- input_report_key(&corgi_ts->input, BTN_TOUCH, (corgi_ts->pendown != 0));
- input_sync(&corgi_ts->input);
+ input_regs(corgi_ts->input, regs);
+ input_report_abs(corgi_ts->input, ABS_X, corgi_ts->tc.x);
+ input_report_abs(corgi_ts->input, ABS_Y, corgi_ts->tc.y);
+ input_report_abs(corgi_ts->input, ABS_PRESSURE, corgi_ts->tc.pressure);
+ input_report_key(corgi_ts->input, BTN_TOUCH, (corgi_ts->pendown != 0));
+ input_sync(corgi_ts->input);
}

static void ts_interrupt_main(struct corgi_ts *corgi_ts, int isTimer, struct pt_regs *regs)
@@ -273,39 +270,44 @@ static int __init corgits_probe(struct d
{
struct corgi_ts *corgi_ts;
struct platform_device *pdev = to_platform_device(dev);
+ struct input_dev *input_dev;
+ int err = -ENOMEM;

- if (!(corgi_ts = kmalloc(sizeof(struct corgi_ts), GFP_KERNEL)))
- return -ENOMEM;
+ corgi_ts = kzalloc(sizeof(struct corgi_ts), GFP_KERNEL);
+ input_dev = input_allocate_device();
+ if (!corgi_ts || !input_dev)
+ goto fail;

dev_set_drvdata(dev, corgi_ts);

- memset(corgi_ts, 0, sizeof(struct corgi_ts));
-
corgi_ts->machinfo = dev->platform_data;
corgi_ts->irq_gpio = platform_get_irq(pdev, 0);

if (corgi_ts->irq_gpio < 0) {
- kfree(corgi_ts);
- return -ENODEV;
+ err = -ENODEV;
+ goto fail;
}

- init_input_dev(&corgi_ts->input);
- corgi_ts->input.evbit[0] = BIT(EV_KEY) | BIT(EV_ABS);
- corgi_ts->input.keybit[LONG(BTN_TOUCH)] = BIT(BTN_TOUCH);
- input_set_abs_params(&corgi_ts->input, ABS_X, X_AXIS_MIN, X_AXIS_MAX, 0, 0);
- input_set_abs_params(&corgi_ts->input, ABS_Y, Y_AXIS_MIN, Y_AXIS_MAX, 0, 0);
- input_set_abs_params(&corgi_ts->input, ABS_PRESSURE, PRESSURE_MIN, PRESSURE_MAX, 0, 0);
-
- strcpy(corgi_ts->phys, "corgits/input0");
-
- corgi_ts->input.private = corgi_ts;
- corgi_ts->input.name = "Corgi Touchscreen";
- corgi_ts->input.dev = dev;
- corgi_ts->input.phys = corgi_ts->phys;
- corgi_ts->input.id.bustype = BUS_HOST;
- corgi_ts->input.id.vendor = 0x0001;
- corgi_ts->input.id.product = 0x0002;
- corgi_ts->input.id.version = 0x0100;
+ corgi_ts->input = input_dev;
+
+ init_timer(&corgi_ts->timer);
+ corgi_ts->timer.data = (unsigned long) corgi_ts;
+ corgi_ts->timer.function = corgi_ts_timer;
+
+ input_dev->name = "Corgi Touchscreen";
+ input_dev->phys = "corgits/input0";
+ input_dev->id.bustype = BUS_HOST;
+ input_dev->id.vendor = 0x0001;
+ input_dev->id.product = 0x0002;
+ input_dev->id.version = 0x0100;
+ input_dev->cdev.dev = dev;
+ input_dev->private = corgi_ts;
+
+ input_dev->evbit[0] = BIT(EV_KEY) | BIT(EV_ABS);
+ input_dev->keybit[LONG(BTN_TOUCH)] = BIT(BTN_TOUCH);
+ input_set_abs_params(input_dev, ABS_X, X_AXIS_MIN, X_AXIS_MAX, 0, 0);
+ input_set_abs_params(input_dev, ABS_Y, Y_AXIS_MIN, Y_AXIS_MAX, 0, 0);
+ input_set_abs_params(input_dev, ABS_PRESSURE, PRESSURE_MIN, PRESSURE_MAX, 0, 0);

pxa_gpio_mode(IRQ_TO_GPIO(corgi_ts->irq_gpio) | GPIO_IN);

@@ -319,25 +321,24 @@ static int __init corgits_probe(struct d
corgi_ssp_ads7846_putget((5u << ADSCTRL_ADR_SH) | ADSCTRL_STS);
mdelay(5);

- init_timer(&corgi_ts->timer);
- corgi_ts->timer.data = (unsigned long) corgi_ts;
- corgi_ts->timer.function = corgi_ts_timer;
-
- input_register_device(&corgi_ts->input);
- corgi_ts->power_mode = PWR_MODE_ACTIVE;
-
if (request_irq(corgi_ts->irq_gpio, ts_interrupt, SA_INTERRUPT, "ts", corgi_ts)) {
- input_unregister_device(&corgi_ts->input);
- kfree(corgi_ts);
- return -EBUSY;
+ err = -EBUSY;
+ goto fail;
}

+ input_register_device(corgi_ts->input);
+
+ corgi_ts->power_mode = PWR_MODE_ACTIVE;
+
/* Enable Falling Edge */
set_irq_type(corgi_ts->irq_gpio, IRQT_FALLING);

- printk(KERN_INFO "input: Corgi Touchscreen Registered\n");
-
return 0;
+
+ fail: input_free_device(input_dev);
+ kfree(corgi_ts);
+ return err;
+
}

static int corgits_remove(struct device *dev)
@@ -347,7 +348,7 @@ static int corgits_remove(struct device
free_irq(corgi_ts->irq_gpio, NULL);
del_timer_sync(&corgi_ts->timer);
corgi_ts->machinfo->put_hsync();
- input_unregister_device(&corgi_ts->input);
+ input_unregister_device(corgi_ts->input);
kfree(corgi_ts);
return 0;
}
diff --git a/drivers/input/touchscreen/elo.c b/drivers/input/touchscreen/elo.c
index 3cdc9ca..c86a2eb 100644
--- a/drivers/input/touchscreen/elo.c
+++ b/drivers/input/touchscreen/elo.c
@@ -36,14 +36,12 @@ MODULE_LICENSE("GPL");

#define ELO_MAX_LENGTH 10

-static char *elo_name = "Elo Serial TouchScreen";
-
/*
* Per-touchscreen data.
*/

struct elo {
- struct input_dev dev;
+ struct input_dev *dev;
struct serio *serio;
int id;
int idx;
@@ -54,7 +52,7 @@ struct elo {

static void elo_process_data_10(struct elo* elo, unsigned char data, struct pt_regs *regs)
{
- struct input_dev *dev = &elo->dev;
+ struct input_dev *dev = elo->dev;

elo->csum += elo->data[elo->idx] = data;

@@ -80,7 +78,7 @@ static void elo_process_data_10(struct e
input_report_abs(dev, ABS_X, (elo->data[4] << 8) | elo->data[3]);
input_report_abs(dev, ABS_Y, (elo->data[6] << 8) | elo->data[5]);
input_report_abs(dev, ABS_PRESSURE, (elo->data[8] << 8) | elo->data[7]);
- input_report_key(dev, BTN_TOUCH, elo->data[2] & 3);
+ input_report_key(dev, BTN_TOUCH, elo->data[8] || elo->data[7]);
input_sync(dev);
}
elo->idx = 0;
@@ -91,7 +89,7 @@ static void elo_process_data_10(struct e

static void elo_process_data_6(struct elo* elo, unsigned char data, struct pt_regs *regs)
{
- struct input_dev *dev = &elo->dev;
+ struct input_dev *dev = elo->dev;

elo->data[elo->idx] = data;

@@ -129,7 +127,7 @@ static void elo_process_data_6(struct el
case 5:
if ((data & 0xf0) == 0) {
input_report_abs(dev, ABS_PRESSURE, elo->data[5]);
- input_report_key(dev, BTN_TOUCH, elo->data[5]);
+ input_report_key(dev, BTN_TOUCH, !!elo->data[5]);
}
input_sync(dev);
elo->idx = 0;
@@ -139,7 +137,7 @@ static void elo_process_data_6(struct el

static void elo_process_data_3(struct elo* elo, unsigned char data, struct pt_regs *regs)
{
- struct input_dev *dev = &elo->dev;
+ struct input_dev *dev = elo->dev;

elo->data[elo->idx] = data;

@@ -191,7 +189,7 @@ static void elo_disconnect(struct serio
{
struct elo* elo = serio_get_drvdata(serio);

- input_unregister_device(&elo->dev);
+ input_unregister_device(elo->dev);
serio_close(serio);
serio_set_drvdata(serio, NULL);
kfree(elo);
@@ -206,67 +204,68 @@ static void elo_disconnect(struct serio
static int elo_connect(struct serio *serio, struct serio_driver *drv)
{
struct elo *elo;
+ struct input_dev *input_dev;
int err;

- if (!(elo = kmalloc(sizeof(struct elo), GFP_KERNEL)))
- return -ENOMEM;
+ elo = kzalloc(sizeof(struct elo), GFP_KERNEL);
+ input_dev = input_allocate_device();
+ if (!elo || !input_dev) {
+ err = -ENOMEM;
+ goto fail;
+ }

- memset(elo, 0, sizeof(struct elo));
+ elo->serio = serio;
+ elo->id = serio->id.id;
+ elo->dev = input_dev;
+ snprintf(elo->phys, sizeof(elo->phys), "%s/input0", serio->phys);

- init_input_dev(&elo->dev);
- elo->dev.evbit[0] = BIT(EV_KEY) | BIT(EV_ABS);
- elo->dev.keybit[LONG(BTN_TOUCH)] = BIT(BTN_TOUCH);
+ input_dev->private = elo;
+ input_dev->name = "Elo Serial TouchScreen";
+ input_dev->phys = elo->phys;
+ input_dev->id.bustype = BUS_RS232;
+ input_dev->id.vendor = SERIO_ELO;
+ input_dev->id.product = elo->id;
+ input_dev->id.version = 0x0100;
+ input_dev->cdev.dev = &serio->dev;

- elo->id = serio->id.id;
+ input_dev->evbit[0] = BIT(EV_KEY) | BIT(EV_ABS);
+ input_dev->keybit[LONG(BTN_TOUCH)] = BIT(BTN_TOUCH);

switch (elo->id) {

case 0: /* 10-byte protocol */
- input_set_abs_params(&elo->dev, ABS_X, 96, 4000, 0, 0);
- input_set_abs_params(&elo->dev, ABS_Y, 96, 4000, 0, 0);
- input_set_abs_params(&elo->dev, ABS_PRESSURE, 0, 255, 0, 0);
+ input_set_abs_params(input_dev, ABS_X, 96, 4000, 0, 0);
+ input_set_abs_params(input_dev, ABS_Y, 96, 4000, 0, 0);
+ input_set_abs_params(input_dev, ABS_PRESSURE, 0, 255, 0, 0);
break;

case 1: /* 6-byte protocol */
- input_set_abs_params(&elo->dev, ABS_PRESSURE, 0, 15, 0, 0);
+ input_set_abs_params(input_dev, ABS_PRESSURE, 0, 15, 0, 0);

case 2: /* 4-byte protocol */
- input_set_abs_params(&elo->dev, ABS_X, 96, 4000, 0, 0);
- input_set_abs_params(&elo->dev, ABS_Y, 96, 4000, 0, 0);
+ input_set_abs_params(input_dev, ABS_X, 96, 4000, 0, 0);
+ input_set_abs_params(input_dev, ABS_Y, 96, 4000, 0, 0);
break;

case 3: /* 3-byte protocol */
- input_set_abs_params(&elo->dev, ABS_X, 0, 255, 0, 0);
- input_set_abs_params(&elo->dev, ABS_Y, 0, 255, 0, 0);
+ input_set_abs_params(input_dev, ABS_X, 0, 255, 0, 0);
+ input_set_abs_params(input_dev, ABS_Y, 0, 255, 0, 0);
break;
}

- elo->serio = serio;
-
- sprintf(elo->phys, "%s/input0", serio->phys);
-
- elo->dev.private = elo;
- elo->dev.name = elo_name;
- elo->dev.phys = elo->phys;
- elo->dev.id.bustype = BUS_RS232;
- elo->dev.id.vendor = SERIO_ELO;
- elo->dev.id.product = elo->id;
- elo->dev.id.version = 0x0100;
-
serio_set_drvdata(serio, elo);

err = serio_open(serio, drv);
- if (err) {
- serio_set_drvdata(serio, NULL);
- kfree(elo);
- return err;
- }
-
- input_register_device(&elo->dev);
-
- printk(KERN_INFO "input: %s on %s\n", elo_name, serio->phys);
+ if (err)
+ goto fail;

+ input_register_device(elo->dev);
return 0;
+
+ fail: serio_set_drvdata(serio, NULL);
+ input_free_device(input_dev);
+ kfree(elo);
+ return err;
}

/*
diff --git a/drivers/input/touchscreen/gunze.c b/drivers/input/touchscreen/gunze.c
index 53a27e4..466da19 100644
--- a/drivers/input/touchscreen/gunze.c
+++ b/drivers/input/touchscreen/gunze.c
@@ -48,14 +48,12 @@ MODULE_LICENSE("GPL");

#define GUNZE_MAX_LENGTH 10

-static char *gunze_name = "Gunze AHL-51S TouchScreen";
-
/*
* Per-touchscreen data.
*/

struct gunze {
- struct input_dev dev;
+ struct input_dev *dev;
struct serio *serio;
int idx;
unsigned char data[GUNZE_MAX_LENGTH];
@@ -64,7 +62,7 @@ struct gunze {

static void gunze_process_packet(struct gunze* gunze, struct pt_regs *regs)
{
- struct input_dev *dev = &gunze->dev;
+ struct input_dev *dev = gunze->dev;

if (gunze->idx != GUNZE_MAX_LENGTH || gunze->data[5] != ',' ||
(gunze->data[0] != 'T' && gunze->data[0] != 'R')) {
@@ -100,11 +98,13 @@ static irqreturn_t gunze_interrupt(struc

static void gunze_disconnect(struct serio *serio)
{
- struct gunze* gunze = serio_get_drvdata(serio);
+ struct gunze *gunze = serio_get_drvdata(serio);

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

@@ -117,45 +117,45 @@ static void gunze_disconnect(struct seri
static int gunze_connect(struct serio *serio, struct serio_driver *drv)
{
struct gunze *gunze;
+ struct input_dev *input_dev;
int err;

- if (!(gunze = kmalloc(sizeof(struct gunze), GFP_KERNEL)))
- return -ENOMEM;
-
- memset(gunze, 0, sizeof(struct gunze));
-
- init_input_dev(&gunze->dev);
- gunze->dev.evbit[0] = BIT(EV_KEY) | BIT(EV_ABS);
- gunze->dev.keybit[LONG(BTN_TOUCH)] = BIT(BTN_TOUCH);
- input_set_abs_params(&gunze->dev, ABS_X, 24, 1000, 0, 0);
- input_set_abs_params(&gunze->dev, ABS_Y, 24, 1000, 0, 0);
+ gunze = kzalloc(sizeof(struct gunze), GFP_KERNEL);
+ input_dev = input_allocate_device();
+ if (!gunze || !input_dev) {
+ err = -ENOMEM;
+ goto fail;
+ }

gunze->serio = serio;
-
+ gunze->dev = input_dev;
sprintf(gunze->phys, "%s/input0", serio->phys);

- gunze->dev.private = gunze;
- gunze->dev.name = gunze_name;
- gunze->dev.phys = gunze->phys;
- gunze->dev.id.bustype = BUS_RS232;
- gunze->dev.id.vendor = SERIO_GUNZE;
- gunze->dev.id.product = 0x0051;
- gunze->dev.id.version = 0x0100;
+ input_dev->private = gunze;
+ input_dev->name = "Gunze AHL-51S TouchScreen";
+ input_dev->phys = gunze->phys;
+ input_dev->id.bustype = BUS_RS232;
+ input_dev->id.vendor = SERIO_GUNZE;
+ input_dev->id.product = 0x0051;
+ input_dev->id.version = 0x0100;
+ input_dev->evbit[0] = BIT(EV_KEY) | BIT(EV_ABS);
+ input_dev->keybit[LONG(BTN_TOUCH)] = BIT(BTN_TOUCH);
+ input_set_abs_params(input_dev, ABS_X, 24, 1000, 0, 0);
+ input_set_abs_params(input_dev, ABS_Y, 24, 1000, 0, 0);

serio_set_drvdata(serio, gunze);

err = serio_open(serio, drv);
- if (err) {
- serio_set_drvdata(serio, NULL);
- kfree(gunze);
- return err;
- }
-
- input_register_device(&gunze->dev);
-
- printk(KERN_INFO "input: %s on %s\n", gunze_name, serio->phys);
+ if (err)
+ goto fail;

+ input_register_device(gunze->dev);
return 0;
+
+ fail: serio_set_drvdata(serio, NULL);
+ input_free_device(input_dev);
+ kfree(gunze);
+ return err;
}

/*
diff --git a/drivers/input/touchscreen/h3600_ts_input.c b/drivers/input/touchscreen/h3600_ts_input.c
index bcfa1e3..a18d56b 100644
--- a/drivers/input/touchscreen/h3600_ts_input.c
+++ b/drivers/input/touchscreen/h3600_ts_input.c
@@ -39,7 +39,6 @@
#include <linux/serio.h>
#include <linux/init.h>
#include <linux/delay.h>
-#include <linux/pm.h>

/* SA1100 serial defines */
#include <asm/arch/hardware.h>
@@ -93,16 +92,12 @@ MODULE_LICENSE("GPL");
#define H3600_SCANCODE_LEFT 8 /* 8 -> left */
#define H3600_SCANCODE_DOWN 9 /* 9 -> down */

-static char *h3600_name = "H3600 TouchScreen";
-
/*
* Per-touchscreen data.
*/
struct h3600_dev {
- struct input_dev dev;
- struct pm_dev *pm_dev;
+ struct input_dev *dev;
struct serio *serio;
- struct pm_dev *pm_dev;
unsigned char event; /* event ID from packet */
unsigned char chksum;
unsigned char len;
@@ -163,33 +158,6 @@ unsigned int h3600_flite_power(struct in
return 0;
}

-static int suspended = 0;
-static int h3600ts_pm_callback(struct pm_dev *pm_dev, pm_request_t req,
- void *data)
-{
- struct input_dev *dev = (struct input_dev *) data;
-
- switch (req) {
- case PM_SUSPEND: /* enter D1-D3 */
- suspended = 1;
- h3600_flite_power(dev, FLITE_PWR_OFF);
- break;
- case PM_BLANK:
- if (!suspended)
- h3600_flite_power(dev, FLITE_PWR_OFF);
- break;
- case PM_RESUME: /* enter D0 */
- /* same as unblank */
- case PM_UNBLANK:
- if (suspended) {
- //initSerial();
- suspended = 0;
- }
- h3600_flite_power(dev, FLITE_PWR_ON);
- break;
- }
- return 0;
-}
#endif

/*
@@ -199,7 +167,7 @@ static int h3600ts_pm_callback(struct pm
*/
static void h3600ts_process_packet(struct h3600_dev *ts, struct pt_regs *regs)
{
- struct input_dev *dev = &ts->dev;
+ struct input_dev *dev = ts->dev;
static int touched = 0;
int key, down = 0;

@@ -295,6 +263,7 @@ static void h3600ts_process_packet(struc
static int h3600ts_event(struct input_dev *dev, unsigned int type,
unsigned int code, int value)
{
+#if 0
struct h3600_dev *ts = dev->private;

switch (type) {
@@ -304,6 +273,8 @@ static int h3600ts_event(struct input_de
}
}
return -1;
+#endif
+ return 0;
}

/*
@@ -380,14 +351,48 @@ static irqreturn_t h3600ts_interrupt(str
static int h3600ts_connect(struct serio *serio, struct serio_driver *drv)
{
struct h3600_dev *ts;
+ struct input_dev *input_dev;
int err;

- if (!(ts = kmalloc(sizeof(struct h3600_dev), GFP_KERNEL)))
- return -ENOMEM;
+ ts = kzalloc(sizeof(struct h3600_dev), GFP_KERNEL);
+ input_dev = input_allocate_device();
+ if (!ts || !input_dev) {
+ err = -ENOMEM;
+ goto fail1;
+ }

- memset(ts, 0, sizeof(struct h3600_dev));
+ ts->serio = serio;
+ ts->dev = input_dev;
+ sprintf(ts->phys, "%s/input0", serio->phys);

- init_input_dev(&ts->dev);
+ input_dev->name = "H3600 TouchScreen";
+ input_dev->phys = ts->phys;
+ input_dev->id.bustype = BUS_RS232;
+ input_dev->id.vendor = SERIO_H3600;
+ input_dev->id.product = 0x0666; /* FIXME !!! We can ask the hardware */
+ input_dev->id.version = 0x0100;
+ input_dev->cdev.dev = &serio->dev;
+ input_dev->private = ts;
+
+ input_dev->event = h3600ts_event;
+
+ input_dev->evbit[0] = BIT(EV_KEY) | BIT(EV_ABS) | BIT(EV_LED) | BIT(EV_PWR);
+ input_dev->ledbit[0] = BIT(LED_SLEEP);
+ input_set_abs_params(input_dev, ABS_X, 60, 985, 0, 0);
+ input_set_abs_params(input_dev, ABS_Y, 35, 1024, 0, 0);
+
+ set_bit(KEY_RECORD, input_dev->keybit);
+ set_bit(KEY_Q, input_dev->keybit);
+ set_bit(KEY_PROG1, input_dev->keybit);
+ set_bit(KEY_PROG2, input_dev->keybit);
+ set_bit(KEY_PROG3, input_dev->keybit);
+ set_bit(KEY_UP, input_dev->keybit);
+ set_bit(KEY_RIGHT, input_dev->keybit);
+ set_bit(KEY_LEFT, input_dev->keybit);
+ set_bit(KEY_DOWN, input_dev->keybit);
+ set_bit(KEY_ENTER, input_dev->keybit);
+ set_bit(KEY_SUSPEND, input_dev->keybit);
+ set_bit(BTN_TOUCH, input_dev->keybit);

/* Device specific stuff */
set_GPIO_IRQ_edge(GPIO_BITSY_ACTION_BUTTON, GPIO_BOTH_EDGES);
@@ -397,73 +402,35 @@ static int h3600ts_connect(struct serio
SA_SHIRQ | SA_INTERRUPT | SA_SAMPLE_RANDOM,
"h3600_action", &ts->dev)) {
printk(KERN_ERR "h3600ts.c: Could not allocate Action Button IRQ!\n");
- kfree(ts);
- return -EBUSY;
+ err = -EBUSY;
+ goto fail2;
}

if (request_irq(IRQ_GPIO_BITSY_NPOWER_BUTTON, npower_button_handler,
SA_SHIRQ | SA_INTERRUPT | SA_SAMPLE_RANDOM,
"h3600_suspend", &ts->dev)) {
- free_irq(IRQ_GPIO_BITSY_ACTION_BUTTON, &ts->dev);
printk(KERN_ERR "h3600ts.c: Could not allocate Power Button IRQ!\n");
- kfree(ts);
- return -EBUSY;
+ err = -EBUSY;
+ goto fail3;
}

- /* Now we have things going we setup our input device */
- ts->dev.evbit[0] = BIT(EV_KEY) | BIT(EV_ABS) | BIT(EV_LED) | BIT(EV_PWR);
- ts->dev.ledbit[0] = BIT(LED_SLEEP);
- input_set_abs_params(&ts->dev, ABS_X, 60, 985, 0, 0);
- input_set_abs_params(&ts->dev, ABS_Y, 35, 1024, 0, 0);
-
- set_bit(KEY_RECORD, ts->dev.keybit);
- set_bit(KEY_Q, ts->dev.keybit);
- set_bit(KEY_PROG1, ts->dev.keybit);
- set_bit(KEY_PROG2, ts->dev.keybit);
- set_bit(KEY_PROG3, ts->dev.keybit);
- set_bit(KEY_UP, ts->dev.keybit);
- set_bit(KEY_RIGHT, ts->dev.keybit);
- set_bit(KEY_LEFT, ts->dev.keybit);
- set_bit(KEY_DOWN, ts->dev.keybit);
- set_bit(KEY_ENTER, ts->dev.keybit);
- ts->dev.keybit[LONG(BTN_TOUCH)] |= BIT(BTN_TOUCH);
- ts->dev.keybit[LONG(KEY_SUSPEND)] |= BIT(KEY_SUSPEND);
-
- ts->serio = serio;
-
- sprintf(ts->phys, "%s/input0", serio->phys);
-
- ts->dev.event = h3600ts_event;
- ts->dev.private = ts;
- ts->dev.name = h3600_name;
- ts->dev.phys = ts->phys;
- ts->dev.id.bustype = BUS_RS232;
- ts->dev.id.vendor = SERIO_H3600;
- ts->dev.id.product = 0x0666; /* FIXME !!! We can ask the hardware */
- ts->dev.id.version = 0x0100;
-
serio_set_drvdata(serio, ts);

err = serio_open(serio, drv);
- if (err) {
- free_irq(IRQ_GPIO_BITSY_ACTION_BUTTON, ts);
- free_irq(IRQ_GPIO_BITSY_NPOWER_BUTTON, ts);
- serio_set_drvdata(serio, NULL);
- kfree(ts);
+ if (err)
return err;
- }

//h3600_flite_control(1, 25); /* default brightness */
-#ifdef CONFIG_PM
- ts->pm_dev = pm_register(PM_ILLUMINATION_DEV, PM_SYS_LIGHT,
- h3600ts_pm_callback);
- printk("registered pm callback\n");
-#endif
- input_register_device(&ts->dev);
-
- printk(KERN_INFO "input: %s on %s\n", h3600_name, serio->phys);
+ input_register_device(ts->dev);

return 0;
+
+fail3: free_irq(IRQ_GPIO_BITSY_NPOWER_BUTTON, ts->dev);
+fail2: free_irq(IRQ_GPIO_BITSY_ACTION_BUTTON, ts->dev);
+fail1: serio_set_drvdata(serio, NULL);
+ input_free_device(input_dev);
+ kfree(ts);
+ return err;
}

/*
@@ -476,9 +443,11 @@ static void h3600ts_disconnect(struct se

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

diff --git a/drivers/input/touchscreen/hp680_ts_input.c b/drivers/input/touchscreen/hp680_ts_input.c
index 7e14044..957dd5a 100644
--- a/drivers/input/touchscreen/hp680_ts_input.c
+++ b/drivers/input/touchscreen/hp680_ts_input.c
@@ -21,10 +21,8 @@

static void do_softint(void *data);

-static struct input_dev hp680_ts_dev;
+static struct input_dev *hp680_ts_dev;
static DECLARE_WORK(work, do_softint, 0);
-static char *hp680_ts_name = "HP Jornada touchscreen";
-static char *hp680_ts_phys = "input0";

static void do_softint(void *data)
{
@@ -58,14 +56,14 @@ static void do_softint(void *data)
}

if (touched) {
- input_report_key(&hp680_ts_dev, BTN_TOUCH, 1);
- input_report_abs(&hp680_ts_dev, ABS_X, absx);
- input_report_abs(&hp680_ts_dev, ABS_Y, absy);
+ input_report_key(hp680_ts_dev, BTN_TOUCH, 1);
+ input_report_abs(hp680_ts_dev, ABS_X, absx);
+ input_report_abs(hp680_ts_dev, ABS_Y, absy);
} else {
- input_report_key(&hp680_ts_dev, BTN_TOUCH, 0);
+ input_report_key(hp680_ts_dev, BTN_TOUCH, 0);
}

- input_sync(&hp680_ts_dev);
+ input_sync(hp680_ts_dev);
enable_irq(HP680_TS_IRQ);
}

@@ -92,27 +90,29 @@ static int __init hp680_ts_init(void)
scpcr |= SCPCR_TS_ENABLE;
ctrl_outw(scpcr, SCPCR);

- memset(&hp680_ts_dev, 0, sizeof(hp680_ts_dev));
- init_input_dev(&hp680_ts_dev);
-
- hp680_ts_dev.evbit[0] = BIT(EV_ABS) | BIT(EV_KEY);
- hp680_ts_dev.absbit[0] = BIT(ABS_X) | BIT(ABS_Y);
- hp680_ts_dev.keybit[LONG(BTN_TOUCH)] = BIT(BTN_TOUCH);
-
- hp680_ts_dev.absmin[ABS_X] = HP680_TS_ABS_X_MIN;
- hp680_ts_dev.absmin[ABS_Y] = HP680_TS_ABS_Y_MIN;
- hp680_ts_dev.absmax[ABS_X] = HP680_TS_ABS_X_MAX;
- hp680_ts_dev.absmax[ABS_Y] = HP680_TS_ABS_Y_MAX;
-
- hp680_ts_dev.name = hp680_ts_name;
- hp680_ts_dev.phys = hp680_ts_phys;
- input_register_device(&hp680_ts_dev);
-
- if (request_irq
- (HP680_TS_IRQ, hp680_ts_interrupt, SA_INTERRUPT, MODNAME, 0) < 0) {
- printk(KERN_ERR "hp680_touchscreen.c : Can't allocate irq %d\n",
+ hp680_ts_dev = input_allocate_device();
+ if (!hp680_ts_dev)
+ return -ENOMEM;
+
+ hp680_ts_dev->evbit[0] = BIT(EV_ABS) | BIT(EV_KEY);
+ hp680_ts_dev->absbit[0] = BIT(ABS_X) | BIT(ABS_Y);
+ hp680_ts_dev->keybit[LONG(BTN_TOUCH)] = BIT(BTN_TOUCH);
+
+ hp680_ts_dev->absmin[ABS_X] = HP680_TS_ABS_X_MIN;
+ hp680_ts_dev->absmin[ABS_Y] = HP680_TS_ABS_Y_MIN;
+ hp680_ts_dev->absmax[ABS_X] = HP680_TS_ABS_X_MAX;
+ hp680_ts_dev->absmax[ABS_Y] = HP680_TS_ABS_Y_MAX;
+
+ hp680_ts_dev->name = "HP Jornada touchscreen";
+ hp680_ts_dev->phys = "hp680_ts/input0";
+
+ input_register_device(hp680_ts_dev);
+
+ if (request_irq(HP680_TS_IRQ, hp680_ts_interrupt,
+ SA_INTERRUPT, MODNAME, 0) < 0) {
+ printk(KERN_ERR "hp680_touchscreen.c: Can't allocate irq %d\n",
HP680_TS_IRQ);
- input_unregister_device(&hp680_ts_dev);
+ input_unregister_device(hp680_ts_dev);
return -EBUSY;
}

@@ -124,7 +124,7 @@ static void __exit hp680_ts_exit(void)
free_irq(HP680_TS_IRQ, 0);
cancel_delayed_work(&work);
flush_scheduled_work();
- input_unregister_device(&hp680_ts_dev);
+ input_unregister_device(hp680_ts_dev);
}

module_init(hp680_ts_init);
diff --git a/drivers/input/touchscreen/mk712.c b/drivers/input/touchscreen/mk712.c
index afaaebe..4844d25 100644
--- a/drivers/input/touchscreen/mk712.c
+++ b/drivers/input/touchscreen/mk712.c
@@ -77,7 +77,7 @@ MODULE_PARM_DESC(irq, "IRQ of MK712 touc
#define MK712_READ_ONE_POINT 0x20
#define MK712_POWERUP 0x40

-static struct input_dev mk712_dev;
+static struct input_dev *mk712_dev;
static DEFINE_SPINLOCK(mk712_lock);

static irqreturn_t mk712_interrupt(int irq, void *dev_id, struct pt_regs *regs)
@@ -88,7 +88,7 @@ static irqreturn_t mk712_interrupt(int i
static unsigned short last_y;

spin_lock(&mk712_lock);
- input_regs(&mk712_dev, regs);
+ input_regs(mk712_dev, regs);

status = inb(mk712_io + MK712_STATUS);

@@ -100,7 +100,7 @@ static irqreturn_t mk712_interrupt(int i
if (~status & MK712_STATUS_TOUCH)
{
debounce = 1;
- input_report_key(&mk712_dev, BTN_TOUCH, 0);
+ input_report_key(mk712_dev, BTN_TOUCH, 0);
goto end;
}

@@ -110,15 +110,15 @@ static irqreturn_t mk712_interrupt(int i
goto end;
}

- input_report_key(&mk712_dev, BTN_TOUCH, 1);
- input_report_abs(&mk712_dev, ABS_X, last_x);
- input_report_abs(&mk712_dev, ABS_Y, last_y);
+ input_report_key(mk712_dev, BTN_TOUCH, 1);
+ input_report_abs(mk712_dev, ABS_X, last_x);
+ input_report_abs(mk712_dev, ABS_Y, last_y);

end:

last_x = inw(mk712_io + MK712_X) & 0x0fff;
last_y = inw(mk712_io + MK712_Y) & 0x0fff;
- input_sync(&mk712_dev);
+ input_sync(mk712_dev);
spin_unlock(&mk712_lock);
return IRQ_HANDLED;
}
@@ -154,30 +154,11 @@ static void mk712_close(struct input_dev
spin_unlock_irqrestore(&mk712_lock, flags);
}

-static struct input_dev mk712_dev = {
- .evbit = { BIT(EV_KEY) | BIT(EV_ABS) },
- .keybit = { [LONG(BTN_TOUCH)] = BIT(BTN_TOUCH) },
- .absbit = { BIT(ABS_X) | BIT(ABS_Y) },
- .open = mk712_open,
- .close = mk712_close,
- .name = "ICS MicroClock MK712 TouchScreen",
- .phys = "isa0260/input0",
- .absmin = { [ABS_X] = 0, [ABS_Y] = 0 },
- .absmax = { [ABS_X] = 0xfff, [ABS_Y] = 0xfff },
- .absfuzz = { [ABS_X] = 88, [ABS_Y] = 88 },
- .id = {
- .bustype = BUS_ISA,
- .vendor = 0x0005,
- .product = 0x0001,
- .version = 0x0100,
- },
-};
-
int __init mk712_init(void)
{
+ int err;

- if(!request_region(mk712_io, 8, "mk712"))
- {
+ if (!request_region(mk712_io, 8, "mk712")) {
printk(KERN_WARNING "mk712: unable to get IO region\n");
return -ENODEV;
}
@@ -188,28 +169,49 @@ int __init mk712_init(void)
(inw(mk712_io + MK712_Y) & 0xf000) ||
(inw(mk712_io + MK712_STATUS) & 0xf333)) {
printk(KERN_WARNING "mk712: device not present\n");
- release_region(mk712_io, 8);
- return -ENODEV;
+ err = -ENODEV;
+ goto fail;
}

- if(request_irq(mk712_irq, mk712_interrupt, 0, "mk712", &mk712_dev))
- {
- printk(KERN_WARNING "mk712: unable to get IRQ\n");
- release_region(mk712_io, 8);
- return -EBUSY;
+ if (!(mk712_dev = input_allocate_device())) {
+ printk(KERN_ERR "mk712: not enough memory\n");
+ err = -ENOMEM;
+ goto fail;
}

- input_register_device(&mk712_dev);
+ mk712_dev->name = "ICS MicroClock MK712 TouchScreen";
+ mk712_dev->phys = "isa0260/input0";
+ mk712_dev->id.bustype = BUS_ISA;
+ mk712_dev->id.vendor = 0x0005;
+ mk712_dev->id.product = 0x0001;
+ mk712_dev->id.version = 0x0100;
+
+ mk712_dev->open = mk712_open;
+ mk712_dev->close = mk712_close;

- printk(KERN_INFO "input: ICS MicroClock MK712 TouchScreen at %#x irq %d\n", mk712_io, mk712_irq);
+ mk712_dev->evbit[0] = BIT(EV_KEY) | BIT(EV_ABS);
+ mk712_dev->keybit[LONG(BTN_TOUCH)] = BIT(BTN_TOUCH);
+ input_set_abs_params(mk712_dev, ABS_X, 0, 0xfff, 88, 0);
+ input_set_abs_params(mk712_dev, ABS_Y, 0, 0xfff, 88, 0);

+ if (request_irq(mk712_irq, mk712_interrupt, 0, "mk712", mk712_dev)) {
+ printk(KERN_WARNING "mk712: unable to get IRQ\n");
+ err = -EBUSY;
+ goto fail;
+ }
+
+ input_register_device(mk712_dev);
return 0;
+
+ fail: input_free_device(mk712_dev);
+ release_region(mk712_io, 8);
+ return err;
}

static void __exit mk712_exit(void)
{
- input_unregister_device(&mk712_dev);
- free_irq(mk712_irq, &mk712_dev);
+ input_unregister_device(mk712_dev);
+ free_irq(mk712_irq, mk712_dev);
release_region(mk712_io, 8);
}

diff --git a/drivers/input/touchscreen/mtouch.c b/drivers/input/touchscreen/mtouch.c
index aa8ee78..1d0d37e 100644
--- a/drivers/input/touchscreen/mtouch.c
+++ b/drivers/input/touchscreen/mtouch.c
@@ -51,14 +51,12 @@ MODULE_LICENSE("GPL");
#define MTOUCH_GET_YC(data) (((data[4])<<7) | data[3])
#define MTOUCH_GET_TOUCHED(data) (MTOUCH_FORMAT_TABLET_TOUCH_BIT & data[0])

-static char *mtouch_name = "MicroTouch Serial TouchScreen";
-
/*
* Per-touchscreen data.
*/

struct mtouch {
- struct input_dev dev;
+ struct input_dev *dev;
struct serio *serio;
int idx;
unsigned char data[MTOUCH_MAX_LENGTH];
@@ -67,7 +65,7 @@ struct mtouch {

static void mtouch_process_format_tablet(struct mtouch *mtouch, struct pt_regs *regs)
{
- struct input_dev *dev = &mtouch->dev;
+ struct input_dev *dev = mtouch->dev;

if (MTOUCH_FORMAT_TABLET_LENGTH == ++mtouch->idx) {
input_regs(dev, regs);
@@ -116,9 +114,11 @@ static void mtouch_disconnect(struct ser
{
struct mtouch* mtouch = serio_get_drvdata(serio);

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

@@ -131,46 +131,46 @@ static void mtouch_disconnect(struct ser
static int mtouch_connect(struct serio *serio, struct serio_driver *drv)
{
struct mtouch *mtouch;
+ struct input_dev *input_dev;
int err;

- if (!(mtouch = kmalloc(sizeof(*mtouch), GFP_KERNEL)))
- return -ENOMEM;
-
- memset(mtouch, 0, sizeof(*mtouch));
-
- init_input_dev(&mtouch->dev);
- mtouch->dev.evbit[0] = BIT(EV_KEY) | BIT(EV_ABS);
- mtouch->dev.keybit[LONG(BTN_TOUCH)] = BIT(BTN_TOUCH);
-
- input_set_abs_params(&mtouch->dev, ABS_X, MTOUCH_MIN_XC, MTOUCH_MAX_XC, 0, 0);
- input_set_abs_params(&mtouch->dev, ABS_Y, MTOUCH_MIN_YC, MTOUCH_MAX_YC, 0, 0);
+ mtouch = kzalloc(sizeof(struct mtouch), GFP_KERNEL);
+ input_dev = input_allocate_device();
+ if (!mtouch || !input_dev) {
+ err = -ENOMEM;
+ goto fail;
+ }

mtouch->serio = serio;
-
+ mtouch->dev = input_dev;
sprintf(mtouch->phys, "%s/input0", serio->phys);

- mtouch->dev.private = mtouch;
- mtouch->dev.name = mtouch_name;
- mtouch->dev.phys = mtouch->phys;
- mtouch->dev.id.bustype = BUS_RS232;
- mtouch->dev.id.vendor = SERIO_MICROTOUCH;
- mtouch->dev.id.product = 0;
- mtouch->dev.id.version = 0x0100;
+ input_dev->private = mtouch;
+ input_dev->name = "MicroTouch Serial TouchScreen";
+ input_dev->phys = mtouch->phys;
+ input_dev->id.bustype = BUS_RS232;
+ input_dev->id.vendor = SERIO_MICROTOUCH;
+ input_dev->id.product = 0;
+ input_dev->id.version = 0x0100;
+ input_dev->evbit[0] = BIT(EV_KEY) | BIT(EV_ABS);
+ input_dev->keybit[LONG(BTN_TOUCH)] = BIT(BTN_TOUCH);
+ input_set_abs_params(mtouch->dev, ABS_X, MTOUCH_MIN_XC, MTOUCH_MAX_XC, 0, 0);
+ input_set_abs_params(mtouch->dev, ABS_Y, MTOUCH_MIN_YC, MTOUCH_MAX_YC, 0, 0);

serio_set_drvdata(serio, mtouch);

err = serio_open(serio, drv);
- if (err) {
- serio_set_drvdata(serio, NULL);
- kfree(mtouch);
- return err;
- }
-
- input_register_device(&mtouch->dev);
+ if (err)
+ goto fail;

- printk(KERN_INFO "input: %s on %s\n", mtouch->dev.name, serio->phys);
+ input_register_device(mtouch->dev);

return 0;
+
+ fail: serio_set_drvdata(serio, NULL);
+ input_free_device(input_dev);
+ kfree(mtouch);
+ return err;
}

/*

2005-10-28 06:39:06

by Greg KH

[permalink] [raw]
Subject: [PATCH] drivers/input/keyboard: convert to dynamic input_dev allocation

[PATCH] drivers/input/keyboard: convert to dynamic input_dev allocation

Input: convert drivers/input/keyboard to dynamic input_dev allocation

This is required for input_dev sysfs integration

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

---
commit 6c54454d97a93b1d747e4b16a45237b03e8ac6d1
tree a92ced3a9db4f4fd88a45e8c3bf85883b743ed55
parent f18c31d676d42b4f75f1520733f4b5b2c966524d
author Dmitry Torokhov <[email protected]> Thu, 15 Sep 2005 02:01:45 -0500
committer Greg Kroah-Hartman <[email protected]> Thu, 27 Oct 2005 22:48:04 -0700

drivers/input/keyboard/amikbd.c | 59 +++++------
drivers/input/keyboard/atkbd.c | 188 +++++++++++++++++++----------------
drivers/input/keyboard/corgikbd.c | 74 +++++++-------
drivers/input/keyboard/lkkbd.c | 126 ++++++++++++-----------
drivers/input/keyboard/maple_keyb.c | 76 ++++++--------
drivers/input/keyboard/newtonkbd.c | 83 +++++++--------
drivers/input/keyboard/spitzkbd.c | 77 ++++++++------
drivers/input/keyboard/sunkbd.c | 117 ++++++++++++----------
drivers/input/keyboard/xtkbd.c | 82 +++++++--------
9 files changed, 450 insertions(+), 432 deletions(-)

diff --git a/drivers/input/keyboard/amikbd.c b/drivers/input/keyboard/amikbd.c
index 4e8e8ea..3d63bc1 100644
--- a/drivers/input/keyboard/amikbd.c
+++ b/drivers/input/keyboard/amikbd.c
@@ -155,10 +155,7 @@ static const char *amikbd_messages[8] =
[7] = KERN_WARNING "amikbd: keyboard interrupt\n"
};

-static struct input_dev amikbd_dev;
-
-static char *amikbd_name = "Amiga keyboard";
-static char *amikbd_phys = "amikbd/input0";
+static struct input_dev *amikbd_dev;

static irqreturn_t amikbd_interrupt(int irq, void *dummy, struct pt_regs *fp)
{
@@ -176,16 +173,16 @@ static irqreturn_t amikbd_interrupt(int

scancode = amikbd_keycode[scancode];

- input_regs(&amikbd_dev, fp);
+ input_regs(amikbd_dev, fp);

if (scancode == KEY_CAPSLOCK) { /* CapsLock is a toggle switch key on Amiga */
- input_report_key(&amikbd_dev, scancode, 1);
- input_report_key(&amikbd_dev, scancode, 0);
- input_sync(&amikbd_dev);
+ input_report_key(amikbd_dev, scancode, 1);
+ input_report_key(amikbd_dev, scancode, 0);
} else {
- input_report_key(&amikbd_dev, scancode, down);
- input_sync(&amikbd_dev);
+ input_report_key(amikbd_dev, scancode, down);
}
+
+ input_sync(amikbd_dev);
} else /* scancodes >= 0x78 are error codes */
printk(amikbd_messages[scancode - 0x78]);

@@ -202,39 +199,41 @@ static int __init amikbd_init(void)
if (!request_mem_region(CIAA_PHYSADDR-1+0xb00, 0x100, "amikeyb"))
return -EBUSY;

- init_input_dev(&amikbd_dev);
-
- amikbd_dev.evbit[0] = BIT(EV_KEY) | BIT(EV_REP);
- amikbd_dev.keycode = amikbd_keycode;
- amikbd_dev.keycodesize = sizeof(unsigned char);
- amikbd_dev.keycodemax = ARRAY_SIZE(amikbd_keycode);
+ amikbd_dev = input_dev_allocate();
+ if (!amikbd_dev) {
+ printk(KERN_ERR "amikbd: not enough memory for input device\n");
+ release_mem_region(CIAA_PHYSADDR - 1 + 0xb00, 0x100);
+ return -ENOMEM;
+ }
+
+ amikbd_dev->name = "Amiga Keyboard";
+ amikbd_dev->phys = "amikbd/input0";
+ amikbd_dev->id.bustype = BUS_AMIGA;
+ amikbd_dev->id.vendor = 0x0001;
+ amikbd_dev->id.product = 0x0001;
+ amikbd_dev->id.version = 0x0100;
+
+ amikbd_dev->evbit[0] = BIT(EV_KEY) | BIT(EV_REP);
+ amikbd_dev->keycode = amikbd_keycode;
+ amikbd_dev->keycodesize = sizeof(unsigned char);
+ amikbd_dev->keycodemax = ARRAY_SIZE(amikbd_keycode);

for (i = 0; i < 0x78; i++)
if (amikbd_keycode[i])
- set_bit(amikbd_keycode[i], amikbd_dev.keybit);
+ set_bit(amikbd_keycode[i], amikbd_dev->keybit);

ciaa.cra &= ~0x41; /* serial data in, turn off TA */
request_irq(IRQ_AMIGA_CIAA_SP, amikbd_interrupt, 0, "amikbd", amikbd_interrupt);

- amikbd_dev.name = amikbd_name;
- amikbd_dev.phys = amikbd_phys;
- amikbd_dev.id.bustype = BUS_AMIGA;
- amikbd_dev.id.vendor = 0x0001;
- amikbd_dev.id.product = 0x0001;
- amikbd_dev.id.version = 0x0100;
-
- input_register_device(&amikbd_dev);
-
- printk(KERN_INFO "input: %s\n", amikbd_name);
-
+ input_register_device(amikbd_dev);
return 0;
}

static void __exit amikbd_exit(void)
{
- input_unregister_device(&amikbd_dev);
free_irq(IRQ_AMIGA_CIAA_SP, amikbd_interrupt);
- release_mem_region(CIAA_PHYSADDR-1+0xb00, 0x100);
+ input_unregister_device(amikbd_dev);
+ release_mem_region(CIAA_PHYSADDR - 1 + 0xb00, 0x100);
}

module_init(amikbd_init);
diff --git a/drivers/input/keyboard/atkbd.c b/drivers/input/keyboard/atkbd.c
index 1ad8c2e..820c7fd 100644
--- a/drivers/input/keyboard/atkbd.c
+++ b/drivers/input/keyboard/atkbd.c
@@ -185,12 +185,12 @@ static struct {

struct atkbd {

- struct ps2dev ps2dev;
+ struct ps2dev ps2dev;
+ struct input_dev *dev;

/* Written only during init */
char name[64];
char phys[32];
- struct input_dev dev;

unsigned short id;
unsigned char keycode[512];
@@ -290,7 +290,7 @@ static irqreturn_t atkbd_interrupt(struc
if (!atkbd->enabled)
goto out;

- input_event(&atkbd->dev, EV_MSC, MSC_RAW, code);
+ input_event(atkbd->dev, EV_MSC, MSC_RAW, code);

if (atkbd->translated) {

@@ -326,10 +326,10 @@ static irqreturn_t atkbd_interrupt(struc
atkbd->release = 1;
goto out;
case ATKBD_RET_HANGUEL:
- atkbd_report_key(&atkbd->dev, regs, KEY_HANGUEL, 3);
+ atkbd_report_key(atkbd->dev, regs, KEY_HANGUEL, 3);
goto out;
case ATKBD_RET_HANJA:
- atkbd_report_key(&atkbd->dev, regs, KEY_HANJA, 3);
+ atkbd_report_key(atkbd->dev, regs, KEY_HANJA, 3);
goto out;
case ATKBD_RET_ERR:
printk(KERN_DEBUG "atkbd.c: Keyboard on %s reports too many keys pressed.\n", serio->phys);
@@ -345,7 +345,7 @@ static irqreturn_t atkbd_interrupt(struc
}

if (atkbd->keycode[code] != ATKBD_KEY_NULL)
- input_event(&atkbd->dev, EV_MSC, MSC_SCAN, code);
+ input_event(atkbd->dev, EV_MSC, MSC_SCAN, code);

switch (atkbd->keycode[code]) {
case ATKBD_KEY_NULL:
@@ -365,7 +365,7 @@ static irqreturn_t atkbd_interrupt(struc
"to make it known.\n",
code & 0x80 ? "e0" : "", code & 0x7f);
}
- input_sync(&atkbd->dev);
+ input_sync(atkbd->dev);
break;
case ATKBD_SCR_1:
scroll = 1 - atkbd->release * 2;
@@ -390,7 +390,7 @@ static irqreturn_t atkbd_interrupt(struc
break;
default:
value = atkbd->release ? 0 :
- (1 + (!atkbd->softrepeat && test_bit(atkbd->keycode[code], atkbd->dev.key)));
+ (1 + (!atkbd->softrepeat && test_bit(atkbd->keycode[code], atkbd->dev->key)));

switch (value) { /* Workaround Toshiba laptop multiple keypress */
case 0:
@@ -398,7 +398,7 @@ static irqreturn_t atkbd_interrupt(struc
break;
case 1:
atkbd->last = code;
- atkbd->time = jiffies + msecs_to_jiffies(atkbd->dev.rep[REP_DELAY]) / 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)
@@ -406,16 +406,16 @@ static irqreturn_t atkbd_interrupt(struc
break;
}

- atkbd_report_key(&atkbd->dev, regs, atkbd->keycode[code], value);
+ atkbd_report_key(atkbd->dev, regs, atkbd->keycode[code], value);
}

if (atkbd->scroll) {
- input_regs(&atkbd->dev, regs);
+ input_regs(atkbd->dev, regs);
if (click != -1)
- input_report_key(&atkbd->dev, BTN_MIDDLE, click);
- input_report_rel(&atkbd->dev, REL_WHEEL, scroll);
- input_report_rel(&atkbd->dev, REL_HWHEEL, hscroll);
- input_sync(&atkbd->dev);
+ input_report_key(atkbd->dev, BTN_MIDDLE, click);
+ input_report_rel(atkbd->dev, REL_WHEEL, scroll);
+ input_report_rel(atkbd->dev, REL_HWHEEL, hscroll);
+ input_sync(atkbd->dev);
}

atkbd->release = 0;
@@ -463,7 +463,6 @@ static int atkbd_event(struct input_dev

return 0;

-
case EV_REP:

if (atkbd->softrepeat) return 0;
@@ -693,7 +692,7 @@ static void atkbd_disconnect(struct seri
device_remove_file(&serio->dev, &atkbd_attr_softrepeat);
device_remove_file(&serio->dev, &atkbd_attr_softraw);

- input_unregister_device(&atkbd->dev);
+ input_unregister_device(atkbd->dev);
serio_close(serio);
serio_set_drvdata(serio, NULL);
kfree(atkbd);
@@ -701,7 +700,7 @@ static void atkbd_disconnect(struct seri


/*
- * atkbd_set_device_attrs() initializes keyboard's keycode table
+ * atkbd_set_keycode_table() initializes keyboard's keycode table
* according to the selected scancode set
*/

@@ -737,53 +736,58 @@ static void atkbd_set_keycode_table(stru

static void atkbd_set_device_attrs(struct atkbd *atkbd)
{
+ struct input_dev *input_dev = atkbd->dev;
int i;

- memset(&atkbd->dev, 0, sizeof(struct input_dev));
+ if (atkbd->extra)
+ sprintf(atkbd->name, "AT Set 2 Extra keyboard");
+ else
+ sprintf(atkbd->name, "AT %s Set %d keyboard",
+ atkbd->translated ? "Translated" : "Raw", atkbd->set);

- init_input_dev(&atkbd->dev);
+ sprintf(atkbd->phys, "%s/input0", atkbd->ps2dev.serio->phys);

- atkbd->dev.name = atkbd->name;
- atkbd->dev.phys = atkbd->phys;
- atkbd->dev.id.bustype = BUS_I8042;
- atkbd->dev.id.vendor = 0x0001;
- atkbd->dev.id.product = atkbd->translated ? 1 : atkbd->set;
- atkbd->dev.id.version = atkbd->id;
- atkbd->dev.event = atkbd_event;
- atkbd->dev.private = atkbd;
- atkbd->dev.dev = &atkbd->ps2dev.serio->dev;
+ input_dev->name = atkbd->name;
+ input_dev->phys = atkbd->phys;
+ input_dev->id.bustype = BUS_I8042;
+ input_dev->id.vendor = 0x0001;
+ input_dev->id.product = atkbd->translated ? 1 : atkbd->set;
+ input_dev->id.version = atkbd->id;
+ input_dev->event = atkbd_event;
+ input_dev->private = atkbd;
+ input_dev->cdev.dev = &atkbd->ps2dev.serio->dev;

- atkbd->dev.evbit[0] = BIT(EV_KEY) | BIT(EV_REP) | BIT(EV_MSC);
+ input_dev->evbit[0] = BIT(EV_KEY) | BIT(EV_REP) | BIT(EV_MSC);

if (atkbd->write) {
- atkbd->dev.evbit[0] |= BIT(EV_LED);
- atkbd->dev.ledbit[0] = BIT(LED_NUML) | BIT(LED_CAPSL) | BIT(LED_SCROLLL);
+ input_dev->evbit[0] |= BIT(EV_LED);
+ input_dev->ledbit[0] = BIT(LED_NUML) | BIT(LED_CAPSL) | BIT(LED_SCROLLL);
}

if (atkbd->extra)
- atkbd->dev.ledbit[0] |= BIT(LED_COMPOSE) | BIT(LED_SUSPEND) |
+ input_dev->ledbit[0] |= BIT(LED_COMPOSE) | BIT(LED_SUSPEND) |
BIT(LED_SLEEP) | BIT(LED_MUTE) | BIT(LED_MISC);

if (!atkbd->softrepeat) {
- atkbd->dev.rep[REP_DELAY] = 250;
- atkbd->dev.rep[REP_PERIOD] = 33;
+ input_dev->rep[REP_DELAY] = 250;
+ input_dev->rep[REP_PERIOD] = 33;
}

- atkbd->dev.mscbit[0] = atkbd->softraw ? BIT(MSC_SCAN) : BIT(MSC_RAW) | BIT(MSC_SCAN);
+ input_dev->mscbit[0] = atkbd->softraw ? BIT(MSC_SCAN) : BIT(MSC_RAW) | BIT(MSC_SCAN);

if (atkbd->scroll) {
- atkbd->dev.evbit[0] |= BIT(EV_REL);
- atkbd->dev.relbit[0] = BIT(REL_WHEEL) | BIT(REL_HWHEEL);
- set_bit(BTN_MIDDLE, atkbd->dev.keybit);
+ input_dev->evbit[0] |= BIT(EV_REL);
+ input_dev->relbit[0] = BIT(REL_WHEEL) | BIT(REL_HWHEEL);
+ set_bit(BTN_MIDDLE, input_dev->keybit);
}

- atkbd->dev.keycode = atkbd->keycode;
- atkbd->dev.keycodesize = sizeof(unsigned char);
- atkbd->dev.keycodemax = ARRAY_SIZE(atkbd_set2_keycode);
+ input_dev->keycode = atkbd->keycode;
+ input_dev->keycodesize = sizeof(unsigned char);
+ input_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);
+ set_bit(atkbd->keycode[i], input_dev->keybit);
}

/*
@@ -796,13 +800,15 @@ static void atkbd_set_device_attrs(struc
static int atkbd_connect(struct serio *serio, struct serio_driver *drv)
{
struct atkbd *atkbd;
- int err;
-
- if (!(atkbd = kmalloc(sizeof(struct atkbd), GFP_KERNEL)))
- return - ENOMEM;
+ struct input_dev *dev;
+ int err = -ENOMEM;

- memset(atkbd, 0, sizeof(struct atkbd));
+ atkbd = kzalloc(sizeof(struct atkbd), GFP_KERNEL);
+ dev = input_allocate_device();
+ if (!atkbd || !dev)
+ goto fail;

+ atkbd->dev = dev;
ps2_init(&atkbd->ps2dev, serio);

switch (serio->id.type) {
@@ -828,19 +834,15 @@ static int atkbd_connect(struct serio *s
serio_set_drvdata(serio, atkbd);

err = serio_open(serio, drv);
- if (err) {
- serio_set_drvdata(serio, NULL);
- kfree(atkbd);
- return err;
- }
+ if (err)
+ goto fail;

if (atkbd->write) {

if (atkbd_probe(atkbd)) {
serio_close(serio);
- serio_set_drvdata(serio, NULL);
- kfree(atkbd);
- return -ENODEV;
+ err = -ENODEV;
+ goto fail;
}

atkbd->set = atkbd_select_set(atkbd, atkbd_set, atkbd_extra);
@@ -851,19 +853,9 @@ static int atkbd_connect(struct serio *s
atkbd->id = 0xab00;
}

- if (atkbd->extra)
- sprintf(atkbd->name, "AT Set 2 Extra keyboard");
- else
- sprintf(atkbd->name, "AT %s Set %d keyboard",
- atkbd->translated ? "Translated" : "Raw", atkbd->set);
-
- sprintf(atkbd->phys, "%s/input0", serio->phys);
-
atkbd_set_keycode_table(atkbd);
atkbd_set_device_attrs(atkbd);

- input_register_device(&atkbd->dev);
-
device_create_file(&serio->dev, &atkbd_attr_extra);
device_create_file(&serio->dev, &atkbd_attr_scroll);
device_create_file(&serio->dev, &atkbd_attr_set);
@@ -872,9 +864,14 @@ static int atkbd_connect(struct serio *s

atkbd_enable(atkbd);

- printk(KERN_INFO "input: %s on %s\n", atkbd->name, serio->phys);
+ input_register_device(atkbd->dev);

return 0;
+
+ fail: serio_set_drvdata(serio, NULL);
+ input_free_device(dev);
+ kfree(atkbd);
+ return err;
}

/*
@@ -896,9 +893,9 @@ static int atkbd_reconnect(struct serio
atkbd_disable(atkbd);

if (atkbd->write) {
- param[0] = (test_bit(LED_SCROLLL, atkbd->dev.led) ? 1 : 0)
- | (test_bit(LED_NUML, atkbd->dev.led) ? 2 : 0)
- | (test_bit(LED_CAPSL, atkbd->dev.led) ? 4 : 0);
+ param[0] = (test_bit(LED_SCROLLL, atkbd->dev->led) ? 1 : 0)
+ | (test_bit(LED_NUML, atkbd->dev->led) ? 2 : 0)
+ | (test_bit(LED_CAPSL, atkbd->dev->led) ? 4 : 0);

if (atkbd_probe(atkbd))
return -1;
@@ -1008,6 +1005,7 @@ static ssize_t atkbd_show_extra(struct a

static ssize_t atkbd_set_extra(struct atkbd *atkbd, const char *buf, size_t count)
{
+ struct input_dev *new_dev;
unsigned long value;
char *rest;

@@ -1019,12 +1017,19 @@ static ssize_t atkbd_set_extra(struct at
return -EINVAL;

if (atkbd->extra != value) {
- /* unregister device as it's properties will change */
- input_unregister_device(&atkbd->dev);
+ /*
+ * Since device's properties will change we need to
+ * unregister old device. But allocate new one first
+ * to make sure we have it.
+ */
+ if (!(new_dev = input_allocate_device()))
+ return -ENOMEM;
+ input_unregister_device(atkbd->dev);
+ atkbd->dev = new_dev;
atkbd->set = atkbd_select_set(atkbd, atkbd->set, value);
atkbd_activate(atkbd);
atkbd_set_device_attrs(atkbd);
- input_register_device(&atkbd->dev);
+ input_register_device(atkbd->dev);
}
return count;
}
@@ -1036,6 +1041,7 @@ static ssize_t atkbd_show_scroll(struct

static ssize_t atkbd_set_scroll(struct atkbd *atkbd, const char *buf, size_t count)
{
+ struct input_dev *new_dev;
unsigned long value;
char *rest;

@@ -1044,12 +1050,14 @@ static ssize_t atkbd_set_scroll(struct a
return -EINVAL;

if (atkbd->scroll != value) {
- /* unregister device as it's properties will change */
- input_unregister_device(&atkbd->dev);
+ if (!(new_dev = input_allocate_device()))
+ return -ENOMEM;
+ input_unregister_device(atkbd->dev);
+ atkbd->dev = new_dev;
atkbd->scroll = value;
atkbd_set_keycode_table(atkbd);
atkbd_set_device_attrs(atkbd);
- input_register_device(&atkbd->dev);
+ input_register_device(atkbd->dev);
}
return count;
}
@@ -1061,6 +1069,7 @@ static ssize_t atkbd_show_set(struct atk

static ssize_t atkbd_set_set(struct atkbd *atkbd, const char *buf, size_t count)
{
+ struct input_dev *new_dev;
unsigned long value;
char *rest;

@@ -1072,13 +1081,15 @@ static ssize_t atkbd_set_set(struct atkb
return -EINVAL;

if (atkbd->set != value) {
- /* unregister device as it's properties will change */
- input_unregister_device(&atkbd->dev);
+ if (!(new_dev = input_allocate_device()))
+ return -ENOMEM;
+ input_unregister_device(atkbd->dev);
+ atkbd->dev = new_dev;
atkbd->set = atkbd_select_set(atkbd, value, atkbd->extra);
atkbd_activate(atkbd);
atkbd_set_keycode_table(atkbd);
atkbd_set_device_attrs(atkbd);
- input_register_device(&atkbd->dev);
+ input_register_device(atkbd->dev);
}
return count;
}
@@ -1090,6 +1101,7 @@ static ssize_t atkbd_show_softrepeat(str

static ssize_t atkbd_set_softrepeat(struct atkbd *atkbd, const char *buf, size_t count)
{
+ struct input_dev *new_dev;
unsigned long value;
char *rest;

@@ -1101,15 +1113,16 @@ static ssize_t atkbd_set_softrepeat(stru
return -EINVAL;

if (atkbd->softrepeat != value) {
- /* unregister device as it's properties will change */
- input_unregister_device(&atkbd->dev);
+ if (!(new_dev = input_allocate_device()))
+ return -ENOMEM;
+ input_unregister_device(atkbd->dev);
+ atkbd->dev = new_dev;
atkbd->softrepeat = value;
if (atkbd->softrepeat)
atkbd->softraw = 1;
atkbd_set_device_attrs(atkbd);
- input_register_device(&atkbd->dev);
+ input_register_device(atkbd->dev);
}
-
return count;
}

@@ -1121,6 +1134,7 @@ static ssize_t atkbd_show_softraw(struct

static ssize_t atkbd_set_softraw(struct atkbd *atkbd, const char *buf, size_t count)
{
+ struct input_dev *new_dev;
unsigned long value;
char *rest;

@@ -1129,11 +1143,13 @@ static ssize_t atkbd_set_softraw(struct
return -EINVAL;

if (atkbd->softraw != value) {
- /* unregister device as it's properties will change */
- input_unregister_device(&atkbd->dev);
+ if (!(new_dev = input_allocate_device()))
+ return -ENOMEM;
+ input_unregister_device(atkbd->dev);
+ atkbd->dev = new_dev;
atkbd->softraw = value;
atkbd_set_device_attrs(atkbd);
- input_register_device(&atkbd->dev);
+ input_register_device(atkbd->dev);
}
return count;
}
diff --git a/drivers/input/keyboard/corgikbd.c b/drivers/input/keyboard/corgikbd.c
index cd4b6e7..564bb36 100644
--- a/drivers/input/keyboard/corgikbd.c
+++ b/drivers/input/keyboard/corgikbd.c
@@ -70,8 +70,7 @@ static unsigned char corgikbd_keycode[NR

struct corgikbd {
unsigned char keycode[ARRAY_SIZE(corgikbd_keycode)];
- struct input_dev input;
- char phys[32];
+ struct input_dev *input;

spinlock_t lock;
struct timer_list timer;
@@ -147,7 +146,7 @@ static void corgikbd_scankeyboard(struct
spin_lock_irqsave(&corgikbd_data->lock, flags);

if (regs)
- input_regs(&corgikbd_data->input, regs);
+ input_regs(corgikbd_data->input, regs);

num_pressed = 0;
for (col = 0; col < KB_COLS; col++) {
@@ -169,14 +168,14 @@ static void corgikbd_scankeyboard(struct
scancode = SCANCODE(row, col);
pressed = rowd & KB_ROWMASK(row);

- input_report_key(&corgikbd_data->input, corgikbd_data->keycode[scancode], pressed);
+ input_report_key(corgikbd_data->input, corgikbd_data->keycode[scancode], pressed);

if (pressed)
num_pressed++;

if (pressed && (corgikbd_data->keycode[scancode] == CORGI_KEY_OFF)
&& time_after(jiffies, corgikbd_data->suspend_jiffies + HZ)) {
- input_event(&corgikbd_data->input, EV_PWR, CORGI_KEY_OFF, 1);
+ input_event(corgikbd_data->input, EV_PWR, CORGI_KEY_OFF, 1);
corgikbd_data->suspend_jiffies=jiffies;
}
}
@@ -185,7 +184,7 @@ static void corgikbd_scankeyboard(struct

corgikbd_activate_all();

- input_sync(&corgikbd_data->input);
+ input_sync(corgikbd_data->input);

/* if any keys are pressed, enable the timer */
if (num_pressed)
@@ -249,9 +248,9 @@ static void corgikbd_hinge_timer(unsigne
if (hinge_count >= HINGE_STABLE_COUNT) {
spin_lock_irqsave(&corgikbd_data->lock, flags);

- input_report_switch(&corgikbd_data->input, SW_0, ((sharpsl_hinge_state & CORGI_SCP_SWA) != 0));
- input_report_switch(&corgikbd_data->input, SW_1, ((sharpsl_hinge_state & CORGI_SCP_SWB) != 0));
- input_sync(&corgikbd_data->input);
+ input_report_switch(corgikbd_data->input, SW_0, ((sharpsl_hinge_state & CORGI_SCP_SWA) != 0));
+ input_report_switch(corgikbd_data->input, SW_1, ((sharpsl_hinge_state & CORGI_SCP_SWB) != 0));
+ input_sync(corgikbd_data->input);

spin_unlock_irqrestore(&corgikbd_data->lock, flags);
}
@@ -287,16 +286,21 @@ static int corgikbd_resume(struct device

static int __init corgikbd_probe(struct device *dev)
{
- int i;
struct corgikbd *corgikbd;
+ struct input_dev *input_dev;
+ int i;

corgikbd = kzalloc(sizeof(struct corgikbd), GFP_KERNEL);
- if (!corgikbd)
+ input_dev = input_allocate_device();
+ if (!corgikbd || !input_dev) {
+ kfree(corgikbd);
+ input_free_device(input_dev);
return -ENOMEM;
+ }

- dev_set_drvdata(dev,corgikbd);
- strcpy(corgikbd->phys, "corgikbd/input0");
+ dev_set_drvdata(dev, corgikbd);

+ corgikbd->input = input_dev;
spin_lock_init(&corgikbd->lock);

/* Init Keyboard rescan timer */
@@ -311,28 +315,30 @@ static int __init corgikbd_probe(struct

corgikbd->suspend_jiffies=jiffies;

- init_input_dev(&corgikbd->input);
- corgikbd->input.private = corgikbd;
- corgikbd->input.name = "Corgi Keyboard";
- corgikbd->input.dev = dev;
- corgikbd->input.phys = corgikbd->phys;
- corgikbd->input.id.bustype = BUS_HOST;
- corgikbd->input.id.vendor = 0x0001;
- corgikbd->input.id.product = 0x0001;
- corgikbd->input.id.version = 0x0100;
- corgikbd->input.evbit[0] = BIT(EV_KEY) | BIT(EV_REP) | BIT(EV_PWR) | BIT(EV_SW);
- corgikbd->input.keycode = corgikbd->keycode;
- corgikbd->input.keycodesize = sizeof(unsigned char);
- corgikbd->input.keycodemax = ARRAY_SIZE(corgikbd_keycode);
-
memcpy(corgikbd->keycode, corgikbd_keycode, sizeof(corgikbd->keycode));
+
+ input_dev->name = "Corgi Keyboard";
+ input_dev->phys = "corgikbd/input0";
+ input_dev->id.bustype = BUS_HOST;
+ input_dev->id.vendor = 0x0001;
+ input_dev->id.product = 0x0001;
+ input_dev->id.version = 0x0100;
+ input_dev->cdev.dev = dev;
+ input_dev->private = corgikbd;
+
+ input_dev->evbit[0] = BIT(EV_KEY) | BIT(EV_REP) | BIT(EV_PWR) | BIT(EV_SW);
+ input_dev->keycode = corgikbd->keycode;
+ input_dev->keycodesize = sizeof(unsigned char);
+ input_dev->keycodemax = ARRAY_SIZE(corgikbd_keycode);
+
for (i = 0; i < ARRAY_SIZE(corgikbd_keycode); i++)
- set_bit(corgikbd->keycode[i], corgikbd->input.keybit);
- clear_bit(0, corgikbd->input.keybit);
- set_bit(SW_0, corgikbd->input.swbit);
- set_bit(SW_1, corgikbd->input.swbit);
+ set_bit(corgikbd->keycode[i], input_dev->keybit);
+ clear_bit(0, input_dev->keybit);
+ set_bit(SW_0, input_dev->swbit);
+ set_bit(SW_1, input_dev->swbit);
+
+ input_register_device(corgikbd->input);

- input_register_device(&corgikbd->input);
mod_timer(&corgikbd->htimer, jiffies + HINGE_SCAN_INTERVAL);

/* Setup sense interrupts - RisingEdge Detect, sense lines as inputs */
@@ -349,8 +355,6 @@ static int __init corgikbd_probe(struct
for (i = 0; i < CORGI_KEY_STROBE_NUM; i++)
pxa_gpio_mode(CORGI_GPIO_KEY_STROBE(i) | GPIO_OUT | GPIO_DFLT_HIGH);

- printk(KERN_INFO "input: Corgi Keyboard Registered\n");
-
return 0;
}

@@ -365,7 +369,7 @@ static int corgikbd_remove(struct device
del_timer_sync(&corgikbd->htimer);
del_timer_sync(&corgikbd->timer);

- input_unregister_device(&corgikbd->input);
+ input_unregister_device(corgikbd->input);

kfree(corgikbd);

diff --git a/drivers/input/keyboard/lkkbd.c b/drivers/input/keyboard/lkkbd.c
index 098963c..7f06780 100644
--- a/drivers/input/keyboard/lkkbd.c
+++ b/drivers/input/keyboard/lkkbd.c
@@ -102,7 +102,7 @@ static int ctrlclick_volume = 100; /* %
module_param (ctrlclick_volume, int, 0);
MODULE_PARM_DESC (ctrlclick_volume, "Ctrlclick volume (in %), default is 100%");

-static int lk201_compose_is_alt = 0;
+static int lk201_compose_is_alt;
module_param (lk201_compose_is_alt, int, 0);
MODULE_PARM_DESC (lk201_compose_is_alt, "If set non-zero, LK201' Compose key "
"will act as an Alt key");
@@ -274,7 +274,7 @@ static lk_keycode_t lkkbd_keycode[LK_NUM
};

#define CHECK_LED(LED, BITS) do { \
- if (test_bit (LED, lk->dev.led)) \
+ if (test_bit (LED, lk->dev->led)) \
leds_on |= BITS; \
else \
leds_off |= BITS; \
@@ -287,7 +287,7 @@ struct lkkbd {
lk_keycode_t keycode[LK_NUM_KEYCODES];
int ignore_bytes;
unsigned char id[LK_NUM_IGNORE_BYTES];
- struct input_dev dev;
+ struct input_dev *dev;
struct serio *serio;
struct work_struct tq;
char name[64];
@@ -423,8 +423,7 @@ lkkbd_interrupt (struct serio *serio, un
DBG (KERN_INFO "Got byte 0x%02x\n", data);

if (lk->ignore_bytes > 0) {
- DBG (KERN_INFO "Ignoring a byte on %s\n",
- lk->name);
+ DBG (KERN_INFO "Ignoring a byte on %s\n", lk->name);
lk->id[LK_NUM_IGNORE_BYTES - lk->ignore_bytes--] = data;

if (lk->ignore_bytes == 0)
@@ -435,14 +434,14 @@ lkkbd_interrupt (struct serio *serio, un

switch (data) {
case LK_ALL_KEYS_UP:
- input_regs (&lk->dev, regs);
+ input_regs (lk->dev, regs);
for (i = 0; i < ARRAY_SIZE (lkkbd_keycode); i++)
if (lk->keycode[i] != KEY_RESERVED)
- input_report_key (&lk->dev, lk->keycode[i], 0);
- input_sync (&lk->dev);
+ input_report_key (lk->dev, lk->keycode[i], 0);
+ input_sync (lk->dev);
break;
case LK_METRONOME:
- DBG (KERN_INFO "Got LK_METRONOME and don't "
+ DBG (KERN_INFO "Got %#d and don't "
"know how to handle...\n");
break;
case LK_OUTPUT_ERROR:
@@ -482,12 +481,12 @@ lkkbd_interrupt (struct serio *serio, un

default:
if (lk->keycode[data] != KEY_RESERVED) {
- input_regs (&lk->dev, regs);
- if (!test_bit (lk->keycode[data], lk->dev.key))
- input_report_key (&lk->dev, lk->keycode[data], 1);
+ input_regs (lk->dev, regs);
+ if (!test_bit (lk->keycode[data], lk->dev->key))
+ input_report_key (lk->dev, lk->keycode[data], 1);
else
- input_report_key (&lk->dev, lk->keycode[data], 0);
- input_sync (&lk->dev);
+ input_report_key (lk->dev, lk->keycode[data], 0);
+ input_sync (lk->dev);
} else
printk (KERN_WARNING "%s: Unknown key with "
"scancode 0x%02x on %s.\n",
@@ -605,7 +604,7 @@ lkkbd_reinit (void *data)
lk->serio->write (lk->serio, volume_to_hw (lk->bell_volume));

/* Enable/disable keyclick (and possibly set volume) */
- if (test_bit (SND_CLICK, lk->dev.snd)) {
+ if (test_bit (SND_CLICK, lk->dev->snd)) {
lk->serio->write (lk->serio, LK_CMD_ENABLE_KEYCLICK);
lk->serio->write (lk->serio, volume_to_hw (lk->keyclick_volume));
lk->serio->write (lk->serio, LK_CMD_ENABLE_CTRCLICK);
@@ -616,7 +615,7 @@ lkkbd_reinit (void *data)
}

/* Sound the bell if needed */
- if (test_bit (SND_BELL, lk->dev.snd))
+ if (test_bit (SND_BELL, lk->dev->snd))
lk->serio->write (lk->serio, LK_CMD_SOUND_BELL);
}

@@ -627,71 +626,70 @@ static int
lkkbd_connect (struct serio *serio, struct serio_driver *drv)
{
struct lkkbd *lk;
+ struct input_dev *input_dev;
int i;
int err;

- if (!(lk = kmalloc (sizeof (struct lkkbd), GFP_KERNEL)))
- return -ENOMEM;
-
- memset (lk, 0, sizeof (struct lkkbd));
-
- init_input_dev (&lk->dev);
- set_bit (EV_KEY, lk->dev.evbit);
- set_bit (EV_LED, lk->dev.evbit);
- set_bit (EV_SND, lk->dev.evbit);
- set_bit (EV_REP, lk->dev.evbit);
- set_bit (LED_CAPSL, lk->dev.ledbit);
- set_bit (LED_SLEEP, lk->dev.ledbit);
- set_bit (LED_COMPOSE, lk->dev.ledbit);
- set_bit (LED_SCROLLL, lk->dev.ledbit);
- set_bit (SND_BELL, lk->dev.sndbit);
- set_bit (SND_CLICK, lk->dev.sndbit);
+ lk = kzalloc (sizeof (struct lkkbd), GFP_KERNEL);
+ input_dev = input_allocate_device ();
+ if (!lk || !input_dev) {
+ err = -ENOMEM;
+ goto fail;
+ }

lk->serio = serio;
-
+ lk->dev = input_dev;
INIT_WORK (&lk->tq, lkkbd_reinit, lk);
-
lk->bell_volume = bell_volume;
lk->keyclick_volume = keyclick_volume;
lk->ctrlclick_volume = ctrlclick_volume;
+ memcpy (lk->keycode, lkkbd_keycode, sizeof (lk_keycode_t) * LK_NUM_KEYCODES);

- lk->dev.keycode = lk->keycode;
- lk->dev.keycodesize = sizeof (lk_keycode_t);
- lk->dev.keycodemax = LK_NUM_KEYCODES;
+ strlcpy (lk->name, "DEC LK keyboard", sizeof(lk->name));
+ snprintf (lk->phys, sizeof(lk->phys), "%s/input0", serio->phys);

- lk->dev.event = lkkbd_event;
- lk->dev.private = lk;
+ input_dev->name = lk->name;
+ input_dev->phys = lk->phys;
+ input_dev->id.bustype = BUS_RS232;
+ input_dev->id.vendor = SERIO_LKKBD;
+ input_dev->id.product = 0;
+ input_dev->id.version = 0x0100;
+ input_dev->cdev.dev = &serio->dev;
+ input_dev->event = lkkbd_event;
+ input_dev->private = lk;
+
+ set_bit (EV_KEY, input_dev->evbit);
+ set_bit (EV_LED, input_dev->evbit);
+ set_bit (EV_SND, input_dev->evbit);
+ set_bit (EV_REP, input_dev->evbit);
+ set_bit (LED_CAPSL, input_dev->ledbit);
+ set_bit (LED_SLEEP, input_dev->ledbit);
+ set_bit (LED_COMPOSE, input_dev->ledbit);
+ set_bit (LED_SCROLLL, input_dev->ledbit);
+ set_bit (SND_BELL, input_dev->sndbit);
+ set_bit (SND_CLICK, input_dev->sndbit);
+
+ input_dev->keycode = lk->keycode;
+ input_dev->keycodesize = sizeof (lk_keycode_t);
+ input_dev->keycodemax = LK_NUM_KEYCODES;
+ for (i = 0; i < LK_NUM_KEYCODES; i++)
+ set_bit (lk->keycode[i], input_dev->keybit);

serio_set_drvdata (serio, lk);

err = serio_open (serio, drv);
- if (err) {
- serio_set_drvdata (serio, NULL);
- kfree (lk);
- return err;
- }
+ if (err)
+ goto fail;

- sprintf (lk->name, "DEC LK keyboard");
- sprintf (lk->phys, "%s/input0", serio->phys);
-
- memcpy (lk->keycode, lkkbd_keycode, sizeof (lk_keycode_t) * LK_NUM_KEYCODES);
- for (i = 0; i < LK_NUM_KEYCODES; i++)
- set_bit (lk->keycode[i], lk->dev.keybit);
-
- lk->dev.name = lk->name;
- lk->dev.phys = lk->phys;
- lk->dev.id.bustype = BUS_RS232;
- lk->dev.id.vendor = SERIO_LKKBD;
- lk->dev.id.product = 0;
- lk->dev.id.version = 0x0100;
- lk->dev.dev = &serio->dev;
-
- input_register_device (&lk->dev);
-
- printk (KERN_INFO "input: %s on %s, initiating reset\n", lk->name, serio->phys);
+ input_register_device (lk->dev);
lk->serio->write (lk->serio, LK_CMD_POWERCYCLE_RESET);

return 0;
+
+ fail: serio_set_drvdata (serio, NULL);
+ input_free_device (input_dev);
+ kfree (lk);
+ return err;
}

/*
@@ -702,9 +700,11 @@ lkkbd_disconnect (struct serio *serio)
{
struct lkkbd *lk = serio_get_drvdata (serio);

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

diff --git a/drivers/input/keyboard/maple_keyb.c b/drivers/input/keyboard/maple_keyb.c
index eecbde2..cc6aaf9 100644
--- a/drivers/input/keyboard/maple_keyb.c
+++ b/drivers/input/keyboard/maple_keyb.c
@@ -37,7 +37,7 @@ static unsigned char dc_kbd_keycode[256]


struct dc_kbd {
- struct input_dev dev;
+ struct input_dev *dev;
unsigned char new[8];
unsigned char old[8];
};
@@ -46,30 +46,24 @@ struct dc_kbd {
static void dc_scan_kbd(struct dc_kbd *kbd)
{
int i;
- struct input_dev *dev = &kbd->dev;
+ struct input_dev *dev = kbd->dev;

- for(i=0; i<8; i++)
- input_report_key(dev,
- dc_kbd_keycode[i+224],
- (kbd->new[0]>>i)&1);
-
- for(i=2; i<8; i++) {
-
- if(kbd->old[i]>3&&memscan(kbd->new+2, kbd->old[i], 6)==NULL) {
- if(dc_kbd_keycode[kbd->old[i]])
- input_report_key(dev,
- dc_kbd_keycode[kbd->old[i]],
- 0);
+ for (i = 0; i < 8; i++)
+ input_report_key(dev, dc_kbd_keycode[i + 224], (kbd->new[0] >> i) & 1);
+
+ for (i = 2; i < 8; i++) {
+
+ if (kbd->old[i] > 3 && memscan(kbd->new + 2, kbd->old[i], 6) == NULL) {
+ if (dc_kbd_keycode[kbd->old[i]])
+ input_report_key(dev, dc_kbd_keycode[kbd->old[i]], 0);
else
printk("Unknown key (scancode %#x) released.",
kbd->old[i]);
}

- if(kbd->new[i]>3&&memscan(kbd->old+2, kbd->new[i], 6)!=NULL) {
+ if (kbd->new[i] > 3 && memscan(kbd->old + 2, kbd->new[i], 6) != NULL) {
if(dc_kbd_keycode[kbd->new[i]])
- input_report_key(dev,
- dc_kbd_keycode[kbd->new[i]],
- 1);
+ input_report_key(dev, dc_kbd_keycode[kbd->new[i]], 1);
else
printk("Unknown key (scancode %#x) pressed.",
kbd->new[i]);
@@ -89,43 +83,39 @@ static void dc_kbd_callback(struct maple
unsigned long *buf = mq->recvbuf;

if (buf[1] == mapledev->function) {
- memcpy(kbd->new, buf+2, 8);
+ memcpy(kbd->new, buf + 2, 8);
dc_scan_kbd(kbd);
}
}

static int dc_kbd_connect(struct maple_device *dev)
{
- int i;
- unsigned long data = be32_to_cpu(dev->devinfo.function_data[0]);
struct dc_kbd *kbd;
+ struct input_dev *input_dev;
+ unsigned long data = be32_to_cpu(dev->devinfo.function_data[0]);
+ int i;

- if (!(kbd = kmalloc(sizeof(struct dc_kbd), GFP_KERNEL)))
- return -1;
- memset(kbd, 0, sizeof(struct dc_kbd));
-
- dev->private_data = kbd;
-
- kbd->dev.evbit[0] = BIT(EV_KEY) | BIT(EV_REP);
-
- init_input_dev(&kbd->dev);
-
- for (i=0; i<255; i++)
- set_bit(dc_kbd_keycode[i], kbd->dev.keybit);
-
- clear_bit(0, kbd->dev.keybit);
+ dev->private_data = kbd = kzalloc(sizeof(struct dc_kbd), GFP_KERNEL);
+ input_dev = input_allocate_device();
+ if (!kbd || !input_dev) {
+ kfree(kbd);
+ input_free_device(input_dev);
+ return -ENOMEM;
+ }

- kbd->dev.private = kbd;
+ kbd->dev = input_dev;

- kbd->dev.name = dev->product_name;
- kbd->dev.id.bustype = BUS_MAPLE;
+ input_dev->name = dev->product_name;
+ input_dev->id.bustype = BUS_MAPLE;
+ input_dev->private = kbd;
+ input_dev->evbit[0] = BIT(EV_KEY) | BIT(EV_REP);
+ for (i = 0; i < 255; i++)
+ set_bit(dc_kbd_keycode[i], input_dev->keybit);
+ clear_bit(0, input_dev->keybit);

- input_register_device(&kbd->dev);
+ input_register_device(kbd->dev);

maple_getcond_callback(dev, dc_kbd_callback, 1, MAPLE_FUNC_KEYBOARD);
-
- printk(KERN_INFO "input: keyboard(0x%lx): %s\n", data, kbd->dev.name);
-
return 0;
}

@@ -134,7 +124,7 @@ static void dc_kbd_disconnect(struct map
{
struct dc_kbd *kbd = dev->private_data;

- input_unregister_device(&kbd->dev);
+ input_unregister_device(kbd->dev);
kfree(kbd);
}

diff --git a/drivers/input/keyboard/newtonkbd.c b/drivers/input/keyboard/newtonkbd.c
index 2e8ce16..d10983c 100644
--- a/drivers/input/keyboard/newtonkbd.c
+++ b/drivers/input/keyboard/newtonkbd.c
@@ -57,11 +57,9 @@ static unsigned char nkbd_keycode[128] =
KEY_LEFT, KEY_RIGHT, KEY_DOWN, KEY_UP, 0
};

-static char *nkbd_name = "Newton Keyboard";
-
struct nkbd {
unsigned char keycode[128];
- struct input_dev dev;
+ struct input_dev *dev;
struct serio *serio;
char phys[32];
};
@@ -73,13 +71,13 @@ static irqreturn_t nkbd_interrupt(struct

/* invalid scan codes are probably the init sequence, so we ignore them */
if (nkbd->keycode[data & NKBD_KEY]) {
- input_regs(&nkbd->dev, regs);
- input_report_key(&nkbd->dev, nkbd->keycode[data & NKBD_KEY], data & NKBD_PRESS);
- input_sync(&nkbd->dev);
+ input_regs(nkbd->dev, regs);
+ input_report_key(nkbd->dev, nkbd->keycode[data & NKBD_KEY], data & NKBD_PRESS);
+ input_sync(nkbd->dev);
}

else if (data == 0xe7) /* end of init sequence */
- printk(KERN_INFO "input: %s on %s\n", nkbd_name, serio->phys);
+ printk(KERN_INFO "input: %s on %s\n", nkbd->dev->name, serio->phys);
return IRQ_HANDLED;

}
@@ -87,62 +85,59 @@ static irqreturn_t nkbd_interrupt(struct
static int nkbd_connect(struct serio *serio, struct serio_driver *drv)
{
struct nkbd *nkbd;
+ struct input_dev *input_dev;
+ int err = -ENOMEM;
int i;
- int err;
-
- if (!(nkbd = kmalloc(sizeof(struct nkbd), GFP_KERNEL)))
- return -ENOMEM;
-
- memset(nkbd, 0, sizeof(struct nkbd));

- nkbd->dev.evbit[0] = BIT(EV_KEY) | BIT(EV_REP);
+ nkbd = kzalloc(sizeof(struct nkbd), GFP_KERNEL);
+ input_dev = input_allocate_device();
+ if (!nkbd || !input_dev)
+ goto fail;

nkbd->serio = serio;
+ nkbd->dev = input_dev;
+ sprintf(nkbd->phys, "%s/input0", serio->phys);
+ memcpy(nkbd->keycode, nkbd_keycode, sizeof(nkbd->keycode));

- init_input_dev(&nkbd->dev);
- nkbd->dev.keycode = nkbd->keycode;
- nkbd->dev.keycodesize = sizeof(unsigned char);
- nkbd->dev.keycodemax = ARRAY_SIZE(nkbd_keycode);
- nkbd->dev.private = nkbd;
+ input_dev->name = "Newton Keyboard";
+ input_dev->phys = nkbd->phys;
+ input_dev->id.bustype = BUS_RS232;
+ input_dev->id.vendor = SERIO_NEWTON;
+ input_dev->id.product = 0x0001;
+ input_dev->id.version = 0x0100;
+ input_dev->cdev.dev = &serio->dev;
+ input_dev->private = nkbd;
+
+ input_dev->evbit[0] = BIT(EV_KEY) | BIT(EV_REP);
+ input_dev->keycode = nkbd->keycode;
+ input_dev->keycodesize = sizeof(unsigned char);
+ input_dev->keycodemax = ARRAY_SIZE(nkbd_keycode);
+ for (i = 0; i < 128; i++)
+ set_bit(nkbd->keycode[i], input_dev->keybit);
+ clear_bit(0, input_dev->keybit);

serio_set_drvdata(serio, nkbd);

err = serio_open(serio, drv);
- if (err) {
- serio_set_drvdata(serio, NULL);
- kfree(nkbd);
- return err;
- }
-
- memcpy(nkbd->keycode, nkbd_keycode, sizeof(nkbd->keycode));
- for (i = 0; i < 128; i++)
- set_bit(nkbd->keycode[i], nkbd->dev.keybit);
- clear_bit(0, nkbd->dev.keybit);
-
- sprintf(nkbd->phys, "%s/input0", serio->phys);
-
- nkbd->dev.name = nkbd_name;
- nkbd->dev.phys = nkbd->phys;
- nkbd->dev.id.bustype = BUS_RS232;
- nkbd->dev.id.vendor = SERIO_NEWTON;
- nkbd->dev.id.product = 0x0001;
- nkbd->dev.id.version = 0x0100;
- nkbd->dev.dev = &serio->dev;
-
- input_register_device(&nkbd->dev);
-
- printk(KERN_INFO "input: %s on %s\n", nkbd_name, serio->phys);
+ if (err)
+ goto fail;

+ input_register_device(nkbd->dev);
return 0;
+
+ fail: serio_set_drvdata(serio, NULL);
+ input_free_device(input_dev);
+ kfree(nkbd);
+ return err;
}

static void nkbd_disconnect(struct serio *serio)
{
struct nkbd *nkbd = serio_get_drvdata(serio);

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

diff --git a/drivers/input/keyboard/spitzkbd.c b/drivers/input/keyboard/spitzkbd.c
index 344f460..732fb31 100644
--- a/drivers/input/keyboard/spitzkbd.c
+++ b/drivers/input/keyboard/spitzkbd.c
@@ -85,7 +85,7 @@ static int spitz_senses[] = {

struct spitzkbd {
unsigned char keycode[ARRAY_SIZE(spitzkbd_keycode)];
- struct input_dev input;
+ struct input_dev *input;
char phys[32];

spinlock_t lock;
@@ -187,8 +187,7 @@ static void spitzkbd_scankeyboard(struct

spin_lock_irqsave(&spitzkbd_data->lock, flags);

- if (regs)
- input_regs(&spitzkbd_data->input, regs);
+ input_regs(spitzkbd_data->input, regs);

num_pressed = 0;
for (col = 0; col < KB_COLS; col++) {
@@ -210,7 +209,7 @@ static void spitzkbd_scankeyboard(struct
scancode = SCANCODE(row, col);
pressed = rowd & KB_ROWMASK(row);

- input_report_key(&spitzkbd_data->input, spitzkbd_data->keycode[scancode], pressed);
+ input_report_key(spitzkbd_data->input, spitzkbd_data->keycode[scancode], pressed);

if (pressed)
num_pressed++;
@@ -220,15 +219,15 @@ static void spitzkbd_scankeyboard(struct

spitzkbd_activate_all();

- input_report_key(&spitzkbd_data->input, SPITZ_KEY_SYNC, (GPLR(SPITZ_GPIO_SYNC) & GPIO_bit(SPITZ_GPIO_SYNC)) != 0 );
- input_report_key(&spitzkbd_data->input, KEY_SUSPEND, pwrkey);
+ input_report_key(spitzkbd_data->input, SPITZ_KEY_SYNC, (GPLR(SPITZ_GPIO_SYNC) & GPIO_bit(SPITZ_GPIO_SYNC)) != 0 );
+ input_report_key(spitzkbd_data->input, KEY_SUSPEND, pwrkey);

if (pwrkey && time_after(jiffies, spitzkbd_data->suspend_jiffies + msecs_to_jiffies(1000))) {
- input_event(&spitzkbd_data->input, EV_PWR, KEY_SUSPEND, 1);
+ input_event(spitzkbd_data->input, EV_PWR, KEY_SUSPEND, 1);
spitzkbd_data->suspend_jiffies = jiffies;
}

- input_sync(&spitzkbd_data->input);
+ input_sync(spitzkbd_data->input);

/* if any keys are pressed, enable the timer */
if (num_pressed)
@@ -259,6 +258,7 @@ static irqreturn_t spitzkbd_interrupt(in
static void spitzkbd_timer_callback(unsigned long data)
{
struct spitzkbd *spitzkbd_data = (struct spitzkbd *) data;
+
spitzkbd_scankeyboard(spitzkbd_data, NULL);
}

@@ -298,9 +298,9 @@ static void spitzkbd_hinge_timer(unsigne
if (hinge_count >= HINGE_STABLE_COUNT) {
spin_lock_irqsave(&spitzkbd_data->lock, flags);

- input_report_switch(&spitzkbd_data->input, SW_0, ((GPLR(SPITZ_GPIO_SWA) & GPIO_bit(SPITZ_GPIO_SWA)) != 0));
- input_report_switch(&spitzkbd_data->input, SW_1, ((GPLR(SPITZ_GPIO_SWB) & GPIO_bit(SPITZ_GPIO_SWB)) != 0));
- input_sync(&spitzkbd_data->input);
+ input_report_switch(spitzkbd_data->input, SW_0, ((GPLR(SPITZ_GPIO_SWA) & GPIO_bit(SPITZ_GPIO_SWA)) != 0));
+ input_report_switch(spitzkbd_data->input, SW_1, ((GPLR(SPITZ_GPIO_SWB) & GPIO_bit(SPITZ_GPIO_SWB)) != 0));
+ input_sync(spitzkbd_data->input);

spin_unlock_irqrestore(&spitzkbd_data->lock, flags);
} else {
@@ -346,14 +346,21 @@ static int spitzkbd_resume(struct device

static int __init spitzkbd_probe(struct device *dev)
{
- int i;
struct spitzkbd *spitzkbd;
+ struct input_dev *input_dev;
+ int i;

spitzkbd = kzalloc(sizeof(struct spitzkbd), GFP_KERNEL);
if (!spitzkbd)
return -ENOMEM;

- dev_set_drvdata(dev,spitzkbd);
+ input_dev = input_allocate_device();
+ if (!input_dev) {
+ kfree(spitzkbd);
+ return -ENOMEM;
+ }
+
+ dev_set_drvdata(dev, spitzkbd);
strcpy(spitzkbd->phys, "spitzkbd/input0");

spin_lock_init(&spitzkbd->lock);
@@ -368,30 +375,34 @@ static int __init spitzkbd_probe(struct
spitzkbd->htimer.function = spitzkbd_hinge_timer;
spitzkbd->htimer.data = (unsigned long) spitzkbd;

- spitzkbd->suspend_jiffies=jiffies;
+ spitzkbd->suspend_jiffies = jiffies;

- init_input_dev(&spitzkbd->input);
- spitzkbd->input.private = spitzkbd;
- spitzkbd->input.name = "Spitz Keyboard";
- spitzkbd->input.dev = dev;
- spitzkbd->input.phys = spitzkbd->phys;
- spitzkbd->input.id.bustype = BUS_HOST;
- spitzkbd->input.id.vendor = 0x0001;
- spitzkbd->input.id.product = 0x0001;
- spitzkbd->input.id.version = 0x0100;
- spitzkbd->input.evbit[0] = BIT(EV_KEY) | BIT(EV_REP) | BIT(EV_PWR) | BIT(EV_SW);
- spitzkbd->input.keycode = spitzkbd->keycode;
- spitzkbd->input.keycodesize = sizeof(unsigned char);
- spitzkbd->input.keycodemax = ARRAY_SIZE(spitzkbd_keycode);
+ spitzkbd->input = input_dev;
+
+ input_dev->private = spitzkbd;
+ input_dev->name = "Spitz Keyboard";
+ input_dev->phys = spitzkbd->phys;
+ input_dev->cdev.dev = dev;
+
+ input_dev->id.bustype = BUS_HOST;
+ input_dev->id.vendor = 0x0001;
+ input_dev->id.product = 0x0001;
+ input_dev->id.version = 0x0100;
+
+ input_dev->evbit[0] = BIT(EV_KEY) | BIT(EV_REP) | BIT(EV_PWR) | BIT(EV_SW);
+ input_dev->keycode = spitzkbd->keycode;
+ input_dev->keycodesize = sizeof(unsigned char);
+ input_dev->keycodemax = ARRAY_SIZE(spitzkbd_keycode);

memcpy(spitzkbd->keycode, spitzkbd_keycode, sizeof(spitzkbd->keycode));
for (i = 0; i < ARRAY_SIZE(spitzkbd_keycode); i++)
- set_bit(spitzkbd->keycode[i], spitzkbd->input.keybit);
- clear_bit(0, spitzkbd->input.keybit);
- set_bit(SW_0, spitzkbd->input.swbit);
- set_bit(SW_1, spitzkbd->input.swbit);
+ set_bit(spitzkbd->keycode[i], input_dev->keybit);
+ clear_bit(0, input_dev->keybit);
+ set_bit(SW_0, input_dev->swbit);
+ set_bit(SW_1, input_dev->swbit);
+
+ input_register_device(input_dev);

- input_register_device(&spitzkbd->input);
mod_timer(&spitzkbd->htimer, jiffies + msecs_to_jiffies(HINGE_SCAN_INTERVAL));

/* Setup sense interrupts - RisingEdge Detect, sense lines as inputs */
@@ -444,7 +455,7 @@ static int spitzkbd_remove(struct device
del_timer_sync(&spitzkbd->htimer);
del_timer_sync(&spitzkbd->timer);

- input_unregister_device(&spitzkbd->input);
+ input_unregister_device(spitzkbd->input);

kfree(spitzkbd);

diff --git a/drivers/input/keyboard/sunkbd.c b/drivers/input/keyboard/sunkbd.c
index 4bae5d8..b15b6d8 100644
--- a/drivers/input/keyboard/sunkbd.c
+++ b/drivers/input/keyboard/sunkbd.c
@@ -76,13 +76,14 @@ static unsigned char sunkbd_keycode[128]

struct sunkbd {
unsigned char keycode[128];
- struct input_dev dev;
+ struct input_dev *dev;
struct serio *serio;
struct work_struct tq;
wait_queue_head_t wait;
char name[64];
char phys[32];
char type;
+ unsigned char enabled;
volatile s8 reset;
volatile s8 layout;
};
@@ -124,10 +125,13 @@ static irqreturn_t sunkbd_interrupt(stru
break;

default:
+ if (!sunkbd->enabled)
+ break;
+
if (sunkbd->keycode[data & SUNKBD_KEY]) {
- input_regs(&sunkbd->dev, regs);
- input_report_key(&sunkbd->dev, sunkbd->keycode[data & SUNKBD_KEY], !(data & SUNKBD_RELEASE));
- input_sync(&sunkbd->dev);
+ input_regs(sunkbd->dev, regs);
+ input_report_key(sunkbd->dev, sunkbd->keycode[data & SUNKBD_KEY], !(data & SUNKBD_RELEASE));
+ input_sync(sunkbd->dev);
} else {
printk(KERN_WARNING "sunkbd.c: Unknown key (scancode %#x) %s.\n",
data & SUNKBD_KEY, data & SUNKBD_RELEASE ? "released" : "pressed");
@@ -184,7 +188,7 @@ static int sunkbd_initialize(struct sunk
sunkbd->reset = -2;
sunkbd->serio->write(sunkbd->serio, SUNKBD_CMD_RESET);
wait_event_interruptible_timeout(sunkbd->wait, sunkbd->reset >= 0, HZ);
- if (sunkbd->reset <0)
+ if (sunkbd->reset < 0)
return -1;

sunkbd->type = sunkbd->reset;
@@ -213,10 +217,17 @@ static void sunkbd_reinit(void *data)

sunkbd->serio->write(sunkbd->serio, SUNKBD_CMD_SETLED);
sunkbd->serio->write(sunkbd->serio,
- (!!test_bit(LED_CAPSL, sunkbd->dev.led) << 3) | (!!test_bit(LED_SCROLLL, sunkbd->dev.led) << 2) |
- (!!test_bit(LED_COMPOSE, sunkbd->dev.led) << 1) | !!test_bit(LED_NUML, sunkbd->dev.led));
- sunkbd->serio->write(sunkbd->serio, SUNKBD_CMD_NOCLICK - !!test_bit(SND_CLICK, sunkbd->dev.snd));
- sunkbd->serio->write(sunkbd->serio, SUNKBD_CMD_BELLOFF - !!test_bit(SND_BELL, sunkbd->dev.snd));
+ (!!test_bit(LED_CAPSL, sunkbd->dev->led) << 3) | (!!test_bit(LED_SCROLLL, sunkbd->dev->led) << 2) |
+ (!!test_bit(LED_COMPOSE, sunkbd->dev->led) << 1) | !!test_bit(LED_NUML, sunkbd->dev->led));
+ sunkbd->serio->write(sunkbd->serio, SUNKBD_CMD_NOCLICK - !!test_bit(SND_CLICK, sunkbd->dev->snd));
+ sunkbd->serio->write(sunkbd->serio, SUNKBD_CMD_BELLOFF - !!test_bit(SND_BELL, sunkbd->dev->snd));
+}
+
+static void sunkbd_enable(struct sunkbd *sunkbd, int enable)
+{
+ serio_pause_rx(sunkbd->serio);
+ sunkbd->enabled = 1;
+ serio_continue_rx(sunkbd->serio);
}

/*
@@ -226,70 +237,64 @@ static void sunkbd_reinit(void *data)
static int sunkbd_connect(struct serio *serio, struct serio_driver *drv)
{
struct sunkbd *sunkbd;
+ struct input_dev *input_dev;
+ int err = -ENOMEM;
int i;
- int err;
-
- if (!(sunkbd = kmalloc(sizeof(struct sunkbd), GFP_KERNEL)))
- return -ENOMEM;

- memset(sunkbd, 0, sizeof(struct sunkbd));
-
- init_input_dev(&sunkbd->dev);
- init_waitqueue_head(&sunkbd->wait);
-
- sunkbd->dev.evbit[0] = BIT(EV_KEY) | BIT(EV_LED) | BIT(EV_SND) | BIT(EV_REP);
- sunkbd->dev.ledbit[0] = BIT(LED_CAPSL) | BIT(LED_COMPOSE) | BIT(LED_SCROLLL) | BIT(LED_NUML);
- sunkbd->dev.sndbit[0] = BIT(SND_CLICK) | BIT(SND_BELL);
+ sunkbd = kzalloc(sizeof(struct sunkbd), GFP_KERNEL);
+ input_dev = input_allocate_device();
+ if (!sunkbd || !input_dev)
+ goto fail;

sunkbd->serio = serio;
-
+ sunkbd->dev = input_dev;
+ init_waitqueue_head(&sunkbd->wait);
INIT_WORK(&sunkbd->tq, sunkbd_reinit, sunkbd);
-
- sunkbd->dev.keycode = sunkbd->keycode;
- sunkbd->dev.keycodesize = sizeof(unsigned char);
- sunkbd->dev.keycodemax = ARRAY_SIZE(sunkbd_keycode);
-
- sunkbd->dev.event = sunkbd_event;
- sunkbd->dev.private = sunkbd;
+ snprintf(sunkbd->phys, sizeof(sunkbd->phys), "%s/input0", serio->phys);

serio_set_drvdata(serio, sunkbd);

err = serio_open(serio, drv);
- if (err) {
- serio_set_drvdata(serio, NULL);
- kfree(sunkbd);
- return err;
- }
+ if (err)
+ goto fail;

if (sunkbd_initialize(sunkbd) < 0) {
serio_close(serio);
- serio_set_drvdata(serio, NULL);
- kfree(sunkbd);
- return -ENODEV;
+ goto fail;
}

sprintf(sunkbd->name, "Sun Type %d keyboard", sunkbd->type);
-
memcpy(sunkbd->keycode, sunkbd_keycode, sizeof(sunkbd->keycode));
- for (i = 0; i < 128; i++)
- set_bit(sunkbd->keycode[i], sunkbd->dev.keybit);
- clear_bit(0, sunkbd->dev.keybit);
-
- sprintf(sunkbd->phys, "%s/input0", serio->phys);
-
- sunkbd->dev.name = sunkbd->name;
- sunkbd->dev.phys = sunkbd->phys;
- sunkbd->dev.id.bustype = BUS_RS232;
- sunkbd->dev.id.vendor = SERIO_SUNKBD;
- sunkbd->dev.id.product = sunkbd->type;
- sunkbd->dev.id.version = 0x0100;
- sunkbd->dev.dev = &serio->dev;

- input_register_device(&sunkbd->dev);
-
- printk(KERN_INFO "input: %s on %s\n", sunkbd->name, serio->phys);
+ input_dev->name = sunkbd->name;
+ input_dev->phys = sunkbd->phys;
+ input_dev->id.bustype = BUS_RS232;
+ input_dev->id.vendor = SERIO_SUNKBD;
+ input_dev->id.product = sunkbd->type;
+ input_dev->id.version = 0x0100;
+ input_dev->cdev.dev = &serio->dev;
+ input_dev->private = sunkbd;
+ input_dev->event = sunkbd_event;
+
+ input_dev->evbit[0] = BIT(EV_KEY) | BIT(EV_LED) | BIT(EV_SND) | BIT(EV_REP);
+ input_dev->ledbit[0] = BIT(LED_CAPSL) | BIT(LED_COMPOSE) | BIT(LED_SCROLLL) | BIT(LED_NUML);
+ input_dev->sndbit[0] = BIT(SND_CLICK) | BIT(SND_BELL);
+
+ input_dev->keycode = sunkbd->keycode;
+ input_dev->keycodesize = sizeof(unsigned char);
+ input_dev->keycodemax = ARRAY_SIZE(sunkbd_keycode);
+ for (i = 0; i < 128; i++)
+ set_bit(sunkbd->keycode[i], input_dev->keybit);
+ clear_bit(0, input_dev->keybit);

+ sunkbd_enable(sunkbd, 1);
+ input_register_device(sunkbd->dev);
return 0;
+
+ fail: serio_set_drvdata(serio, NULL);
+ input_free_device(input_dev);
+ kfree(sunkbd);
+ return err;
}

/*
@@ -299,7 +304,9 @@ static int sunkbd_connect(struct serio *
static void sunkbd_disconnect(struct serio *serio)
{
struct sunkbd *sunkbd = serio_get_drvdata(serio);
- input_unregister_device(&sunkbd->dev);
+
+ sunkbd_enable(sunkbd, 0);
+ input_unregister_device(sunkbd->dev);
serio_close(serio);
serio_set_drvdata(serio, NULL);
kfree(sunkbd);
diff --git a/drivers/input/keyboard/xtkbd.c b/drivers/input/keyboard/xtkbd.c
index 19eaec7..4135e3e 100644
--- a/drivers/input/keyboard/xtkbd.c
+++ b/drivers/input/keyboard/xtkbd.c
@@ -56,11 +56,9 @@ static unsigned char xtkbd_keycode[256]
106
};

-static char *xtkbd_name = "XT Keyboard";
-
struct xtkbd {
unsigned char keycode[256];
- struct input_dev dev;
+ struct input_dev *dev;
struct serio *serio;
char phys[32];
};
@@ -77,9 +75,9 @@ static irqreturn_t xtkbd_interrupt(struc
default:

if (xtkbd->keycode[data & XTKBD_KEY]) {
- input_regs(&xtkbd->dev, regs);
- input_report_key(&xtkbd->dev, xtkbd->keycode[data & XTKBD_KEY], !(data & XTKBD_RELEASE));
- input_sync(&xtkbd->dev);
+ input_regs(xtkbd->dev, regs);
+ input_report_key(xtkbd->dev, xtkbd->keycode[data & XTKBD_KEY], !(data & XTKBD_RELEASE));
+ input_sync(xtkbd->dev);
} else {
printk(KERN_WARNING "xtkbd.c: Unknown key (scancode %#x) %s.\n",
data & XTKBD_KEY, data & XTKBD_RELEASE ? "released" : "pressed");
@@ -91,62 +89,60 @@ static irqreturn_t xtkbd_interrupt(struc
static int xtkbd_connect(struct serio *serio, struct serio_driver *drv)
{
struct xtkbd *xtkbd;
+ struct input_dev *input_dev;
+ int err = -ENOMEM;
int i;
- int err;
-
- if (!(xtkbd = kmalloc(sizeof(struct xtkbd), GFP_KERNEL)))
- return -ENOMEM;
-
- memset(xtkbd, 0, sizeof(struct xtkbd));

- xtkbd->dev.evbit[0] = BIT(EV_KEY) | BIT(EV_REP);
+ xtkbd = kmalloc(sizeof(struct xtkbd), GFP_KERNEL);
+ input_dev = input_allocate_device();
+ if (!xtkbd || !input_dev)
+ goto fail;

xtkbd->serio = serio;
-
- init_input_dev(&xtkbd->dev);
- xtkbd->dev.keycode = xtkbd->keycode;
- xtkbd->dev.keycodesize = sizeof(unsigned char);
- xtkbd->dev.keycodemax = ARRAY_SIZE(xtkbd_keycode);
- xtkbd->dev.private = xtkbd;
-
- serio_set_drvdata(serio, xtkbd);
-
- err = serio_open(serio, drv);
- if (err) {
- serio_set_drvdata(serio, NULL);
- kfree(xtkbd);
- return err;
- }
-
+ xtkbd->dev = input_dev;
+ sprintf(xtkbd->phys, "%s/input0", serio->phys);
memcpy(xtkbd->keycode, xtkbd_keycode, sizeof(xtkbd->keycode));
- for (i = 0; i < 255; i++)
- set_bit(xtkbd->keycode[i], xtkbd->dev.keybit);
- clear_bit(0, xtkbd->dev.keybit);

- sprintf(xtkbd->phys, "%s/input0", serio->phys);
+ input_dev->name = "XT Keyboard";
+ input_dev->phys = xtkbd->phys;
+ input_dev->id.bustype = BUS_XTKBD;
+ input_dev->id.vendor = 0x0001;
+ input_dev->id.product = 0x0001;
+ input_dev->id.version = 0x0100;
+ input_dev->cdev.dev = &serio->dev;
+ input_dev->private = xtkbd;
+
+ input_dev->evbit[0] = BIT(EV_KEY) | BIT(EV_REP);
+ input_dev->keycode = xtkbd->keycode;
+ input_dev->keycodesize = sizeof(unsigned char);
+ input_dev->keycodemax = ARRAY_SIZE(xtkbd_keycode);

- xtkbd->dev.name = xtkbd_name;
- xtkbd->dev.phys = xtkbd->phys;
- xtkbd->dev.id.bustype = BUS_XTKBD;
- xtkbd->dev.id.vendor = 0x0001;
- xtkbd->dev.id.product = 0x0001;
- xtkbd->dev.id.version = 0x0100;
- xtkbd->dev.dev = &serio->dev;
+ for (i = 0; i < 255; i++)
+ set_bit(xtkbd->keycode[i], input_dev->keybit);
+ clear_bit(0, input_dev->keybit);

- input_register_device(&xtkbd->dev);
+ serio_set_drvdata(serio, xtkbd);

- printk(KERN_INFO "input: %s on %s\n", xtkbd_name, serio->phys);
+ err = serio_open(serio, drv);
+ if (err)
+ goto fail;

+ input_register_device(xtkbd->dev);
return 0;
+
+ fail: serio_set_drvdata(serio, NULL);
+ input_free_device(input_dev);
+ kfree(xtkbd);
+ return err;
}

static void xtkbd_disconnect(struct serio *serio)
{
struct xtkbd *xtkbd = serio_get_drvdata(serio);

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


2005-10-28 06:39:51

by Greg KH

[permalink] [raw]
Subject: [PATCH] drivers/input/mouse: convert to dynamic input_dev allocation

[PATCH] drivers/input/mouse: convert to dynamic input_dev allocation

Input: convert drivers/input/mouse to dynamic input_dev allocation

This is required for input_dev sysfs integration

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

---
commit f18c31d676d42b4f75f1520733f4b5b2c966524d
tree 9e16a56703102547b10c664ef155099c0dad9e2d
parent 4086434e3a16b83e0cc651b5519f911dfa010cc7
author Dmitry Torokhov <[email protected]> Thu, 15 Sep 2005 02:01:44 -0500
committer Greg Kroah-Hartman <[email protected]> Thu, 27 Oct 2005 22:48:03 -0700

drivers/input/mouse/alps.c | 67 +++++++++++++-----------
drivers/input/mouse/alps.h | 2 -
drivers/input/mouse/amimouse.c | 51 +++++++++----------
drivers/input/mouse/inport.c | 96 ++++++++++++++++++-----------------
drivers/input/mouse/lifebook.c | 16 +++---
drivers/input/mouse/logibm.c | 88 ++++++++++++++++----------------
drivers/input/mouse/logips2pp.c | 20 ++++---
drivers/input/mouse/maplemouse.c | 10 +---
drivers/input/mouse/pc110pad.c | 70 ++++++++++++-------------
drivers/input/mouse/psmouse-base.c | 99 +++++++++++++++++++-----------------
drivers/input/mouse/psmouse.h | 2 -
drivers/input/mouse/rpcmouse.c | 43 ++++++++--------
drivers/input/mouse/sermouse.c | 84 +++++++++++++++----------------
drivers/input/mouse/synaptics.c | 6 +-
drivers/input/mouse/vsxxxaa.c | 84 +++++++++++++++----------------
15 files changed, 370 insertions(+), 368 deletions(-)

diff --git a/drivers/input/mouse/alps.c b/drivers/input/mouse/alps.c
index b20783f..4acc7fd 100644
--- a/drivers/input/mouse/alps.c
+++ b/drivers/input/mouse/alps.c
@@ -79,8 +79,8 @@ static void alps_process_packet(struct p
{
struct alps_data *priv = psmouse->private;
unsigned char *packet = psmouse->packet;
- struct input_dev *dev = &psmouse->dev;
- struct input_dev *dev2 = &priv->dev2;
+ struct input_dev *dev = psmouse->dev;
+ struct input_dev *dev2 = priv->dev2;
int x, y, z, ges, fin, left, right, middle;
int back = 0, forward = 0;

@@ -379,20 +379,24 @@ static int alps_reconnect(struct psmouse
static void alps_disconnect(struct psmouse *psmouse)
{
struct alps_data *priv = psmouse->private;
+
psmouse_reset(psmouse);
- input_unregister_device(&priv->dev2);
+ input_unregister_device(priv->dev2);
kfree(priv);
}

int alps_init(struct psmouse *psmouse)
{
struct alps_data *priv;
+ struct input_dev *dev1 = psmouse->dev, *dev2;
int version;

- psmouse->private = priv = kmalloc(sizeof(struct alps_data), GFP_KERNEL);
- if (!priv)
+ psmouse->private = priv = kzalloc(sizeof(struct alps_data), GFP_KERNEL);
+ dev2 = input_allocate_device();
+ if (!priv || !dev2)
goto init_fail;
- memset(priv, 0, sizeof(struct alps_data));
+
+ priv->dev2 = dev2;

if (!(priv->i = alps_get_model(psmouse, &version)))
goto init_fail;
@@ -411,41 +415,39 @@ int alps_init(struct psmouse *psmouse)
if ((priv->i->flags & ALPS_PASS) && alps_passthrough_mode(psmouse, 0))
goto init_fail;

- psmouse->dev.evbit[LONG(EV_KEY)] |= BIT(EV_KEY);
- psmouse->dev.keybit[LONG(BTN_TOUCH)] |= BIT(BTN_TOUCH);
- psmouse->dev.keybit[LONG(BTN_TOOL_FINGER)] |= BIT(BTN_TOOL_FINGER);
- psmouse->dev.keybit[LONG(BTN_LEFT)] |= BIT(BTN_LEFT) | BIT(BTN_MIDDLE) | BIT(BTN_RIGHT);
-
- psmouse->dev.evbit[LONG(EV_ABS)] |= BIT(EV_ABS);
- input_set_abs_params(&psmouse->dev, ABS_X, 0, 1023, 0, 0);
- input_set_abs_params(&psmouse->dev, ABS_Y, 0, 767, 0, 0);
- input_set_abs_params(&psmouse->dev, ABS_PRESSURE, 0, 127, 0, 0);
+ dev1->evbit[LONG(EV_KEY)] |= BIT(EV_KEY);
+ dev1->keybit[LONG(BTN_TOUCH)] |= BIT(BTN_TOUCH);
+ dev1->keybit[LONG(BTN_TOOL_FINGER)] |= BIT(BTN_TOOL_FINGER);
+ dev1->keybit[LONG(BTN_LEFT)] |= BIT(BTN_LEFT) | BIT(BTN_MIDDLE) | BIT(BTN_RIGHT);
+
+ dev1->evbit[LONG(EV_ABS)] |= BIT(EV_ABS);
+ input_set_abs_params(dev1, ABS_X, 0, 1023, 0, 0);
+ input_set_abs_params(dev1, ABS_Y, 0, 767, 0, 0);
+ input_set_abs_params(dev1, ABS_PRESSURE, 0, 127, 0, 0);

if (priv->i->flags & ALPS_WHEEL) {
- psmouse->dev.evbit[LONG(EV_REL)] |= BIT(EV_REL);
- psmouse->dev.relbit[LONG(REL_WHEEL)] |= BIT(REL_WHEEL);
+ dev1->evbit[LONG(EV_REL)] |= BIT(EV_REL);
+ dev1->relbit[LONG(REL_WHEEL)] |= BIT(REL_WHEEL);
}

if (priv->i->flags & (ALPS_FW_BK_1 | ALPS_FW_BK_2)) {
- psmouse->dev.keybit[LONG(BTN_FORWARD)] |= BIT(BTN_FORWARD);
- psmouse->dev.keybit[LONG(BTN_BACK)] |= BIT(BTN_BACK);
+ dev1->keybit[LONG(BTN_FORWARD)] |= BIT(BTN_FORWARD);
+ dev1->keybit[LONG(BTN_BACK)] |= BIT(BTN_BACK);
}

sprintf(priv->phys, "%s/input1", psmouse->ps2dev.serio->phys);
- priv->dev2.phys = priv->phys;
- priv->dev2.name = (priv->i->flags & ALPS_DUALPOINT) ? "DualPoint Stick" : "PS/2 Mouse";
- priv->dev2.id.bustype = BUS_I8042;
- priv->dev2.id.vendor = 0x0002;
- priv->dev2.id.product = PSMOUSE_ALPS;
- priv->dev2.id.version = 0x0000;
-
- priv->dev2.evbit[0] = BIT(EV_KEY) | BIT(EV_REL);
- priv->dev2.relbit[LONG(REL_X)] |= BIT(REL_X) | BIT(REL_Y);
- priv->dev2.keybit[LONG(BTN_LEFT)] |= BIT(BTN_LEFT) | BIT(BTN_MIDDLE) | BIT(BTN_RIGHT);
-
- input_register_device(&priv->dev2);
+ dev2->phys = priv->phys;
+ dev2->name = (priv->i->flags & ALPS_DUALPOINT) ? "DualPoint Stick" : "PS/2 Mouse";
+ dev2->id.bustype = BUS_I8042;
+ dev2->id.vendor = 0x0002;
+ dev2->id.product = PSMOUSE_ALPS;
+ dev2->id.version = 0x0000;
+
+ dev2->evbit[0] = BIT(EV_KEY) | BIT(EV_REL);
+ dev2->relbit[LONG(REL_X)] |= BIT(REL_X) | BIT(REL_Y);
+ dev2->keybit[LONG(BTN_LEFT)] |= BIT(BTN_LEFT) | BIT(BTN_MIDDLE) | BIT(BTN_RIGHT);

- printk(KERN_INFO "input: %s on %s\n", priv->dev2.name, psmouse->ps2dev.serio->phys);
+ input_register_device(priv->dev2);

psmouse->protocol_handler = alps_process_byte;
psmouse->disconnect = alps_disconnect;
@@ -455,6 +457,7 @@ int alps_init(struct psmouse *psmouse)
return 0;

init_fail:
+ input_free_device(dev2);
kfree(priv);
return -1;
}
diff --git a/drivers/input/mouse/alps.h b/drivers/input/mouse/alps.h
index aba103d..e428f8d 100644
--- a/drivers/input/mouse/alps.h
+++ b/drivers/input/mouse/alps.h
@@ -22,7 +22,7 @@ struct alps_model_info {
};

struct alps_data {
- struct input_dev dev2; /* Relative device */
+ struct input_dev *dev2; /* Relative device */
char name[32]; /* Name */
char phys[32]; /* Phys */
struct alps_model_info *i; /* Info */
diff --git a/drivers/input/mouse/amimouse.c b/drivers/input/mouse/amimouse.c
index e994849..d13d4c8 100644
--- a/drivers/input/mouse/amimouse.c
+++ b/drivers/input/mouse/amimouse.c
@@ -34,10 +34,7 @@ MODULE_DESCRIPTION("Amiga mouse driver")
MODULE_LICENSE("GPL");

static int amimouse_lastx, amimouse_lasty;
-static struct input_dev amimouse_dev;
-
-static char *amimouse_name = "Amiga mouse";
-static char *amimouse_phys = "amimouse/input0";
+static struct input_dev *amimouse_dev;

static irqreturn_t amimouse_interrupt(int irq, void *dummy, struct pt_regs *fp)
{
@@ -62,16 +59,16 @@ static irqreturn_t amimouse_interrupt(in

potgor = custom.potgor;

- input_regs(&amimouse_dev, fp);
+ input_regs(amimouse_dev, fp);

- input_report_rel(&amimouse_dev, REL_X, dx);
- input_report_rel(&amimouse_dev, REL_Y, dy);
+ input_report_rel(amimouse_dev, REL_X, dx);
+ input_report_rel(amimouse_dev, REL_Y, dy);

- input_report_key(&amimouse_dev, BTN_LEFT, ciaa.pra & 0x40);
- input_report_key(&amimouse_dev, BTN_MIDDLE, potgor & 0x0100);
- input_report_key(&amimouse_dev, BTN_RIGHT, potgor & 0x0400);
+ input_report_key(amimouse_dev, BTN_LEFT, ciaa.pra & 0x40);
+ input_report_key(amimouse_dev, BTN_MIDDLE, potgor & 0x0100);
+ input_report_key(amimouse_dev, BTN_RIGHT, potgor & 0x0400);

- input_sync(&amimouse_dev);
+ input_sync(amimouse_dev);

return IRQ_HANDLED;
}
@@ -103,28 +100,30 @@ static int __init amimouse_init(void)
if (!MACH_IS_AMIGA || !AMIGAHW_PRESENT(AMI_MOUSE))
return -ENODEV;

- amimouse_dev.evbit[0] = BIT(EV_KEY) | BIT(EV_REL);
- amimouse_dev.relbit[0] = BIT(REL_X) | BIT(REL_Y);
- amimouse_dev.keybit[LONG(BTN_LEFT)] = BIT(BTN_LEFT) | BIT(BTN_MIDDLE) | BIT(BTN_RIGHT);
- amimouse_dev.open = amimouse_open;
- amimouse_dev.close = amimouse_close;
-
- amimouse_dev.name = amimouse_name;
- amimouse_dev.phys = amimouse_phys;
- amimouse_dev.id.bustype = BUS_AMIGA;
- amimouse_dev.id.vendor = 0x0001;
- amimouse_dev.id.product = 0x0002;
- amimouse_dev.id.version = 0x0100;
+ if (!(amimouse_dev = input_allocate_device()))
+ return -ENOMEM;
+
+ amimouse_dev->name = "Amiga mouse";
+ amimouse_dev->phys = "amimouse/input0";
+ amimouse_dev->id.bustype = BUS_AMIGA;
+ amimouse_dev->id.vendor = 0x0001;
+ amimouse_dev->id.product = 0x0002;
+ amimouse_dev->id.version = 0x0100;
+
+ amimouse_dev->evbit[0] = BIT(EV_KEY) | BIT(EV_REL);
+ amimouse_dev->relbit[0] = BIT(REL_X) | BIT(REL_Y);
+ amimouse_dev->keybit[LONG(BTN_LEFT)] = BIT(BTN_LEFT) | BIT(BTN_MIDDLE) | BIT(BTN_RIGHT);
+ amimouse_dev->open = amimouse_open;
+ amimouse_dev->close = amimouse_close;

- input_register_device(&amimouse_dev);
+ input_register_device(amimouse_dev);

- printk(KERN_INFO "input: %s at joy0dat\n", amimouse_name);
return 0;
}

static void __exit amimouse_exit(void)
{
- input_unregister_device(&amimouse_dev);
+ input_unregister_device(amimouse_dev);
}

module_init(amimouse_init);
diff --git a/drivers/input/mouse/inport.c b/drivers/input/mouse/inport.c
index 1f62c01..afc66f5 100644
--- a/drivers/input/mouse/inport.c
+++ b/drivers/input/mouse/inport.c
@@ -87,40 +87,7 @@ MODULE_PARM_DESC(irq, "IRQ number (5=def

__obsolete_setup("inport_irq=");

-static irqreturn_t inport_interrupt(int irq, void *dev_id, struct pt_regs *regs);
-
-static int inport_open(struct input_dev *dev)
-{
- if (request_irq(inport_irq, inport_interrupt, 0, "inport", NULL))
- return -EBUSY;
- outb(INPORT_REG_MODE, INPORT_CONTROL_PORT);
- outb(INPORT_MODE_IRQ | INPORT_MODE_BASE, INPORT_DATA_PORT);
-
- return 0;
-}
-
-static void inport_close(struct input_dev *dev)
-{
- outb(INPORT_REG_MODE, INPORT_CONTROL_PORT);
- outb(INPORT_MODE_BASE, INPORT_DATA_PORT);
- free_irq(inport_irq, NULL);
-}
-
-static struct input_dev inport_dev = {
- .evbit = { BIT(EV_KEY) | BIT(EV_REL) },
- .keybit = { [LONG(BTN_LEFT)] = BIT(BTN_LEFT) | BIT(BTN_MIDDLE) | BIT(BTN_RIGHT) },
- .relbit = { BIT(REL_X) | BIT(REL_Y) },
- .open = inport_open,
- .close = inport_close,
- .name = INPORT_NAME,
- .phys = "isa023c/input0",
- .id = {
- .bustype = BUS_ISA,
- .vendor = INPORT_VENDOR,
- .product = 0x0001,
- .version = 0x0100,
- },
-};
+static struct input_dev *inport_dev;

static irqreturn_t inport_interrupt(int irq, void *dev_id, struct pt_regs *regs)
{
@@ -129,31 +96,48 @@ static irqreturn_t inport_interrupt(int
outb(INPORT_REG_MODE, INPORT_CONTROL_PORT);
outb(INPORT_MODE_HOLD | INPORT_MODE_IRQ | INPORT_MODE_BASE, INPORT_DATA_PORT);

- input_regs(&inport_dev, regs);
+ input_regs(inport_dev, regs);

outb(INPORT_REG_X, INPORT_CONTROL_PORT);
- input_report_rel(&inport_dev, REL_X, inb(INPORT_DATA_PORT));
+ input_report_rel(inport_dev, REL_X, inb(INPORT_DATA_PORT));

outb(INPORT_REG_Y, INPORT_CONTROL_PORT);
- input_report_rel(&inport_dev, REL_Y, inb(INPORT_DATA_PORT));
+ input_report_rel(inport_dev, REL_Y, inb(INPORT_DATA_PORT));

outb(INPORT_REG_BTNS, INPORT_CONTROL_PORT);
buttons = inb(INPORT_DATA_PORT);

- input_report_key(&inport_dev, BTN_MIDDLE, buttons & 1);
- input_report_key(&inport_dev, BTN_LEFT, buttons & 2);
- input_report_key(&inport_dev, BTN_RIGHT, buttons & 4);
+ input_report_key(inport_dev, BTN_MIDDLE, buttons & 1);
+ input_report_key(inport_dev, BTN_LEFT, buttons & 2);
+ input_report_key(inport_dev, BTN_RIGHT, buttons & 4);

outb(INPORT_REG_MODE, INPORT_CONTROL_PORT);
outb(INPORT_MODE_IRQ | INPORT_MODE_BASE, INPORT_DATA_PORT);

- input_sync(&inport_dev);
+ input_sync(inport_dev);
return IRQ_HANDLED;
}

+static int inport_open(struct input_dev *dev)
+{
+ if (request_irq(inport_irq, inport_interrupt, 0, "inport", NULL))
+ return -EBUSY;
+ outb(INPORT_REG_MODE, INPORT_CONTROL_PORT);
+ outb(INPORT_MODE_IRQ | INPORT_MODE_BASE, INPORT_DATA_PORT);
+
+ return 0;
+}
+
+static void inport_close(struct input_dev *dev)
+{
+ outb(INPORT_REG_MODE, INPORT_CONTROL_PORT);
+ outb(INPORT_MODE_BASE, INPORT_DATA_PORT);
+ free_irq(inport_irq, NULL);
+}
+
static int __init inport_init(void)
{
- unsigned char a,b,c;
+ unsigned char a, b, c;

if (!request_region(INPORT_BASE, INPORT_EXTENT, "inport")) {
printk(KERN_ERR "inport.c: Can't allocate ports at %#x\n", INPORT_BASE);
@@ -163,26 +147,44 @@ static int __init inport_init(void)
a = inb(INPORT_SIGNATURE_PORT);
b = inb(INPORT_SIGNATURE_PORT);
c = inb(INPORT_SIGNATURE_PORT);
- if (( a == b ) || ( a != c )) {
+ if (a == b || a != c) {
release_region(INPORT_BASE, INPORT_EXTENT);
printk(KERN_ERR "inport.c: Didn't find InPort mouse at %#x\n", INPORT_BASE);
return -ENODEV;
}

+ if (!(inport_dev = input_allocate_device())) {
+ printk(KERN_ERR "inport.c: Not enough memory for input device\n");
+ release_region(INPORT_BASE, INPORT_EXTENT);
+ return -ENOMEM;
+ }
+
+ inport_dev->name = INPORT_NAME;
+ inport_dev->phys = "isa023c/input0";
+ inport_dev->id.bustype = BUS_ISA;
+ inport_dev->id.vendor = INPORT_VENDOR;
+ inport_dev->id.product = 0x0001;
+ inport_dev->id.version = 0x0100;
+
+ inport_dev->evbit[0] = BIT(EV_KEY) | BIT(EV_REL);
+ inport_dev->keybit[LONG(BTN_LEFT)] = BIT(BTN_LEFT) | BIT(BTN_MIDDLE) | BIT(BTN_RIGHT);
+ inport_dev->relbit[0] = BIT(REL_X) | BIT(REL_Y);
+
+ inport_dev->open = inport_open;
+ inport_dev->close = inport_close;
+
outb(INPORT_RESET, INPORT_CONTROL_PORT);
outb(INPORT_REG_MODE, INPORT_CONTROL_PORT);
outb(INPORT_MODE_BASE, INPORT_DATA_PORT);

- input_register_device(&inport_dev);
-
- printk(KERN_INFO "input: " INPORT_NAME " at %#x irq %d\n", INPORT_BASE, inport_irq);
+ input_register_device(inport_dev);

return 0;
}

static void __exit inport_exit(void)
{
- input_unregister_device(&inport_dev);
+ input_unregister_device(inport_dev);
release_region(INPORT_BASE, INPORT_EXTENT);
}

diff --git a/drivers/input/mouse/lifebook.c b/drivers/input/mouse/lifebook.c
index bd9df9b..5599142 100644
--- a/drivers/input/mouse/lifebook.c
+++ b/drivers/input/mouse/lifebook.c
@@ -34,7 +34,7 @@ static struct dmi_system_id lifebook_dmi
static psmouse_ret_t lifebook_process_byte(struct psmouse *psmouse, struct pt_regs *regs)
{
unsigned char *packet = psmouse->packet;
- struct input_dev *dev = &psmouse->dev;
+ struct input_dev *dev = psmouse->dev;

if (psmouse->pktcnt != 3)
return PSMOUSE_GOOD_DATA;
@@ -113,15 +113,17 @@ int lifebook_detect(struct psmouse *psmo

int lifebook_init(struct psmouse *psmouse)
{
+ struct input_dev *input_dev = psmouse->dev;
+
if (lifebook_absolute_mode(psmouse))
return -1;

- psmouse->dev.evbit[0] = BIT(EV_ABS) | BIT(EV_KEY) | BIT(EV_REL);
- psmouse->dev.keybit[LONG(BTN_LEFT)] = BIT(BTN_LEFT) | BIT(BTN_MIDDLE) | BIT(BTN_RIGHT);
- psmouse->dev.keybit[LONG(BTN_TOUCH)] = BIT(BTN_TOUCH);
- psmouse->dev.relbit[0] = BIT(REL_X) | BIT(REL_Y);
- input_set_abs_params(&psmouse->dev, ABS_X, 0, 1024, 0, 0);
- input_set_abs_params(&psmouse->dev, ABS_Y, 0, 1024, 0, 0);
+ input_dev->evbit[0] = BIT(EV_ABS) | BIT(EV_KEY) | BIT(EV_REL);
+ input_dev->keybit[LONG(BTN_LEFT)] = BIT(BTN_LEFT) | BIT(BTN_MIDDLE) | BIT(BTN_RIGHT);
+ input_dev->keybit[LONG(BTN_TOUCH)] = BIT(BTN_TOUCH);
+ input_dev->relbit[0] = BIT(REL_X) | BIT(REL_Y);
+ input_set_abs_params(input_dev, ABS_X, 0, 1024, 0, 0);
+ input_set_abs_params(input_dev, ABS_Y, 0, 1024, 0, 0);

psmouse->protocol_handler = lifebook_process_byte;
psmouse->set_resolution = lifebook_set_resolution;
diff --git a/drivers/input/mouse/logibm.c b/drivers/input/mouse/logibm.c
index 8b52431..9c7ce38 100644
--- a/drivers/input/mouse/logibm.c
+++ b/drivers/input/mouse/logibm.c
@@ -77,39 +77,7 @@ MODULE_PARM_DESC(irq, "IRQ number (5=def

__obsolete_setup("logibm_irq=");

-static irqreturn_t logibm_interrupt(int irq, void *dev_id, struct pt_regs *regs);
-
-static int logibm_open(struct input_dev *dev)
-{
- if (request_irq(logibm_irq, logibm_interrupt, 0, "logibm", NULL)) {
- printk(KERN_ERR "logibm.c: Can't allocate irq %d\n", logibm_irq);
- return -EBUSY;
- }
- outb(LOGIBM_ENABLE_IRQ, LOGIBM_CONTROL_PORT);
- return 0;
-}
-
-static void logibm_close(struct input_dev *dev)
-{
- outb(LOGIBM_DISABLE_IRQ, LOGIBM_CONTROL_PORT);
- free_irq(logibm_irq, NULL);
-}
-
-static struct input_dev logibm_dev = {
- .evbit = { BIT(EV_KEY) | BIT(EV_REL) },
- .keybit = { [LONG(BTN_LEFT)] = BIT(BTN_LEFT) | BIT(BTN_MIDDLE) | BIT(BTN_RIGHT) },
- .relbit = { BIT(REL_X) | BIT(REL_Y) },
- .open = logibm_open,
- .close = logibm_close,
- .name = "Logitech bus mouse",
- .phys = "isa023c/input0",
- .id = {
- .bustype = BUS_ISA,
- .vendor = 0x0003,
- .product = 0x0001,
- .version = 0x0100,
- },
-};
+static struct input_dev *logibm_dev;

static irqreturn_t logibm_interrupt(int irq, void *dev_id, struct pt_regs *regs)
{
@@ -127,18 +95,34 @@ static irqreturn_t logibm_interrupt(int
dy |= (buttons & 0xf) << 4;
buttons = ~buttons >> 5;

- input_regs(&logibm_dev, regs);
- input_report_rel(&logibm_dev, REL_X, dx);
- input_report_rel(&logibm_dev, REL_Y, dy);
- input_report_key(&logibm_dev, BTN_RIGHT, buttons & 1);
- input_report_key(&logibm_dev, BTN_MIDDLE, buttons & 2);
- input_report_key(&logibm_dev, BTN_LEFT, buttons & 4);
- input_sync(&logibm_dev);
+ input_regs(logibm_dev, regs);
+ input_report_rel(logibm_dev, REL_X, dx);
+ input_report_rel(logibm_dev, REL_Y, dy);
+ input_report_key(logibm_dev, BTN_RIGHT, buttons & 1);
+ input_report_key(logibm_dev, BTN_MIDDLE, buttons & 2);
+ input_report_key(logibm_dev, BTN_LEFT, buttons & 4);
+ input_sync(logibm_dev);

outb(LOGIBM_ENABLE_IRQ, LOGIBM_CONTROL_PORT);
return IRQ_HANDLED;
}

+static int logibm_open(struct input_dev *dev)
+{
+ if (request_irq(logibm_irq, logibm_interrupt, 0, "logibm", NULL)) {
+ printk(KERN_ERR "logibm.c: Can't allocate irq %d\n", logibm_irq);
+ return -EBUSY;
+ }
+ outb(LOGIBM_ENABLE_IRQ, LOGIBM_CONTROL_PORT);
+ return 0;
+}
+
+static void logibm_close(struct input_dev *dev)
+{
+ outb(LOGIBM_DISABLE_IRQ, LOGIBM_CONTROL_PORT);
+ free_irq(logibm_irq, NULL);
+}
+
static int __init logibm_init(void)
{
if (!request_region(LOGIBM_BASE, LOGIBM_EXTENT, "logibm")) {
@@ -159,16 +143,34 @@ static int __init logibm_init(void)
outb(LOGIBM_DEFAULT_MODE, LOGIBM_CONFIG_PORT);
outb(LOGIBM_DISABLE_IRQ, LOGIBM_CONTROL_PORT);

- input_register_device(&logibm_dev);
+ if (!(logibm_dev = input_allocate_device())) {
+ printk(KERN_ERR "logibm.c: Not enough memory for input device\n");
+ release_region(LOGIBM_BASE, LOGIBM_EXTENT);
+ return -ENOMEM;
+ }
+
+ logibm_dev->name = "Logitech bus mouse";
+ logibm_dev->phys = "isa023c/input0";
+ logibm_dev->id.bustype = BUS_ISA;
+ logibm_dev->id.vendor = 0x0003;
+ logibm_dev->id.product = 0x0001;
+ logibm_dev->id.version = 0x0100;
+
+ logibm_dev->evbit[0] = BIT(EV_KEY) | BIT(EV_REL);
+ logibm_dev->keybit[LONG(BTN_LEFT)] = BIT(BTN_LEFT) | BIT(BTN_MIDDLE) | BIT(BTN_RIGHT);
+ logibm_dev->relbit[0] = BIT(REL_X) | BIT(REL_Y);
+
+ logibm_dev->open = logibm_open;
+ logibm_dev->close = logibm_close;

- printk(KERN_INFO "input: Logitech bus mouse at %#x irq %d\n", LOGIBM_BASE, logibm_irq);
+ input_register_device(logibm_dev);

return 0;
}

static void __exit logibm_exit(void)
{
- input_unregister_device(&logibm_dev);
+ input_unregister_device(logibm_dev);
release_region(LOGIBM_BASE, LOGIBM_EXTENT);
}

diff --git a/drivers/input/mouse/logips2pp.c b/drivers/input/mouse/logips2pp.c
index 7df9652..0f69ff4 100644
--- a/drivers/input/mouse/logips2pp.c
+++ b/drivers/input/mouse/logips2pp.c
@@ -40,7 +40,7 @@ struct ps2pp_info {

static psmouse_ret_t ps2pp_process_byte(struct psmouse *psmouse, struct pt_regs *regs)
{
- struct input_dev *dev = &psmouse->dev;
+ struct input_dev *dev = psmouse->dev;
unsigned char *packet = psmouse->packet;

if (psmouse->pktcnt < 3)
@@ -257,25 +257,27 @@ static struct ps2pp_info *get_model_info
static void ps2pp_set_model_properties(struct psmouse *psmouse, struct ps2pp_info *model_info,
int using_ps2pp)
{
+ struct input_dev *input_dev = psmouse->dev;
+
if (model_info->features & PS2PP_SIDE_BTN)
- set_bit(BTN_SIDE, psmouse->dev.keybit);
+ set_bit(BTN_SIDE, input_dev->keybit);

if (model_info->features & PS2PP_EXTRA_BTN)
- set_bit(BTN_EXTRA, psmouse->dev.keybit);
+ set_bit(BTN_EXTRA, input_dev->keybit);

if (model_info->features & PS2PP_TASK_BTN)
- set_bit(BTN_TASK, psmouse->dev.keybit);
+ set_bit(BTN_TASK, input_dev->keybit);

if (model_info->features & PS2PP_NAV_BTN) {
- set_bit(BTN_FORWARD, psmouse->dev.keybit);
- set_bit(BTN_BACK, psmouse->dev.keybit);
+ set_bit(BTN_FORWARD, input_dev->keybit);
+ set_bit(BTN_BACK, input_dev->keybit);
}

if (model_info->features & PS2PP_WHEEL)
- set_bit(REL_WHEEL, psmouse->dev.relbit);
+ set_bit(REL_WHEEL, input_dev->relbit);

if (model_info->features & PS2PP_HWHEEL)
- set_bit(REL_HWHEEL, psmouse->dev.relbit);
+ set_bit(REL_HWHEEL, input_dev->relbit);

switch (model_info->kind) {
case PS2PP_KIND_WHEEL:
@@ -387,7 +389,7 @@ int ps2pp_init(struct psmouse *psmouse,
}

if (buttons < 3)
- clear_bit(BTN_MIDDLE, psmouse->dev.keybit);
+ clear_bit(BTN_MIDDLE, psmouse->dev->keybit);

if (model_info)
ps2pp_set_model_properties(psmouse, model_info, use_ps2pp);
diff --git a/drivers/input/mouse/maplemouse.c b/drivers/input/mouse/maplemouse.c
index e90c60c..b5b34fe 100644
--- a/drivers/input/mouse/maplemouse.c
+++ b/drivers/input/mouse/maplemouse.c
@@ -41,13 +41,12 @@ static int dc_mouse_connect(struct maple
unsigned long data = be32_to_cpu(dev->devinfo.function_data[0]);
struct input_dev *input_dev;

- if (!(input_dev = kmalloc(sizeof(struct input_dev), GFP_KERNEL)))
- return -1;
+ dev->private_data = input_dev = input_allocate_device();
+ if (!input_dev)
+ return -ENOMEM;

dev->private_data = input_dev;

- memset(input_dev, 0, sizeof(struct dc_mouse));
- init_input_dev(input_dev);
input_dev->evbit[0] = BIT(EV_KEY) | BIT(EV_REL);
input_dev->keybit[LONG(BTN_MOUSE)] = BIT(BTN_LEFT) | BIT(BTN_RIGHT) | BIT(BTN_MIDDLE);
input_dev->relbit[0] = BIT(REL_X) | BIT(REL_Y) | BIT(REL_WHEEL);
@@ -59,8 +58,6 @@ static int dc_mouse_connect(struct maple

maple_getcond_callback(dev, dc_mouse_callback, 1, MAPLE_FUNC_MOUSE);

- printk(KERN_INFO "input: mouse(0x%lx): %s\n", data, input_dev->name);
-
return 0;
}

@@ -70,7 +67,6 @@ static void dc_mouse_disconnect(struct m
struct input_dev *input_dev = dev->private_data;

input_unregister_device(input_dev);
- kfree(input_dev);
}


diff --git a/drivers/input/mouse/pc110pad.c b/drivers/input/mouse/pc110pad.c
index 93393d5..d284ea7 100644
--- a/drivers/input/mouse/pc110pad.c
+++ b/drivers/input/mouse/pc110pad.c
@@ -53,13 +53,10 @@ MODULE_LICENSE("GPL");
static int pc110pad_irq = 10;
static int pc110pad_io = 0x15e0;

-static struct input_dev pc110pad_dev;
+static struct input_dev *pc110pad_dev;
static int pc110pad_data[3];
static int pc110pad_count;

-static char *pc110pad_name = "IBM PC110 TouchPad";
-static char *pc110pad_phys = "isa15e0/input0";
-
static irqreturn_t pc110pad_interrupt(int irq, void *ptr, struct pt_regs *regs)
{
int value = inb_p(pc110pad_io);
@@ -74,14 +71,14 @@ static irqreturn_t pc110pad_interrupt(in
if (pc110pad_count < 3)
return IRQ_HANDLED;

- input_regs(&pc110pad_dev, regs);
- input_report_key(&pc110pad_dev, BTN_TOUCH,
+ input_regs(pc110pad_dev, regs);
+ input_report_key(pc110pad_dev, BTN_TOUCH,
pc110pad_data[0] & 0x01);
- input_report_abs(&pc110pad_dev, ABS_X,
+ input_report_abs(pc110pad_dev, ABS_X,
pc110pad_data[1] | ((pc110pad_data[0] << 3) & 0x80) | ((pc110pad_data[0] << 1) & 0x100));
- input_report_abs(&pc110pad_dev, ABS_Y,
+ input_report_abs(pc110pad_dev, ABS_Y,
pc110pad_data[2] | ((pc110pad_data[0] << 4) & 0x80));
- input_sync(&pc110pad_dev);
+ input_sync(pc110pad_dev);

pc110pad_count = 0;
return IRQ_HANDLED;
@@ -94,9 +91,9 @@ static void pc110pad_close(struct input_

static int pc110pad_open(struct input_dev *dev)
{
- pc110pad_interrupt(0,NULL,NULL);
- pc110pad_interrupt(0,NULL,NULL);
- pc110pad_interrupt(0,NULL,NULL);
+ pc110pad_interrupt(0, NULL, NULL);
+ pc110pad_interrupt(0, NULL, NULL);
+ pc110pad_interrupt(0, NULL, NULL);
outb(PC110PAD_ON, pc110pad_io + 2);
pc110pad_count = 0;

@@ -127,45 +124,46 @@ static int __init pc110pad_init(void)

outb(PC110PAD_OFF, pc110pad_io + 2);

- if (request_irq(pc110pad_irq, pc110pad_interrupt, 0, "pc110pad", NULL))
- {
+ if (request_irq(pc110pad_irq, pc110pad_interrupt, 0, "pc110pad", NULL)) {
release_region(pc110pad_io, 4);
printk(KERN_ERR "pc110pad: Unable to get irq %d.\n", pc110pad_irq);
return -EBUSY;
}

- pc110pad_dev.evbit[0] = BIT(EV_KEY) | BIT(EV_ABS);
- pc110pad_dev.absbit[0] = BIT(ABS_X) | BIT(ABS_Y);
- pc110pad_dev.keybit[LONG(BTN_TOUCH)] = BIT(BTN_TOUCH);
-
- pc110pad_dev.absmax[ABS_X] = 0x1ff;
- pc110pad_dev.absmax[ABS_Y] = 0x0ff;
-
- pc110pad_dev.open = pc110pad_open;
- pc110pad_dev.close = pc110pad_close;
-
- pc110pad_dev.name = pc110pad_name;
- pc110pad_dev.phys = pc110pad_phys;
- pc110pad_dev.id.bustype = BUS_ISA;
- pc110pad_dev.id.vendor = 0x0003;
- pc110pad_dev.id.product = 0x0001;
- pc110pad_dev.id.version = 0x0100;
+ if (!(pc110pad_dev = input_allocate_device())) {
+ free_irq(pc110pad_irq, NULL);
+ release_region(pc110pad_io, 4);
+ printk(KERN_ERR "pc110pad: Not enough memory.\n");
+ return -ENOMEM;
+ }
+
+ pc110pad_dev->name = "IBM PC110 TouchPad";
+ pc110pad_dev->phys = "isa15e0/input0";
+ pc110pad_dev->id.bustype = BUS_ISA;
+ pc110pad_dev->id.vendor = 0x0003;
+ pc110pad_dev->id.product = 0x0001;
+ pc110pad_dev->id.version = 0x0100;
+
+ pc110pad_dev->evbit[0] = BIT(EV_KEY) | BIT(EV_ABS);
+ pc110pad_dev->absbit[0] = BIT(ABS_X) | BIT(ABS_Y);
+ pc110pad_dev->keybit[LONG(BTN_TOUCH)] = BIT(BTN_TOUCH);

- input_register_device(&pc110pad_dev);
+ pc110pad_dev->absmax[ABS_X] = 0x1ff;
+ pc110pad_dev->absmax[ABS_Y] = 0x0ff;

- printk(KERN_INFO "input: %s at %#x irq %d\n",
- pc110pad_name, pc110pad_io, pc110pad_irq);
+ pc110pad_dev->open = pc110pad_open;
+ pc110pad_dev->close = pc110pad_close;
+
+ input_register_device(pc110pad_dev);

return 0;
}

static void __exit pc110pad_exit(void)
{
- input_unregister_device(&pc110pad_dev);
-
outb(PC110PAD_OFF, pc110pad_io + 2);
-
free_irq(pc110pad_irq, NULL);
+ input_unregister_device(pc110pad_dev);
release_region(pc110pad_io, 4);
}

diff --git a/drivers/input/mouse/psmouse-base.c b/drivers/input/mouse/psmouse-base.c
index af24313..6ee9999 100644
--- a/drivers/input/mouse/psmouse-base.c
+++ b/drivers/input/mouse/psmouse-base.c
@@ -114,7 +114,7 @@ struct psmouse_protocol {

static psmouse_ret_t psmouse_process_byte(struct psmouse *psmouse, struct pt_regs *regs)
{
- struct input_dev *dev = &psmouse->dev;
+ struct input_dev *dev = psmouse->dev;
unsigned char *packet = psmouse->packet;

if (psmouse->pktcnt < psmouse->pktsize)
@@ -333,12 +333,11 @@ static int genius_detect(struct psmouse
return -1;

if (set_properties) {
- set_bit(BTN_EXTRA, psmouse->dev.keybit);
- set_bit(BTN_SIDE, psmouse->dev.keybit);
- set_bit(REL_WHEEL, psmouse->dev.relbit);
+ set_bit(BTN_EXTRA, psmouse->dev->keybit);
+ set_bit(BTN_SIDE, psmouse->dev->keybit);
+ set_bit(REL_WHEEL, psmouse->dev->relbit);

psmouse->vendor = "Genius";
- psmouse->name = "Wheel Mouse";
psmouse->pktsize = 4;
}

@@ -365,8 +364,8 @@ static int intellimouse_detect(struct ps
return -1;

if (set_properties) {
- set_bit(BTN_MIDDLE, psmouse->dev.keybit);
- set_bit(REL_WHEEL, psmouse->dev.relbit);
+ set_bit(BTN_MIDDLE, psmouse->dev->keybit);
+ set_bit(REL_WHEEL, psmouse->dev->relbit);

if (!psmouse->vendor) psmouse->vendor = "Generic";
if (!psmouse->name) psmouse->name = "Wheel Mouse";
@@ -398,10 +397,10 @@ static int im_explorer_detect(struct psm
return -1;

if (set_properties) {
- set_bit(BTN_MIDDLE, psmouse->dev.keybit);
- set_bit(REL_WHEEL, psmouse->dev.relbit);
- set_bit(BTN_SIDE, psmouse->dev.keybit);
- set_bit(BTN_EXTRA, psmouse->dev.keybit);
+ set_bit(BTN_MIDDLE, psmouse->dev->keybit);
+ set_bit(REL_WHEEL, psmouse->dev->relbit);
+ set_bit(BTN_SIDE, psmouse->dev->keybit);
+ set_bit(BTN_EXTRA, psmouse->dev->keybit);

if (!psmouse->vendor) psmouse->vendor = "Generic";
if (!psmouse->name) psmouse->name = "Explorer Mouse";
@@ -433,7 +432,7 @@ static int thinking_detect(struct psmous
return -1;

if (set_properties) {
- set_bit(BTN_EXTRA, psmouse->dev.keybit);
+ set_bit(BTN_EXTRA, psmouse->dev->keybit);

psmouse->vendor = "Kensington";
psmouse->name = "ThinkingMouse";
@@ -839,9 +838,9 @@ static void psmouse_disconnect(struct se

psmouse_set_state(psmouse, PSMOUSE_IGNORE);

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

if (parent)
@@ -852,16 +851,14 @@ static void psmouse_disconnect(struct se

static int psmouse_switch_protocol(struct psmouse *psmouse, struct psmouse_protocol *proto)
{
- memset(&psmouse->dev, 0, sizeof(struct input_dev));
+ struct input_dev *input_dev = psmouse->dev;

- init_input_dev(&psmouse->dev);
+ input_dev->private = psmouse;
+ input_dev->cdev.dev = &psmouse->ps2dev.serio->dev;

- psmouse->dev.private = psmouse;
- psmouse->dev.dev = &psmouse->ps2dev.serio->dev;
-
- 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);
+ input_dev->evbit[0] = BIT(EV_KEY) | BIT(EV_REL);
+ input_dev->keybit[LONG(BTN_MOUSE)] = BIT(BTN_LEFT) | BIT(BTN_MIDDLE) | BIT(BTN_RIGHT);
+ input_dev->relbit[0] = BIT(REL_X) | BIT(REL_Y);

psmouse->set_rate = psmouse_set_rate;
psmouse->set_resolution = psmouse_set_resolution;
@@ -883,12 +880,12 @@ static int psmouse_switch_protocol(struc
sprintf(psmouse->devname, "%s %s %s",
psmouse_protocol_by_type(psmouse->type)->name, psmouse->vendor, psmouse->name);

- psmouse->dev.name = psmouse->devname;
- psmouse->dev.phys = psmouse->phys;
- psmouse->dev.id.bustype = BUS_I8042;
- psmouse->dev.id.vendor = 0x0002;
- psmouse->dev.id.product = psmouse->type;
- psmouse->dev.id.version = psmouse->model;
+ input_dev->name = psmouse->devname;
+ input_dev->phys = psmouse->phys;
+ input_dev->id.bustype = BUS_I8042;
+ input_dev->id.vendor = 0x0002;
+ input_dev->id.product = psmouse->type;
+ input_dev->id.version = psmouse->model;

return 0;
}
@@ -900,7 +897,8 @@ static int psmouse_switch_protocol(struc
static int psmouse_connect(struct serio *serio, struct serio_driver *drv)
{
struct psmouse *psmouse, *parent = NULL;
- int retval;
+ struct input_dev *input_dev;
+ int retval = -ENOMEM;

down(&psmouse_sem);

@@ -913,12 +911,13 @@ static int psmouse_connect(struct serio
psmouse_deactivate(parent);
}

- if (!(psmouse = kzalloc(sizeof(struct psmouse), GFP_KERNEL))) {
- retval = -ENOMEM;
+ psmouse = kzalloc(sizeof(struct psmouse), GFP_KERNEL);
+ input_dev = input_allocate_device();
+ if (!psmouse || !input_dev)
goto out;
- }

ps2_init(&psmouse->ps2dev, serio);
+ psmouse->dev = input_dev;
sprintf(psmouse->phys, "%s/input0", serio->phys);

psmouse_set_state(psmouse, PSMOUSE_INITIALIZING);
@@ -926,16 +925,11 @@ static int psmouse_connect(struct serio
serio_set_drvdata(serio, psmouse);

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

if (psmouse_probe(psmouse) < 0) {
serio_close(serio);
- serio_set_drvdata(serio, NULL);
- kfree(psmouse);
retval = -ENODEV;
goto out;
}
@@ -947,13 +941,11 @@ static int psmouse_connect(struct serio

psmouse_switch_protocol(psmouse, NULL);

- input_register_device(&psmouse->dev);
- printk(KERN_INFO "input: %s on %s\n", psmouse->devname, serio->phys);
-
psmouse_set_state(psmouse, PSMOUSE_CMD_MODE);
-
psmouse_initialize(psmouse);

+ input_register_device(psmouse->dev);
+
if (parent && parent->pt_activate)
parent->pt_activate(parent);

@@ -964,6 +956,12 @@ static int psmouse_connect(struct serio
retval = 0;

out:
+ if (retval) {
+ serio_set_drvdata(serio, NULL);
+ input_free_device(input_dev);
+ kfree(psmouse);
+ }
+
/* If this is a pass-through port the parent needs to be re-activated */
if (parent)
psmouse_activate(parent);
@@ -1161,6 +1159,7 @@ static ssize_t psmouse_attr_set_protocol
{
struct serio *serio = psmouse->ps2dev.serio;
struct psmouse *parent = NULL;
+ struct input_dev *new_dev;
struct psmouse_protocol *proto;
int retry = 0;

@@ -1170,9 +1169,13 @@ static ssize_t psmouse_attr_set_protocol
if (psmouse->type == proto->type)
return count;

+ if (!(new_dev = input_allocate_device()))
+ return -ENOMEM;
+
while (serio->child) {
if (++retry > 3) {
printk(KERN_WARNING "psmouse: failed to destroy child port, protocol change aborted.\n");
+ input_free_device(new_dev);
return -EIO;
}

@@ -1182,11 +1185,15 @@ static ssize_t psmouse_attr_set_protocol
serio_pin_driver_uninterruptible(serio);
down(&psmouse_sem);

- if (serio->drv != &psmouse_drv)
+ if (serio->drv != &psmouse_drv) {
+ input_free_device(new_dev);
return -ENODEV;
+ }

- if (psmouse->type == proto->type)
+ if (psmouse->type == proto->type) {
+ input_free_device(new_dev);
return count; /* switched by other thread */
+ }
}

if (serio->parent && serio->id.type == SERIO_PS_PSTHRU) {
@@ -1199,8 +1206,9 @@ static ssize_t psmouse_attr_set_protocol
psmouse->disconnect(psmouse);

psmouse_set_state(psmouse, PSMOUSE_IGNORE);
- input_unregister_device(&psmouse->dev);
+ input_unregister_device(psmouse->dev);

+ psmouse->dev = new_dev;
psmouse_set_state(psmouse, PSMOUSE_INITIALIZING);

if (psmouse_switch_protocol(psmouse, proto) < 0) {
@@ -1212,8 +1220,7 @@ static ssize_t psmouse_attr_set_protocol
psmouse_initialize(psmouse);
psmouse_set_state(psmouse, PSMOUSE_CMD_MODE);

- input_register_device(&psmouse->dev);
- printk(KERN_INFO "input: %s on %s\n", psmouse->devname, serio->phys);
+ input_register_device(psmouse->dev);

if (parent && parent->pt_activate)
parent->pt_activate(parent);
diff --git a/drivers/input/mouse/psmouse.h b/drivers/input/mouse/psmouse.h
index 45d2bd7..7c4192b 100644
--- a/drivers/input/mouse/psmouse.h
+++ b/drivers/input/mouse/psmouse.h
@@ -36,7 +36,7 @@ typedef enum {

struct psmouse {
void *private;
- struct input_dev dev;
+ struct input_dev *dev;
struct ps2dev ps2dev;
char *vendor;
char *name;
diff --git a/drivers/input/mouse/rpcmouse.c b/drivers/input/mouse/rpcmouse.c
index 8fe1212..09b6ffd 100644
--- a/drivers/input/mouse/rpcmouse.c
+++ b/drivers/input/mouse/rpcmouse.c
@@ -34,20 +34,7 @@ MODULE_DESCRIPTION("Acorn RiscPC mouse d
MODULE_LICENSE("GPL");

static short rpcmouse_lastx, rpcmouse_lasty;
-
-static struct input_dev rpcmouse_dev = {
- .evbit = { BIT(EV_KEY) | BIT(EV_REL) },
- .keybit = { [LONG(BTN_LEFT)] = BIT(BTN_LEFT) | BIT(BTN_MIDDLE) | BIT(BTN_RIGHT) },
- .relbit = { BIT(REL_X) | BIT(REL_Y) },
- .name = "Acorn RiscPC Mouse",
- .phys = "rpcmouse/input0",
- .id = {
- .bustype = BUS_HOST,
- .vendor = 0x0005,
- .product = 0x0001,
- .version = 0x0100,
- },
-};
+static struct input_dev *rpcmouse_dev;

static irqreturn_t rpcmouse_irq(int irq, void *dev_id, struct pt_regs *regs)
{
@@ -78,29 +65,41 @@ static irqreturn_t rpcmouse_irq(int irq,
return IRQ_HANDLED;
}

+
static int __init rpcmouse_init(void)
{
- init_input_dev(&rpcmouse_dev);
+ if (!(rpcmouse_dev = input_allocate_device()))
+ return -ENOMEM;
+
+ rpcmouse_dev->name = "Acorn RiscPC Mouse";
+ rpcmouse_dev->phys = "rpcmouse/input0";
+ rpcmouse_dev->id.bustype = BUS_HOST;
+ rpcmouse_dev->id.vendor = 0x0005;
+ rpcmouse_dev->id.product = 0x0001;
+ rpcmouse_dev->id.version = 0x0100;
+
+ rpcmouse_dev->evbit[0] = BIT(EV_KEY) | BIT(EV_REL);
+ rpcmouse_dev->keybit[LONG(BTN_LEFT)] = BIT(BTN_LEFT) | BIT(BTN_MIDDLE) | BIT(BTN_RIGHT);
+ rpcmouse_dev->relbit[0] = BIT(REL_X) | BIT(REL_Y);

rpcmouse_lastx = (short) iomd_readl(IOMD_MOUSEX);
rpcmouse_lasty = (short) iomd_readl(IOMD_MOUSEY);

- if (request_irq(IRQ_VSYNCPULSE, rpcmouse_irq, SA_SHIRQ, "rpcmouse", &rpcmouse_dev)) {
+ if (request_irq(IRQ_VSYNCPULSE, rpcmouse_irq, SA_SHIRQ, "rpcmouse", rpcmouse_dev)) {
printk(KERN_ERR "rpcmouse: unable to allocate VSYNC interrupt\n");
- return -1;
+ input_free_device(rpcmouse_dev);
+ return -EBUSY;
}

- input_register_device(&rpcmouse_dev);
-
- printk(KERN_INFO "input: Acorn RiscPC mouse\n");
+ input_register_device(rpcmouse_dev);

return 0;
}

static void __exit rpcmouse_exit(void)
{
- input_unregister_device(&rpcmouse_dev);
- free_irq(IRQ_VSYNCPULSE, &rpcmouse_dev);
+ free_irq(IRQ_VSYNCPULSE, rpcmouse_dev);
+ input_unregister_device(rpcmouse_dev);
}

module_init(rpcmouse_init);
diff --git a/drivers/input/mouse/sermouse.c b/drivers/input/mouse/sermouse.c
index d12b93a..4bf5843 100644
--- a/drivers/input/mouse/sermouse.c
+++ b/drivers/input/mouse/sermouse.c
@@ -48,7 +48,7 @@ static char *sermouse_protocols[] = { "N
"Logitech MZ++ Mouse"};

struct sermouse {
- struct input_dev dev;
+ struct input_dev *dev;
signed char buf[8];
unsigned char count;
unsigned char type;
@@ -64,7 +64,7 @@ struct sermouse {

static void sermouse_process_msc(struct sermouse *sermouse, signed char data, struct pt_regs *regs)
{
- struct input_dev *dev = &sermouse->dev;
+ struct input_dev *dev = sermouse->dev;
signed char *buf = sermouse->buf;

input_regs(dev, regs);
@@ -107,7 +107,7 @@ static void sermouse_process_msc(struct

static void sermouse_process_ms(struct sermouse *sermouse, signed char data, struct pt_regs *regs)
{
- struct input_dev *dev = &sermouse->dev;
+ struct input_dev *dev = sermouse->dev;
signed char *buf = sermouse->buf;

if (data & 0x40) sermouse->count = 0;
@@ -230,9 +230,9 @@ static void sermouse_disconnect(struct s
{
struct sermouse *sermouse = serio_get_drvdata(serio);

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

@@ -244,56 +244,52 @@ static void sermouse_disconnect(struct s
static int sermouse_connect(struct serio *serio, struct serio_driver *drv)
{
struct sermouse *sermouse;
- unsigned char c;
- int err;
-
- if (!serio->id.proto || serio->id.proto > SERIO_MZPP)
- return -ENODEV;
-
- if (!(sermouse = kmalloc(sizeof(struct sermouse), GFP_KERNEL)))
- return -ENOMEM;
-
- memset(sermouse, 0, sizeof(struct sermouse));
-
- init_input_dev(&sermouse->dev);
- sermouse->dev.evbit[0] = BIT(EV_KEY) | BIT(EV_REL);
- sermouse->dev.keybit[LONG(BTN_MOUSE)] = BIT(BTN_LEFT) | BIT(BTN_RIGHT);
- sermouse->dev.relbit[0] = BIT(REL_X) | BIT(REL_Y);
- sermouse->dev.private = sermouse;
-
- 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);
- if (c & 0x04) set_bit(BTN_EXTRA, sermouse->dev.keybit);
- if (c & 0x10) set_bit(REL_WHEEL, sermouse->dev.relbit);
- if (c & 0x20) set_bit(REL_HWHEEL, sermouse->dev.relbit);
+ struct input_dev *input_dev;
+ unsigned char c = serio->id.extra;
+ int err = -ENOMEM;
+
+ sermouse = kzalloc(sizeof(struct sermouse), GFP_KERNEL);
+ input_dev = input_allocate_device();
+ if (!sermouse || !input_dev)
+ goto fail;

+ sermouse->dev = input_dev;
sprintf(sermouse->phys, "%s/input0", serio->phys);
+ sermouse->type = serio->id.proto;

- sermouse->dev.name = sermouse_protocols[sermouse->type];
- sermouse->dev.phys = sermouse->phys;
- sermouse->dev.id.bustype = BUS_RS232;
- sermouse->dev.id.vendor = sermouse->type;
- sermouse->dev.id.product = c;
- sermouse->dev.id.version = 0x0100;
- sermouse->dev.dev = &serio->dev;
+ input_dev->name = sermouse_protocols[sermouse->type];
+ input_dev->phys = sermouse->phys;
+ input_dev->id.bustype = BUS_RS232;
+ input_dev->id.vendor = sermouse->type;
+ input_dev->id.product = c;
+ input_dev->id.version = 0x0100;
+ input_dev->cdev.dev = &serio->dev;
+
+ input_dev->evbit[0] = BIT(EV_KEY) | BIT(EV_REL);
+ input_dev->keybit[LONG(BTN_MOUSE)] = BIT(BTN_LEFT) | BIT(BTN_RIGHT);
+ input_dev->relbit[0] = BIT(REL_X) | BIT(REL_Y);
+ input_dev->private = sermouse;
+
+ if (c & 0x01) set_bit(BTN_MIDDLE, input_dev->keybit);
+ if (c & 0x02) set_bit(BTN_SIDE, input_dev->keybit);
+ if (c & 0x04) set_bit(BTN_EXTRA, input_dev->keybit);
+ if (c & 0x10) set_bit(REL_WHEEL, input_dev->relbit);
+ if (c & 0x20) set_bit(REL_HWHEEL, input_dev->relbit);

serio_set_drvdata(serio, sermouse);

err = serio_open(serio, drv);
- if (err) {
- serio_set_drvdata(serio, NULL);
- kfree(sermouse);
- return err;
- }
-
- input_register_device(&sermouse->dev);
+ if (err)
+ goto fail;

- printk(KERN_INFO "input: %s on %s\n", sermouse_protocols[sermouse->type], serio->phys);
+ input_register_device(sermouse->dev);

return 0;
+
+ fail: serio_set_drvdata(serio, NULL);
+ input_free_device(input_dev);
+ kfree(sermouse);
+ return err;
}

static struct serio_device_id sermouse_serio_ids[] = {
diff --git a/drivers/input/mouse/synaptics.c b/drivers/input/mouse/synaptics.c
index 0293094..97cdfd6 100644
--- a/drivers/input/mouse/synaptics.c
+++ b/drivers/input/mouse/synaptics.c
@@ -342,7 +342,7 @@ static void synaptics_parse_hw_state(uns
*/
static void synaptics_process_packet(struct psmouse *psmouse)
{
- struct input_dev *dev = &psmouse->dev;
+ struct input_dev *dev = psmouse->dev;
struct synaptics_data *priv = psmouse->private;
struct synaptics_hw_state hw;
int num_fingers;
@@ -473,7 +473,7 @@ static unsigned char synaptics_detect_pk

static psmouse_ret_t synaptics_process_byte(struct psmouse *psmouse, struct pt_regs *regs)
{
- struct input_dev *dev = &psmouse->dev;
+ struct input_dev *dev = psmouse->dev;
struct synaptics_data *priv = psmouse->private;

input_regs(dev, regs);
@@ -645,7 +645,7 @@ int synaptics_init(struct psmouse *psmou
SYN_ID_MAJOR(priv->identity), SYN_ID_MINOR(priv->identity),
priv->model_id, priv->capabilities, priv->ext_cap);

- set_input_params(&psmouse->dev, priv);
+ set_input_params(psmouse->dev, priv);

psmouse->protocol_handler = synaptics_process_byte;
psmouse->set_rate = synaptics_set_rate;
diff --git a/drivers/input/mouse/vsxxxaa.c b/drivers/input/mouse/vsxxxaa.c
index f024be9..36e9442 100644
--- a/drivers/input/mouse/vsxxxaa.c
+++ b/drivers/input/mouse/vsxxxaa.c
@@ -112,7 +112,7 @@ MODULE_LICENSE ("GPL");


struct vsxxxaa {
- struct input_dev dev;
+ struct input_dev *dev;
struct serio *serio;
#define BUFLEN 15 /* At least 5 is needed for a full tablet packet */
unsigned char buf[BUFLEN];
@@ -211,7 +211,7 @@ vsxxxaa_smells_like_packet (struct vsxxx
static void
vsxxxaa_handle_REL_packet (struct vsxxxaa *mouse, struct pt_regs *regs)
{
- struct input_dev *dev = &mouse->dev;
+ struct input_dev *dev = mouse->dev;
unsigned char *buf = mouse->buf;
int left, middle, right;
int dx, dy;
@@ -269,7 +269,7 @@ vsxxxaa_handle_REL_packet (struct vsxxxa
static void
vsxxxaa_handle_ABS_packet (struct vsxxxaa *mouse, struct pt_regs *regs)
{
- struct input_dev *dev = &mouse->dev;
+ struct input_dev *dev = mouse->dev;
unsigned char *buf = mouse->buf;
int left, middle, right, touch;
int x, y;
@@ -323,7 +323,7 @@ vsxxxaa_handle_ABS_packet (struct vsxxxa
static void
vsxxxaa_handle_POR_packet (struct vsxxxaa *mouse, struct pt_regs *regs)
{
- struct input_dev *dev = &mouse->dev;
+ struct input_dev *dev = mouse->dev;
unsigned char *buf = mouse->buf;
int left, middle, right;
unsigned char error;
@@ -483,9 +483,9 @@ vsxxxaa_disconnect (struct serio *serio)
{
struct vsxxxaa *mouse = serio_get_drvdata (serio);

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

@@ -493,61 +493,57 @@ static int
vsxxxaa_connect (struct serio *serio, struct serio_driver *drv)
{
struct vsxxxaa *mouse;
- int err;
+ struct input_dev *input_dev;
+ int err = -ENOMEM;

- if (!(mouse = kmalloc (sizeof (struct vsxxxaa), GFP_KERNEL)))
- return -ENOMEM;
-
- memset (mouse, 0, sizeof (struct vsxxxaa));
-
- init_input_dev (&mouse->dev);
- set_bit (EV_KEY, mouse->dev.evbit); /* We have buttons */
- set_bit (EV_REL, mouse->dev.evbit);
- set_bit (EV_ABS, mouse->dev.evbit);
- set_bit (BTN_LEFT, mouse->dev.keybit); /* We have 3 buttons */
- set_bit (BTN_MIDDLE, mouse->dev.keybit);
- set_bit (BTN_RIGHT, mouse->dev.keybit);
- set_bit (BTN_TOUCH, mouse->dev.keybit); /* ...and Tablet */
- set_bit (REL_X, mouse->dev.relbit);
- set_bit (REL_Y, mouse->dev.relbit);
- set_bit (ABS_X, mouse->dev.absbit);
- set_bit (ABS_Y, mouse->dev.absbit);
-
- mouse->dev.absmin[ABS_X] = 0;
- mouse->dev.absmax[ABS_X] = 1023;
- mouse->dev.absmin[ABS_Y] = 0;
- mouse->dev.absmax[ABS_Y] = 1023;
-
- mouse->dev.private = mouse;
+ mouse = kzalloc (sizeof (struct vsxxxaa), GFP_KERNEL);
+ input_dev = input_allocate_device ();
+ if (!mouse || !input_dev)
+ goto fail;

+ mouse->dev = input_dev;
+ mouse->serio = serio;
sprintf (mouse->name, "DEC VSXXX-AA/-GA mouse or VSXXX-AB digitizer");
sprintf (mouse->phys, "%s/input0", serio->phys);
- mouse->dev.name = mouse->name;
- mouse->dev.phys = mouse->phys;
- mouse->dev.id.bustype = BUS_RS232;
- mouse->dev.dev = &serio->dev;
- mouse->serio = serio;
+
+ input_dev->name = mouse->name;
+ input_dev->phys = mouse->phys;
+ input_dev->id.bustype = BUS_RS232;
+ input_dev->cdev.dev = &serio->dev;
+ input_dev->private = mouse;
+
+ set_bit (EV_KEY, input_dev->evbit); /* We have buttons */
+ set_bit (EV_REL, input_dev->evbit);
+ set_bit (EV_ABS, input_dev->evbit);
+ set_bit (BTN_LEFT, input_dev->keybit); /* We have 3 buttons */
+ set_bit (BTN_MIDDLE, input_dev->keybit);
+ set_bit (BTN_RIGHT, input_dev->keybit);
+ set_bit (BTN_TOUCH, input_dev->keybit); /* ...and Tablet */
+ set_bit (REL_X, input_dev->relbit);
+ set_bit (REL_Y, input_dev->relbit);
+ input_set_abs_params (input_dev, ABS_X, 0, 1023, 0, 0);
+ input_set_abs_params (input_dev, ABS_Y, 0, 1023, 0, 0);

serio_set_drvdata (serio, mouse);

err = serio_open (serio, drv);
- if (err) {
- serio_set_drvdata (serio, NULL);
- kfree (mouse);
- return err;
- }
+ if (err)
+ goto fail;

/*
* Request selftest. Standard packet format and differential
* mode will be requested after the device ID'ed successfully.
*/
- mouse->serio->write (mouse->serio, 'T'); /* Test */
-
- input_register_device (&mouse->dev);
+ serio->write (serio, 'T'); /* Test */

- printk (KERN_INFO "input: %s on %s\n", mouse->name, mouse->phys);
+ input_register_device (input_dev);

return 0;
+
+ fail: serio_set_drvdata (serio, NULL);
+ input_free_device (input_dev);
+ kfree (mouse);
+ return err;
}

static struct serio_device_id vsxxaa_serio_ids[] = {

2005-10-28 06:40:47

by Greg KH

[permalink] [raw]
Subject: [PATCH] Input: convert onetouch to dynamic input_dev allocation

[PATCH] Input: convert onetouch to dynamic input_dev allocation

Input: convert onetouch to dynamic input_dev allocation

This is required for input_dev sysfs integration

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

---
commit 9b372d662ed489f3aac7e88e9452ce4c923b11d7
tree aa2c555213301822a76e00f07511538849a9c5bf
parent 218e51d8b7c75a09e156696c037e6e3383a7808b
author Dmitry Torokhov <[email protected]> Thu, 15 Sep 2005 02:01:43 -0500
committer Greg Kroah-Hartman <[email protected]> Thu, 27 Oct 2005 22:48:04 -0700

drivers/usb/storage/onetouch.c | 105 ++++++++++++++++++++--------------------
1 files changed, 53 insertions(+), 52 deletions(-)

diff --git a/drivers/usb/storage/onetouch.c b/drivers/usb/storage/onetouch.c
index 2c9402d..89401a5 100644
--- a/drivers/usb/storage/onetouch.c
+++ b/drivers/usb/storage/onetouch.c
@@ -5,7 +5,7 @@
* Copyright (c) 2005 Nick Sillik <[email protected]>
*
* Initial work by:
- * Copyright (c) 2003 Erik Thyren <[email protected]>
+ * Copyright (c) 2003 Erik Thyren <[email protected]>
*
* Based on usbmouse.c (Vojtech Pavlik) and xpad.c (Marko Friedemann)
*
@@ -46,7 +46,7 @@ void onetouch_release_input(void *onetou
struct usb_onetouch {
char name[128];
char phys[64];
- struct input_dev dev; /* input device interface */
+ struct input_dev *dev; /* input device interface */
struct usb_device *udev; /* usb device */

struct urb *irq; /* urb for interrupt in report */
@@ -58,7 +58,7 @@ static void usb_onetouch_irq(struct urb
{
struct usb_onetouch *onetouch = urb->context;
signed char *data = onetouch->data;
- struct input_dev *dev = &onetouch->dev;
+ struct input_dev *dev = onetouch->dev;
int status;

switch (urb->status) {
@@ -74,11 +74,9 @@ static void usb_onetouch_irq(struct urb
}

input_regs(dev, regs);
-
- input_report_key(&onetouch->dev, ONETOUCH_BUTTON,
- data[0] & 0x02);
-
+ input_report_key(dev, ONETOUCH_BUTTON, data[0] & 0x02);
input_sync(dev);
+
resubmit:
status = usb_submit_urb (urb, SLAB_ATOMIC);
if (status)
@@ -113,8 +111,8 @@ int onetouch_connect_input(struct us_dat
struct usb_host_interface *interface;
struct usb_endpoint_descriptor *endpoint;
struct usb_onetouch *onetouch;
+ struct input_dev *input_dev;
int pipe, maxp;
- char path[64];

interface = ss->pusb_intf->cur_altsetting;

@@ -122,62 +120,62 @@ int onetouch_connect_input(struct us_dat
return -ENODEV;

endpoint = &interface->endpoint[2].desc;
- if(!(endpoint->bEndpointAddress & USB_DIR_IN))
+ if (!(endpoint->bEndpointAddress & USB_DIR_IN))
return -ENODEV;
- if((endpoint->bmAttributes & USB_ENDPOINT_XFERTYPE_MASK)
+ if ((endpoint->bmAttributes & USB_ENDPOINT_XFERTYPE_MASK)
!= USB_ENDPOINT_XFER_INT)
return -ENODEV;

pipe = usb_rcvintpipe(udev, endpoint->bEndpointAddress);
maxp = usb_maxpacket(udev, pipe, usb_pipeout(pipe));

- if (!(onetouch = kcalloc(1, sizeof(struct usb_onetouch), GFP_KERNEL)))
- return -ENOMEM;
+ onetouch = kzalloc(sizeof(struct usb_onetouch), GFP_KERNEL);
+ input_dev = input_allocate_device();
+ if (!onetouch || !input_dev)
+ goto fail1;

onetouch->data = usb_buffer_alloc(udev, ONETOUCH_PKT_LEN,
SLAB_ATOMIC, &onetouch->data_dma);
- if (!onetouch->data){
- kfree(onetouch);
- return -ENOMEM;
- }
+ if (!onetouch->data)
+ goto fail1;

onetouch->irq = usb_alloc_urb(0, GFP_KERNEL);
- if (!onetouch->irq){
- kfree(onetouch);
- usb_buffer_free(udev, ONETOUCH_PKT_LEN,
- onetouch->data, onetouch->data_dma);
- return -ENODEV;
- }
-
+ if (!onetouch->irq)
+ goto fail2;

onetouch->udev = udev;
-
- set_bit(EV_KEY, onetouch->dev.evbit);
- set_bit(ONETOUCH_BUTTON, onetouch->dev.keybit);
- clear_bit(0, onetouch->dev.keybit);
-
- onetouch->dev.private = onetouch;
- onetouch->dev.open = usb_onetouch_open;
- onetouch->dev.close = usb_onetouch_close;
-
- usb_make_path(udev, path, sizeof(path));
- sprintf(onetouch->phys, "%s/input0", path);
-
- onetouch->dev.name = onetouch->name;
- onetouch->dev.phys = onetouch->phys;
-
- usb_to_input_id(udev, &onetouch->dev.id);
-
- onetouch->dev.dev = &udev->dev;
+ onetouch->dev = input_dev;

if (udev->manufacturer)
- strcat(onetouch->name, udev->manufacturer);
- if (udev->product)
- sprintf(onetouch->name, "%s %s", onetouch->name,
- udev->product);
+ strlcpy(onetouch->name, udev->manufacturer,
+ sizeof(onetouch->name));
+ if (udev->product) {
+ if (udev->manufacturer)
+ strlcat(onetouch->name, " ", sizeof(onetouch->name));
+ strlcat(onetouch->name, udev->product, sizeof(onetouch->name));
+ }
+
if (!strlen(onetouch->name))
- sprintf(onetouch->name, "Maxtor Onetouch %04x:%04x",
- onetouch->dev.id.vendor, onetouch->dev.id.product);
+ snprintf(onetouch->name, sizeof(onetouch->name),
+ "Maxtor Onetouch %04x:%04x",
+ le16_to_cpu(udev->descriptor.idVendor),
+ le16_to_cpu(udev->descriptor.idProduct));
+
+ usb_make_path(udev, onetouch->phys, sizeof(onetouch->phys));
+ strlcat(onetouch->phys, "/input0", sizeof(onetouch->phys));
+
+ input_dev->name = onetouch->name;
+ input_dev->phys = onetouch->phys;
+ usb_to_input_id(udev, &input_dev->id);
+ input_dev->cdev.dev = &udev->dev;
+
+ set_bit(EV_KEY, input_dev->evbit);
+ set_bit(ONETOUCH_BUTTON, input_dev->keybit);
+ clear_bit(0, input_dev->keybit);
+
+ input_dev->private = onetouch;
+ input_dev->open = usb_onetouch_open;
+ input_dev->close = usb_onetouch_close;

usb_fill_int_urb(onetouch->irq, udev, pipe, onetouch->data,
(maxp > 8 ? 8 : maxp),
@@ -188,10 +186,15 @@ int onetouch_connect_input(struct us_dat
ss->extra_destructor = onetouch_release_input;
ss->extra = onetouch;

- input_register_device(&onetouch->dev);
- printk(KERN_INFO "usb-input: %s on %s\n", onetouch->dev.name, path);
+ input_register_device(onetouch->dev);

return 0;
+
+ fail2: usb_buffer_free(udev, ONETOUCH_PKT_LEN,
+ onetouch->data, onetouch->data_dma);
+ fail1: kfree(onetouch);
+ input_free_device(input_dev);
+ return -ENOMEM;
}

void onetouch_release_input(void *onetouch_)
@@ -200,11 +203,9 @@ void onetouch_release_input(void *onetou

if (onetouch) {
usb_kill_urb(onetouch->irq);
- input_unregister_device(&onetouch->dev);
+ input_unregister_device(onetouch->dev);
usb_free_urb(onetouch->irq);
usb_buffer_free(onetouch->udev, ONETOUCH_PKT_LEN,
onetouch->data, onetouch->data_dma);
- printk(KERN_INFO "usb-input: deregistering %s\n",
- onetouch->dev.name);
}
}

2005-10-28 06:39:51

by Greg KH

[permalink] [raw]
Subject: [PATCH] Driver Core: document struct class_device properly

[PATCH] Driver Core: document struct class_device properly

Signed-off-by: Greg Kroah-Hartman <[email protected]>

---
commit e9a873633c67dd048c9d53f3e934e83df10312d1
tree 9152a484f16797773dce293c205e5e71b1260322
parent c5d4abda2b87357d5ba32b0c8babb532eb75d9c7
author Greg Kroah-Hartman <[email protected]> Thu, 27 Oct 2005 22:25:43 -0700
committer Greg Kroah-Hartman <[email protected]> Thu, 27 Oct 2005 22:48:03 -0700

include/linux/device.h | 24 ++++++++++++++++++++++++
1 files changed, 24 insertions(+), 0 deletions(-)

diff --git a/include/linux/device.h b/include/linux/device.h
index 226e550..10ab780 100644
--- a/include/linux/device.h
+++ b/include/linux/device.h
@@ -203,6 +203,30 @@ struct class_device_attribute class_devi
extern int class_device_create_file(struct class_device *,
const struct class_device_attribute *);

+/**
+ * struct class_device - class devices
+ * @class: pointer to the parent class for this class device. This is required.
+ * @devt: for internal use by the driver core only.
+ * @node: for internal use by the driver core only.
+ * @kobj: for internal use by the driver core only.
+ * @devt_attr: for internal use by the driver core only.
+ * @dev: if set, a symlink to the struct device is created in the sysfs
+ * directory for this struct class device.
+ * @class_data: pointer to whatever you want to store here for this struct
+ * class_device. Use class_get_devdata() and class_set_devdata() to get and
+ * set this pointer.
+ * @parent: pointer to a struct class_device that is the parent of this struct
+ * class_device. If NULL, this class_device will show up at the root of the
+ * struct class in sysfs (which is probably what you want to have happen.)
+ * @release: pointer to a release function for this struct class_device. If
+ * set, this will be called instead of the class specific release function.
+ * Only use this if you want to override the default release function, like
+ * when you are nesting class_device structures.
+ * @hotplug: pointer to a hotplug function for this struct class_device. If
+ * set, this will be called instead of the class specific hotplug function.
+ * Only use this if you want to override the default hotplug function, like
+ * when you are nesting class_device structures.
+ */
struct class_device {
struct list_head node;


2005-10-28 06:39:50

by Greg KH

[permalink] [raw]
Subject: [PATCH] add sysfs attr to re-emit device hotplug event

[PATCH] add sysfs attr to re-emit device hotplug event

A "coldplug + udevstart" can be simple like this:
for i in /sys/block/*/*/uevent; do echo 1 > $i; done
for i in /sys/class/*/*/uevent; do echo 1 > $i; done
for i in /sys/bus/*/devices/*/uevent; do echo 1 > $i; done

Signed-off-by: Kay Sievers <[email protected]>
Signed-off-by: Greg Kroah-Hartman <[email protected]>

---
commit d54bc6daa47cc8821fee219877916b32119ab919
tree 10276fc0e96b02d7afb906dcef19737d935d0828
parent 6f5ace97359fa038cffb977dcf057764197f0df5
author Kay Sievers <[email protected]> Sat, 01 Oct 2005 14:49:43 +0200
committer Greg Kroah-Hartman <[email protected]> Thu, 27 Oct 2005 22:48:00 -0700

drivers/base/class.c | 16 ++++++++++++-
drivers/base/core.c | 16 +++++++++++++
drivers/block/genhd.c | 25 +++++++++++++++++++++
fs/partitions/check.c | 27 ++++++++++++++++++++++-
include/linux/device.h | 57 ++++++++++++++++++++++++------------------------
include/linux/genhd.h | 1 +
6 files changed, 110 insertions(+), 32 deletions(-)

diff --git a/drivers/base/class.c b/drivers/base/class.c
index 73d44cf..3cf6eb3 100644
--- a/drivers/base/class.c
+++ b/drivers/base/class.c
@@ -442,6 +442,13 @@ static ssize_t show_dev(struct class_dev
return print_dev_t(buf, class_dev->devt);
}

+static ssize_t store_uevent(struct class_device *class_dev,
+ const char *buf, size_t count)
+{
+ kobject_hotplug(&class_dev->kobj, KOBJ_ADD);
+ return count;
+}
+
void class_device_initialize(struct class_device *class_dev)
{
kobj_set_kset_s(class_dev, class_obj_subsys);
@@ -497,6 +504,12 @@ int class_device_add(struct class_device
goto register_done;

/* add the needed attributes to this device */
+ class_dev->uevent_attr.attr.name = "uevent";
+ class_dev->uevent_attr.attr.mode = S_IWUSR;
+ class_dev->uevent_attr.attr.owner = parent->owner;
+ class_dev->uevent_attr.store = store_uevent;
+ class_device_create_file(class_dev, &class_dev->uevent_attr);
+
if (MAJOR(class_dev->devt)) {
struct class_device_attribute *attr;
attr = kzalloc(sizeof(*attr), GFP_KERNEL);
@@ -505,12 +518,10 @@ int class_device_add(struct class_device
kobject_del(&class_dev->kobj);
goto register_done;
}
-
attr->attr.name = "dev";
attr->attr.mode = S_IRUGO;
attr->attr.owner = parent->owner;
attr->show = show_dev;
- attr->store = NULL;
class_device_create_file(class_dev, attr);
class_dev->devt_attr = attr;
}
@@ -621,6 +632,7 @@ void class_device_del(struct class_devic
sysfs_remove_link(&class_dev->kobj, "device");
sysfs_remove_link(&class_dev->dev->kobj, class_name);
}
+ class_device_remove_file(class_dev, &class_dev->uevent_attr);
if (class_dev->devt_attr)
class_device_remove_file(class_dev, class_dev->devt_attr);
class_device_remove_attrs(class_dev);
diff --git a/drivers/base/core.c b/drivers/base/core.c
index 3110919..ac4b5fd 100644
--- a/drivers/base/core.c
+++ b/drivers/base/core.c
@@ -154,6 +154,13 @@ static struct kset_hotplug_ops device_ho
.hotplug = dev_hotplug,
};

+static ssize_t store_uevent(struct device *dev, struct device_attribute *attr,
+ const char *buf, size_t count)
+{
+ kobject_hotplug(&dev->kobj, KOBJ_ADD);
+ return count;
+}
+
/**
* device_subsys - structure to be registered with kobject core.
*/
@@ -259,6 +266,14 @@ int device_add(struct device *dev)

if ((error = kobject_add(&dev->kobj)))
goto Error;
+
+ dev->uevent_attr.attr.name = "uevent";
+ dev->uevent_attr.attr.mode = S_IWUSR;
+ if (dev->driver)
+ dev->uevent_attr.attr.owner = dev->driver->owner;
+ dev->uevent_attr.store = store_uevent;
+ device_create_file(dev, &dev->uevent_attr);
+
kobject_hotplug(&dev->kobj, KOBJ_ADD);
if ((error = device_pm_add(dev)))
goto PMError;
@@ -350,6 +365,7 @@ void device_del(struct device * dev)

if (parent)
klist_del(&dev->knode_parent);
+ device_remove_file(dev, &dev->uevent_attr);

/* Notify the platform of the removal, in case they
* need to do anything...
diff --git a/drivers/block/genhd.c b/drivers/block/genhd.c
index d42840c..486ce1f 100644
--- a/drivers/block/genhd.c
+++ b/drivers/block/genhd.c
@@ -337,10 +337,30 @@ static ssize_t disk_attr_show(struct kob
return ret;
}

+static ssize_t disk_attr_store(struct kobject * kobj, struct attribute * attr,
+ const char *page, size_t count)
+{
+ struct gendisk *disk = to_disk(kobj);
+ struct disk_attribute *disk_attr =
+ container_of(attr,struct disk_attribute,attr);
+ ssize_t ret = 0;
+
+ if (disk_attr->store)
+ ret = disk_attr->store(disk, page, count);
+ return ret;
+}
+
static struct sysfs_ops disk_sysfs_ops = {
.show = &disk_attr_show,
+ .store = &disk_attr_store,
};

+static ssize_t disk_uevent_store(struct gendisk * disk,
+ const char *buf, size_t count)
+{
+ kobject_hotplug(&disk->kobj, KOBJ_ADD);
+ return count;
+}
static ssize_t disk_dev_read(struct gendisk * disk, char *page)
{
dev_t base = MKDEV(disk->major, disk->first_minor);
@@ -382,6 +402,10 @@ static ssize_t disk_stats_read(struct ge
jiffies_to_msecs(disk_stat_read(disk, io_ticks)),
jiffies_to_msecs(disk_stat_read(disk, time_in_queue)));
}
+static struct disk_attribute disk_attr_uevent = {
+ .attr = {.name = "uevent", .mode = S_IWUSR },
+ .store = disk_uevent_store
+};
static struct disk_attribute disk_attr_dev = {
.attr = {.name = "dev", .mode = S_IRUGO },
.show = disk_dev_read
@@ -404,6 +428,7 @@ static struct disk_attribute disk_attr_s
};

static struct attribute * default_attrs[] = {
+ &disk_attr_uevent.attr,
&disk_attr_dev.attr,
&disk_attr_range.attr,
&disk_attr_removable.attr,
diff --git a/fs/partitions/check.c b/fs/partitions/check.c
index 77e178f..d95a110 100644
--- a/fs/partitions/check.c
+++ b/fs/partitions/check.c
@@ -192,6 +192,7 @@ check_partition(struct gendisk *hd, stru
struct part_attribute {
struct attribute attr;
ssize_t (*show)(struct hd_struct *,char *);
+ ssize_t (*store)(struct hd_struct *,const char *, size_t);
};

static ssize_t
@@ -201,14 +202,33 @@ part_attr_show(struct kobject * kobj, st
struct part_attribute * part_attr = container_of(attr,struct part_attribute,attr);
ssize_t ret = 0;
if (part_attr->show)
- ret = part_attr->show(p,page);
+ ret = part_attr->show(p, page);
+ return ret;
+}
+static ssize_t
+part_attr_store(struct kobject * kobj, struct attribute * attr,
+ const char *page, size_t count)
+{
+ struct hd_struct * p = container_of(kobj,struct hd_struct,kobj);
+ struct part_attribute * part_attr = container_of(attr,struct part_attribute,attr);
+ ssize_t ret = 0;
+
+ if (part_attr->store)
+ ret = part_attr->store(p, page, count);
return ret;
}

static struct sysfs_ops part_sysfs_ops = {
.show = part_attr_show,
+ .store = part_attr_store,
};

+static ssize_t part_uevent_store(struct hd_struct * p,
+ const char *page, size_t count)
+{
+ kobject_hotplug(&p->kobj, KOBJ_ADD);
+ return count;
+}
static ssize_t part_dev_read(struct hd_struct * p, char *page)
{
struct gendisk *disk = container_of(p->kobj.parent,struct gendisk,kobj);
@@ -229,6 +249,10 @@ static ssize_t part_stat_read(struct hd_
p->reads, (unsigned long long)p->read_sectors,
p->writes, (unsigned long long)p->write_sectors);
}
+static struct part_attribute part_attr_uevent = {
+ .attr = {.name = "uevent", .mode = S_IWUSR },
+ .store = part_uevent_store
+};
static struct part_attribute part_attr_dev = {
.attr = {.name = "dev", .mode = S_IRUGO },
.show = part_dev_read
@@ -247,6 +271,7 @@ static struct part_attribute part_attr_s
};

static struct attribute * default_attrs[] = {
+ &part_attr_uevent.attr,
&part_attr_dev.attr,
&part_attr_start.attr,
&part_attr_size.attr,
diff --git a/include/linux/device.h b/include/linux/device.h
index a53a822..e86a580 100644
--- a/include/linux/device.h
+++ b/include/linux/device.h
@@ -190,6 +190,18 @@ struct class_attribute class_attr_##_nam
extern int class_create_file(struct class *, const struct class_attribute *);
extern void class_remove_file(struct class *, const struct class_attribute *);

+struct class_device_attribute {
+ struct attribute attr;
+ ssize_t (*show)(struct class_device *, char * buf);
+ ssize_t (*store)(struct class_device *, const char * buf, size_t count);
+};
+
+#define CLASS_DEVICE_ATTR(_name,_mode,_show,_store) \
+struct class_device_attribute class_device_attr_##_name = \
+ __ATTR(_name,_mode,_show,_store)
+
+extern int class_device_create_file(struct class_device *,
+ const struct class_device_attribute *);

struct class_device {
struct list_head node;
@@ -198,6 +210,7 @@ struct class_device {
struct class * class; /* required */
dev_t devt; /* dev_t, creates the sysfs "dev" */
struct class_device_attribute *devt_attr;
+ struct class_device_attribute uevent_attr;
struct device * dev; /* not necessary, but nice to have */
void * class_data; /* class-specific data */

@@ -228,18 +241,6 @@ extern int class_device_rename(struct cl
extern struct class_device * class_device_get(struct class_device *);
extern void class_device_put(struct class_device *);

-struct class_device_attribute {
- struct attribute attr;
- ssize_t (*show)(struct class_device *, char * buf);
- ssize_t (*store)(struct class_device *, const char * buf, size_t count);
-};
-
-#define CLASS_DEVICE_ATTR(_name,_mode,_show,_store) \
-struct class_device_attribute class_device_attr_##_name = \
- __ATTR(_name,_mode,_show,_store)
-
-extern int class_device_create_file(struct class_device *,
- const struct class_device_attribute *);
extern void class_device_remove_file(struct class_device *,
const struct class_device_attribute *);
extern int class_device_create_bin_file(struct class_device *,
@@ -266,6 +267,20 @@ extern struct class_device *class_device
extern void class_device_destroy(struct class *cls, dev_t devt);


+/* interface for exporting device attributes */
+struct device_attribute {
+ struct attribute attr;
+ ssize_t (*show)(struct device *dev, struct device_attribute *attr,
+ char *buf);
+ ssize_t (*store)(struct device *dev, struct device_attribute *attr,
+ const char *buf, size_t count);
+};
+
+#define DEVICE_ATTR(_name,_mode,_show,_store) \
+struct device_attribute dev_attr_##_name = __ATTR(_name,_mode,_show,_store)
+
+extern int device_create_file(struct device *device, struct device_attribute * entry);
+extern void device_remove_file(struct device * dev, struct device_attribute * attr);
struct device {
struct klist klist_children;
struct klist_node knode_parent; /* node in sibling list */
@@ -275,6 +290,7 @@ struct device {

struct kobject kobj;
char bus_id[BUS_ID_SIZE]; /* position on parent bus */
+ struct device_attribute uevent_attr;

struct semaphore sem; /* semaphore to synchronize calls to
* its driver.
@@ -343,23 +359,6 @@ extern int device_attach(struct device
extern void driver_attach(struct device_driver * drv);


-/* driverfs interface for exporting device attributes */
-
-struct device_attribute {
- struct attribute attr;
- ssize_t (*show)(struct device *dev, struct device_attribute *attr,
- char *buf);
- ssize_t (*store)(struct device *dev, struct device_attribute *attr,
- const char *buf, size_t count);
-};
-
-#define DEVICE_ATTR(_name,_mode,_show,_store) \
-struct device_attribute dev_attr_##_name = __ATTR(_name,_mode,_show,_store)
-
-
-extern int device_create_file(struct device *device, struct device_attribute * entry);
-extern void device_remove_file(struct device * dev, struct device_attribute * attr);
-
/*
* Platform "fixup" functions - allow the platform to have their say
* about devices and actions that the general device layer doesn't
diff --git a/include/linux/genhd.h b/include/linux/genhd.h
index 01796c4..78af348 100644
--- a/include/linux/genhd.h
+++ b/include/linux/genhd.h
@@ -132,6 +132,7 @@ struct gendisk {
struct disk_attribute {
struct attribute attr;
ssize_t (*show)(struct gendisk *, char *);
+ ssize_t (*store)(struct gendisk *, const char *, size_t);
};

/*

2005-10-28 06:42:09

by Greg KH

[permalink] [raw]
Subject: [PATCH] Driver Core: add the ability for class_device structures to be nested

[PATCH] Driver Core: add the ability for class_device structures to be nested

This patch allows struct class_device to be nested, so that another
struct class_device can be the parent of a new one, instead of only
having the struct class be the parent. This will allow us to
(hopefully) fix up the input and video class subsystem mess.

But please people, don't go crazy and start making huge trees of class
devices, you should only need 2 levels deep to get everything to work
(remember to use a class_interface to get notification of a new class
device being added to the system.)

Oh, this also allows us to have the possibility of potentially, someday,
moving /sys/block into /sys/class. The main hindrance is that pesky
/dev numberspace issue...

Signed-off-by: Greg Kroah-Hartman <[email protected]>

---
commit a82c307b63c2e516090c702ed409cb89ef633a1c
tree 51f0bd8fd7cb2204d2d0826f50fc8672b2fe9169
parent d54bc6daa47cc8821fee219877916b32119ab919
author Greg Kroah-Hartman <[email protected]> Thu, 27 Oct 2005 22:25:43 -0700
committer Greg Kroah-Hartman <[email protected]> Thu, 27 Oct 2005 22:48:01 -0700

drivers/base/class.c | 125 +++++++++++++++++++++++++++++++-----------------
include/linux/device.h | 13 ++++-
2 files changed, 91 insertions(+), 47 deletions(-)

diff --git a/drivers/base/class.c b/drivers/base/class.c
index 3cf6eb3..c3e5697 100644
--- a/drivers/base/class.c
+++ b/drivers/base/class.c
@@ -99,7 +99,8 @@ struct class * class_get(struct class *

void class_put(struct class * cls)
{
- subsys_put(&cls->subsys);
+ if (cls)
+ subsys_put(&cls->subsys);
}


@@ -165,14 +166,25 @@ void class_unregister(struct class * cls

static void class_create_release(struct class *cls)
{
+ pr_debug("%s called for %s\n", __FUNCTION__, cls->name);
kfree(cls);
}

static void class_device_create_release(struct class_device *class_dev)
{
+ pr_debug("%s called for %s\n", __FUNCTION__, class_dev->class_id);
kfree(class_dev);
}

+/* needed to allow these devices to have parent class devices */
+static int class_device_create_hotplug(struct class_device *class_dev,
+ char **envp, int num_envp,
+ char *buffer, int buffer_size)
+{
+ pr_debug("%s called for %s\n", __FUNCTION__, class_dev->class_id);
+ return 0;
+}
+
/**
* class_create - create a struct class structure
* @owner: pointer to the module that is to "own" this struct class
@@ -301,10 +313,12 @@ static void class_dev_release(struct kob
kfree(cd->devt_attr);
cd->devt_attr = NULL;

- if (cls->release)
+ if (cd->release)
+ cd->release(cd);
+ else if (cls->release)
cls->release(cd);
else {
- printk(KERN_ERR "Device class '%s' does not have a release() function, "
+ printk(KERN_ERR "Class Device '%s' does not have a release() function, "
"it is broken and must be fixed.\n",
cd->class_id);
WARN_ON(1);
@@ -382,14 +396,18 @@ static int class_hotplug(struct kset *ks
buffer = &buffer[length];
buffer_size -= length;

- if (class_dev->class->hotplug) {
- /* have the bus specific function add its stuff */
- retval = class_dev->class->hotplug (class_dev, envp, num_envp,
- buffer, buffer_size);
- if (retval) {
- pr_debug ("%s - hotplug() returned %d\n",
- __FUNCTION__, retval);
- }
+ if (class_dev->hotplug) {
+ /* have the class device specific function add its stuff */
+ retval = class_dev->hotplug(class_dev, envp, num_envp,
+ buffer, buffer_size);
+ if (retval)
+ pr_debug("class_dev->hotplug() returned %d\n", retval);
+ } else if (class_dev->class->hotplug) {
+ /* have the class specific function add its stuff */
+ retval = class_dev->class->hotplug(class_dev, envp, num_envp,
+ buffer, buffer_size);
+ if (retval)
+ pr_debug("class->hotplug() returned %d\n", retval);
}

return retval;
@@ -476,37 +494,42 @@ static char *make_class_name(struct clas

int class_device_add(struct class_device *class_dev)
{
- struct class * parent = NULL;
- struct class_interface * class_intf;
+ struct class *parent_class = NULL;
+ struct class_device *parent_class_dev = NULL;
+ struct class_interface *class_intf;
char *class_name = NULL;
- int error;
+ int error = -EINVAL;

class_dev = class_device_get(class_dev);
if (!class_dev)
return -EINVAL;

- if (!strlen(class_dev->class_id)) {
- error = -EINVAL;
+ if (!strlen(class_dev->class_id))
goto register_done;
- }

- parent = class_get(class_dev->class);
+ parent_class = class_get(class_dev->class);
+ if (!parent_class)
+ goto register_done;
+ parent_class_dev = class_device_get(class_dev->parent);

pr_debug("CLASS: registering class device: ID = '%s'\n",
class_dev->class_id);

/* first, register with generic layer. */
kobject_set_name(&class_dev->kobj, "%s", class_dev->class_id);
- if (parent)
- class_dev->kobj.parent = &parent->subsys.kset.kobj;
+ if (parent_class_dev)
+ class_dev->kobj.parent = &parent_class_dev->kobj;
+ else
+ class_dev->kobj.parent = &parent_class->subsys.kset.kobj;

- if ((error = kobject_add(&class_dev->kobj)))
+ error = kobject_add(&class_dev->kobj);
+ if (error)
goto register_done;

/* add the needed attributes to this device */
class_dev->uevent_attr.attr.name = "uevent";
class_dev->uevent_attr.attr.mode = S_IWUSR;
- class_dev->uevent_attr.attr.owner = parent->owner;
+ class_dev->uevent_attr.attr.owner = parent_class->owner;
class_dev->uevent_attr.store = store_uevent;
class_device_create_file(class_dev, &class_dev->uevent_attr);

@@ -520,7 +543,7 @@ int class_device_add(struct class_device
}
attr->attr.name = "dev";
attr->attr.mode = S_IRUGO;
- attr->attr.owner = parent->owner;
+ attr->attr.owner = parent_class->owner;
attr->show = show_dev;
class_device_create_file(class_dev, attr);
class_dev->devt_attr = attr;
@@ -538,18 +561,20 @@ int class_device_add(struct class_device
kobject_hotplug(&class_dev->kobj, KOBJ_ADD);

/* notify any interfaces this device is now here */
- if (parent) {
- down(&parent->sem);
- list_add_tail(&class_dev->node, &parent->children);
- list_for_each_entry(class_intf, &parent->interfaces, node)
+ if (parent_class) {
+ down(&parent_class->sem);
+ list_add_tail(&class_dev->node, &parent_class->children);
+ list_for_each_entry(class_intf, &parent_class->interfaces, node)
if (class_intf->add)
class_intf->add(class_dev, class_intf);
- up(&parent->sem);
+ up(&parent_class->sem);
}

register_done:
- if (error && parent)
- class_put(parent);
+ if (error) {
+ class_put(parent_class);
+ class_device_put(parent_class_dev);
+ }
class_device_put(class_dev);
kfree(class_name);
return error;
@@ -564,21 +589,28 @@ int class_device_register(struct class_d
/**
* class_device_create - creates a class device and registers it with sysfs
* @cs: pointer to the struct class that this device should be registered to.
+ * @parent: pointer to the parent struct class_device of this new device, if any.
* @dev: the dev_t for the char device to be added.
* @device: a pointer to a struct device that is assiociated with this class device.
* @fmt: string for the class device's name
*
* This function can be used by char device classes. A struct
* class_device will be created in sysfs, registered to the specified
- * class. A "dev" file will be created, showing the dev_t for the
- * device. The pointer to the struct class_device will be returned from
- * the call. Any further sysfs files that might be required can be
- * created using this pointer.
+ * class.
+ * A "dev" file will be created, showing the dev_t for the device, if
+ * the dev_t is not 0,0.
+ * If a pointer to a parent struct class_device is passed in, the newly
+ * created struct class_device will be a child of that device in sysfs.
+ * The pointer to the struct class_device will be returned from the
+ * call. Any further sysfs files that might be required can be created
+ * using this pointer.
*
* Note: the struct class passed to this function must have previously
* been created with a call to class_create().
*/
-struct class_device *class_device_create(struct class *cls, dev_t devt,
+struct class_device *class_device_create(struct class *cls,
+ struct class_device *parent,
+ dev_t devt,
struct device *device, char *fmt, ...)
{
va_list args;
@@ -597,6 +629,9 @@ struct class_device *class_device_create
class_dev->devt = devt;
class_dev->dev = device;
class_dev->class = cls;
+ class_dev->parent = parent;
+ class_dev->release = class_device_create_release;
+ class_dev->hotplug = class_device_create_hotplug;

va_start(args, fmt);
vsnprintf(class_dev->class_id, BUS_ID_SIZE, fmt, args);
@@ -614,17 +649,18 @@ error:

void class_device_del(struct class_device *class_dev)
{
- struct class * parent = class_dev->class;
- struct class_interface * class_intf;
+ struct class *parent_class = class_dev->class;
+ struct class_device *parent_device = class_dev->parent;
+ struct class_interface *class_intf;
char *class_name = NULL;

- if (parent) {
- down(&parent->sem);
+ if (parent_class) {
+ down(&parent_class->sem);
list_del_init(&class_dev->node);
- list_for_each_entry(class_intf, &parent->interfaces, node)
+ list_for_each_entry(class_intf, &parent_class->interfaces, node)
if (class_intf->remove)
class_intf->remove(class_dev, class_intf);
- up(&parent->sem);
+ up(&parent_class->sem);
}

if (class_dev->dev) {
@@ -640,8 +676,8 @@ void class_device_del(struct class_devic
kobject_hotplug(&class_dev->kobj, KOBJ_REMOVE);
kobject_del(&class_dev->kobj);

- if (parent)
- class_put(parent);
+ class_device_put(parent_device);
+ class_put(parent_class);
kfree(class_name);
}

@@ -721,7 +757,8 @@ struct class_device * class_device_get(s

void class_device_put(struct class_device *class_dev)
{
- kobject_put(&class_dev->kobj);
+ if (class_dev)
+ kobject_put(&class_dev->kobj);
}


diff --git a/include/linux/device.h b/include/linux/device.h
index e86a580..226e550 100644
--- a/include/linux/device.h
+++ b/include/linux/device.h
@@ -213,7 +213,11 @@ struct class_device {
struct class_device_attribute uevent_attr;
struct device * dev; /* not necessary, but nice to have */
void * class_data; /* class-specific data */
+ struct class_device *parent; /* parent of this child device, if there is one */

+ void (*release)(struct class_device *dev);
+ int (*hotplug)(struct class_device *dev, char **envp,
+ int num_envp, char *buffer, int buffer_size);
char class_id[BUS_ID_SIZE]; /* unique to this class */
};

@@ -261,9 +265,12 @@ extern void class_interface_unregister(s

extern struct class *class_create(struct module *owner, char *name);
extern void class_destroy(struct class *cls);
-extern struct class_device *class_device_create(struct class *cls, dev_t devt,
- struct device *device, char *fmt, ...)
- __attribute__((format(printf,4,5)));
+extern struct class_device *class_device_create(struct class *cls,
+ struct class_device *parent,
+ dev_t devt,
+ struct device *device,
+ char *fmt, ...)
+ __attribute__((format(printf,5,6)));
extern void class_device_destroy(struct class *cls, dev_t devt);



2005-10-28 06:43:01

by Greg KH

[permalink] [raw]
Subject: [PATCH] Driver Core: fix up all callers of class_device_create()

[PATCH] Driver Core: fix up all callers of class_device_create()

The previous patch adding the ability to nest struct class_device
changed the paramaters to the call class_device_create(). This patch
fixes up all in-kernel users of the function.

Signed-off-by: Greg Kroah-Hartman <[email protected]>

---
commit c5d4abda2b87357d5ba32b0c8babb532eb75d9c7
tree 0e91246ed9a9a2e8e057e553e6028afbc25bd336
parent a82c307b63c2e516090c702ed409cb89ef633a1c
author Greg Kroah-Hartman <[email protected]> Thu, 27 Oct 2005 22:25:43 -0700
committer Greg Kroah-Hartman <[email protected]> Thu, 27 Oct 2005 22:48:02 -0700

arch/i386/kernel/cpuid.c | 2 +-
arch/i386/kernel/msr.c | 2 +-
drivers/block/aoe/aoechr.c | 2 +-
drivers/block/paride/pg.c | 2 +-
drivers/block/paride/pt.c | 4 ++--
drivers/char/dsp56k.c | 2 +-
drivers/char/ftape/zftape/zftape-init.c | 12 ++++++------
drivers/char/ip2main.c | 10 ++++++----
drivers/char/ipmi/ipmi_devintf.c | 2 +-
drivers/char/istallion.c | 3 ++-
drivers/char/lp.c | 2 +-
drivers/char/mem.c | 3 ++-
drivers/char/misc.c | 2 +-
drivers/char/ppdev.c | 2 +-
drivers/char/raw.c | 4 ++--
drivers/char/snsc.c | 2 +-
drivers/char/stallion.c | 4 +++-
drivers/char/tipar.c | 2 +-
drivers/char/tty_io.c | 10 +++++-----
drivers/char/vc_screen.c | 10 ++++++----
drivers/char/viotape.c | 4 ++--
drivers/hwmon/hwmon.c | 2 +-
drivers/ide/ide-tape.c | 4 ++--
drivers/ieee1394/dv1394.c | 2 +-
drivers/ieee1394/raw1394.c | 2 +-
drivers/ieee1394/video1394.c | 2 +-
drivers/infiniband/core/ucm.c | 2 +-
drivers/input/evdev.c | 2 +-
drivers/input/joydev.c | 2 +-
drivers/input/mousedev.c | 4 ++--
drivers/input/tsdev.c | 2 +-
drivers/isdn/capi/capi.c | 2 +-
drivers/macintosh/adb.c | 2 +-
drivers/media/dvb/dvb-core/dvbdev.c | 2 +-
drivers/message/i2o/iop.c | 2 +-
drivers/mtd/mtdchar.c | 4 ++--
drivers/net/ppp_generic.c | 2 +-
drivers/net/wan/cosa.c | 2 +-
drivers/s390/char/tape_class.c | 1 +
drivers/s390/char/vmlogrdr.c | 1 +
drivers/scsi/ch.c | 2 +-
drivers/scsi/osst.c | 2 +-
drivers/scsi/sg.c | 2 +-
drivers/scsi/st.c | 2 +-
drivers/usb/core/devio.c | 2 +-
drivers/usb/core/file.c | 4 +++-
drivers/usb/core/hcd.c | 3 ++-
drivers/video/fbmem.c | 2 +-
fs/coda/psdev.c | 4 ++--
sound/core/sound.c | 2 +-
sound/oss/soundcard.c | 4 ++--
sound/sound_core.c | 2 +-
52 files changed, 86 insertions(+), 73 deletions(-)

diff --git a/arch/i386/kernel/cpuid.c b/arch/i386/kernel/cpuid.c
index 4647db4..13bae79 100644
--- a/arch/i386/kernel/cpuid.c
+++ b/arch/i386/kernel/cpuid.c
@@ -163,7 +163,7 @@ static int cpuid_class_device_create(int
int err = 0;
struct class_device *class_err;

- class_err = class_device_create(cpuid_class, MKDEV(CPUID_MAJOR, i), NULL, "cpu%d",i);
+ class_err = class_device_create(cpuid_class, NULL, MKDEV(CPUID_MAJOR, i), NULL, "cpu%d",i);
if (IS_ERR(class_err))
err = PTR_ERR(class_err);
return err;
diff --git a/arch/i386/kernel/msr.c b/arch/i386/kernel/msr.c
index 03100d6..44470fe 100644
--- a/arch/i386/kernel/msr.c
+++ b/arch/i386/kernel/msr.c
@@ -246,7 +246,7 @@ static int msr_class_device_create(int i
int err = 0;
struct class_device *class_err;

- class_err = class_device_create(msr_class, MKDEV(MSR_MAJOR, i), NULL, "msr%d",i);
+ class_err = class_device_create(msr_class, NULL, MKDEV(MSR_MAJOR, i), NULL, "msr%d",i);
if (IS_ERR(class_err))
err = PTR_ERR(class_err);
return err;
diff --git a/drivers/block/aoe/aoechr.c b/drivers/block/aoe/aoechr.c
index 45a2430..41ae0ed 100644
--- a/drivers/block/aoe/aoechr.c
+++ b/drivers/block/aoe/aoechr.c
@@ -224,7 +224,7 @@ aoechr_init(void)
return PTR_ERR(aoe_class);
}
for (i = 0; i < ARRAY_SIZE(chardevs); ++i)
- class_device_create(aoe_class,
+ class_device_create(aoe_class, NULL,
MKDEV(AOE_MAJOR, chardevs[i].minor),
NULL, chardevs[i].name);

diff --git a/drivers/block/paride/pg.c b/drivers/block/paride/pg.c
index b398239..82f2d6d 100644
--- a/drivers/block/paride/pg.c
+++ b/drivers/block/paride/pg.c
@@ -674,7 +674,7 @@ static int __init pg_init(void)
for (unit = 0; unit < PG_UNITS; unit++) {
struct pg *dev = &devices[unit];
if (dev->present) {
- class_device_create(pg_class, MKDEV(major, unit),
+ class_device_create(pg_class, NULL, MKDEV(major, unit),
NULL, "pg%u", unit);
err = devfs_mk_cdev(MKDEV(major, unit),
S_IFCHR | S_IRUSR | S_IWUSR, "pg/%u",
diff --git a/drivers/block/paride/pt.c b/drivers/block/paride/pt.c
index d8d3523..686c955 100644
--- a/drivers/block/paride/pt.c
+++ b/drivers/block/paride/pt.c
@@ -971,7 +971,7 @@ static int __init pt_init(void)
devfs_mk_dir("pt");
for (unit = 0; unit < PT_UNITS; unit++)
if (pt[unit].present) {
- class_device_create(pt_class, MKDEV(major, unit),
+ class_device_create(pt_class, NULL, MKDEV(major, unit),
NULL, "pt%d", unit);
err = devfs_mk_cdev(MKDEV(major, unit),
S_IFCHR | S_IRUSR | S_IWUSR,
@@ -980,7 +980,7 @@ static int __init pt_init(void)
class_device_destroy(pt_class, MKDEV(major, unit));
goto out_class;
}
- class_device_create(pt_class, MKDEV(major, unit + 128),
+ class_device_create(pt_class, NULL, MKDEV(major, unit + 128),
NULL, "pt%dn", unit);
err = devfs_mk_cdev(MKDEV(major, unit + 128),
S_IFCHR | S_IRUSR | S_IWUSR,
diff --git a/drivers/char/dsp56k.c b/drivers/char/dsp56k.c
index 26271e3..8693835 100644
--- a/drivers/char/dsp56k.c
+++ b/drivers/char/dsp56k.c
@@ -515,7 +515,7 @@ static int __init dsp56k_init_driver(voi
err = PTR_ERR(dsp56k_class);
goto out_chrdev;
}
- class_device_create(dsp56k_class, MKDEV(DSP56K_MAJOR, 0), NULL, "dsp56k");
+ class_device_create(dsp56k_class, NULL, MKDEV(DSP56K_MAJOR, 0), NULL, "dsp56k");

err = devfs_mk_cdev(MKDEV(DSP56K_MAJOR, 0),
S_IFCHR | S_IRUSR | S_IWUSR, "dsp56k");
diff --git a/drivers/char/ftape/zftape/zftape-init.c b/drivers/char/ftape/zftape/zftape-init.c
index 5745b74..821357c 100644
--- a/drivers/char/ftape/zftape/zftape-init.c
+++ b/drivers/char/ftape/zftape/zftape-init.c
@@ -331,27 +331,27 @@ KERN_INFO

zft_class = class_create(THIS_MODULE, "zft");
for (i = 0; i < 4; i++) {
- class_device_create(zft_class, MKDEV(QIC117_TAPE_MAJOR, i), NULL, "qft%i", i);
+ class_device_create(zft_class, NULL, MKDEV(QIC117_TAPE_MAJOR, i), NULL, "qft%i", i);
devfs_mk_cdev(MKDEV(QIC117_TAPE_MAJOR, i),
S_IFCHR | S_IRUSR | S_IWUSR,
"qft%i", i);
- class_device_create(zft_class, MKDEV(QIC117_TAPE_MAJOR, i + 4), NULL, "nqft%i", i);
+ class_device_create(zft_class, NULL, MKDEV(QIC117_TAPE_MAJOR, i + 4), NULL, "nqft%i", i);
devfs_mk_cdev(MKDEV(QIC117_TAPE_MAJOR, i + 4),
S_IFCHR | S_IRUSR | S_IWUSR,
"nqft%i", i);
- class_device_create(zft_class, MKDEV(QIC117_TAPE_MAJOR, i + 16), NULL, "zqft%i", i);
+ class_device_create(zft_class, NULL, MKDEV(QIC117_TAPE_MAJOR, i + 16), NULL, "zqft%i", i);
devfs_mk_cdev(MKDEV(QIC117_TAPE_MAJOR, i + 16),
S_IFCHR | S_IRUSR | S_IWUSR,
"zqft%i", i);
- class_device_create(zft_class, MKDEV(QIC117_TAPE_MAJOR, i + 20), NULL, "nzqft%i", i);
+ class_device_create(zft_class, NULL, MKDEV(QIC117_TAPE_MAJOR, i + 20), NULL, "nzqft%i", i);
devfs_mk_cdev(MKDEV(QIC117_TAPE_MAJOR, i + 20),
S_IFCHR | S_IRUSR | S_IWUSR,
"nzqft%i", i);
- class_device_create(zft_class, MKDEV(QIC117_TAPE_MAJOR, i + 32), NULL, "rawqft%i", i);
+ class_device_create(zft_class, NULL, MKDEV(QIC117_TAPE_MAJOR, i + 32), NULL, "rawqft%i", i);
devfs_mk_cdev(MKDEV(QIC117_TAPE_MAJOR, i + 32),
S_IFCHR | S_IRUSR | S_IWUSR,
"rawqft%i", i);
- class_device_create(zft_class, MKDEV(QIC117_TAPE_MAJOR, i + 36), NULL, "nrawrawqft%i", i);
+ class_device_create(zft_class, NULL, MKDEV(QIC117_TAPE_MAJOR, i + 36), NULL, "nrawrawqft%i", i);
devfs_mk_cdev(MKDEV(QIC117_TAPE_MAJOR, i + 36),
S_IFCHR | S_IRUSR | S_IWUSR,
"nrawqft%i", i);
diff --git a/drivers/char/ip2main.c b/drivers/char/ip2main.c
index 9e4e26a..d815d19 100644
--- a/drivers/char/ip2main.c
+++ b/drivers/char/ip2main.c
@@ -721,8 +721,9 @@ ip2_loadmain(int *iop, int *irqp, unsign
}

if ( NULL != ( pB = i2BoardPtrTable[i] ) ) {
- class_device_create(ip2_class, MKDEV(IP2_IPL_MAJOR,
- 4 * i), NULL, "ipl%d", i);
+ class_device_create(ip2_class, NULL,
+ MKDEV(IP2_IPL_MAJOR, 4 * i),
+ NULL, "ipl%d", i);
err = devfs_mk_cdev(MKDEV(IP2_IPL_MAJOR, 4 * i),
S_IRUSR | S_IWUSR | S_IRGRP | S_IFCHR,
"ip2/ipl%d", i);
@@ -732,8 +733,9 @@ ip2_loadmain(int *iop, int *irqp, unsign
goto out_class;
}

- class_device_create(ip2_class, MKDEV(IP2_IPL_MAJOR,
- 4 * i + 1), NULL, "stat%d", i);
+ class_device_create(ip2_class, NULL,
+ MKDEV(IP2_IPL_MAJOR, 4 * i + 1),
+ NULL, "stat%d", i);
err = devfs_mk_cdev(MKDEV(IP2_IPL_MAJOR, 4 * i + 1),
S_IRUSR | S_IWUSR | S_IRGRP | S_IFCHR,
"ip2/stat%d", i);
diff --git a/drivers/char/ipmi/ipmi_devintf.c b/drivers/char/ipmi/ipmi_devintf.c
index a09ff10..7c0684d 100644
--- a/drivers/char/ipmi/ipmi_devintf.c
+++ b/drivers/char/ipmi/ipmi_devintf.c
@@ -798,7 +798,7 @@ static void ipmi_new_smi(int if_num)
devfs_mk_cdev(dev, S_IFCHR | S_IRUSR | S_IWUSR,
"ipmidev/%d", if_num);

- class_device_create(ipmi_class, dev, NULL, "ipmi%d", if_num);
+ class_device_create(ipmi_class, NULL, dev, NULL, "ipmi%d", if_num);
}

static void ipmi_smi_gone(int if_num)
diff --git a/drivers/char/istallion.c b/drivers/char/istallion.c
index 9c19e54..e3ddbdb 100644
--- a/drivers/char/istallion.c
+++ b/drivers/char/istallion.c
@@ -5246,7 +5246,8 @@ int __init stli_init(void)
devfs_mk_cdev(MKDEV(STL_SIOMEMMAJOR, i),
S_IFCHR | S_IRUSR | S_IWUSR,
"staliomem/%d", i);
- class_device_create(istallion_class, MKDEV(STL_SIOMEMMAJOR, i),
+ class_device_create(istallion_class, NULL,
+ MKDEV(STL_SIOMEMMAJOR, i),
NULL, "staliomem%d", i);
}

diff --git a/drivers/char/lp.c b/drivers/char/lp.c
index 2afb903..e572605 100644
--- a/drivers/char/lp.c
+++ b/drivers/char/lp.c
@@ -805,7 +805,7 @@ static int lp_register(int nr, struct pa
if (reset)
lp_reset(nr);

- class_device_create(lp_class, MKDEV(LP_MAJOR, nr), NULL,
+ class_device_create(lp_class, NULL, MKDEV(LP_MAJOR, nr), NULL,
"lp%d", nr);
devfs_mk_cdev(MKDEV(LP_MAJOR, nr), S_IFCHR | S_IRUGO | S_IWUGO,
"printers/%d", nr);
diff --git a/drivers/char/mem.c b/drivers/char/mem.c
index f182752..38be4b0 100644
--- a/drivers/char/mem.c
+++ b/drivers/char/mem.c
@@ -920,7 +920,8 @@ static int __init chr_dev_init(void)

mem_class = class_create(THIS_MODULE, "mem");
for (i = 0; i < ARRAY_SIZE(devlist); i++) {
- class_device_create(mem_class, MKDEV(MEM_MAJOR, devlist[i].minor),
+ class_device_create(mem_class, NULL,
+ MKDEV(MEM_MAJOR, devlist[i].minor),
NULL, devlist[i].name);
devfs_mk_cdev(MKDEV(MEM_MAJOR, devlist[i].minor),
S_IFCHR | devlist[i].mode, devlist[i].name);
diff --git a/drivers/char/misc.c b/drivers/char/misc.c
index 0c83751..3e4c041 100644
--- a/drivers/char/misc.c
+++ b/drivers/char/misc.c
@@ -234,7 +234,7 @@ int misc_register(struct miscdevice * mi
}
dev = MKDEV(MISC_MAJOR, misc->minor);

- misc->class = class_device_create(misc_class, dev, misc->dev,
+ misc->class = class_device_create(misc_class, NULL, dev, misc->dev,
"%s", misc->name);
if (IS_ERR(misc->class)) {
err = PTR_ERR(misc->class);
diff --git a/drivers/char/ppdev.c b/drivers/char/ppdev.c
index 0e22880..306ee0f 100644
--- a/drivers/char/ppdev.c
+++ b/drivers/char/ppdev.c
@@ -752,7 +752,7 @@ static struct file_operations pp_fops =

static void pp_attach(struct parport *port)
{
- class_device_create(ppdev_class, MKDEV(PP_MAJOR, port->number),
+ class_device_create(ppdev_class, NULL, MKDEV(PP_MAJOR, port->number),
NULL, "parport%d", port->number);
}

diff --git a/drivers/char/raw.c b/drivers/char/raw.c
index f13e5de..30e4cbe 100644
--- a/drivers/char/raw.c
+++ b/drivers/char/raw.c
@@ -128,7 +128,7 @@ raw_ioctl(struct inode *inode, struct fi
static void bind_device(struct raw_config_request *rq)
{
class_device_destroy(raw_class, MKDEV(RAW_MAJOR, rq->raw_minor));
- class_device_create(raw_class, MKDEV(RAW_MAJOR, rq->raw_minor),
+ class_device_create(raw_class, NULL, MKDEV(RAW_MAJOR, rq->raw_minor),
NULL, "raw%d", rq->raw_minor);
}

@@ -307,7 +307,7 @@ static int __init raw_init(void)
unregister_chrdev_region(dev, MAX_RAW_MINORS);
goto error;
}
- class_device_create(raw_class, MKDEV(RAW_MAJOR, 0), NULL, "rawctl");
+ class_device_create(raw_class, NULL, MKDEV(RAW_MAJOR, 0), NULL, "rawctl");

devfs_mk_cdev(MKDEV(RAW_MAJOR, 0),
S_IFCHR | S_IRUGO | S_IWUGO,
diff --git a/drivers/char/snsc.c b/drivers/char/snsc.c
index 261a41b..1758a83 100644
--- a/drivers/char/snsc.c
+++ b/drivers/char/snsc.c
@@ -437,7 +437,7 @@ scdrv_init(void)
continue;
}

- class_device_create(snsc_class, dev, NULL,
+ class_device_create(snsc_class, NULL, dev, NULL,
"%s", devname);

ia64_sn_irtr_intr_enable(scd->scd_nasid,
diff --git a/drivers/char/stallion.c b/drivers/char/stallion.c
index 951545a..1c68641 100644
--- a/drivers/char/stallion.c
+++ b/drivers/char/stallion.c
@@ -3095,7 +3095,9 @@ static int __init stl_init(void)
devfs_mk_cdev(MKDEV(STL_SIOMEMMAJOR, i),
S_IFCHR|S_IRUSR|S_IWUSR,
"staliomem/%d", i);
- class_device_create(stallion_class, MKDEV(STL_SIOMEMMAJOR, i), NULL, "staliomem%d", i);
+ class_device_create(stallion_class, NULL,
+ MKDEV(STL_SIOMEMMAJOR, i), NULL,
+ "staliomem%d", i);
}

stl_serial->owner = THIS_MODULE;
diff --git a/drivers/char/tipar.c b/drivers/char/tipar.c
index ec78d2f..41a94bc 100644
--- a/drivers/char/tipar.c
+++ b/drivers/char/tipar.c
@@ -436,7 +436,7 @@ tipar_register(int nr, struct parport *p
goto out;
}

- class_device_create(tipar_class, MKDEV(TIPAR_MAJOR,
+ class_device_create(tipar_class, NULL, MKDEV(TIPAR_MAJOR,
TIPAR_MINOR + nr), NULL, "par%d", nr);
/* Use devfs, tree: /dev/ticables/par/[0..2] */
err = devfs_mk_cdev(MKDEV(TIPAR_MAJOR, TIPAR_MINOR + nr),
diff --git a/drivers/char/tty_io.c b/drivers/char/tty_io.c
index e5953f3..f5649a3 100644
--- a/drivers/char/tty_io.c
+++ b/drivers/char/tty_io.c
@@ -2728,7 +2728,7 @@ void tty_register_device(struct tty_driv
pty_line_name(driver, index, name);
else
tty_line_name(driver, index, name);
- class_device_create(tty_class, dev, device, name);
+ class_device_create(tty_class, NULL, dev, device, "%s", name);
}

/**
@@ -2983,14 +2983,14 @@ static int __init tty_init(void)
register_chrdev_region(MKDEV(TTYAUX_MAJOR, 0), 1, "/dev/tty") < 0)
panic("Couldn't register /dev/tty driver\n");
devfs_mk_cdev(MKDEV(TTYAUX_MAJOR, 0), S_IFCHR|S_IRUGO|S_IWUGO, "tty");
- class_device_create(tty_class, MKDEV(TTYAUX_MAJOR, 0), NULL, "tty");
+ class_device_create(tty_class, NULL, MKDEV(TTYAUX_MAJOR, 0), NULL, "tty");

cdev_init(&console_cdev, &console_fops);
if (cdev_add(&console_cdev, MKDEV(TTYAUX_MAJOR, 1), 1) ||
register_chrdev_region(MKDEV(TTYAUX_MAJOR, 1), 1, "/dev/console") < 0)
panic("Couldn't register /dev/console driver\n");
devfs_mk_cdev(MKDEV(TTYAUX_MAJOR, 1), S_IFCHR|S_IRUSR|S_IWUSR, "console");
- class_device_create(tty_class, MKDEV(TTYAUX_MAJOR, 1), NULL, "console");
+ class_device_create(tty_class, NULL, MKDEV(TTYAUX_MAJOR, 1), NULL, "console");

#ifdef CONFIG_UNIX98_PTYS
cdev_init(&ptmx_cdev, &ptmx_fops);
@@ -2998,7 +2998,7 @@ static int __init tty_init(void)
register_chrdev_region(MKDEV(TTYAUX_MAJOR, 2), 1, "/dev/ptmx") < 0)
panic("Couldn't register /dev/ptmx driver\n");
devfs_mk_cdev(MKDEV(TTYAUX_MAJOR, 2), S_IFCHR|S_IRUGO|S_IWUGO, "ptmx");
- class_device_create(tty_class, MKDEV(TTYAUX_MAJOR, 2), NULL, "ptmx");
+ class_device_create(tty_class, NULL, MKDEV(TTYAUX_MAJOR, 2), NULL, "ptmx");
#endif

#ifdef CONFIG_VT
@@ -3007,7 +3007,7 @@ static int __init tty_init(void)
register_chrdev_region(MKDEV(TTY_MAJOR, 0), 1, "/dev/vc/0") < 0)
panic("Couldn't register /dev/tty0 driver\n");
devfs_mk_cdev(MKDEV(TTY_MAJOR, 0), S_IFCHR|S_IRUSR|S_IWUSR, "vc/0");
- class_device_create(tty_class, MKDEV(TTY_MAJOR, 0), NULL, "tty0");
+ class_device_create(tty_class, NULL, MKDEV(TTY_MAJOR, 0), NULL, "tty0");

vty_init();
#endif
diff --git a/drivers/char/vc_screen.c b/drivers/char/vc_screen.c
index 79c2928..f66c7ad 100644
--- a/drivers/char/vc_screen.c
+++ b/drivers/char/vc_screen.c
@@ -484,8 +484,10 @@ void vcs_make_devfs(struct tty_struct *t
devfs_mk_cdev(MKDEV(VCS_MAJOR, tty->index + 129),
S_IFCHR|S_IRUSR|S_IWUSR,
"vcc/a%u", tty->index + 1);
- class_device_create(vc_class, MKDEV(VCS_MAJOR, tty->index + 1), NULL, "vcs%u", tty->index + 1);
- class_device_create(vc_class, MKDEV(VCS_MAJOR, tty->index + 129), NULL, "vcsa%u", tty->index + 1);
+ class_device_create(vc_class, NULL, MKDEV(VCS_MAJOR, tty->index + 1),
+ NULL, "vcs%u", tty->index + 1);
+ class_device_create(vc_class, NULL, MKDEV(VCS_MAJOR, tty->index + 129),
+ NULL, "vcsa%u", tty->index + 1);
}
void vcs_remove_devfs(struct tty_struct *tty)
{
@@ -503,7 +505,7 @@ int __init vcs_init(void)

devfs_mk_cdev(MKDEV(VCS_MAJOR, 0), S_IFCHR|S_IRUSR|S_IWUSR, "vcc/0");
devfs_mk_cdev(MKDEV(VCS_MAJOR, 128), S_IFCHR|S_IRUSR|S_IWUSR, "vcc/a0");
- class_device_create(vc_class, MKDEV(VCS_MAJOR, 0), NULL, "vcs");
- class_device_create(vc_class, MKDEV(VCS_MAJOR, 128), NULL, "vcsa");
+ class_device_create(vc_class, NULL, MKDEV(VCS_MAJOR, 0), NULL, "vcs");
+ class_device_create(vc_class, NULL, MKDEV(VCS_MAJOR, 128), NULL, "vcsa");
return 0;
}
diff --git a/drivers/char/viotape.c b/drivers/char/viotape.c
index 0aff45f..a5e104f 100644
--- a/drivers/char/viotape.c
+++ b/drivers/char/viotape.c
@@ -956,9 +956,9 @@ static int viotape_probe(struct vio_dev
state[i].cur_part = 0;
for (j = 0; j < MAX_PARTITIONS; ++j)
state[i].part_stat_rwi[j] = VIOT_IDLE;
- class_device_create(tape_class, MKDEV(VIOTAPE_MAJOR, i), NULL,
+ class_device_create(tape_class, NULL, MKDEV(VIOTAPE_MAJOR, i), NULL,
"iseries!vt%d", i);
- class_device_create(tape_class, MKDEV(VIOTAPE_MAJOR, i | 0x80),
+ class_device_create(tape_class, NULL, MKDEV(VIOTAPE_MAJOR, i | 0x80),
NULL, "iseries!nvt%d", i);
devfs_mk_cdev(MKDEV(VIOTAPE_MAJOR, i), S_IFCHR | S_IRUSR | S_IWUSR,
"iseries/vt%d", i);
diff --git a/drivers/hwmon/hwmon.c b/drivers/hwmon/hwmon.c
index 9b41c9b..6f48579 100644
--- a/drivers/hwmon/hwmon.c
+++ b/drivers/hwmon/hwmon.c
@@ -45,7 +45,7 @@ struct class_device *hwmon_device_regist
return ERR_PTR(-ENOMEM);

id = id & MAX_ID_MASK;
- cdev = class_device_create(hwmon_class, MKDEV(0,0), dev,
+ cdev = class_device_create(hwmon_class, NULL, MKDEV(0,0), dev,
HWMON_ID_FORMAT, id);

if (IS_ERR(cdev))
diff --git a/drivers/ide/ide-tape.c b/drivers/ide/ide-tape.c
index 95abe98..47f2b83 100644
--- a/drivers/ide/ide-tape.c
+++ b/drivers/ide/ide-tape.c
@@ -4884,9 +4884,9 @@ static int ide_tape_probe(struct device

idetape_setup(drive, tape, minor);

- class_device_create(idetape_sysfs_class,
+ class_device_create(idetape_sysfs_class, NULL,
MKDEV(IDETAPE_MAJOR, minor), dev, "%s", tape->name);
- class_device_create(idetape_sysfs_class,
+ class_device_create(idetape_sysfs_class, NULL,
MKDEV(IDETAPE_MAJOR, minor + 128), dev, "n%s", tape->name);

devfs_mk_cdev(MKDEV(HWIF(drive)->major, minor),
diff --git a/drivers/ieee1394/dv1394.c b/drivers/ieee1394/dv1394.c
index e34730c..cbbbe14 100644
--- a/drivers/ieee1394/dv1394.c
+++ b/drivers/ieee1394/dv1394.c
@@ -2361,7 +2361,7 @@ static void dv1394_add_host (struct hpsb

ohci = (struct ti_ohci *)host->hostdata;

- class_device_create(hpsb_protocol_class, MKDEV(
+ class_device_create(hpsb_protocol_class, NULL, MKDEV(
IEEE1394_MAJOR, IEEE1394_MINOR_BLOCK_DV1394 * 16 + (id<<2)),
NULL, "dv1394-%d", id);
devfs_mk_dir("ieee1394/dv/host%d", id);
diff --git a/drivers/ieee1394/raw1394.c b/drivers/ieee1394/raw1394.c
index 0470f77..24411e6 100644
--- a/drivers/ieee1394/raw1394.c
+++ b/drivers/ieee1394/raw1394.c
@@ -2912,7 +2912,7 @@ static int __init init_raw1394(void)

hpsb_register_highlevel(&raw1394_highlevel);

- if (IS_ERR(class_device_create(hpsb_protocol_class, MKDEV(
+ if (IS_ERR(class_device_create(hpsb_protocol_class, NULL, MKDEV(
IEEE1394_MAJOR, IEEE1394_MINOR_BLOCK_RAW1394 * 16),
NULL, RAW1394_DEVICE_NAME))) {
ret = -EFAULT;
diff --git a/drivers/ieee1394/video1394.c b/drivers/ieee1394/video1394.c
index 11be9c9..23911da 100644
--- a/drivers/ieee1394/video1394.c
+++ b/drivers/ieee1394/video1394.c
@@ -1370,7 +1370,7 @@ static void video1394_add_host (struct h
hpsb_set_hostinfo_key(&video1394_highlevel, host, ohci->host->id);

minor = IEEE1394_MINOR_BLOCK_VIDEO1394 * 16 + ohci->host->id;
- class_device_create(hpsb_protocol_class, MKDEV(
+ class_device_create(hpsb_protocol_class, NULL, MKDEV(
IEEE1394_MAJOR, minor),
NULL, "%s-%d", VIDEO1394_DRIVER_NAME, ohci->host->id);
devfs_mk_cdev(MKDEV(IEEE1394_MAJOR, minor),
diff --git a/drivers/infiniband/core/ucm.c b/drivers/infiniband/core/ucm.c
index d0f0b0a..021b8f1 100644
--- a/drivers/infiniband/core/ucm.c
+++ b/drivers/infiniband/core/ucm.c
@@ -1300,7 +1300,7 @@ static int __init ib_ucm_init(void)
goto err_class;
}

- class_device_create(ib_ucm_class, IB_UCM_DEV, NULL, "ucm");
+ class_device_create(ib_ucm_class, NULL, IB_UCM_DEV, NULL, "ucm");

idr_init(&ctx_id_table);
init_MUTEX(&ctx_id_mutex);
diff --git a/drivers/input/evdev.c b/drivers/input/evdev.c
index 3738d17..83b694c 100644
--- a/drivers/input/evdev.c
+++ b/drivers/input/evdev.c
@@ -689,7 +689,7 @@ static struct input_handle *evdev_connec

devfs_mk_cdev(MKDEV(INPUT_MAJOR, EVDEV_MINOR_BASE + minor),
S_IFCHR|S_IRUGO|S_IWUSR, "input/event%d", minor);
- class_device_create(input_class,
+ class_device_create(input_class, NULL,
MKDEV(INPUT_MAJOR, EVDEV_MINOR_BASE + minor),
dev->dev, "event%d", minor);

diff --git a/drivers/input/joydev.c b/drivers/input/joydev.c
index e0938d1..c696fb2 100644
--- a/drivers/input/joydev.c
+++ b/drivers/input/joydev.c
@@ -516,7 +516,7 @@ static struct input_handle *joydev_conne

devfs_mk_cdev(MKDEV(INPUT_MAJOR, JOYDEV_MINOR_BASE + minor),
S_IFCHR|S_IRUGO|S_IWUSR, "input/js%d", minor);
- class_device_create(input_class,
+ class_device_create(input_class, NULL,
MKDEV(INPUT_MAJOR, JOYDEV_MINOR_BASE + minor),
dev->dev, "js%d", minor);

diff --git a/drivers/input/mousedev.c b/drivers/input/mousedev.c
index c6194a9..d7144e1 100644
--- a/drivers/input/mousedev.c
+++ b/drivers/input/mousedev.c
@@ -651,7 +651,7 @@ static struct input_handle *mousedev_con

devfs_mk_cdev(MKDEV(INPUT_MAJOR, MOUSEDEV_MINOR_BASE + minor),
S_IFCHR|S_IRUGO|S_IWUSR, "input/mouse%d", minor);
- class_device_create(input_class,
+ class_device_create(input_class, NULL,
MKDEV(INPUT_MAJOR, MOUSEDEV_MINOR_BASE + minor),
dev->dev, "mouse%d", minor);

@@ -740,7 +740,7 @@ static int __init mousedev_init(void)

devfs_mk_cdev(MKDEV(INPUT_MAJOR, MOUSEDEV_MINOR_BASE + MOUSEDEV_MIX),
S_IFCHR|S_IRUGO|S_IWUSR, "input/mice");
- class_device_create(input_class,
+ class_device_create(input_class, NULL,
MKDEV(INPUT_MAJOR, MOUSEDEV_MINOR_BASE + MOUSEDEV_MIX), NULL, "mice");

#ifdef CONFIG_INPUT_MOUSEDEV_PSAUX
diff --git a/drivers/input/tsdev.c b/drivers/input/tsdev.c
index 50c63a1..fbb35c9 100644
--- a/drivers/input/tsdev.c
+++ b/drivers/input/tsdev.c
@@ -414,7 +414,7 @@ static struct input_handle *tsdev_connec
S_IFCHR|S_IRUGO|S_IWUSR, "input/ts%d", minor);
devfs_mk_cdev(MKDEV(INPUT_MAJOR, TSDEV_MINOR_BASE + minor + TSDEV_MINORS/2),
S_IFCHR|S_IRUGO|S_IWUSR, "input/tsraw%d", minor);
- class_device_create(input_class,
+ class_device_create(input_class, NULL,
MKDEV(INPUT_MAJOR, TSDEV_MINOR_BASE + minor),
dev->dev, "ts%d", minor);

diff --git a/drivers/isdn/capi/capi.c b/drivers/isdn/capi/capi.c
index 04fb606..11ae0fd 100644
--- a/drivers/isdn/capi/capi.c
+++ b/drivers/isdn/capi/capi.c
@@ -1505,7 +1505,7 @@ static int __init capi_init(void)
return PTR_ERR(capi_class);
}

- class_device_create(capi_class, MKDEV(capi_major, 0), NULL, "capi");
+ class_device_create(capi_class, NULL, MKDEV(capi_major, 0), NULL, "capi");
devfs_mk_cdev(MKDEV(capi_major, 0), S_IFCHR | S_IRUSR | S_IWUSR,
"isdn/capi20");

diff --git a/drivers/macintosh/adb.c b/drivers/macintosh/adb.c
index c0dc1e3..d2ead17 100644
--- a/drivers/macintosh/adb.c
+++ b/drivers/macintosh/adb.c
@@ -905,5 +905,5 @@ adbdev_init(void)
adb_dev_class = class_create(THIS_MODULE, "adb");
if (IS_ERR(adb_dev_class))
return;
- class_device_create(adb_dev_class, MKDEV(ADB_MAJOR, 0), NULL, "adb");
+ class_device_create(adb_dev_class, NULL, MKDEV(ADB_MAJOR, 0), NULL, "adb");
}
diff --git a/drivers/media/dvb/dvb-core/dvbdev.c b/drivers/media/dvb/dvb-core/dvbdev.c
index 4b7adca..477b4fa 100644
--- a/drivers/media/dvb/dvb-core/dvbdev.c
+++ b/drivers/media/dvb/dvb-core/dvbdev.c
@@ -235,7 +235,7 @@ int dvb_register_device(struct dvb_adapt
S_IFCHR | S_IRUSR | S_IWUSR,
"dvb/adapter%d/%s%d", adap->num, dnames[type], id);

- class_device_create(dvb_class, MKDEV(DVB_MAJOR, nums2minor(adap->num, type, id)),
+ class_device_create(dvb_class, NULL, MKDEV(DVB_MAJOR, nums2minor(adap->num, type, id)),
NULL, "dvb%d.%s%d", adap->num, dnames[type], id);

dprintk("DVB: register adapter%d/%s%d @ minor: %i (0x%02x)\n",
diff --git a/drivers/message/i2o/iop.c b/drivers/message/i2o/iop.c
index 176fb57..361da8d 100644
--- a/drivers/message/i2o/iop.c
+++ b/drivers/message/i2o/iop.c
@@ -1141,7 +1141,7 @@ int i2o_iop_add(struct i2o_controller *c
goto iop_reset;
}

- c->classdev = class_device_create(i2o_controller_class, 0,
+ c->classdev = class_device_create(i2o_controller_class, NULL, MKDEV(0,0),
&c->device, "iop%d", c->unit);
if (IS_ERR(c->classdev)) {
osm_err("%s: could not add controller class\n", c->name);
diff --git a/drivers/mtd/mtdchar.c b/drivers/mtd/mtdchar.c
index 1ed602a..c534fd5 100644
--- a/drivers/mtd/mtdchar.c
+++ b/drivers/mtd/mtdchar.c
@@ -24,10 +24,10 @@ static void mtd_notify_add(struct mtd_in
if (!mtd)
return;

- class_device_create(mtd_class, MKDEV(MTD_CHAR_MAJOR, mtd->index*2),
+ class_device_create(mtd_class, NULL, MKDEV(MTD_CHAR_MAJOR, mtd->index*2),
NULL, "mtd%d", mtd->index);

- class_device_create(mtd_class,
+ class_device_create(mtd_class, NULL,
MKDEV(MTD_CHAR_MAJOR, mtd->index*2+1),
NULL, "mtd%dro", mtd->index);
}
diff --git a/drivers/net/ppp_generic.c b/drivers/net/ppp_generic.c
index 0df7e92..d3c9958 100644
--- a/drivers/net/ppp_generic.c
+++ b/drivers/net/ppp_generic.c
@@ -863,7 +863,7 @@ static int __init ppp_init(void)
err = PTR_ERR(ppp_class);
goto out_chrdev;
}
- class_device_create(ppp_class, MKDEV(PPP_MAJOR, 0), NULL, "ppp");
+ class_device_create(ppp_class, NULL, MKDEV(PPP_MAJOR, 0), NULL, "ppp");
err = devfs_mk_cdev(MKDEV(PPP_MAJOR, 0),
S_IFCHR|S_IRUSR|S_IWUSR, "ppp");
if (err)
diff --git a/drivers/net/wan/cosa.c b/drivers/net/wan/cosa.c
index 7ff814f..ace68e5 100644
--- a/drivers/net/wan/cosa.c
+++ b/drivers/net/wan/cosa.c
@@ -400,7 +400,7 @@ static int __init cosa_init(void)
goto out_chrdev;
}
for (i=0; i<nr_cards; i++) {
- class_device_create(cosa_class, MKDEV(cosa_major, i),
+ class_device_create(cosa_class, NULL, MKDEV(cosa_major, i),
NULL, "cosa%d", i);
err = devfs_mk_cdev(MKDEV(cosa_major, i),
S_IFCHR|S_IRUSR|S_IWUSR,
diff --git a/drivers/s390/char/tape_class.c b/drivers/s390/char/tape_class.c
index ed0cb1f..fcaee44 100644
--- a/drivers/s390/char/tape_class.c
+++ b/drivers/s390/char/tape_class.c
@@ -72,6 +72,7 @@ struct tape_class_device *register_tape_

tcd->class_device = class_device_create(
tape_class,
+ NULL,
tcd->char_device->dev,
device,
"%s", tcd->device_name
diff --git a/drivers/s390/char/vmlogrdr.c b/drivers/s390/char/vmlogrdr.c
index 491f00c..a107fec 100644
--- a/drivers/s390/char/vmlogrdr.c
+++ b/drivers/s390/char/vmlogrdr.c
@@ -787,6 +787,7 @@ vmlogrdr_register_device(struct vmlogrdr
return ret;
}
priv->class_device = class_device_create(
+ NULL,
vmlogrdr_class,
MKDEV(vmlogrdr_major, priv->minor_num),
dev,
diff --git a/drivers/scsi/ch.c b/drivers/scsi/ch.c
index da6e51c..540147c 100644
--- a/drivers/scsi/ch.c
+++ b/drivers/scsi/ch.c
@@ -936,7 +936,7 @@ static int ch_probe(struct device *dev)
if (init)
ch_init_elem(ch);

- class_device_create(ch_sysfs_class,
+ class_device_create(ch_sysfs_class, NULL,
MKDEV(SCSI_CHANGER_MAJOR,ch->minor),
dev, "s%s", ch->name);

diff --git a/drivers/scsi/osst.c b/drivers/scsi/osst.c
index 3f2f246..0bb60de 100644
--- a/drivers/scsi/osst.c
+++ b/drivers/scsi/osst.c
@@ -5627,7 +5627,7 @@ static void osst_sysfs_add(dev_t dev, st

if (!osst_sysfs_valid) return;

- osst_class_member = class_device_create(osst_sysfs_class, dev, device, "%s", name);
+ osst_class_member = class_device_create(osst_sysfs_class, NULL, dev, device, "%s", name);
if (IS_ERR(osst_class_member)) {
printk(KERN_WARNING "osst :W: Unable to add sysfs class member %s\n", name);
return;
diff --git a/drivers/scsi/sg.c b/drivers/scsi/sg.c
index f0d8b4e..40886e1 100644
--- a/drivers/scsi/sg.c
+++ b/drivers/scsi/sg.c
@@ -1550,7 +1550,7 @@ sg_add(struct class_device *cl_dev, stru
if (sg_sysfs_valid) {
struct class_device * sg_class_member;

- sg_class_member = class_device_create(sg_sysfs_class,
+ sg_class_member = class_device_create(sg_sysfs_class, NULL,
MKDEV(SCSI_GENERIC_MAJOR, k),
cl_dev->dev, "%s",
disk->disk_name);
diff --git a/drivers/scsi/st.c b/drivers/scsi/st.c
index d001c04..d45ba48 100644
--- a/drivers/scsi/st.c
+++ b/drivers/scsi/st.c
@@ -4375,7 +4375,7 @@ static void do_create_class_files(struct
snprintf(name, 10, "%s%s%s", rew ? "n" : "",
STp->disk->disk_name, st_formats[i]);
st_class_member =
- class_device_create(st_sysfs_class,
+ class_device_create(st_sysfs_class, NULL,
MKDEV(SCSI_TAPE_MAJOR,
TAPE_MINOR(dev_num, mode, rew)),
&STp->device->sdev_gendev, "%s", name);
diff --git a/drivers/usb/core/devio.c b/drivers/usb/core/devio.c
index 487ff67..befe0c7 100644
--- a/drivers/usb/core/devio.c
+++ b/drivers/usb/core/devio.c
@@ -1509,7 +1509,7 @@ void usbdev_add(struct usb_device *dev)
{
int minor = ((dev->bus->busnum-1) * 128) + (dev->devnum-1);

- dev->class_dev = class_device_create(usb_device_class,
+ dev->class_dev = class_device_create(usb_device_class, NULL,
MKDEV(USB_DEVICE_MAJOR, minor), &dev->dev,
"usbdev%d.%d", dev->bus->busnum, dev->devnum);

diff --git a/drivers/usb/core/file.c b/drivers/usb/core/file.c
index 65ca131..78cb4be 100644
--- a/drivers/usb/core/file.c
+++ b/drivers/usb/core/file.c
@@ -172,7 +172,9 @@ int usb_register_dev(struct usb_interfac
++temp;
else
temp = name;
- intf->class_dev = class_device_create(usb_class, MKDEV(USB_MAJOR, minor), &intf->dev, "%s", temp);
+ intf->class_dev = class_device_create(usb_class, NULL,
+ MKDEV(USB_MAJOR, minor),
+ &intf->dev, "%s", temp);
if (IS_ERR(intf->class_dev)) {
spin_lock (&minor_lock);
usb_minors[intf->minor] = NULL;
diff --git a/drivers/usb/core/hcd.c b/drivers/usb/core/hcd.c
index 1017a97..c3eb66f 100644
--- a/drivers/usb/core/hcd.c
+++ b/drivers/usb/core/hcd.c
@@ -782,7 +782,8 @@ static int usb_register_bus(struct usb_b
return -E2BIG;
}

- bus->class_dev = class_device_create(usb_host_class, MKDEV(0,0), bus->controller, "usb_host%d", busnum);
+ bus->class_dev = class_device_create(usb_host_class, NULL, MKDEV(0,0),
+ bus->controller, "usb_host%d", busnum);
if (IS_ERR(bus->class_dev)) {
clear_bit(busnum, busmap.busmap);
up(&usb_bus_list_lock);
diff --git a/drivers/video/fbmem.c b/drivers/video/fbmem.c
index 70be700..9073be4 100644
--- a/drivers/video/fbmem.c
+++ b/drivers/video/fbmem.c
@@ -1031,7 +1031,7 @@ register_framebuffer(struct fb_info *fb_
break;
fb_info->node = i;

- fb_info->class_device = class_device_create(fb_class, MKDEV(FB_MAJOR, i),
+ fb_info->class_device = class_device_create(fb_class, NULL, MKDEV(FB_MAJOR, i),
fb_info->device, "fb%d", i);
if (IS_ERR(fb_info->class_device)) {
/* Not fatal */
diff --git a/fs/coda/psdev.c b/fs/coda/psdev.c
index 3d1cce3..6a3df88 100644
--- a/fs/coda/psdev.c
+++ b/fs/coda/psdev.c
@@ -370,8 +370,8 @@ static int init_coda_psdev(void)
}
devfs_mk_dir ("coda");
for (i = 0; i < MAX_CODADEVS; i++) {
- class_device_create(coda_psdev_class, MKDEV(CODA_PSDEV_MAJOR,i),
- NULL, "cfs%d", i);
+ class_device_create(coda_psdev_class, NULL,
+ MKDEV(CODA_PSDEV_MAJOR,i), NULL, "cfs%d", i);
err = devfs_mk_cdev(MKDEV(CODA_PSDEV_MAJOR, i),
S_IFCHR|S_IRUSR|S_IWUSR, "coda/%d", i);
if (err)
diff --git a/sound/core/sound.c b/sound/core/sound.c
index 9e76bdd..b57519a 100644
--- a/sound/core/sound.c
+++ b/sound/core/sound.c
@@ -231,7 +231,7 @@ int snd_register_device(int type, snd_ca
devfs_mk_cdev(MKDEV(major, minor), S_IFCHR | device_mode, "snd/%s", name);
if (card)
device = card->dev;
- class_device_create(sound_class, MKDEV(major, minor), device, "%s", name);
+ class_device_create(sound_class, NULL, MKDEV(major, minor), device, "%s", name);

up(&sound_mutex);
return 0;
diff --git a/sound/oss/soundcard.c b/sound/oss/soundcard.c
index 95fa81e..d33bb46 100644
--- a/sound/oss/soundcard.c
+++ b/sound/oss/soundcard.c
@@ -567,7 +567,7 @@ static int __init oss_init(void)
devfs_mk_cdev(MKDEV(SOUND_MAJOR, dev_list[i].minor),
S_IFCHR | dev_list[i].mode,
"sound/%s", dev_list[i].name);
- class_device_create(sound_class,
+ class_device_create(sound_class, NULL,
MKDEV(SOUND_MAJOR, dev_list[i].minor),
NULL, "%s", dev_list[i].name);

@@ -579,7 +579,7 @@ static int __init oss_init(void)
dev_list[i].minor + (j*0x10)),
S_IFCHR | dev_list[i].mode,
"sound/%s%d", dev_list[i].name, j);
- class_device_create(sound_class,
+ class_device_create(sound_class, NULL,
MKDEV(SOUND_MAJOR, dev_list[i].minor + (j*0x10)),
NULL, "%s%d", dev_list[i].name, j);
}
diff --git a/sound/sound_core.c b/sound/sound_core.c
index 954f994..394b53e 100644
--- a/sound/sound_core.c
+++ b/sound/sound_core.c
@@ -174,7 +174,7 @@ static int sound_insert_unit(struct soun

devfs_mk_cdev(MKDEV(SOUND_MAJOR, s->unit_minor),
S_IFCHR | mode, s->name);
- class_device_create(sound_class, MKDEV(SOUND_MAJOR, s->unit_minor),
+ class_device_create(sound_class, NULL, MKDEV(SOUND_MAJOR, s->unit_minor),
dev, s->name+6);
return r;


2005-10-28 06:43:56

by Greg KH

[permalink] [raw]
Subject: [PATCH] I2O: remove i2o_device_class

[PATCH] I2O: remove i2o_device_class

I2O: cleanup - remove i2o_device_class

I2O devices reside on their own bus so there should be no reason
to also have i2c_device class that mirros i2o bus.

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

---
commit b02f028de21efe6ba60d1896462a219f1356ea34
tree b1ea0338d95ff9cdf7861d58b3fb26d4d79cc4a3
parent 3d7eba1bed51352c3bd68b4e507c021ad7db928a
author Dmitry Torokhov <[email protected]> Thu, 29 Sep 2005 00:40:07 -0500
committer Greg Kroah-Hartman <[email protected]> Thu, 27 Oct 2005 22:48:00 -0700

drivers/message/i2o/core.h | 3 --
drivers/message/i2o/device.c | 71 ++++++++----------------------------------
drivers/message/i2o/driver.c | 3 ++
drivers/message/i2o/iop.c | 10 +-----
include/linux/i2o.h | 2 -
5 files changed, 17 insertions(+), 72 deletions(-)

diff --git a/drivers/message/i2o/core.h b/drivers/message/i2o/core.h
index c5bcfd7..9eefedb 100644
--- a/drivers/message/i2o/core.h
+++ b/drivers/message/i2o/core.h
@@ -36,9 +36,6 @@ extern void __exit i2o_pci_exit(void);
extern void i2o_device_remove(struct i2o_device *);
extern int i2o_device_parse_lct(struct i2o_controller *);

-extern int i2o_device_init(void);
-extern void i2o_device_exit(void);
-
/* IOP */
extern struct i2o_controller *i2o_iop_alloc(void);
extern void i2o_iop_free(struct i2o_controller *);
diff --git a/drivers/message/i2o/device.c b/drivers/message/i2o/device.c
index 551d582..d987996 100644
--- a/drivers/message/i2o/device.c
+++ b/drivers/message/i2o/device.c
@@ -138,17 +138,6 @@ static void i2o_device_release(struct de
kfree(i2o_dev);
}

-/**
- * i2o_device_class_release - I2O class device release function
- * @cd: I2O class device which is added to the I2O device class
- *
- * The function is just a stub - memory will be freed when
- * associated I2O device is released.
- */
-static void i2o_device_class_release(struct class_device *cd)
-{
- /* empty */
-}

/**
* i2o_device_class_show_class_id - Displays class id of I2O device
@@ -157,12 +146,13 @@ static void i2o_device_class_release(str
*
* Returns the number of bytes which are printed into the buffer.
*/
-static ssize_t i2o_device_class_show_class_id(struct class_device *cd,
- char *buf)
+static ssize_t i2o_device_show_class_id(struct device *dev,
+ struct device_attribute *attr,
+ char *buf)
{
- struct i2o_device *dev = to_i2o_device(cd->dev);
+ struct i2o_device *i2o_dev = to_i2o_device(dev);

- sprintf(buf, "0x%03x\n", dev->lct_data.class_id);
+ sprintf(buf, "0x%03x\n", i2o_dev->lct_data.class_id);
return strlen(buf) + 1;
}

@@ -173,27 +163,22 @@ static ssize_t i2o_device_class_show_cla
*
* Returns the number of bytes which are printed into the buffer.
*/
-static ssize_t i2o_device_class_show_tid(struct class_device *cd, char *buf)
+static ssize_t i2o_device_show_tid(struct device *dev,
+ struct device_attribute *attr,
+ char *buf)
{
- struct i2o_device *dev = to_i2o_device(cd->dev);
+ struct i2o_device *i2o_dev = to_i2o_device(dev);

- sprintf(buf, "0x%03x\n", dev->lct_data.tid);
+ sprintf(buf, "0x%03x\n", i2o_dev->lct_data.tid);
return strlen(buf) + 1;
}

-static struct class_device_attribute i2o_device_class_attrs[] = {
- __ATTR(class_id, S_IRUGO, i2o_device_class_show_class_id, NULL),
- __ATTR(tid, S_IRUGO, i2o_device_class_show_tid, NULL),
+struct device_attribute i2o_device_attrs[] = {
+ __ATTR(class_id, S_IRUGO, i2o_device_show_class_id, NULL),
+ __ATTR(tid, S_IRUGO, i2o_device_show_tid, NULL),
__ATTR_NULL
};

-/* I2O device class */
-static struct class i2o_device_class = {
- .name = "i2o_device",
- .release = i2o_device_class_release,
- .class_dev_attrs = i2o_device_class_attrs,
-};
-
/**
* i2o_device_alloc - Allocate a I2O device and initialize it
*
@@ -217,8 +202,6 @@ static struct i2o_device *i2o_device_all

dev->device.bus = &i2o_bus_type;
dev->device.release = &i2o_device_release;
- dev->classdev.class = &i2o_device_class;
- dev->classdev.dev = &dev->device;

return dev;
}
@@ -311,17 +294,12 @@ static struct i2o_device *i2o_device_add
snprintf(dev->device.bus_id, BUS_ID_SIZE, "%d:%03x", c->unit,
dev->lct_data.tid);

- snprintf(dev->classdev.class_id, BUS_ID_SIZE, "%d:%03x", c->unit,
- dev->lct_data.tid);
-
dev->device.parent = &c->device;

device_register(&dev->device);

list_add_tail(&dev->list, &c->devices);

- class_device_register(&dev->classdev);
-
i2o_setup_sysfs_links(dev);

i2o_driver_notify_device_add_all(dev);
@@ -343,7 +321,6 @@ void i2o_device_remove(struct i2o_device
{
i2o_driver_notify_device_remove_all(i2o_dev);
i2o_remove_sysfs_links(i2o_dev);
- class_device_unregister(&i2o_dev->classdev);
list_del(&i2o_dev->list);
device_unregister(&i2o_dev->device);
}
@@ -598,28 +575,6 @@ int i2o_parm_table_get(struct i2o_device
return size;
}

-/**
- * i2o_device_init - Initialize I2O devices
- *
- * Registers the I2O device class.
- *
- * Returns 0 on success or negative error code on failure.
- */
-int i2o_device_init(void)
-{
- return class_register(&i2o_device_class);
-}
-
-/**
- * i2o_device_exit - I2O devices exit function
- *
- * Unregisters the I2O device class.
- */
-void i2o_device_exit(void)
-{
- class_unregister(&i2o_device_class);
-}
-
EXPORT_SYMBOL(i2o_device_claim);
EXPORT_SYMBOL(i2o_device_claim_release);
EXPORT_SYMBOL(i2o_parm_field_get);
diff --git a/drivers/message/i2o/driver.c b/drivers/message/i2o/driver.c
index 739bfde..0079a4b 100644
--- a/drivers/message/i2o/driver.c
+++ b/drivers/message/i2o/driver.c
@@ -58,9 +58,12 @@ static int i2o_bus_match(struct device *
};

/* I2O bus type */
+extern struct device_attribute i2o_device_attrs[];
+
struct bus_type i2o_bus_type = {
.name = "i2o",
.match = i2o_bus_match,
+ .dev_attrs = i2o_device_attrs,
};

/**
diff --git a/drivers/message/i2o/iop.c b/drivers/message/i2o/iop.c
index 15deb45..176fb57 100644
--- a/drivers/message/i2o/iop.c
+++ b/drivers/message/i2o/iop.c
@@ -1243,14 +1243,10 @@ static int __init i2o_iop_init(void)

printk(KERN_INFO OSM_DESCRIPTION " v" OSM_VERSION "\n");

- rc = i2o_device_init();
- if (rc)
- goto exit;
-
i2o_controller_class = class_create(THIS_MODULE, "i2o_controller");
if (IS_ERR(i2o_controller_class)) {
osm_err("can't register class i2o_controller\n");
- goto device_exit;
+ goto exit;
}

if ((rc = i2o_driver_init()))
@@ -1273,9 +1269,6 @@ static int __init i2o_iop_init(void)
class_exit:
class_destroy(i2o_controller_class);

- device_exit:
- i2o_device_exit();
-
exit:
return rc;
}
@@ -1291,7 +1284,6 @@ static void __exit i2o_iop_exit(void)
i2o_exec_exit();
i2o_driver_exit();
class_destroy(i2o_controller_class);
- i2o_device_exit();
};

module_init(i2o_iop_init);
diff --git a/include/linux/i2o.h b/include/linux/i2o.h
index 694ea29..84db8f6 100644
--- a/include/linux/i2o.h
+++ b/include/linux/i2o.h
@@ -66,8 +66,6 @@ struct i2o_device {
struct device device;

struct semaphore lock; /* device lock */
-
- struct class_device classdev; /* i2o device class */
};

/*

2005-10-28 06:42:08

by Greg KH

[permalink] [raw]
Subject: [PATCH] Driver core: pass interface to class interface methods

[PATCH] Driver core: pass interface to class interface methods

Driver core: pass interface to class intreface methods

Pass interface as argument to add() and remove() class interface
methods. This way a subsystem can implement generic add/remove
handlers and then call interface-specific ones.

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

---
commit 6f5ace97359fa038cffb977dcf057764197f0df5
tree 704698b1aea6b88af22a5c3cf7f81e2dc9d4b313
parent b02f028de21efe6ba60d1896462a219f1356ea34
author Dmitry Torokhov <[email protected]> Thu, 15 Sep 2005 02:01:36 -0500
committer Greg Kroah-Hartman <[email protected]> Thu, 27 Oct 2005 22:48:00 -0700

drivers/base/class.c | 8 ++++----
drivers/pcmcia/ds.c | 6 ++++--
drivers/pcmcia/rsrc_nonstatic.c | 6 ++++--
drivers/pcmcia/socket_sysfs.c | 6 ++++--
drivers/scsi/sg.c | 8 ++++----
include/linux/device.h | 4 ++--
6 files changed, 22 insertions(+), 16 deletions(-)

diff --git a/drivers/base/class.c b/drivers/base/class.c
index 8df58c5..73d44cf 100644
--- a/drivers/base/class.c
+++ b/drivers/base/class.c
@@ -532,7 +532,7 @@ int class_device_add(struct class_device
list_add_tail(&class_dev->node, &parent->children);
list_for_each_entry(class_intf, &parent->interfaces, node)
if (class_intf->add)
- class_intf->add(class_dev);
+ class_intf->add(class_dev, class_intf);
up(&parent->sem);
}

@@ -612,7 +612,7 @@ void class_device_del(struct class_devic
list_del_init(&class_dev->node);
list_for_each_entry(class_intf, &parent->interfaces, node)
if (class_intf->remove)
- class_intf->remove(class_dev);
+ class_intf->remove(class_dev, class_intf);
up(&parent->sem);
}

@@ -729,7 +729,7 @@ int class_interface_register(struct clas
list_add_tail(&class_intf->node, &parent->interfaces);
if (class_intf->add) {
list_for_each_entry(class_dev, &parent->children, node)
- class_intf->add(class_dev);
+ class_intf->add(class_dev, class_intf);
}
up(&parent->sem);

@@ -748,7 +748,7 @@ void class_interface_unregister(struct c
list_del_init(&class_intf->node);
if (class_intf->remove) {
list_for_each_entry(class_dev, &parent->children, node)
- class_intf->remove(class_dev);
+ class_intf->remove(class_dev, class_intf);
}
up(&parent->sem);

diff --git a/drivers/pcmcia/ds.c b/drivers/pcmcia/ds.c
index 080608c..39d096b 100644
--- a/drivers/pcmcia/ds.c
+++ b/drivers/pcmcia/ds.c
@@ -1157,7 +1157,8 @@ static struct pcmcia_callback pcmcia_bus
.requery = pcmcia_bus_rescan,
};

-static int __devinit pcmcia_bus_add_socket(struct class_device *class_dev)
+static int __devinit pcmcia_bus_add_socket(struct class_device *class_dev,
+ struct class_interface *class_intf)
{
struct pcmcia_socket *socket = class_get_devdata(class_dev);
int ret;
@@ -1192,7 +1193,8 @@ static int __devinit pcmcia_bus_add_sock
return 0;
}

-static void pcmcia_bus_remove_socket(struct class_device *class_dev)
+static void pcmcia_bus_remove_socket(struct class_device *class_dev,
+ struct class_interface *class_intf)
{
struct pcmcia_socket *socket = class_get_devdata(class_dev);

diff --git a/drivers/pcmcia/rsrc_nonstatic.c b/drivers/pcmcia/rsrc_nonstatic.c
index f9a5c70..fc87e7e 100644
--- a/drivers/pcmcia/rsrc_nonstatic.c
+++ b/drivers/pcmcia/rsrc_nonstatic.c
@@ -994,7 +994,8 @@ static struct class_device_attribute *pc
NULL,
};

-static int __devinit pccard_sysfs_add_rsrc(struct class_device *class_dev)
+static int __devinit pccard_sysfs_add_rsrc(struct class_device *class_dev,
+ struct class_interface *class_intf)
{
struct pcmcia_socket *s = class_get_devdata(class_dev);
struct class_device_attribute **attr;
@@ -1011,7 +1012,8 @@ static int __devinit pccard_sysfs_add_rs
return ret;
}

-static void __devexit pccard_sysfs_remove_rsrc(struct class_device *class_dev)
+static void __devexit pccard_sysfs_remove_rsrc(struct class_device *class_dev,
+ struct class_interface *class_intf)
{
struct pcmcia_socket *s = class_get_devdata(class_dev);
struct class_device_attribute **attr;
diff --git a/drivers/pcmcia/socket_sysfs.c b/drivers/pcmcia/socket_sysfs.c
index 1040a6c..4a3150a 100644
--- a/drivers/pcmcia/socket_sysfs.c
+++ b/drivers/pcmcia/socket_sysfs.c
@@ -341,7 +341,8 @@ static struct bin_attribute pccard_cis_a
.write = pccard_store_cis,
};

-static int __devinit pccard_sysfs_add_socket(struct class_device *class_dev)
+static int __devinit pccard_sysfs_add_socket(struct class_device *class_dev,
+ struct class_interface *class_intf)
{
struct class_device_attribute **attr;
int ret = 0;
@@ -357,7 +358,8 @@ static int __devinit pccard_sysfs_add_so
return ret;
}

-static void __devexit pccard_sysfs_remove_socket(struct class_device *class_dev)
+static void __devexit pccard_sysfs_remove_socket(struct class_device *class_dev,
+ struct class_interface *class_intf)
{
struct class_device_attribute **attr;

diff --git a/drivers/scsi/sg.c b/drivers/scsi/sg.c
index ad94367..f0d8b4e 100644
--- a/drivers/scsi/sg.c
+++ b/drivers/scsi/sg.c
@@ -104,8 +104,8 @@ static int sg_allow_dio = SG_ALLOW_DIO_D

#define SG_DEV_ARR_LUMP 32 /* amount to over allocate sg_dev_arr by */

-static int sg_add(struct class_device *);
-static void sg_remove(struct class_device *);
+static int sg_add(struct class_device *, struct class_interface *);
+static void sg_remove(struct class_device *, struct class_interface *);

static Scsi_Request *dummy_cmdp; /* only used for sizeof */

@@ -1506,7 +1506,7 @@ static int sg_alloc(struct gendisk *disk
}

static int
-sg_add(struct class_device *cl_dev)
+sg_add(struct class_device *cl_dev, struct class_interface *cl_intf)
{
struct scsi_device *scsidp = to_scsi_device(cl_dev->dev);
struct gendisk *disk;
@@ -1582,7 +1582,7 @@ out:
}

static void
-sg_remove(struct class_device *cl_dev)
+sg_remove(struct class_device *cl_dev, struct class_interface *cl_intf)
{
struct scsi_device *scsidp = to_scsi_device(cl_dev->dev);
Sg_device *sdp = NULL;
diff --git a/include/linux/device.h b/include/linux/device.h
index 95d607a..a53a822 100644
--- a/include/linux/device.h
+++ b/include/linux/device.h
@@ -251,8 +251,8 @@ struct class_interface {
struct list_head node;
struct class *class;

- int (*add) (struct class_device *);
- void (*remove) (struct class_device *);
+ int (*add) (struct class_device *, struct class_interface *);
+ void (*remove) (struct class_device *, struct class_interface *);
};

extern int class_interface_register(struct class_interface *);

2005-10-28 06:42:59

by Greg KH

[permalink] [raw]
Subject: [PATCH] I2O: Clean up some pretty bad driver model abuses in the i2o code

[PATCH] I2O: Clean up some pretty bad driver model abuses in the i2o code

Signed-off-by: Greg Kroah-Hartman <[email protected]>

---
commit 3d7eba1bed51352c3bd68b4e507c021ad7db928a
tree 39f070d720ed7ab91e9ebd178e345cdbb2ce5193
parent e12574538ea88cd5e15d7135e9ae6e267d314f2c
author Greg Kroah-Hartman <[email protected]> Thu, 27 Oct 2005 22:25:43 -0700
committer Greg Kroah-Hartman <[email protected]> Thu, 27 Oct 2005 22:48:00 -0700

drivers/message/i2o/iop.c | 22 ++++++++++------------
include/linux/i2o.h | 2 +-
2 files changed, 11 insertions(+), 13 deletions(-)

diff --git a/drivers/message/i2o/iop.c b/drivers/message/i2o/iop.c
index 42f8b81..15deb45 100644
--- a/drivers/message/i2o/iop.c
+++ b/drivers/message/i2o/iop.c
@@ -833,6 +833,7 @@ void i2o_iop_remove(struct i2o_controlle
list_for_each_entry_safe(dev, tmp, &c->devices, list)
i2o_device_remove(dev);

+ class_device_unregister(c->classdev);
device_del(&c->device);

/* Ask the IOP to switch to RESET state */
@@ -1077,9 +1078,7 @@ static void i2o_iop_release(struct devic
};

/* I2O controller class */
-static struct class i2o_controller_class = {
- .name = "i2o_controller",
-};
+static struct class *i2o_controller_class;

/**
* i2o_iop_alloc - Allocate and initialize a i2o_controller struct
@@ -1110,14 +1109,10 @@ struct i2o_controller *i2o_iop_alloc(voi
sprintf(c->name, "iop%d", c->unit);

device_initialize(&c->device);
- class_device_initialize(&c->classdev);

c->device.release = &i2o_iop_release;
- c->classdev.class = &i2o_controller_class;
- c->classdev.dev = &c->device;

snprintf(c->device.bus_id, BUS_ID_SIZE, "iop%d", c->unit);
- snprintf(c->classdev.class_id, BUS_ID_SIZE, "iop%d", c->unit);

#if BITS_PER_LONG == 64
spin_lock_init(&c->context_list_lock);
@@ -1146,7 +1141,9 @@ int i2o_iop_add(struct i2o_controller *c
goto iop_reset;
}

- if ((rc = class_device_add(&c->classdev))) {
+ c->classdev = class_device_create(i2o_controller_class, 0,
+ &c->device, "iop%d", c->unit);
+ if (IS_ERR(c->classdev)) {
osm_err("%s: could not add controller class\n", c->name);
goto device_del;
}
@@ -1184,7 +1181,7 @@ int i2o_iop_add(struct i2o_controller *c
return 0;

class_del:
- class_device_del(&c->classdev);
+ class_device_unregister(c->classdev);

device_del:
device_del(&c->device);
@@ -1250,7 +1247,8 @@ static int __init i2o_iop_init(void)
if (rc)
goto exit;

- if ((rc = class_register(&i2o_controller_class))) {
+ i2o_controller_class = class_create(THIS_MODULE, "i2o_controller");
+ if (IS_ERR(i2o_controller_class)) {
osm_err("can't register class i2o_controller\n");
goto device_exit;
}
@@ -1273,7 +1271,7 @@ static int __init i2o_iop_init(void)
i2o_driver_exit();

class_exit:
- class_unregister(&i2o_controller_class);
+ class_destroy(i2o_controller_class);

device_exit:
i2o_device_exit();
@@ -1292,7 +1290,7 @@ static void __exit i2o_iop_exit(void)
i2o_pci_exit();
i2o_exec_exit();
i2o_driver_exit();
- class_unregister(&i2o_controller_class);
+ class_destroy(i2o_controller_class);
i2o_device_exit();
};

diff --git a/include/linux/i2o.h b/include/linux/i2o.h
index bdc286e..694ea29 100644
--- a/include/linux/i2o.h
+++ b/include/linux/i2o.h
@@ -194,7 +194,7 @@ struct i2o_controller {
struct resource mem_resource; /* Mem resource allocated to the IOP */

struct device device;
- struct class_device classdev; /* I2O controller class */
+ struct class_device *classdev; /* I2O controller class device */
struct i2o_device *exec; /* Executive */
#if BITS_PER_LONG == 64
spinlock_t context_list_lock; /* lock for context_list */

2005-10-28 06:44:45

by Greg KH

[permalink] [raw]
Subject: [PATCH] Input: prepare to sysfs integration

[PATCH] Input: prepare to sysfs integration

Input: prepare to sysfs integration

Add struct class_device to input_dev; add input_allocate_dev()
to dynamically allocate input devices; dynamically allocated
devices are automatically registered with sysfs.

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

---
commit 4086434e3a16b83e0cc651b5519f911dfa010cc7
tree a1b2f8d3605f58084c1272404d89cd723e240d8d
parent f2e28e004f12e0e3fd1edf3ca1f35b42ab45988f
author Dmitry Torokhov <[email protected]> Thu, 15 Sep 2005 02:01:39 -0500
committer Greg Kroah-Hartman <[email protected]> Thu, 27 Oct 2005 22:48:03 -0700

drivers/input/input.c | 77 ++++++++++++++++++++++++++++++++++++++++++++++---
include/linux/input.h | 24 +++++++++++++++
2 files changed, 95 insertions(+), 6 deletions(-)

diff --git a/drivers/input/input.c b/drivers/input/input.c
index 072bbf5..0e2e890 100644
--- a/drivers/input/input.c
+++ b/drivers/input/input.c
@@ -27,6 +27,7 @@ MODULE_AUTHOR("Vojtech Pavlik <vojtech@s
MODULE_DESCRIPTION("Input core");
MODULE_LICENSE("GPL");

+EXPORT_SYMBOL(input_allocate_device);
EXPORT_SYMBOL(input_register_device);
EXPORT_SYMBOL(input_unregister_device);
EXPORT_SYMBOL(input_register_handler);
@@ -605,6 +606,56 @@ static inline int input_proc_init(void)
static inline void input_proc_exit(void) { }
#endif

+static void input_dev_release(struct class_device *class_dev)
+{
+ struct input_dev *dev = to_input_dev(class_dev);
+
+ kfree(dev);
+ module_put(THIS_MODULE);
+}
+
+static struct class input_dev_class = {
+ .name = "input_dev",
+ .release = input_dev_release,
+};
+
+struct input_dev *input_allocate_device(void)
+{
+ struct input_dev *dev;
+
+ dev = kzalloc(sizeof(struct input_dev), GFP_KERNEL);
+ if (dev) {
+ dev->dynalloc = 1;
+ dev->cdev.class = &input_dev_class;
+ class_device_initialize(&dev->cdev);
+ INIT_LIST_HEAD(&dev->h_list);
+ INIT_LIST_HEAD(&dev->node);
+ }
+
+ return dev;
+}
+
+static void input_register_classdevice(struct input_dev *dev)
+{
+ static atomic_t input_no = ATOMIC_INIT(0);
+ const char *path;
+
+ __module_get(THIS_MODULE);
+
+ dev->dev = dev->cdev.dev;
+
+ snprintf(dev->cdev.class_id, sizeof(dev->cdev.class_id),
+ "input%ld", (unsigned long) atomic_inc_return(&input_no) - 1);
+
+ path = kobject_get_path(&dev->cdev.class->subsys.kset.kobj, GFP_KERNEL);
+ printk(KERN_INFO "input: %s/%s as %s\n",
+ dev->name ? dev->name : "Unspecified device",
+ path ? path : "", dev->cdev.class_id);
+ kfree(path);
+
+ class_device_add(&dev->cdev);
+}
+
void input_register_device(struct input_dev *dev)
{
struct input_handle *handle;
@@ -637,6 +688,10 @@ void input_register_device(struct input_
if ((handle = handler->connect(handler, dev, id)))
input_link_handle(handle);

+
+ if (dev->dynalloc)
+ input_register_classdevice(dev);
+
#ifdef CONFIG_HOTPLUG
input_call_hotplug("add", dev);
#endif
@@ -665,6 +720,9 @@ void input_unregister_device(struct inpu

list_del_init(&dev->node);

+ if (dev->dynalloc)
+ class_device_unregister(&dev->cdev);
+
input_wakeup_procfs_readers();
}

@@ -753,26 +811,34 @@ static int __init input_init(void)
{
int err;

+ err = class_register(&input_dev_class);
+ if (err) {
+ printk(KERN_ERR "input: unable to register input_dev class\n");
+ return err;
+ }
+
input_class = class_create(THIS_MODULE, "input");
if (IS_ERR(input_class)) {
printk(KERN_ERR "input: unable to register input class\n");
- return PTR_ERR(input_class);
+ err = PTR_ERR(input_class);
+ goto fail1;
}

err = input_proc_init();
if (err)
- goto fail1;
+ goto fail2;

err = register_chrdev(INPUT_MAJOR, "input", &input_fops);
if (err) {
printk(KERN_ERR "input: unable to register char major %d", INPUT_MAJOR);
- goto fail2;
+ goto fail3;
}

return 0;

- fail2: input_proc_exit();
- fail1: class_destroy(input_class);
+ fail3: input_proc_exit();
+ fail2: class_destroy(input_class);
+ fail1: class_unregister(&input_dev_class);
return err;
}

@@ -781,6 +847,7 @@ static void __exit input_exit(void)
input_proc_exit();
unregister_chrdev(INPUT_MAJOR, "input");
class_destroy(input_class);
+ class_unregister(&input_dev_class);
}

subsys_initcall(input_init);
diff --git a/include/linux/input.h b/include/linux/input.h
index e8c296f..3defa29 100644
--- a/include/linux/input.h
+++ b/include/linux/input.h
@@ -12,6 +12,7 @@
#ifdef __KERNEL__
#include <linux/time.h>
#include <linux/list.h>
+#include <linux/device.h>
#else
#include <sys/time.h>
#include <sys/ioctl.h>
@@ -889,11 +890,15 @@ struct input_dev {
struct semaphore sem; /* serializes open and close operations */
unsigned int users;

- struct device *dev;
+ struct class_device cdev;
+ struct device *dev; /* will be removed soon */
+
+ int dynalloc; /* temporarily */

struct list_head h_list;
struct list_head node;
};
+#define to_input_dev(d) container_of(d, struct input_dev, cdev)

/*
* Structure for hotplug & device<->driver matching.
@@ -984,6 +989,23 @@ static inline void init_input_dev(struct
INIT_LIST_HEAD(&dev->node);
}

+struct input_dev *input_allocate_device(void);
+
+static inline void input_free_device(struct input_dev *dev)
+{
+ kfree(dev);
+}
+
+static inline struct input_dev *input_get_device(struct input_dev *dev)
+{
+ return to_input_dev(class_device_get(&dev->cdev));
+}
+
+static inline void input_put_device(struct input_dev *dev)
+{
+ class_device_put(&dev->cdev);
+}
+
void input_register_device(struct input_dev *);
void input_unregister_device(struct input_dev *);


2005-10-28 06:44:44

by Greg KH

[permalink] [raw]
Subject: [PATCH] add sysfs support for ide tape

[PATCH] add sysfs support for ide tape

I was recently given an old Travan tape drive and asked to do something
useful with it. The ide-scsi + st (+serverworks ide controller) combo
results in a hard lockup of the machine which I have not had the energy to
debug, so I turned to ide-tape (which seems to work). The system in
question debian stable, using udev to manage /dev.

The following patch to ide-tape.c allows udev to create the cdev nodes for
my drive.

Cc: Gadi Oxman <[email protected]>
Cc: Greg KH <[email protected]>
Signed-off-by: Andrew Morton <[email protected]>
Signed-off-by: Greg Kroah-Hartman <[email protected]>

---
commit e801e49d1ca90da1ab0286a3688f2465cb1e45e4
tree e7983a7c7dce4213431a1b951d3d803167ed41f9
parent 271c0df6e700b3f208b1802a1e96bb9eeeaa880c
author Will Dyson <[email protected]> Fri, 16 Sep 2005 02:55:07 -0700
committer Greg Kroah-Hartman <[email protected]> Thu, 27 Oct 2005 22:47:59 -0700

drivers/ide/ide-tape.c | 38 ++++++++++++++++++++++++++++++++++++--
1 files changed, 36 insertions(+), 2 deletions(-)

diff --git a/drivers/ide/ide-tape.c b/drivers/ide/ide-tape.c
index ee38e6b..95abe98 100644
--- a/drivers/ide/ide-tape.c
+++ b/drivers/ide/ide-tape.c
@@ -1013,6 +1013,8 @@ typedef struct ide_tape_obj {

static DECLARE_MUTEX(idetape_ref_sem);

+static struct class *idetape_sysfs_class;
+
#define to_ide_tape(obj) container_of(obj, struct ide_tape_obj, kref)

#define ide_tape_g(disk) \
@@ -4704,6 +4706,10 @@ static void ide_tape_release(struct kref

drive->dsc_overlap = 0;
drive->driver_data = NULL;
+ class_device_destroy(idetape_sysfs_class,
+ MKDEV(IDETAPE_MAJOR, tape->minor));
+ class_device_destroy(idetape_sysfs_class,
+ MKDEV(IDETAPE_MAJOR, tape->minor + 128));
devfs_remove("%s/mt", drive->devfs_name);
devfs_remove("%s/mtn", drive->devfs_name);
devfs_unregister_tape(g->number);
@@ -4878,6 +4884,11 @@ static int ide_tape_probe(struct device

idetape_setup(drive, tape, minor);

+ class_device_create(idetape_sysfs_class,
+ MKDEV(IDETAPE_MAJOR, minor), dev, "%s", tape->name);
+ class_device_create(idetape_sysfs_class,
+ MKDEV(IDETAPE_MAJOR, minor + 128), dev, "n%s", tape->name);
+
devfs_mk_cdev(MKDEV(HWIF(drive)->major, minor),
S_IFCHR | S_IRUGO | S_IWUGO,
"%s/mt", drive->devfs_name);
@@ -4903,6 +4914,7 @@ MODULE_LICENSE("GPL");
static void __exit idetape_exit (void)
{
driver_unregister(&idetape_driver.gen_driver);
+ class_destroy(idetape_sysfs_class);
unregister_chrdev(IDETAPE_MAJOR, "ht");
}

@@ -4911,11 +4923,33 @@ static void __exit idetape_exit (void)
*/
static int idetape_init (void)
{
+ int error = 1;
+ idetape_sysfs_class = class_create(THIS_MODULE, "ide_tape");
+ if (IS_ERR(idetape_sysfs_class)) {
+ idetape_sysfs_class = NULL;
+ printk(KERN_ERR "Unable to create sysfs class for ide tapes\n");
+ error = -EBUSY;
+ goto out;
+ }
+
if (register_chrdev(IDETAPE_MAJOR, "ht", &idetape_fops)) {
printk(KERN_ERR "ide-tape: Failed to register character device interface\n");
- return -EBUSY;
+ error = -EBUSY;
+ goto out_free_class;
}
- return driver_register(&idetape_driver.gen_driver);
+
+ error = driver_register(&idetape_driver.gen_driver);
+ if (error)
+ goto out_free_driver;
+
+ return 0;
+
+out_free_driver:
+ driver_unregister(&idetape_driver.gen_driver);
+out_free_class:
+ class_destroy(idetape_sysfs_class);
+out:
+ return error;
}

module_init(idetape_init);

2005-10-28 06:45:31

by Greg KH

[permalink] [raw]
Subject: [PATCH] I2O: remove class interface

[PATCH] I2O: remove class interface

I2O: remove i2o_device_class_interface misuse

The intent of class interfaces was to provide different
'views' at the same object, not just run some code every
time a new class device is registered. Kill interface
structure, make class core register default attributes
and set up sysfs links right when registering class
devices.

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

---
commit e12574538ea88cd5e15d7135e9ae6e267d314f2c
tree 301ed903a0a558c231c69b6390db67f7a169c184
parent 85a44726f49989a2647cd850d55ec5be75727c5b
author Dmitry Torokhov <[email protected]> Thu, 15 Sep 2005 02:01:32 -0500
committer Greg Kroah-Hartman <[email protected]> Thu, 27 Oct 2005 22:48:00 -0700

drivers/message/i2o/device.c | 255 ++++++++++++++++++++----------------------
1 files changed, 122 insertions(+), 133 deletions(-)

diff --git a/drivers/message/i2o/device.c b/drivers/message/i2o/device.c
index 21f16ba..551d582 100644
--- a/drivers/message/i2o/device.c
+++ b/drivers/message/i2o/device.c
@@ -45,10 +45,10 @@ static inline int i2o_device_issue_claim
writel(type, &msg->body[0]);

return i2o_msg_post_wait(dev->iop, m, 60);
-};
+}

/**
- * i2o_device_claim - claim a device for use by an OSM
+ * i2o_device_claim - claim a device for use by an OSM
* @dev: I2O device to claim
* @drv: I2O driver which wants to claim the device
*
@@ -73,7 +73,7 @@ int i2o_device_claim(struct i2o_device *
up(&dev->lock);

return rc;
-};
+}

/**
* i2o_device_claim_release - release a device that the OSM is using
@@ -119,7 +119,8 @@ int i2o_device_claim_release(struct i2o_
up(&dev->lock);

return rc;
-};
+}
+

/**
* i2o_device_release - release the memory for a I2O device
@@ -135,39 +136,62 @@ static void i2o_device_release(struct de
pr_debug("i2o: device %s released\n", dev->bus_id);

kfree(i2o_dev);
-};
+}

/**
- * i2o_device_class_release - Remove I2O device attributes
+ * i2o_device_class_release - I2O class device release function
* @cd: I2O class device which is added to the I2O device class
*
- * Removes attributes from the I2O device again. Also search each device
- * on the controller for I2O devices which refert to this device as parent
- * or user and remove this links also.
+ * The function is just a stub - memory will be freed when
+ * associated I2O device is released.
*/
static void i2o_device_class_release(struct class_device *cd)
{
- struct i2o_device *i2o_dev, *tmp;
- struct i2o_controller *c;
+ /* empty */
+}

- i2o_dev = to_i2o_device(cd->dev);
- c = i2o_dev->iop;
+/**
+ * i2o_device_class_show_class_id - Displays class id of I2O device
+ * @cd: class device of which the class id should be displayed
+ * @buf: buffer into which the class id should be printed
+ *
+ * Returns the number of bytes which are printed into the buffer.
+ */
+static ssize_t i2o_device_class_show_class_id(struct class_device *cd,
+ char *buf)
+{
+ struct i2o_device *dev = to_i2o_device(cd->dev);

- sysfs_remove_link(&i2o_dev->device.kobj, "parent");
- sysfs_remove_link(&i2o_dev->device.kobj, "user");
+ sprintf(buf, "0x%03x\n", dev->lct_data.class_id);
+ return strlen(buf) + 1;
+}

- list_for_each_entry(tmp, &c->devices, list) {
- if (tmp->lct_data.parent_tid == i2o_dev->lct_data.tid)
- sysfs_remove_link(&tmp->device.kobj, "parent");
- if (tmp->lct_data.user_tid == i2o_dev->lct_data.tid)
- sysfs_remove_link(&tmp->device.kobj, "user");
- }
+/**
+ * i2o_device_class_show_tid - Displays TID of I2O device
+ * @cd: class device of which the TID should be displayed
+ * @buf: buffer into which the class id should be printed
+ *
+ * Returns the number of bytes which are printed into the buffer.
+ */
+static ssize_t i2o_device_class_show_tid(struct class_device *cd, char *buf)
+{
+ struct i2o_device *dev = to_i2o_device(cd->dev);
+
+ sprintf(buf, "0x%03x\n", dev->lct_data.tid);
+ return strlen(buf) + 1;
+}
+
+static struct class_device_attribute i2o_device_class_attrs[] = {
+ __ATTR(class_id, S_IRUGO, i2o_device_class_show_class_id, NULL),
+ __ATTR(tid, S_IRUGO, i2o_device_class_show_tid, NULL),
+ __ATTR_NULL
};

/* I2O device class */
static struct class i2o_device_class = {
- .name = "i2o_device",
- .release = i2o_device_class_release
+ .name = "i2o_device",
+ .release = i2o_device_class_release,
+ .class_dev_attrs = i2o_device_class_attrs,
};

/**
@@ -197,7 +221,67 @@ static struct i2o_device *i2o_device_all
dev->classdev.dev = &dev->device;

return dev;
-};
+}
+
+/**
+ * i2o_setup_sysfs_links - Adds attributes to the I2O device
+ * @cd: I2O class device which is added to the I2O device class
+ *
+ * This function get called when a I2O device is added to the class. It
+ * creates the attributes for each device and creates user/parent symlink
+ * if necessary.
+ *
+ * Returns 0 on success or negative error code on failure.
+ */
+static void i2o_setup_sysfs_links(struct i2o_device *i2o_dev)
+{
+ struct i2o_controller *c = i2o_dev->iop;
+ struct i2o_device *tmp;
+
+ /* create user entries for this device */
+ tmp = i2o_iop_find_device(i2o_dev->iop, i2o_dev->lct_data.user_tid);
+ if (tmp && tmp != i2o_dev)
+ sysfs_create_link(&i2o_dev->device.kobj,
+ &tmp->device.kobj, "user");
+
+ /* create user entries refering to this device */
+ list_for_each_entry(tmp, &c->devices, list)
+ if (tmp->lct_data.user_tid == i2o_dev->lct_data.tid &&
+ tmp != i2o_dev)
+ sysfs_create_link(&tmp->device.kobj,
+ &i2o_dev->device.kobj, "user");
+
+ /* create parent entries for this device */
+ tmp = i2o_iop_find_device(i2o_dev->iop, i2o_dev->lct_data.parent_tid);
+ if (tmp && tmp != i2o_dev)
+ sysfs_create_link(&i2o_dev->device.kobj,
+ &tmp->device.kobj, "parent");
+
+ /* create parent entries refering to this device */
+ list_for_each_entry(tmp, &c->devices, list)
+ if (tmp->lct_data.parent_tid == i2o_dev->lct_data.tid &&
+ tmp != i2o_dev)
+ sysfs_create_link(&tmp->device.kobj,
+ &i2o_dev->device.kobj, "parent");
+}
+
+static void i2o_remove_sysfs_links(struct i2o_device *i2o_dev)
+{
+ struct i2o_controller *c = i2o_dev->iop;
+ struct i2o_device *tmp;
+
+ sysfs_remove_link(&i2o_dev->device.kobj, "parent");
+ sysfs_remove_link(&i2o_dev->device.kobj, "user");
+
+ list_for_each_entry(tmp, &c->devices, list) {
+ if (tmp->lct_data.parent_tid == i2o_dev->lct_data.tid)
+ sysfs_remove_link(&tmp->device.kobj, "parent");
+ if (tmp->lct_data.user_tid == i2o_dev->lct_data.tid)
+ sysfs_remove_link(&tmp->device.kobj, "user");
+ }
+}
+
+

/**
* i2o_device_add - allocate a new I2O device and add it to the IOP
@@ -222,6 +306,7 @@ static struct i2o_device *i2o_device_add
}

dev->lct_data = *entry;
+ dev->iop = c;

snprintf(dev->device.bus_id, BUS_ID_SIZE, "%d:%03x", c->unit,
dev->lct_data.tid);
@@ -229,7 +314,6 @@ static struct i2o_device *i2o_device_add
snprintf(dev->classdev.class_id, BUS_ID_SIZE, "%d:%03x", c->unit,
dev->lct_data.tid);

- dev->iop = c;
dev->device.parent = &c->device;

device_register(&dev->device);
@@ -238,12 +322,14 @@ static struct i2o_device *i2o_device_add

class_device_register(&dev->classdev);

+ i2o_setup_sysfs_links(dev);
+
i2o_driver_notify_device_add_all(dev);

pr_debug("i2o: device %s added\n", dev->device.bus_id);

return dev;
-};
+}

/**
* i2o_device_remove - remove an I2O device from the I2O core
@@ -256,10 +342,11 @@ static struct i2o_device *i2o_device_add
void i2o_device_remove(struct i2o_device *i2o_dev)
{
i2o_driver_notify_device_remove_all(i2o_dev);
+ i2o_remove_sysfs_links(i2o_dev);
class_device_unregister(&i2o_dev->classdev);
list_del(&i2o_dev->list);
device_unregister(&i2o_dev->device);
-};
+}

/**
* i2o_device_parse_lct - Parse a previously fetched LCT and create devices
@@ -337,99 +424,8 @@ int i2o_device_parse_lct(struct i2o_cont
up(&c->lct_lock);

return 0;
-};
-
-/**
- * i2o_device_class_show_class_id - Displays class id of I2O device
- * @cd: class device of which the class id should be displayed
- * @buf: buffer into which the class id should be printed
- *
- * Returns the number of bytes which are printed into the buffer.
- */
-static ssize_t i2o_device_class_show_class_id(struct class_device *cd,
- char *buf)
-{
- struct i2o_device *dev = to_i2o_device(cd->dev);
-
- sprintf(buf, "0x%03x\n", dev->lct_data.class_id);
- return strlen(buf) + 1;
-};
-
-/**
- * i2o_device_class_show_tid - Displays TID of I2O device
- * @cd: class device of which the TID should be displayed
- * @buf: buffer into which the class id should be printed
- *
- * Returns the number of bytes which are printed into the buffer.
- */
-static ssize_t i2o_device_class_show_tid(struct class_device *cd, char *buf)
-{
- struct i2o_device *dev = to_i2o_device(cd->dev);
-
- sprintf(buf, "0x%03x\n", dev->lct_data.tid);
- return strlen(buf) + 1;
-};
-
-/* I2O device class attributes */
-static CLASS_DEVICE_ATTR(class_id, S_IRUGO, i2o_device_class_show_class_id,
- NULL);
-static CLASS_DEVICE_ATTR(tid, S_IRUGO, i2o_device_class_show_tid, NULL);
-
-/**
- * i2o_device_class_add - Adds attributes to the I2O device
- * @cd: I2O class device which is added to the I2O device class
- *
- * This function get called when a I2O device is added to the class. It
- * creates the attributes for each device and creates user/parent symlink
- * if necessary.
- *
- * Returns 0 on success or negative error code on failure.
- */
-static int i2o_device_class_add(struct class_device *cd)
-{
- struct i2o_device *i2o_dev, *tmp;
- struct i2o_controller *c;
-
- i2o_dev = to_i2o_device(cd->dev);
- c = i2o_dev->iop;
-
- class_device_create_file(cd, &class_device_attr_class_id);
- class_device_create_file(cd, &class_device_attr_tid);
-
- /* create user entries for this device */
- tmp = i2o_iop_find_device(i2o_dev->iop, i2o_dev->lct_data.user_tid);
- if (tmp && (tmp != i2o_dev))
- sysfs_create_link(&i2o_dev->device.kobj, &tmp->device.kobj,
- "user");
-
- /* create user entries refering to this device */
- list_for_each_entry(tmp, &c->devices, list)
- if ((tmp->lct_data.user_tid == i2o_dev->lct_data.tid)
- && (tmp != i2o_dev))
- sysfs_create_link(&tmp->device.kobj,
- &i2o_dev->device.kobj, "user");
-
- /* create parent entries for this device */
- tmp = i2o_iop_find_device(i2o_dev->iop, i2o_dev->lct_data.parent_tid);
- if (tmp && (tmp != i2o_dev))
- sysfs_create_link(&i2o_dev->device.kobj, &tmp->device.kobj,
- "parent");
-
- /* create parent entries refering to this device */
- list_for_each_entry(tmp, &c->devices, list)
- if ((tmp->lct_data.parent_tid == i2o_dev->lct_data.tid)
- && (tmp != i2o_dev))
- sysfs_create_link(&tmp->device.kobj,
- &i2o_dev->device.kobj, "parent");
-
- return 0;
-};
+}

-/* I2O device class interface */
-static struct class_interface i2o_device_class_interface = {
- .class = &i2o_device_class,
- .add = i2o_device_class_add
-};

/*
* Run time support routines
@@ -553,11 +549,11 @@ int i2o_parm_field_get(struct i2o_device
}

/*
- * if oper == I2O_PARAMS_TABLE_GET, get from all rows
- * if fieldcount == -1 return all fields
+ * if oper == I2O_PARAMS_TABLE_GET, get from all rows
+ * if fieldcount == -1 return all fields
* ibuf and ibuflen are unused (use NULL, 0)
- * else return specific fields
- * ibuf contains fieldindexes
+ * else return specific fields
+ * ibuf contains fieldindexes
*
* if oper == I2O_PARAMS_LIST_GET, get from specific rows
* if fieldcount == -1 return all fields
@@ -611,14 +607,8 @@ int i2o_parm_table_get(struct i2o_device
*/
int i2o_device_init(void)
{
- int rc;
-
- rc = class_register(&i2o_device_class);
- if (rc)
- return rc;
-
- return class_interface_register(&i2o_device_class_interface);
-};
+ return class_register(&i2o_device_class);
+}

/**
* i2o_device_exit - I2O devices exit function
@@ -627,9 +617,8 @@ int i2o_device_init(void)
*/
void i2o_device_exit(void)
{
- class_interface_register(&i2o_device_class_interface);
class_unregister(&i2o_device_class);
-};
+}

EXPORT_SYMBOL(i2o_device_claim);
EXPORT_SYMBOL(i2o_device_claim_release);

2005-10-28 06:45:58

by Greg KH

[permalink] [raw]
Subject: [PATCH] aoe: use get_unaligned for accesses in ATA id buffer

[PATCH] aoe: use get_unaligned for accesses in ATA id buffer

Signed-off-by: "Ed L. Cashin" <[email protected]>
Signed-off-by: David S. Miller <[email protected]>
Signed-off-by: Greg Kroah-Hartman <[email protected]>

Use get_unaligned for possibly-unaligned multi-byte accesses to the
ATA device identify response buffer.

---
commit 786fbf6c1eb91e7e70a1ef42ff2523aff0f09850
tree 2a2d7be04f20f9c3a2d133eaa37d33797d7e27da
parent 741b2252a5e14d6c60a913c77a6099abe73a854a
author Ed L. Cashin <[email protected]> Thu, 29 Sep 2005 12:47:40 -0400
committer Greg Kroah-Hartman <[email protected]> Thu, 27 Oct 2005 22:47:58 -0700

drivers/block/aoe/aoecmd.c | 15 ++++++++-------
1 files changed, 8 insertions(+), 7 deletions(-)

diff --git a/drivers/block/aoe/aoecmd.c b/drivers/block/aoe/aoecmd.c
index b5be4b7..5c9c7c1 100644
--- a/drivers/block/aoe/aoecmd.c
+++ b/drivers/block/aoe/aoecmd.c
@@ -8,6 +8,7 @@
#include <linux/blkdev.h>
#include <linux/skbuff.h>
#include <linux/netdevice.h>
+#include <asm/unaligned.h>
#include "aoe.h"

#define TIMERTICK (HZ / 10)
@@ -311,16 +312,16 @@ ataid_complete(struct aoedev *d, unsigne
u16 n;

/* word 83: command set supported */
- n = le16_to_cpup((__le16 *) &id[83<<1]);
+ n = le16_to_cpu(get_unaligned((__le16 *) &id[83<<1]));

/* word 86: command set/feature enabled */
- n |= le16_to_cpup((__le16 *) &id[86<<1]);
+ n |= le16_to_cpu(get_unaligned((__le16 *) &id[86<<1]));

if (n & (1<<10)) { /* bit 10: LBA 48 */
d->flags |= DEVFL_EXT;

/* word 100: number lba48 sectors */
- ssize = le64_to_cpup((__le64 *) &id[100<<1]);
+ ssize = le64_to_cpu(get_unaligned((__le64 *) &id[100<<1]));

/* set as in ide-disk.c:init_idedisk_capacity */
d->geo.cylinders = ssize;
@@ -331,12 +332,12 @@ ataid_complete(struct aoedev *d, unsigne
d->flags &= ~DEVFL_EXT;

/* number lba28 sectors */
- ssize = le32_to_cpup((__le32 *) &id[60<<1]);
+ ssize = le32_to_cpu(get_unaligned((__le32 *) &id[60<<1]));

/* NOTE: obsolete in ATA 6 */
- d->geo.cylinders = le16_to_cpup((__le16 *) &id[54<<1]);
- d->geo.heads = le16_to_cpup((__le16 *) &id[55<<1]);
- d->geo.sectors = le16_to_cpup((__le16 *) &id[56<<1]);
+ d->geo.cylinders = le16_to_cpu(get_unaligned((__le16 *) &id[54<<1]));
+ d->geo.heads = le16_to_cpu(get_unaligned((__le16 *) &id[55<<1]));
+ d->geo.sectors = le16_to_cpu(get_unaligned((__le16 *) &id[56<<1]));
}
d->ssize = ssize;
d->geo.start = 0;

2005-10-28 06:55:08

by Dmitry Torokhov

[permalink] [raw]
Subject: Re: [PATCH] Driver Core: document struct class_device properly

On Friday 28 October 2005 01:30, Greg KH wrote:
> [PATCH] Driver Core: document struct class_device properly
...

> + * @release: pointer to a release function for this struct class_device. If
> + * set, this will be called instead of the class specific release function.
> + * Only use this if you want to override the default release function, like
> + * when you are nesting class_device structures.
> + * @hotplug: pointer to a hotplug function for this struct class_device. If
> + * set, this will be called instead of the class specific hotplug function.
> + * Only use this if you want to override the default hotplug function, like
> + * when you are nesting class_device structures.

Greg,

Is this solution for nesting class devices considered permanent or is it
a stop-gap measure? I hope it is latter as these 2 new methods allow one
class device walk all over class's intended interface and semantics and
you can no longer rely that objects of the same class have similar
characteristics/attributes and similar behavior. You already had to
abandon using class's default attributes when dealing with nested devices,
I think it is wrong long-term solution.

What about Kay's proposal about moving (as far as userspace concerned)
everything into /sys/devices?

--
Dmitry

2005-10-28 06:55:42

by Jan-Benedict Glaw

[permalink] [raw]
Subject: Re: [PATCH] drivers/input/keyboard: convert to dynamic input_dev allocation

On Thu, 2005-10-27 23:30:24 -0700, Greg KH <[email protected]> wrote:
> diff --git a/drivers/input/keyboard/lkkbd.c b/drivers/input/keyboard/lkkbd.c
> index 098963c..7f06780 100644
> @@ -435,14 +434,14 @@ lkkbd_interrupt (struct serio *serio, un
>
> switch (data) {
> case LK_ALL_KEYS_UP:
> - input_regs (&lk->dev, regs);
> + input_regs (lk->dev, regs);
> for (i = 0; i < ARRAY_SIZE (lkkbd_keycode); i++)
> if (lk->keycode[i] != KEY_RESERVED)
> - input_report_key (&lk->dev, lk->keycode[i], 0);
> - input_sync (&lk->dev);
> + input_report_key (lk->dev, lk->keycode[i], 0);
> + input_sync (lk->dev);
> break;
> case LK_METRONOME:
> - DBG (KERN_INFO "Got LK_METRONOME and don't "
> + DBG (KERN_INFO "Got %#d and don't "
> "know how to handle...\n");
> break;
> case LK_OUTPUT_ERROR:

The format change (%#d) should take an argument on stack, shouldn't
it? But there's nothing pushed? ...or is it just a typo?

MfG, JBG

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


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

2005-10-28 07:05:39

by Dmitry Torokhov

[permalink] [raw]
Subject: Re: [PATCH] drivers/input/keyboard: convert to dynamic input_dev allocation

On Friday 28 October 2005 01:55, Jan-Benedict Glaw wrote:
> On Thu, 2005-10-27 23:30:24 -0700, Greg KH <[email protected]> wrote:
> > diff --git a/drivers/input/keyboard/lkkbd.c b/drivers/input/keyboard/lkkbd.c
> > index 098963c..7f06780 100644
> > @@ -435,14 +434,14 @@ lkkbd_interrupt (struct serio *serio, un
> >
> > switch (data) {
> > case LK_ALL_KEYS_UP:
> > - input_regs (&lk->dev, regs);
> > + input_regs (lk->dev, regs);
> > for (i = 0; i < ARRAY_SIZE (lkkbd_keycode); i++)
> > if (lk->keycode[i] != KEY_RESERVED)
> > - input_report_key (&lk->dev, lk->keycode[i], 0);
> > - input_sync (&lk->dev);
> > + input_report_key (lk->dev, lk->keycode[i], 0);
> > + input_sync (lk->dev);
> > break;
> > case LK_METRONOME:
> > - DBG (KERN_INFO "Got LK_METRONOME and don't "
> > + DBG (KERN_INFO "Got %#d and don't "
> > "know how to handle...\n");
> > break;
> > case LK_OUTPUT_ERROR:
>
> The format change (%#d) should take an argument on stack, shouldn't
> it? But there's nothing pushed? ...or is it just a typo?
>

I think I messed it up... Was probably trying to do "default" case and then
reverted back. Will fix.

--
Dmitry

2005-10-28 09:22:00

by Al Viro

[permalink] [raw]
Subject: Re: [PATCH] kobject: fix gfp flags type

On Thu, Oct 27, 2005 at 11:30:22PM -0700, Greg KH wrote:
> [PATCH] kobject: fix gfp flags type
>
> Fix implicit nocast warnings in kobject_uevent code, including __nocast:
> lib/kobject_uevent.c:78:37: warning: implicit cast to nocast type
> lib/kobject_uevent.c:97:51: warning: implicit cast to nocast type
> lib/kobject_uevent.c:120:27: warning: implicit cast to nocast type
>
> Signed-off-by: Randy Dunlap <[email protected]>
> Signed-off-by: Greg Kroah-Hartman <[email protected]>

NAK - explicit use of __nocast is wrong here.

2005-10-28 10:51:57

by Andrew Morton

[permalink] [raw]
Subject: Re: [PATCH] pci device wakeup flags

Greg KH <[email protected]> wrote:
>
> [PATCH] pci device wakeup flags
>
> This patch teaches "pci_dev" about the new driver model wakeup support:
>
> - It marks devices as supporting wakeup when "can issue PME#" is
> listed in its PCI PM capability.
>
> - pci_enable_wake() refuses to enable wake if that's been disabled
> (e.g. through sysfs).
>
> NOTE that a recent patch changed PCI probing, and this reverts part
> of that change ... so that driver model initialization is again done
> before the PCI setup.
>
> (One issue is that the driver model "init + add == register" pattern isn't
> being used inside PCI ... and that probe change worsened the problem by
> making "add" do some "init" too. Maybe PCI should match the driver model
> more closely, and just grow a new "pci_dev_init" function.)

This is the patch which I've been religiously dropping from -mm because it
kills my Mac G5. What are we doing merging this?

2005-10-28 14:31:37

by Linus Torvalds

[permalink] [raw]
Subject: Re: [PATCH] pci device wakeup flags



On Fri, 28 Oct 2005, Andrew Morton wrote:
>
> This is the patch which I've been religiously dropping from -mm because it
> kills my Mac G5. What are we doing merging this?

Well, since my main machine is a Mac G5, we certainly /aren't/ merging it
if it kills it.

Linus

2005-10-28 15:51:26

by Greg KH

[permalink] [raw]
Subject: Re: [PATCH] pci device wakeup flags

On Fri, Oct 28, 2005 at 03:51:16AM -0700, Andrew Morton wrote:
> Greg KH <[email protected]> wrote:
> >
> > [PATCH] pci device wakeup flags
> >
> > This patch teaches "pci_dev" about the new driver model wakeup support:
> >
> > - It marks devices as supporting wakeup when "can issue PME#" is
> > listed in its PCI PM capability.
> >
> > - pci_enable_wake() refuses to enable wake if that's been disabled
> > (e.g. through sysfs).
> >
> > NOTE that a recent patch changed PCI probing, and this reverts part
> > of that change ... so that driver model initialization is again done
> > before the PCI setup.
> >
> > (One issue is that the driver model "init + add == register" pattern isn't
> > being used inside PCI ... and that probe change worsened the problem by
> > making "add" do some "init" too. Maybe PCI should match the driver model
> > more closely, and just grow a new "pci_dev_init" function.)
>
> This is the patch which I've been religiously dropping from -mm because it
> kills my Mac G5. What are we doing merging this?

Crap, sorry about that. I've deleted my tree and will rebuild it. I
thought that it was one of the usb patches in my tree that was causing
you problems. I'll not include this one until we get to the bottom of
it (and with David gone, that might take a while.)

Again, very sorry about this.

Oh, and I'll also drop the one from Randy with the gfp flags, and
properly attribute Russell's patch.

thanks,

greg k-h

2005-10-28 17:48:47

by Greg KH

[permalink] [raw]
Subject: Re: [GIT PATCH] Driver Core patches for 2.6.14

On Thu, Oct 27, 2005 at 11:29:21PM -0700, Greg KH wrote:
> Here are a lot of driver core patches for 2.6.14. They have all been in
> the past few -mm releases with no problems. They contain the following
> things:

Ok, I've fixed up the issues people had with this tree. I've removed
the offending pci patch, the gfp_flag patch, added a documentation
patch, and (hopefully) proper attributed Russell's patch. I've also
merged against your latest tree.

Please pull from:
rsync://rsync.kernel.org/pub/scm/linux/kernel/git/gregkh/driver-2.6.git/
or if master.kernel.org hasn't synced up yet:
master.kernel.org:/pub/scm/linux/kernel/git/gregkh/driver-2.6.git/

Below is the diffstat and shortlog of the changes.

thanks,

greg k-h

Documentation/Changes | 2
Documentation/DocBook/writing_usb_driver.tmpl | 3
Documentation/driver-model/driver.txt | 68 ---
Documentation/driver-model/porting.txt | 2
arch/arm/common/locomo.c | 10
arch/arm/common/sa1111.c | 11
arch/arm/common/scoop.c | 24 -
arch/arm/mach-pxa/corgi_ssp.c | 24 -
arch/arm/mach-sa1100/neponset.c | 28 -
arch/i386/kernel/cpuid.c | 2
arch/i386/kernel/msr.c | 2
drivers/base/attribute_container.c | 2
drivers/base/base.h | 12
drivers/base/class.c | 152 ++++--
drivers/base/core.c | 21
drivers/base/cpu.c | 1
drivers/base/driver.c | 3
drivers/base/firmware.c | 3
drivers/base/init.c | 10
drivers/base/platform.c | 22
drivers/base/power/sysfs.c | 73 +++
drivers/block/aoe/aoe.h | 2
drivers/block/aoe/aoechr.c | 2
drivers/block/aoe/aoecmd.c | 15
drivers/block/genhd.c | 25 +
drivers/block/paride/pg.c | 2
drivers/block/paride/pt.c | 4
drivers/char/dsp56k.c | 2
drivers/char/ftape/zftape/zftape-init.c | 12
drivers/char/ip2main.c | 10
drivers/char/ipmi/ipmi_devintf.c | 2
drivers/char/istallion.c | 3
drivers/char/lp.c | 2
drivers/char/mem.c | 3
drivers/char/misc.c | 2
drivers/char/ppdev.c | 2
drivers/char/raw.c | 4
drivers/char/s3c2410-rtc.c | 20
drivers/char/snsc.c | 2
drivers/char/sonypi.c | 106 ++--
drivers/char/stallion.c | 4
drivers/char/tipar.c | 2
drivers/char/tty_io.c | 10
drivers/char/vc_screen.c | 10
drivers/char/viotape.c | 4
drivers/char/watchdog/s3c2410_wdt.c | 34 -
drivers/hwmon/hdaps.c | 6
drivers/hwmon/hwmon.c | 2
drivers/i2c/busses/i2c-s3c2410.c | 8
drivers/i2c/i2c-core.c | 4
drivers/ide/ide-tape.c | 42 +
drivers/ieee1394/dv1394.c | 2
drivers/ieee1394/nodemgr.c | 4
drivers/ieee1394/raw1394.c | 2
drivers/ieee1394/video1394.c | 2
drivers/infiniband/core/ucm.c | 2
drivers/input/evdev.c | 26 -
drivers/input/input.c | 555 +++++++++++++++----------
drivers/input/joydev.c | 26 -
drivers/input/joystick/adi.c | 93 ++--
drivers/input/joystick/amijoy.c | 87 ++-
drivers/input/joystick/analog.c | 100 ++--
drivers/input/joystick/cobra.c | 70 +--
drivers/input/joystick/db9.c | 292 +++++++------
drivers/input/joystick/gamecon.c | 396 +++++++++--------
drivers/input/joystick/gf2k.c | 71 +--
drivers/input/joystick/grip.c | 85 ++-
drivers/input/joystick/grip_mp.c | 149 +++---
drivers/input/joystick/guillemot.c | 53 +-
drivers/input/joystick/iforce/iforce-main.c | 106 ++--
drivers/input/joystick/iforce/iforce-packets.c | 5
drivers/input/joystick/iforce/iforce-serio.c | 10
drivers/input/joystick/iforce/iforce-usb.c | 22
drivers/input/joystick/iforce/iforce.h | 2
drivers/input/joystick/interact.c | 55 +-
drivers/input/joystick/magellan.c | 71 +--
drivers/input/joystick/sidewinder.c | 72 +--
drivers/input/joystick/spaceball.c | 82 +--
drivers/input/joystick/spaceorb.c | 78 +--
drivers/input/joystick/stinger.c | 75 +--
drivers/input/joystick/tmdc.c | 324 ++++++++------
drivers/input/joystick/turbografx.c | 223 ++++++----
drivers/input/joystick/twidjoy.c | 118 ++---
drivers/input/joystick/warrior.c | 83 +--
drivers/input/keyboard/amikbd.c | 59 +-
drivers/input/keyboard/atkbd.c | 188 ++++----
drivers/input/keyboard/corgikbd.c | 96 ++--
drivers/input/keyboard/lkkbd.c | 126 ++---
drivers/input/keyboard/maple_keyb.c | 76 +--
drivers/input/keyboard/newtonkbd.c | 83 +--
drivers/input/keyboard/spitzkbd.c | 121 ++---
drivers/input/keyboard/sunkbd.c | 117 ++---
drivers/input/keyboard/xtkbd.c | 82 +--
drivers/input/misc/m68kspkr.c | 40 -
drivers/input/misc/pcspkr.c | 34 -
drivers/input/misc/sparcspkr.c | 45 --
drivers/input/mouse/alps.c | 67 +--
drivers/input/mouse/alps.h | 2
drivers/input/mouse/amimouse.c | 51 +-
drivers/input/mouse/inport.c | 96 ++--
drivers/input/mouse/lifebook.c | 16
drivers/input/mouse/logibm.c | 88 ++-
drivers/input/mouse/logips2pp.c | 20
drivers/input/mouse/maplemouse.c | 10
drivers/input/mouse/pc110pad.c | 70 +--
drivers/input/mouse/psmouse-base.c | 99 ++--
drivers/input/mouse/psmouse.h | 2
drivers/input/mouse/rpcmouse.c | 43 -
drivers/input/mouse/sermouse.c | 84 +--
drivers/input/mouse/synaptics.c | 6
drivers/input/mouse/vsxxxaa.c | 84 +--
drivers/input/mousedev.c | 41 -
drivers/input/serio/i8042.c | 13
drivers/input/touchscreen/corgi_ts.c | 131 ++---
drivers/input/touchscreen/elo.c | 89 +---
drivers/input/touchscreen/gunze.c | 66 +-
drivers/input/touchscreen/h3600_ts_input.c | 149 ++----
drivers/input/touchscreen/hp680_ts_input.c | 58 +-
drivers/input/touchscreen/mk712.c | 80 +--
drivers/input/touchscreen/mtouch.c | 64 +-
drivers/input/tsdev.c | 29 -
drivers/isdn/capi/capi.c | 2
drivers/macintosh/adb.c | 2
drivers/macintosh/adbhid.c | 220 +++++----
drivers/macintosh/mac_hid.c | 44 +
drivers/media/common/ir-common.c | 1
drivers/media/dvb/cinergyT2/cinergyT2.c | 108 +++-
drivers/media/dvb/dvb-core/dvbdev.c | 2
drivers/media/dvb/dvb-usb/dvb-usb-remote.c | 50 +-
drivers/media/dvb/dvb-usb/dvb-usb.h | 3
drivers/media/dvb/ttpci/av7110_ir.c | 37 -
drivers/media/dvb/ttpci/budget-ci.c | 24 -
drivers/media/dvb/ttusb-dec/ttusb_dec.c | 51 +-
drivers/media/video/bttvp.h | 2
drivers/media/video/cx88/cx88-input.c | 58 +-
drivers/media/video/ir-kbd-gpio.c | 52 +-
drivers/media/video/ir-kbd-i2c.c | 33 -
drivers/media/video/msp3400.c | 8
drivers/media/video/saa7134/saa7134-input.c | 39 -
drivers/media/video/saa7134/saa7134.h | 2
drivers/media/video/tda9887.c | 4
drivers/media/video/tuner-core.c | 4
drivers/message/i2o/core.h | 3
drivers/message/i2o/device.c | 326 ++++++--------
drivers/message/i2o/driver.c | 3
drivers/message/i2o/iop.c | 34 -
drivers/mfd/mcp-sa11x0.c | 20
drivers/mfd/ucb1x00-ts.c | 45 +-
drivers/mmc/pxamci.c | 8
drivers/mmc/wbsd.c | 4
drivers/mtd/maps/sa1100-flash.c | 8
drivers/mtd/mtdchar.c | 4
drivers/net/dm9000.c | 8
drivers/net/irda/sa1100_ir.c | 8
drivers/net/irda/smsc-ircc2.c | 12
drivers/net/phy/mdio_bus.c | 20
drivers/net/ppp_generic.c | 2
drivers/net/smc91x.c | 8
drivers/net/wan/cosa.c | 2
drivers/pci/pcie/portdrv_core.c | 4
drivers/pcmcia/au1000_generic.c | 21
drivers/pcmcia/ds.c | 6
drivers/pcmcia/hd64465_ss.c | 20
drivers/pcmcia/i82365.c | 20
drivers/pcmcia/m32r_cfc.c | 21
drivers/pcmcia/m32r_pcc.c | 21
drivers/pcmcia/omap_cf.c | 18
drivers/pcmcia/pxa2xx_base.c | 26 -
drivers/pcmcia/rsrc_nonstatic.c | 6
drivers/pcmcia/sa1100_generic.c | 20
drivers/pcmcia/socket_sysfs.c | 6
drivers/pcmcia/tcic.c | 20
drivers/pcmcia/vrc4171_card.c | 24 -
drivers/s390/char/tape_class.c | 1
drivers/s390/char/vmlogrdr.c | 1
drivers/scsi/ch.c | 2
drivers/scsi/osst.c | 2
drivers/scsi/sg.c | 10
drivers/scsi/st.c | 2
drivers/serial/8250.c | 10
drivers/serial/imx.c | 8
drivers/serial/mpc52xx_uart.c | 8
drivers/serial/pxa.c | 8
drivers/serial/s3c2410.c | 9
drivers/serial/sa1100.c | 8
drivers/serial/vr41xx_siu.c | 10
drivers/usb/core/devio.c | 2
drivers/usb/core/file.c | 4
drivers/usb/core/hcd.c | 3
drivers/usb/core/hub.c | 16
drivers/usb/gadget/dummy_hcd.c | 22
drivers/usb/gadget/omap_udc.c | 9
drivers/usb/gadget/pxa2xx_udc.c | 17
drivers/usb/host/isp116x-hcd.c | 14
drivers/usb/host/ohci-omap.c | 10
drivers/usb/host/ohci-pxa27x.c | 4
drivers/usb/host/sl811-hcd.c | 10
drivers/usb/input/acecad.c | 78 +--
drivers/usb/input/aiptek.c | 209 ++++-----
drivers/usb/input/appletouch.c | 130 +++--
drivers/usb/input/ati_remote.c | 173 ++++---
drivers/usb/input/hid-core.c | 51 +-
drivers/usb/input/hid-input.c | 58 +-
drivers/usb/input/hid-lgff.c | 17
drivers/usb/input/hid-tmff.c | 11
drivers/usb/input/hid.h | 2
drivers/usb/input/itmtouch.c | 72 +--
drivers/usb/input/kbtab.c | 86 +--
drivers/usb/input/keyspan_remote.c | 214 ++++-----
drivers/usb/input/mtouchusb.c | 111 ++---
drivers/usb/input/pid.c | 12
drivers/usb/input/powermate.c | 136 +++---
drivers/usb/input/touchkitusb.c | 116 ++---
drivers/usb/input/usbkbd.c | 105 ++--
drivers/usb/input/usbmouse.c | 97 ++--
drivers/usb/input/wacom.c | 142 ++----
drivers/usb/input/xpad.c | 97 +---
drivers/usb/input/yealink.c | 66 +-
drivers/usb/media/konicawc.c | 89 ++--
drivers/usb/storage/onetouch.c | 105 ++--
drivers/video/backlight/corgi_bl.c | 10
drivers/video/fbmem.c | 2
drivers/video/imxfb.c | 10
drivers/video/pxafb.c | 10
drivers/video/s1d13xxxfb.c | 7
drivers/video/s3c2410fb.c | 29 -
drivers/video/sa1100fb.c | 10
drivers/video/w100fb.c | 48 +-
fs/coda/psdev.c | 4
fs/partitions/check.c | 27 +
include/linux/device.h | 115 ++---
include/linux/genhd.h | 1
include/linux/i2o.h | 4
include/linux/input.h | 28 +
include/linux/pm.h | 26 +
lib/kobject_uevent.c | 2
net/bluetooth/hidp/core.c | 13
sound/arm/pxa2xx-ac97.c | 8
sound/core/init.c | 14
sound/core/sound.c | 2
sound/oss/soundcard.c | 4
sound/pci/ac97/ac97_bus.c | 6
sound/ppc/beep.c | 68 +--
sound/sound_core.c | 2
244 files changed, 5682 insertions(+), 5316 deletions(-)


Ben Dooks:
drivers/base - fix sparse warnings

David Brownell:
driver model wakeup flags
usb device wakeup flags

Dmitry Torokhov:
I2O: remove class interface
Driver core: send hotplug event before adding class interfaces
I2O: remove i2o_device_class
Driver core: pass interface to class interface methods
drivers/input/mouse: convert to dynamic input_dev allocation
drivers/input/keyboard: convert to dynamic input_dev allocation
Input: kill devfs references
Input: convert ucb1x00-ts to dynamic input_dev allocation
drivers/usb/input: convert to dynamic input_dev allocation
Input: prepare to sysfs integration
Input: convert konicawc to dynamic input_dev allocation
drivers/input/joystick: convert to dynamic input_dev allocation
Input: convert driver/input/misc to dynamic input_dev allocation
Input: convert onetouch to dynamic input_dev allocation
Input: convert sonypi to dynamic input_dev allocation
drivers/media: convert to dynamic input_dev allocation
Input: convert drivers/macintosh to dynamic input_dev allocation
drivers/input/touchscreen: convert to dynamic input_dev allocation
Input: show sysfs path in /proc/bus/input/devices
Input: convert net/bluetooth to dynamic input_dev allocation
Input: export input_dev data via sysfs attributes
Input: convert sound/ppc/beep to dynamic input_dev allocation
input core: remove custom-made hotplug handler

Ed L Cashin:
aoe: use get_unaligned for accesses in ATA id buffer
aoe: update to version 14

Erik Hovland:
changes device to driver in porting.txt
kobject_uevent.c has a typo in a comment

Greg Kroah-Hartman:
Driver Core: add the ability for class_device structures to be nested
I2O: Clean up some pretty bad driver model abuses in the i2o code
Driver Core: fix up all callers of class_device_create()
Driver Core: document struct class_device properly
INPUT: register the input class device sooner
INPUT: export input_dev_class so that input drivers can use it.
INPUT: Fix oops when accessing sysfs files of nested input devices
INPUT: move the input class devices under their new input_dev devices
update required version of udev
INPUT: remove the input_class structure, as it is unused.
INPUT: Create symlinks for backwards compatibility
INPUT: rename input_dev_class to input_class to be correct.

Jesper Juhl:
Driver Core: Big kfree NULL check cleanup - Documentation

Kay Sievers:
add sysfs attr to re-emit device hotplug event

Randy Dunlap:
kernel-doc: drivers/base fixes

Russell King:
DRIVER MODEL: Get rid of the obsolete tri-level suspend/resume callbacks

Takashi Iwai:
Fix documentation of driver suspend/resume callbacks

Will Dyson:
add sysfs support for ide tape

2005-10-28 18:55:32

by Jan-Benedict Glaw

[permalink] [raw]
Subject: Re: [GIT PATCH] Driver Core patches for 2.6.14

On Fri, 2005-10-28 10:48:12 -0700, Greg KH <[email protected]> wrote:
> Please pull from:
> rsync://rsync.kernel.org/pub/scm/linux/kernel/git/gregkh/driver-2.6.git/
> or if master.kernel.org hasn't synced up yet:
> master.kernel.org:/pub/scm/linux/kernel/git/gregkh/driver-2.6.git/
>
> Below is the diffstat and shortlog of the changes.

> drivers/input/keyboard/lkkbd.c | 126 ++---

Not ACKed. This patch contains a not-fixed (though reported) wrong
printk format in lkkbd_interrupt() "case LK_METRONOME:" Though I
haven't tested it yet, it's ACKed by me after this is fixed.

> drivers/input/mouse/vsxxxaa.c | 84 +--

Acked-by: Jan-Benedict Glaw <[email protected]>

MfG, JBG

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


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

2005-10-28 19:11:44

by Greg KH

[permalink] [raw]
Subject: Re: [GIT PATCH] Driver Core patches for 2.6.14

On Fri, Oct 28, 2005 at 08:55:30PM +0200, Jan-Benedict Glaw wrote:
> On Fri, 2005-10-28 10:48:12 -0700, Greg KH <[email protected]> wrote:
> > Please pull from:
> > rsync://rsync.kernel.org/pub/scm/linux/kernel/git/gregkh/driver-2.6.git/
> > or if master.kernel.org hasn't synced up yet:
> > master.kernel.org:/pub/scm/linux/kernel/git/gregkh/driver-2.6.git/
> >
> > Below is the diffstat and shortlog of the changes.
>
> > drivers/input/keyboard/lkkbd.c | 126 ++---
>
> Not ACKed. This patch contains a not-fixed (though reported) wrong
> printk format in lkkbd_interrupt() "case LK_METRONOME:" Though I
> haven't tested it yet, it's ACKed by me after this is fixed.

That can be a one-line add on patch once it is created. I can easily
send that later.

thanks,

greg k-h

2005-10-28 19:11:38

by Greg KH

[permalink] [raw]
Subject: Re: [PATCH] Driver Core: document struct class_device properly

On Fri, Oct 28, 2005 at 01:54:59AM -0500, Dmitry Torokhov wrote:
> On Friday 28 October 2005 01:30, Greg KH wrote:
> > [PATCH] Driver Core: document struct class_device properly
> ...
>
> > + * @release: pointer to a release function for this struct class_device. If
> > + * set, this will be called instead of the class specific release function.
> > + * Only use this if you want to override the default release function, like
> > + * when you are nesting class_device structures.
> > + * @hotplug: pointer to a hotplug function for this struct class_device. If
> > + * set, this will be called instead of the class specific hotplug function.
> > + * Only use this if you want to override the default hotplug function, like
> > + * when you are nesting class_device structures.
>
> Greg,
>
> Is this solution for nesting class devices considered permanent or is it
> a stop-gap measure?

As I detalied a while ago, a stop-gap for now.

> I hope it is latter as these 2 new methods allow one
> class device walk all over class's intended interface and semantics and
> you can no longer rely that objects of the same class have similar
> characteristics/attributes and similar behavior. You already had to
> abandon using class's default attributes when dealing with nested devices,
> I think it is wrong long-term solution.
>
> What about Kay's proposal about moving (as far as userspace concerned)
> everything into /sys/devices?

That's exactly what I am now working on. But it will take much longer
than 2.6.15 to get there for that. More like the next 6 months or so at
the least...

For a good description of the latest summary, see:
http://www.kroah.com/log/linux/driver_model_changes.html
thanks,

greg k-h

2005-10-28 19:16:32

by Jan-Benedict Glaw

[permalink] [raw]
Subject: Re: [GIT PATCH] Driver Core patches for 2.6.14

On Fri, 2005-10-28 12:11:07 -0700, Greg KH <[email protected]> wrote:
> On Fri, Oct 28, 2005 at 08:55:30PM +0200, Jan-Benedict Glaw wrote:
> > On Fri, 2005-10-28 10:48:12 -0700, Greg KH <[email protected]> wrote:
> > > drivers/input/keyboard/lkkbd.c | 126 ++---
> >
> > Not ACKed. This patch contains a not-fixed (though reported) wrong
> > printk format in lkkbd_interrupt() "case LK_METRONOME:" Though I
> > haven't tested it yet, it's ACKed by me after this is fixed.
>
> That can be a one-line add on patch once it is created. I can easily
> send that later.

Jap, that's okay. But somebody needs to do that:)

MfG, JBG

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


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

2005-10-28 19:18:56

by Dmitry Torokhov

[permalink] [raw]
Subject: Re: [PATCH] Driver Core: document struct class_device properly

On 10/28/05, Greg KH <[email protected]> wrote:
> On Fri, Oct 28, 2005 at 01:54:59AM -0500, Dmitry Torokhov wrote:
> > On Friday 28 October 2005 01:30, Greg KH wrote:
> > > [PATCH] Driver Core: document struct class_device properly
> > ...
> >
> > > + * @release: pointer to a release function for this struct class_device. If
> > > + * set, this will be called instead of the class specific release function.
> > > + * Only use this if you want to override the default release function, like
> > > + * when you are nesting class_device structures.
> > > + * @hotplug: pointer to a hotplug function for this struct class_device. If
> > > + * set, this will be called instead of the class specific hotplug function.
> > > + * Only use this if you want to override the default hotplug function, like
> > > + * when you are nesting class_device structures.
> >
> > Greg,
> >
> > Is this solution for nesting class devices considered permanent or is it
> > a stop-gap measure?
>
> As I detalied a while ago, a stop-gap for now.
>

Ok, I kind of lost track of what has been decided in the end. Thank
you for confirming it.

--
Dmitry

2005-10-28 19:35:15

by Andrew Morton

[permalink] [raw]
Subject: Re: [PATCH] pci device wakeup flags

Greg KH <[email protected]> wrote:
>
> I
> thought that it was one of the usb patches in my tree that was causing
> you problems.

That's a separate problem. gregkh-usb-usb-pm-09.patch causes my x86 box to
hang partway though boot. I drop that from -mm as well.

2005-10-28 19:46:29

by Greg KH

[permalink] [raw]
Subject: Re: [PATCH] pci device wakeup flags

On Fri, Oct 28, 2005 at 12:34:34PM -0700, Andrew Morton wrote:
> Greg KH <[email protected]> wrote:
> >
> > I
> > thought that it was one of the usb patches in my tree that was causing
> > you problems.
>
> That's a separate problem. gregkh-usb-usb-pm-09.patch causes my x86 box to
> hang partway though boot. I drop that from -mm as well.

Ugh, ok, at least I wasn't that far off. I'll make sure to not send the
usb pm patches in the round of usb updates until that gets figured out.

thanks,

greg k-h

2005-10-28 19:48:04

by Linus Torvalds

[permalink] [raw]
Subject: Re: [PATCH] pci device wakeup flags



On Fri, 28 Oct 2005, Andrew Morton wrote:

> Greg KH <[email protected]> wrote:
> >
> > I
> > thought that it was one of the usb patches in my tree that was causing
> > you problems.
>
> That's a separate problem. gregkh-usb-usb-pm-09.patch causes my x86 box to
> hang partway though boot. I drop that from -mm as well.

Just to verify: that one isn't in the current driver core tree, right? I
assume that's in Greg's USB tree..

Greg?

Linus

2005-10-28 19:57:06

by Russell King

[permalink] [raw]
Subject: Re: [PATCH] pci device wakeup flags

On Fri, Oct 28, 2005 at 12:45:28PM -0700, Greg KH wrote:
> Ugh, ok, at least I wasn't that far off. I'll make sure to not send the
> usb pm patches in the round of usb updates until that gets figured out.

On Fri, Oct 28, 2005 at 12:47:50PM -0700, Linus Torvalds wrote:
> Just to verify: that one isn't in the current driver core tree, right? I
> assume that's in Greg's USB tree..

Greg,

Any chance of putting my driver model changes into the driver core tree?
ISTR the reason they ended up in the USB tree was because they clashed
with the usb-pm patches. However, if the usb-pm patches are
problematical, I'd rather my driver model changes weren't held up.

Alternatively, I could ask Linus to take them directly from me if
you're happy for that to happen.

--
Russell King
Linux kernel 2.6 ARM Linux - http://www.arm.linux.org.uk/
maintainer of: 2.6 Serial core

2005-10-28 20:02:17

by Greg KH

[permalink] [raw]
Subject: Re: [PATCH] pci device wakeup flags

On Fri, Oct 28, 2005 at 12:47:50PM -0700, Linus Torvalds wrote:
>
>
> On Fri, 28 Oct 2005, Andrew Morton wrote:
>
> > Greg KH <[email protected]> wrote:
> > >
> > > I
> > > thought that it was one of the usb patches in my tree that was causing
> > > you problems.
> >
> > That's a separate problem. gregkh-usb-usb-pm-09.patch causes my x86 box to
> > hang partway though boot. I drop that from -mm as well.
>
> Just to verify: that one isn't in the current driver core tree, right? I
> assume that's in Greg's USB tree..
>
> Greg?

Yes, that is correct, that patch is not in this git tree that I asked
you to pull from. All of the patches that break Andrew's boxes will not
be sent to you until I figure out what is happening and fix them.

thanks,

greg k-h

2005-10-28 20:08:51

by Greg KH

[permalink] [raw]
Subject: Re: [PATCH] pci device wakeup flags

On Fri, Oct 28, 2005 at 08:56:54PM +0100, Russell King wrote:
> On Fri, Oct 28, 2005 at 12:45:28PM -0700, Greg KH wrote:
> > Ugh, ok, at least I wasn't that far off. I'll make sure to not send the
> > usb pm patches in the round of usb updates until that gets figured out.
>
> On Fri, Oct 28, 2005 at 12:47:50PM -0700, Linus Torvalds wrote:
> > Just to verify: that one isn't in the current driver core tree, right? I
> > assume that's in Greg's USB tree..
>
> Greg,
>
> Any chance of putting my driver model changes into the driver core tree?

They are in there already. :)

> ISTR the reason they ended up in the USB tree was because they clashed
> with the usb-pm patches. However, if the usb-pm patches are
> problematical, I'd rather my driver model changes weren't held up.

They have not been held up. I made the required usb-pm fixups already,
based on your patches. They are dependant on your changes, not the
other way around.

thanks,

greg k-h

2005-10-28 23:04:18

by Benjamin Herrenschmidt

[permalink] [raw]
Subject: Re: [PATCH] pci device wakeup flags

On Fri, 2005-10-28 at 07:31 -0700, Linus Torvalds wrote:
>
> On Fri, 28 Oct 2005, Andrew Morton wrote:
> >
> > This is the patch which I've been religiously dropping from -mm because it
> > kills my Mac G5. What are we doing merging this?
>
> Well, since my main machine is a Mac G5, we certainly /aren't/ merging it
> if it kills it.

Yah, that's a known one, the problem is due to the removal of
device_initialize() from pci_device_add(). The breaks the new mecanism
on ppc64 that creates the PCI tree from the firmware instead of probing
the bus. In addition, even with that fixed, the code looking for PME#
will not be run on the pmac neither.

I'm not 100% what is the best fix at this point. I suppose it would be 2
things, let me know what you think about it:

- Have the ppc64 PCI tree code call device_initialize() itself before
calling pci_device_add()

- Move the search of PME# (and possibly other similar bits) from probe
to pci_device_add()

Ben.


2005-10-29 05:59:42

by Dmitry Torokhov

[permalink] [raw]
Subject: Re: [PATCH] drivers/input/keyboard: convert to dynamic input_dev allocation

On Friday 28 October 2005 02:05, Dmitry Torokhov wrote:
> On Friday 28 October 2005 01:55, Jan-Benedict Glaw wrote:
> > On Thu, 2005-10-27 23:30:24 -0700, Greg KH <[email protected]> wrote:
> > > diff --git a/drivers/input/keyboard/lkkbd.c b/drivers/input/keyboard/lkkbd.c
> > > index 098963c..7f06780 100644
> > > @@ -435,14 +434,14 @@ lkkbd_interrupt (struct serio *serio, un
> > >
> > > switch (data) {
> > > case LK_ALL_KEYS_UP:
> > > - input_regs (&lk->dev, regs);
> > > + input_regs (lk->dev, regs);
> > > for (i = 0; i < ARRAY_SIZE (lkkbd_keycode); i++)
> > > if (lk->keycode[i] != KEY_RESERVED)
> > > - input_report_key (&lk->dev, lk->keycode[i], 0);
> > > - input_sync (&lk->dev);
> > > + input_report_key (lk->dev, lk->keycode[i], 0);
> > > + input_sync (lk->dev);
> > > break;
> > > case LK_METRONOME:
> > > - DBG (KERN_INFO "Got LK_METRONOME and don't "
> > > + DBG (KERN_INFO "Got %#d and don't "
> > > "know how to handle...\n");
> > > break;
> > > case LK_OUTPUT_ERROR:
> >
> > The format change (%#d) should take an argument on stack, shouldn't
> > it? But there's nothing pushed? ...or is it just a typo?
> >
>
> I think I messed it up... Was probably trying to do "default" case and then
> reverted back. Will fix.
>

That's what I wanted to do...

--
Dmitry

Input: lkkbd - consolidate messages in lkkbd_interrup()

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

drivers/input/keyboard/lkkbd.c | 28 +++++-----------------------
1 files changed, 5 insertions(+), 23 deletions(-)

Index: work/drivers/input/keyboard/lkkbd.c
===================================================================
--- work.orig/drivers/input/keyboard/lkkbd.c
+++ work/drivers/input/keyboard/lkkbd.c
@@ -440,38 +440,20 @@ lkkbd_interrupt (struct serio *serio, un
input_report_key (lk->dev, lk->keycode[i], 0);
input_sync (lk->dev);
break;
+
case LK_METRONOME:
- DBG (KERN_INFO "Got %#d and don't "
- "know how to handle...\n");
- break;
case LK_OUTPUT_ERROR:
- DBG (KERN_INFO "Got LK_OUTPUT_ERROR and don't "
- "know how to handle...\n");
- break;
case LK_INPUT_ERROR:
- DBG (KERN_INFO "Got LK_INPUT_ERROR and don't "
- "know how to handle...\n");
- break;
case LK_KBD_LOCKED:
- DBG (KERN_INFO "Got LK_KBD_LOCKED and don't "
- "know how to handle...\n");
- break;
case LK_KBD_TEST_MODE_ACK:
- DBG (KERN_INFO "Got LK_KBD_TEST_MODE_ACK and don't "
- "know how to handle...\n");
- break;
case LK_PREFIX_KEY_DOWN:
- DBG (KERN_INFO "Got LK_PREFIX_KEY_DOWN and don't "
- "know how to handle...\n");
- break;
case LK_MODE_CHANGE_ACK:
- DBG (KERN_INFO "Got LK_MODE_CHANGE_ACK and ignored "
- "it properly...\n");
- break;
case LK_RESPONSE_RESERVED:
- DBG (KERN_INFO "Got LK_RESPONSE_RESERVED and don't "
- "know how to handle...\n");
+ DBG (KERN_INFO
+ "Got 0x%02x and don't know how to handle...\n",
+ data);
break;
+
case 0x01:
DBG (KERN_INFO "Got 0x01, scheduling re-initialization\n");
lk->ignore_bytes = LK_NUM_IGNORE_BYTES;

2005-10-29 14:37:39

by Jan-Benedict Glaw

[permalink] [raw]
Subject: Re: [PATCH] drivers/input/keyboard: convert to dynamic input_dev allocation

On Sat, 2005-10-29 00:59:36 -0500, Dmitry Torokhov <[email protected]> wrote:
> On Friday 28 October 2005 02:05, Dmitry Torokhov wrote:
> drivers/input/keyboard/lkkbd.c | 28 +++++-----------------------
> 1 files changed, 5 insertions(+), 23 deletions(-)
>
> Index: work/drivers/input/keyboard/lkkbd.c
> ===================================================================
> --- work.orig/drivers/input/keyboard/lkkbd.c
> +++ work/drivers/input/keyboard/lkkbd.c
> @@ -440,38 +440,20 @@ lkkbd_interrupt (struct serio *serio, un
> input_report_key (lk->dev, lk->keycode[i], 0);
> input_sync (lk->dev);
> break;
> +
> case LK_METRONOME:
> - DBG (KERN_INFO "Got %#d and don't "
> - "know how to handle...\n");
> - break;
> case LK_OUTPUT_ERROR:
> - DBG (KERN_INFO "Got LK_OUTPUT_ERROR and don't "
> - "know how to handle...\n");
> - break;
> case LK_INPUT_ERROR:
> - DBG (KERN_INFO "Got LK_INPUT_ERROR and don't "
> - "know how to handle...\n");
> - break;
> case LK_KBD_LOCKED:
> - DBG (KERN_INFO "Got LK_KBD_LOCKED and don't "
> - "know how to handle...\n");
> - break;
> case LK_KBD_TEST_MODE_ACK:
> - DBG (KERN_INFO "Got LK_KBD_TEST_MODE_ACK and don't "
> - "know how to handle...\n");
> - break;
> case LK_PREFIX_KEY_DOWN:
> - DBG (KERN_INFO "Got LK_PREFIX_KEY_DOWN and don't "
> - "know how to handle...\n");
> - break;
> case LK_MODE_CHANGE_ACK:
> - DBG (KERN_INFO "Got LK_MODE_CHANGE_ACK and ignored "
> - "it properly...\n");
> - break;
> case LK_RESPONSE_RESERVED:
> - DBG (KERN_INFO "Got LK_RESPONSE_RESERVED and don't "
> - "know how to handle...\n");
> + DBG (KERN_INFO
> + "Got 0x%02x and don't know how to handle...\n",
> + data);
> break;
> +
> case 0x01:
> DBG (KERN_INFO "Got 0x01, scheduling re-initialization\n");
> lk->ignore_bytes = LK_NUM_IGNORE_BYTES;

That'll greatly help in debugging it if needed. Thanks.

If you really want to make that switch smaller, please put some small
table like

#define RESPONSE(x) { .value = x, .name = #x, }
struct {
unsigned char value;
unsigned char *name;
} response[] {
RESPONSE (LK_KBD_TEST_MODE_ACK),
RESPONSE (LK_PREFIX_KEY_DOWN),
...
};

into the driver along with a small search function like

unsigned char *
find_response_name (unsigned char value)
{
int i;

for (i = 0; i < ARRAY_SIZE (response); i++)
if (response[i].value == value)
return response[i].name;

return NULL;
}

MfG, JBG

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


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

2005-10-29 15:04:56

by Jan-Benedict Glaw

[permalink] [raw]
Subject: Re: [PATCH] drivers/input/keyboard: convert to dynamic input_dev allocation

Hi Dmitry!

On Sat, 2005-10-29 00:59:36 -0500, Dmitry Torokhov <[email protected]> wrote:

[...a patch I don't like]

Please use this patch instead:

Input: lkkbd - consolidate messages in lkkbd_interrup()

Signed-off-by: Jan-Benedict Glaw <[email protected]>
---

lkkbd.c | 99 ++++++++++++++++++++++++++++++++++++----------------------------
1 files changed, 57 insertions(+), 42 deletions(-)

diff --git a/drivers/input/keyboard/lkkbd.c b/drivers/input/keyboard/lkkbd.c
index 7f06780..f72a9ce 100644
--- a/drivers/input/keyboard/lkkbd.c
+++ b/drivers/input/keyboard/lkkbd.c
@@ -273,11 +273,11 @@ static lk_keycode_t lkkbd_keycode[LK_NUM
[0xfb] = KEY_APOSTROPHE,
};

-#define CHECK_LED(LED, BITS) do { \
- if (test_bit (LED, lk->dev->led)) \
- leds_on |= BITS; \
- else \
- leds_off |= BITS; \
+#define CHECK_LED(LK, VAR_ON, VAR_OFF, LED, BITS) do { \
+ if (test_bit (LED, (LK)->dev->led)) \
+ VAR_ON |= BITS; \
+ else \
+ VAR_OFF |= BITS; \
} while (0)

/*
@@ -299,6 +299,40 @@ struct lkkbd {
};

/*
+ * Responses from the keyboard and mapping back to their names.
+ */
+struct {
+ unsigned char value;
+ unsigned char *name;
+} lk_response[] = {
+#define RESPONSE(x) { .value = (x), .name = #x, }
+ RESPONSE (LK_STUCK_KEY),
+ RESPONSE (LK_SELFTEST_FAILED),
+ RESPONSE (LK_ALL_KEYS_UP),
+ RESPONSE (LK_METRONOME),
+ RESPONSE (LK_OUTPUT_ERROR),
+ RESPONSE (LK_INPUT_ERROR),
+ RESPONSE (LK_KBD_LOCKED),
+ RESPONSE (LK_KBD_TEST_MODE_ACK),
+ RESPONSE (LK_PREFIX_KEY_DOWN),
+ RESPONSE (LK_MODE_CHANGE_ACK),
+ RESPONSE (LK_RESPONSE_RESERVED),
+#undef RESPONSE
+};
+
+unsigned char *
+response_name (unsigned char value)
+{
+ int i;
+
+ for (i = 0; i < ARRAY_SIZE (lk_response); i++)
+ if (lk_response[i].value == value)
+ return lk_response[i].name;
+
+ return "unknown";
+}
+
+/*
* Calculate volume parameter byte for a given volume.
*/
static unsigned char
@@ -440,43 +474,24 @@ lkkbd_interrupt (struct serio *serio, un
input_report_key (lk->dev, lk->keycode[i], 0);
input_sync (lk->dev);
break;
- case LK_METRONOME:
- DBG (KERN_INFO "Got %#d and don't "
- "know how to handle...\n");
+
+ case 0x01:
+ DBG (KERN_INFO "Got 0x01, scheduling re-initialization\n");
+ lk->ignore_bytes = LK_NUM_IGNORE_BYTES;
+ lk->id[LK_NUM_IGNORE_BYTES - lk->ignore_bytes--] = data;
+ schedule_work (&lk->tq);
break;
+
+ case LK_METRONOME:
case LK_OUTPUT_ERROR:
- DBG (KERN_INFO "Got LK_OUTPUT_ERROR and don't "
- "know how to handle...\n");
- break;
case LK_INPUT_ERROR:
- DBG (KERN_INFO "Got LK_INPUT_ERROR and don't "
- "know how to handle...\n");
- break;
case LK_KBD_LOCKED:
- DBG (KERN_INFO "Got LK_KBD_LOCKED and don't "
- "know how to handle...\n");
- break;
case LK_KBD_TEST_MODE_ACK:
- DBG (KERN_INFO "Got LK_KBD_TEST_MODE_ACK and don't "
- "know how to handle...\n");
- break;
case LK_PREFIX_KEY_DOWN:
- DBG (KERN_INFO "Got LK_PREFIX_KEY_DOWN and don't "
- "know how to handle...\n");
- break;
case LK_MODE_CHANGE_ACK:
- DBG (KERN_INFO "Got LK_MODE_CHANGE_ACK and ignored "
- "it properly...\n");
- break;
case LK_RESPONSE_RESERVED:
- DBG (KERN_INFO "Got LK_RESPONSE_RESERVED and don't "
- "know how to handle...\n");
- break;
- case 0x01:
- DBG (KERN_INFO "Got 0x01, scheduling re-initialization\n");
- lk->ignore_bytes = LK_NUM_IGNORE_BYTES;
- lk->id[LK_NUM_IGNORE_BYTES - lk->ignore_bytes--] = data;
- schedule_work (&lk->tq);
+ DBG (KERN_INFO "Got %s and don't know how to handle...\n",
+ response_name (data));
break;

default:
@@ -509,10 +524,10 @@ lkkbd_event (struct input_dev *dev, unsi

switch (type) {
case EV_LED:
- CHECK_LED (LED_CAPSL, LK_LED_SHIFTLOCK);
- CHECK_LED (LED_COMPOSE, LK_LED_COMPOSE);
- CHECK_LED (LED_SCROLLL, LK_LED_SCROLLLOCK);
- CHECK_LED (LED_SLEEP, LK_LED_WAIT);
+ CHECK_LED (lk, leds_on, leds_off, LED_CAPSL, LK_LED_SHIFTLOCK);
+ CHECK_LED (lk, leds_on, leds_off, LED_COMPOSE, LK_LED_COMPOSE);
+ CHECK_LED (lk, leds_on, leds_off, LED_SCROLLL, LK_LED_SCROLLLOCK);
+ CHECK_LED (lk, leds_on, leds_off, LED_SLEEP, LK_LED_WAIT);
if (leds_on != 0) {
lk->serio->write (lk->serio, LK_CMD_LED_ON);
lk->serio->write (lk->serio, leds_on);
@@ -574,10 +589,10 @@ lkkbd_reinit (void *data)
lk->serio->write (lk->serio, LK_CMD_SET_DEFAULTS);

/* Set LEDs */
- CHECK_LED (LED_CAPSL, LK_LED_SHIFTLOCK);
- CHECK_LED (LED_COMPOSE, LK_LED_COMPOSE);
- CHECK_LED (LED_SCROLLL, LK_LED_SCROLLLOCK);
- CHECK_LED (LED_SLEEP, LK_LED_WAIT);
+ CHECK_LED (lk, leds_on, leds_off, LED_CAPSL, LK_LED_SHIFTLOCK);
+ CHECK_LED (lk, leds_on, leds_off, LED_COMPOSE, LK_LED_COMPOSE);
+ CHECK_LED (lk, leds_on, leds_off, LED_SCROLLL, LK_LED_SCROLLLOCK);
+ CHECK_LED (lk, leds_on, leds_off, LED_SLEEP, LK_LED_WAIT);
if (leds_on != 0) {
lk->serio->write (lk->serio, LK_CMD_LED_ON);
lk->serio->write (lk->serio, leds_on);

Thanks, JBG

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


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

2005-10-29 16:28:53

by Dmitry Torokhov

[permalink] [raw]
Subject: Re: [PATCH] drivers/input/keyboard: convert to dynamic input_dev allocation

On Saturday 29 October 2005 10:04, Jan-Benedict Glaw wrote:
> Hi Dmitry!
>
> On Sat, 2005-10-29 00:59:36 -0500, Dmitry Torokhov <[email protected]> wrote:
>
> [...a patch I don't like]
>

[ .. a patch that now I don't like ..]

The messages are only generated when someone explicitely enables LKKBD_DEBUG,
and if someone does enable it he surely can map the numeric values himself.
There is no need to clutter the code with insignificant details.

--
Dmitry

2005-10-29 18:53:24

by Jan-Benedict Glaw

[permalink] [raw]
Subject: Re: [PATCH] drivers/input/keyboard: convert to dynamic input_dev allocation

On Sat, 2005-10-29 11:28:47 -0500, Dmitry Torokhov <[email protected]> wrote:
> On Saturday 29 October 2005 10:04, Jan-Benedict Glaw wrote:
> > On Sat, 2005-10-29 00:59:36 -0500, Dmitry Torokhov <[email protected]> wrote:
> >
> > [...a patch I don't like]
> [ .. a patch that now I don't like ..]
>
> The messages are only generated when someone explicitely enables LKKBD_DEBUG,
> and if someone does enable it he surely can map the numeric values himself.
> There is no need to clutter the code with insignificant details.

Actually, I think there is. It should just be easy to use; albeit
that, if you look precisely at it, there are some defines etc that
aren't even used. Why? Because it documents the hardware.

I didn't like the larce switch either, but I kept it there for a
reason. So I'd really like to keep the ability to print out these
values by name. I don't think it hurts, so please keep it there.

Here's a revised version of the patch, making the function and it's
data static, as well as stuffing them into #ifdef DEBUG.

diff --git a/drivers/input/keyboard/lkkbd.c b/drivers/input/keyboard/lkkbd.c
index 7f06780..7173441 100644
--- a/drivers/input/keyboard/lkkbd.c
+++ b/drivers/input/keyboard/lkkbd.c
@@ -273,11 +273,11 @@ static lk_keycode_t lkkbd_keycode[LK_NUM
[0xfb] = KEY_APOSTROPHE,
};

-#define CHECK_LED(LED, BITS) do { \
- if (test_bit (LED, lk->dev->led)) \
- leds_on |= BITS; \
- else \
- leds_off |= BITS; \
+#define CHECK_LED(LK, VAR_ON, VAR_OFF, LED, BITS) do { \
+ if (test_bit (LED, (LK)->dev->led)) \
+ VAR_ON |= BITS; \
+ else \
+ VAR_OFF |= BITS; \
} while (0)

/*
@@ -298,6 +298,42 @@ struct lkkbd {
int ctrlclick_volume;
};

+#ifdef LKKBD_DEBUG
+/*
+ * Responses from the keyboard and mapping back to their names.
+ */
+static struct {
+ unsigned char value;
+ unsigned char *name;
+} lk_response[] = {
+#define RESPONSE(x) { .value = (x), .name = #x, }
+ RESPONSE (LK_STUCK_KEY),
+ RESPONSE (LK_SELFTEST_FAILED),
+ RESPONSE (LK_ALL_KEYS_UP),
+ RESPONSE (LK_METRONOME),
+ RESPONSE (LK_OUTPUT_ERROR),
+ RESPONSE (LK_INPUT_ERROR),
+ RESPONSE (LK_KBD_LOCKED),
+ RESPONSE (LK_KBD_TEST_MODE_ACK),
+ RESPONSE (LK_PREFIX_KEY_DOWN),
+ RESPONSE (LK_MODE_CHANGE_ACK),
+ RESPONSE (LK_RESPONSE_RESERVED),
+#undef RESPONSE
+};
+
+static unsigned char *
+response_name (unsigned char value)
+{
+ int i;
+
+ for (i = 0; i < ARRAY_SIZE (lk_response); i++)
+ if (lk_response[i].value == value)
+ return lk_response[i].name;
+
+ return "unknown";
+}
+#endif /* LKKBD_DEBUG */
+
/*
* Calculate volume parameter byte for a given volume.
*/
@@ -440,43 +476,24 @@ lkkbd_interrupt (struct serio *serio, un
input_report_key (lk->dev, lk->keycode[i], 0);
input_sync (lk->dev);
break;
- case LK_METRONOME:
- DBG (KERN_INFO "Got %#d and don't "
- "know how to handle...\n");
+
+ case 0x01:
+ DBG (KERN_INFO "Got 0x01, scheduling re-initialization\n");
+ lk->ignore_bytes = LK_NUM_IGNORE_BYTES;
+ lk->id[LK_NUM_IGNORE_BYTES - lk->ignore_bytes--] = data;
+ schedule_work (&lk->tq);
break;
+
+ case LK_METRONOME:
case LK_OUTPUT_ERROR:
- DBG (KERN_INFO "Got LK_OUTPUT_ERROR and don't "
- "know how to handle...\n");
- break;
case LK_INPUT_ERROR:
- DBG (KERN_INFO "Got LK_INPUT_ERROR and don't "
- "know how to handle...\n");
- break;
case LK_KBD_LOCKED:
- DBG (KERN_INFO "Got LK_KBD_LOCKED and don't "
- "know how to handle...\n");
- break;
case LK_KBD_TEST_MODE_ACK:
- DBG (KERN_INFO "Got LK_KBD_TEST_MODE_ACK and don't "
- "know how to handle...\n");
- break;
case LK_PREFIX_KEY_DOWN:
- DBG (KERN_INFO "Got LK_PREFIX_KEY_DOWN and don't "
- "know how to handle...\n");
- break;
case LK_MODE_CHANGE_ACK:
- DBG (KERN_INFO "Got LK_MODE_CHANGE_ACK and ignored "
- "it properly...\n");
- break;
case LK_RESPONSE_RESERVED:
- DBG (KERN_INFO "Got LK_RESPONSE_RESERVED and don't "
- "know how to handle...\n");
- break;
- case 0x01:
- DBG (KERN_INFO "Got 0x01, scheduling re-initialization\n");
- lk->ignore_bytes = LK_NUM_IGNORE_BYTES;
- lk->id[LK_NUM_IGNORE_BYTES - lk->ignore_bytes--] = data;
- schedule_work (&lk->tq);
+ DBG (KERN_INFO "Got %s and don't know how to handle...\n",
+ response_name (data));
break;

default:
@@ -509,10 +526,10 @@ lkkbd_event (struct input_dev *dev, unsi

switch (type) {
case EV_LED:
- CHECK_LED (LED_CAPSL, LK_LED_SHIFTLOCK);
- CHECK_LED (LED_COMPOSE, LK_LED_COMPOSE);
- CHECK_LED (LED_SCROLLL, LK_LED_SCROLLLOCK);
- CHECK_LED (LED_SLEEP, LK_LED_WAIT);
+ CHECK_LED (lk, leds_on, leds_off, LED_CAPSL, LK_LED_SHIFTLOCK);
+ CHECK_LED (lk, leds_on, leds_off, LED_COMPOSE, LK_LED_COMPOSE);
+ CHECK_LED (lk, leds_on, leds_off, LED_SCROLLL, LK_LED_SCROLLLOCK);
+ CHECK_LED (lk, leds_on, leds_off, LED_SLEEP, LK_LED_WAIT);
if (leds_on != 0) {
lk->serio->write (lk->serio, LK_CMD_LED_ON);
lk->serio->write (lk->serio, leds_on);
@@ -574,10 +591,10 @@ lkkbd_reinit (void *data)
lk->serio->write (lk->serio, LK_CMD_SET_DEFAULTS);

/* Set LEDs */
- CHECK_LED (LED_CAPSL, LK_LED_SHIFTLOCK);
- CHECK_LED (LED_COMPOSE, LK_LED_COMPOSE);
- CHECK_LED (LED_SCROLLL, LK_LED_SCROLLLOCK);
- CHECK_LED (LED_SLEEP, LK_LED_WAIT);
+ CHECK_LED (lk, leds_on, leds_off, LED_CAPSL, LK_LED_SHIFTLOCK);
+ CHECK_LED (lk, leds_on, leds_off, LED_COMPOSE, LK_LED_COMPOSE);
+ CHECK_LED (lk, leds_on, leds_off, LED_SCROLLL, LK_LED_SCROLLLOCK);
+ CHECK_LED (lk, leds_on, leds_off, LED_SLEEP, LK_LED_WAIT);
if (leds_on != 0) {
lk->serio->write (lk->serio, LK_CMD_LED_ON);
lk->serio->write (lk->serio, leds_on);


MfG, JBG

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


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

2005-10-30 12:40:25

by Pavel Machek

[permalink] [raw]
Subject: Re: [PATCH] driver model wakeup flags

Hi!

> * There's a writeable sysfs "wakeup" file, with one of two values:
> - "enabled", when the policy is to allow wakeup
> - "disabled", when the policy is not to allow it
> - "" if the device can't currently issue wakeups

Could we either get "not-supported" value here, or remove the file if it is not
supported? Having empty file is ugly...

--
64 bytes from 195.113.31.123: icmp_seq=28 ttl=51 time=448769.1 ms

2005-10-31 07:02:18

by Dmitry Torokhov

[permalink] [raw]
Subject: Re: [PATCH] drivers/input/keyboard: convert to dynamic input_dev allocation

On Saturday 29 October 2005 13:53, Jan-Benedict Glaw wrote:
> Here's a revised version of the patch, making the function and it's
> data static, as well as stuffing them into #ifdef DEBUG.
>

If you could resend the patch with Signed-off-by line I would add it
to my input tree.

Thanks!

--
Dmitry

2005-10-31 07:21:00

by Jan-Benedict Glaw

[permalink] [raw]
Subject: [PATCH] input/lkkbd: misc fixes

On Mon, 2005-10-31 02:02:15 -0500, Dmitry Torokhov <[email protected]> wrote:
> On Saturday 29 October 2005 13:53, Jan-Benedict Glaw wrote:
> > Here's a revised version of the patch, making the function and it's
> > data static, as well as stuffing them into #ifdef DEBUG.
>
> If you could resend the patch with Signed-off-by line I would add it
> to my input tree.

Thanks a lot, so here it is, against current git.

This patch fixes three issues with the lkkbd.c driver:
* Fix a printk() format to match the stack
* Hide debugging code into #ifdef, which allows to simplify
the large switch statement
* Update macros to not reference variables not given as
arguments

Signed-off-by: Jan-Benedict Glaw <[email protected]>

---
lkkbd.c | 101 +++++++++++++++++++++++++++++++++++++---------------------------
1 file changed, 59 insertions(+), 42 deletions(-)

diff --git a/drivers/input/keyboard/lkkbd.c b/drivers/input/keyboard/lkkbd.c
index 7f06780..7173441 100644
--- a/drivers/input/keyboard/lkkbd.c
+++ b/drivers/input/keyboard/lkkbd.c
@@ -273,11 +273,11 @@ static lk_keycode_t lkkbd_keycode[LK_NUM
[0xfb] = KEY_APOSTROPHE,
};

-#define CHECK_LED(LED, BITS) do { \
- if (test_bit (LED, lk->dev->led)) \
- leds_on |= BITS; \
- else \
- leds_off |= BITS; \
+#define CHECK_LED(LK, VAR_ON, VAR_OFF, LED, BITS) do { \
+ if (test_bit (LED, (LK)->dev->led)) \
+ VAR_ON |= BITS; \
+ else \
+ VAR_OFF |= BITS; \
} while (0)

/*
@@ -298,6 +298,42 @@ struct lkkbd {
int ctrlclick_volume;
};

+#ifdef LKKBD_DEBUG
+/*
+ * Responses from the keyboard and mapping back to their names.
+ */
+static struct {
+ unsigned char value;
+ unsigned char *name;
+} lk_response[] = {
+#define RESPONSE(x) { .value = (x), .name = #x, }
+ RESPONSE (LK_STUCK_KEY),
+ RESPONSE (LK_SELFTEST_FAILED),
+ RESPONSE (LK_ALL_KEYS_UP),
+ RESPONSE (LK_METRONOME),
+ RESPONSE (LK_OUTPUT_ERROR),
+ RESPONSE (LK_INPUT_ERROR),
+ RESPONSE (LK_KBD_LOCKED),
+ RESPONSE (LK_KBD_TEST_MODE_ACK),
+ RESPONSE (LK_PREFIX_KEY_DOWN),
+ RESPONSE (LK_MODE_CHANGE_ACK),
+ RESPONSE (LK_RESPONSE_RESERVED),
+#undef RESPONSE
+};
+
+static unsigned char *
+response_name (unsigned char value)
+{
+ int i;
+
+ for (i = 0; i < ARRAY_SIZE (lk_response); i++)
+ if (lk_response[i].value == value)
+ return lk_response[i].name;
+
+ return "<unknown>";
+}
+#endif /* LKKBD_DEBUG */
+
/*
* Calculate volume parameter byte for a given volume.
*/
@@ -440,43 +476,24 @@ lkkbd_interrupt (struct serio *serio, un
input_report_key (lk->dev, lk->keycode[i], 0);
input_sync (lk->dev);
break;
- case LK_METRONOME:
- DBG (KERN_INFO "Got %#d and don't "
- "know how to handle...\n");
+
+ case 0x01:
+ DBG (KERN_INFO "Got 0x01, scheduling re-initialization\n");
+ lk->ignore_bytes = LK_NUM_IGNORE_BYTES;
+ lk->id[LK_NUM_IGNORE_BYTES - lk->ignore_bytes--] = data;
+ schedule_work (&lk->tq);
break;
+
+ case LK_METRONOME:
case LK_OUTPUT_ERROR:
- DBG (KERN_INFO "Got LK_OUTPUT_ERROR and don't "
- "know how to handle...\n");
- break;
case LK_INPUT_ERROR:
- DBG (KERN_INFO "Got LK_INPUT_ERROR and don't "
- "know how to handle...\n");
- break;
case LK_KBD_LOCKED:
- DBG (KERN_INFO "Got LK_KBD_LOCKED and don't "
- "know how to handle...\n");
- break;
case LK_KBD_TEST_MODE_ACK:
- DBG (KERN_INFO "Got LK_KBD_TEST_MODE_ACK and don't "
- "know how to handle...\n");
- break;
case LK_PREFIX_KEY_DOWN:
- DBG (KERN_INFO "Got LK_PREFIX_KEY_DOWN and don't "
- "know how to handle...\n");
- break;
case LK_MODE_CHANGE_ACK:
- DBG (KERN_INFO "Got LK_MODE_CHANGE_ACK and ignored "
- "it properly...\n");
- break;
case LK_RESPONSE_RESERVED:
- DBG (KERN_INFO "Got LK_RESPONSE_RESERVED and don't "
- "know how to handle...\n");
- break;
- case 0x01:
- DBG (KERN_INFO "Got 0x01, scheduling re-initialization\n");
- lk->ignore_bytes = LK_NUM_IGNORE_BYTES;
- lk->id[LK_NUM_IGNORE_BYTES - lk->ignore_bytes--] = data;
- schedule_work (&lk->tq);
+ DBG (KERN_INFO "Got %s and don't know how to handle...\n",
+ response_name (data));
break;

default:
@@ -509,10 +526,10 @@ lkkbd_event (struct input_dev *dev, unsi

switch (type) {
case EV_LED:
- CHECK_LED (LED_CAPSL, LK_LED_SHIFTLOCK);
- CHECK_LED (LED_COMPOSE, LK_LED_COMPOSE);
- CHECK_LED (LED_SCROLLL, LK_LED_SCROLLLOCK);
- CHECK_LED (LED_SLEEP, LK_LED_WAIT);
+ CHECK_LED (lk, leds_on, leds_off, LED_CAPSL, LK_LED_SHIFTLOCK);
+ CHECK_LED (lk, leds_on, leds_off, LED_COMPOSE, LK_LED_COMPOSE);
+ CHECK_LED (lk, leds_on, leds_off, LED_SCROLLL, LK_LED_SCROLLLOCK);
+ CHECK_LED (lk, leds_on, leds_off, LED_SLEEP, LK_LED_WAIT);
if (leds_on != 0) {
lk->serio->write (lk->serio, LK_CMD_LED_ON);
lk->serio->write (lk->serio, leds_on);
@@ -574,10 +591,10 @@ lkkbd_reinit (void *data)
lk->serio->write (lk->serio, LK_CMD_SET_DEFAULTS);

/* Set LEDs */
- CHECK_LED (LED_CAPSL, LK_LED_SHIFTLOCK);
- CHECK_LED (LED_COMPOSE, LK_LED_COMPOSE);
- CHECK_LED (LED_SCROLLL, LK_LED_SCROLLLOCK);
- CHECK_LED (LED_SLEEP, LK_LED_WAIT);
+ CHECK_LED (lk, leds_on, leds_off, LED_CAPSL, LK_LED_SHIFTLOCK);
+ CHECK_LED (lk, leds_on, leds_off, LED_COMPOSE, LK_LED_COMPOSE);
+ CHECK_LED (lk, leds_on, leds_off, LED_SCROLLL, LK_LED_SCROLLLOCK);
+ CHECK_LED (lk, leds_on, leds_off, LED_SLEEP, LK_LED_WAIT);
if (leds_on != 0) {
lk->serio->write (lk->serio, LK_CMD_LED_ON);
lk->serio->write (lk->serio, leds_on);

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


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

2005-11-02 23:29:32

by Greg KH

[permalink] [raw]
Subject: Re: [PATCH] driver model wakeup flags

On Sat, Oct 29, 2005 at 09:55:41AM +0200, Pavel Machek wrote:
> Hi!
>
> > * There's a writeable sysfs "wakeup" file, with one of two values:
> > - "enabled", when the policy is to allow wakeup
> > - "disabled", when the policy is not to allow it
> > - "" if the device can't currently issue wakeups
>
> Could we either get "not-supported" value here, or remove the file if it is not
> supported? Having empty file is ugly...

Sure, have a patch for this? :)

thanks,

greg k-h

2005-11-04 17:44:00

by David Brownell

[permalink] [raw]
Subject: Re: [PATCH] driver model wakeup flags

On Wednesday 02 November 2005 1:59 pm, Greg KH wrote:
> On Sat, Oct 29, 2005 at 09:55:41AM +0200, Pavel Machek wrote:
> > Hi!
> >
> > > * There's a writeable sysfs "wakeup" file, with one of two values:
> > > - "enabled", when the policy is to allow wakeup
> > > - "disabled", when the policy is not to allow it
> > > - "" if the device can't currently issue wakeups
> >
> > Could we either get "not-supported" value here, or remove the file if it is not
> > supported? Having empty file is ugly...
>
> Sure, have a patch for this? :)

Turns out that "remove if not supported" is impractical; I did have
that implemented, and backed it out as I got deeper into testing.

For one example, the "can wakeup" for USB devices is a function of what
configuration the device is in ... so a device with two configurations
(call them #5 and #42) as well as "unconfigured" (config #0) might
not support wakeup in two of its three states; maybe only #42 supports
remote wakeup.

Yes, those empty files bothered me a bit too.

- Dave

2005-11-07 08:01:07

by Miles Bader

[permalink] [raw]
Subject: Re: [PATCH] Driver Core: document struct class_device properly

Greg KH <[email protected]> writes:
>> What about Kay's proposal about moving (as far as userspace concerned)
>> everything into /sys/devices?
>
> That's exactly what I am now working on. But it will take much longer
> than 2.6.15 to get there for that. More like the next 6 months or so at
> the least...

BTW, is there a reason why "devices" is plural, as opposed to the
singular names used for other directories holding types of objects
("/sys/class" "/sys/bus" "/dev" "/lib" etc.)?

Thanks,

-Miles
--
`There are more things in heaven and earth, Horatio,
Than are dreamt of in your philosophy.'

2005-11-07 17:20:08

by Greg KH

[permalink] [raw]
Subject: Re: [PATCH] Driver Core: document struct class_device properly

On Mon, Nov 07, 2005 at 05:00:35PM +0900, Miles Bader wrote:
> Greg KH <[email protected]> writes:
> >> What about Kay's proposal about moving (as far as userspace concerned)
> >> everything into /sys/devices?
> >
> > That's exactly what I am now working on. But it will take much longer
> > than 2.6.15 to get there for that. More like the next 6 months or so at
> > the least...
>
> BTW, is there a reason why "devices" is plural, as opposed to the
> singular names used for other directories holding types of objects
> ("/sys/class" "/sys/bus" "/dev" "/lib" etc.)?

That's just the way it happened, no real "reason" behind it :)

thanks,

greg k-h