aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/input/mouse/pc110pad.c
diff options
context:
space:
mode:
authorDmitry Torokhov <dtor_core@ameritech.net>2005-09-15 03:01:44 -0400
committerGreg Kroah-Hartman <gregkh@suse.de>2005-10-28 12:52:52 -0400
commit2e5b636bb5f8dacbb91d08544e2c41ebcad5dace (patch)
tree059a2078d7b11713cad4675a9d8a062337957102 /drivers/input/mouse/pc110pad.c
parentd19fbe8a763634395d4bef40fc88cdb61c4a6274 (diff)
[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 <dtor@mail.ru> Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
Diffstat (limited to 'drivers/input/mouse/pc110pad.c')
-rw-r--r--drivers/input/mouse/pc110pad.c64
1 files changed, 31 insertions, 33 deletions
diff --git a/drivers/input/mouse/pc110pad.c b/drivers/input/mouse/pc110pad.c
index 93393d5c0078..d284ea712151 100644
--- a/drivers/input/mouse/pc110pad.c
+++ b/drivers/input/mouse/pc110pad.c
@@ -53,13 +53,10 @@ MODULE_LICENSE("GPL");
53static int pc110pad_irq = 10; 53static int pc110pad_irq = 10;
54static int pc110pad_io = 0x15e0; 54static int pc110pad_io = 0x15e0;
55 55
56static struct input_dev pc110pad_dev; 56static struct input_dev *pc110pad_dev;
57static int pc110pad_data[3]; 57static int pc110pad_data[3];
58static int pc110pad_count; 58static int pc110pad_count;
59 59
60static char *pc110pad_name = "IBM PC110 TouchPad";
61static char *pc110pad_phys = "isa15e0/input0";
62
63static irqreturn_t pc110pad_interrupt(int irq, void *ptr, struct pt_regs *regs) 60static irqreturn_t pc110pad_interrupt(int irq, void *ptr, struct pt_regs *regs)
64{ 61{
65 int value = inb_p(pc110pad_io); 62 int value = inb_p(pc110pad_io);
@@ -74,14 +71,14 @@ static irqreturn_t pc110pad_interrupt(int irq, void *ptr, struct pt_regs *regs)
74 if (pc110pad_count < 3) 71 if (pc110pad_count < 3)
75 return IRQ_HANDLED; 72 return IRQ_HANDLED;
76 73
77 input_regs(&pc110pad_dev, regs); 74 input_regs(pc110pad_dev, regs);
78 input_report_key(&pc110pad_dev, BTN_TOUCH, 75 input_report_key(pc110pad_dev, BTN_TOUCH,
79 pc110pad_data[0] & 0x01); 76 pc110pad_data[0] & 0x01);
80 input_report_abs(&pc110pad_dev, ABS_X, 77 input_report_abs(pc110pad_dev, ABS_X,
81 pc110pad_data[1] | ((pc110pad_data[0] << 3) & 0x80) | ((pc110pad_data[0] << 1) & 0x100)); 78 pc110pad_data[1] | ((pc110pad_data[0] << 3) & 0x80) | ((pc110pad_data[0] << 1) & 0x100));
82 input_report_abs(&pc110pad_dev, ABS_Y, 79 input_report_abs(pc110pad_dev, ABS_Y,
83 pc110pad_data[2] | ((pc110pad_data[0] << 4) & 0x80)); 80 pc110pad_data[2] | ((pc110pad_data[0] << 4) & 0x80));
84 input_sync(&pc110pad_dev); 81 input_sync(pc110pad_dev);
85 82
86 pc110pad_count = 0; 83 pc110pad_count = 0;
87 return IRQ_HANDLED; 84 return IRQ_HANDLED;
@@ -94,9 +91,9 @@ static void pc110pad_close(struct input_dev *dev)
94 91
95static int pc110pad_open(struct input_dev *dev) 92static int pc110pad_open(struct input_dev *dev)
96{ 93{
97 pc110pad_interrupt(0,NULL,NULL); 94 pc110pad_interrupt(0, NULL, NULL);
98 pc110pad_interrupt(0,NULL,NULL); 95 pc110pad_interrupt(0, NULL, NULL);
99 pc110pad_interrupt(0,NULL,NULL); 96 pc110pad_interrupt(0, NULL, NULL);
100 outb(PC110PAD_ON, pc110pad_io + 2); 97 outb(PC110PAD_ON, pc110pad_io + 2);
101 pc110pad_count = 0; 98 pc110pad_count = 0;
102 99
@@ -127,45 +124,46 @@ static int __init pc110pad_init(void)
127 124
128 outb(PC110PAD_OFF, pc110pad_io + 2); 125 outb(PC110PAD_OFF, pc110pad_io + 2);
129 126
130 if (request_irq(pc110pad_irq, pc110pad_interrupt, 0, "pc110pad", NULL)) 127 if (request_irq(pc110pad_irq, pc110pad_interrupt, 0, "pc110pad", NULL)) {
131 {
132 release_region(pc110pad_io, 4); 128 release_region(pc110pad_io, 4);
133 printk(KERN_ERR "pc110pad: Unable to get irq %d.\n", pc110pad_irq); 129 printk(KERN_ERR "pc110pad: Unable to get irq %d.\n", pc110pad_irq);
134 return -EBUSY; 130 return -EBUSY;
135 } 131 }
136 132
137 pc110pad_dev.evbit[0] = BIT(EV_KEY) | BIT(EV_ABS); 133 if (!(pc110pad_dev = input_allocate_device())) {
138 pc110pad_dev.absbit[0] = BIT(ABS_X) | BIT(ABS_Y); 134 free_irq(pc110pad_irq, NULL);
139 pc110pad_dev.keybit[LONG(BTN_TOUCH)] = BIT(BTN_TOUCH); 135 release_region(pc110pad_io, 4);
136 printk(KERN_ERR "pc110pad: Not enough memory.\n");
137 return -ENOMEM;
138 }
140 139
141 pc110pad_dev.absmax[ABS_X] = 0x1ff; 140 pc110pad_dev->name = "IBM PC110 TouchPad";
142 pc110pad_dev.absmax[ABS_Y] = 0x0ff; 141 pc110pad_dev->phys = "isa15e0/input0";
142 pc110pad_dev->id.bustype = BUS_ISA;
143 pc110pad_dev->id.vendor = 0x0003;
144 pc110pad_dev->id.product = 0x0001;
145 pc110pad_dev->id.version = 0x0100;
143 146
144 pc110pad_dev.open = pc110pad_open; 147 pc110pad_dev->evbit[0] = BIT(EV_KEY) | BIT(EV_ABS);
145 pc110pad_dev.close = pc110pad_close; 148 pc110pad_dev->absbit[0] = BIT(ABS_X) | BIT(ABS_Y);
149 pc110pad_dev->keybit[LONG(BTN_TOUCH)] = BIT(BTN_TOUCH);
146 150
147 pc110pad_dev.name = pc110pad_name; 151 pc110pad_dev->absmax[ABS_X] = 0x1ff;
148 pc110pad_dev.phys = pc110pad_phys; 152 pc110pad_dev->absmax[ABS_Y] = 0x0ff;
149 pc110pad_dev.id.bustype = BUS_ISA;
150 pc110pad_dev.id.vendor = 0x0003;
151 pc110pad_dev.id.product = 0x0001;
152 pc110pad_dev.id.version = 0x0100;
153 153
154 input_register_device(&pc110pad_dev); 154 pc110pad_dev->open = pc110pad_open;
155 pc110pad_dev->close = pc110pad_close;
155 156
156 printk(KERN_INFO "input: %s at %#x irq %d\n", 157 input_register_device(pc110pad_dev);
157 pc110pad_name, pc110pad_io, pc110pad_irq);
158 158
159 return 0; 159 return 0;
160} 160}
161 161
162static void __exit pc110pad_exit(void) 162static void __exit pc110pad_exit(void)
163{ 163{
164 input_unregister_device(&pc110pad_dev);
165
166 outb(PC110PAD_OFF, pc110pad_io + 2); 164 outb(PC110PAD_OFF, pc110pad_io + 2);
167
168 free_irq(pc110pad_irq, NULL); 165 free_irq(pc110pad_irq, NULL);
166 input_unregister_device(pc110pad_dev);
169 release_region(pc110pad_io, 4); 167 release_region(pc110pad_io, 4);
170} 168}
171 169