Skip to content

Commit

Permalink
[PARISC] Update parisc specific input code from parisc tree
Browse files Browse the repository at this point in the history
Update drivers to new input layer changes.

Signed-off-by: Helge Deller <deller@parisc-linux.org>
Signed-off-by: Matthew Wilcox <willy@parisc-linux.org>

Reorder code in gscps2_interrupt() and only enable ports when opened.
This fixes issues with hangs booting an SMP kernel on my C360.
Previously serio_interrupt() could be called before the lock in
struct serio was initialised.

Signed-off-by: Richard Hirst <rhirst@parisc-linux.org>

Signed-off-by: Kyle McMartin <kyle@parisc-linux.org>
  • Loading branch information
Matthew Wilcox authored and Kyle McMartin committed Oct 22, 2005
1 parent ae8c75c commit 6ab0f5c
Show file tree
Hide file tree
Showing 9 changed files with 1,011 additions and 31 deletions.
28 changes: 20 additions & 8 deletions drivers/input/keyboard/hil_kbd.c
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,7 @@ static irqreturn_t hil_kbd_interrupt(struct serio *serio,
hil_packet packet;
int idx;

kbd = (struct hil_kbd *)serio->private;
kbd = serio_get_drvdata(serio);
if (kbd == NULL) {
BUG();
return IRQ_HANDLED;
Expand Down Expand Up @@ -234,7 +234,7 @@ static void hil_kbd_disconnect(struct serio *serio)
{
struct hil_kbd *kbd;

kbd = (struct hil_kbd *)serio->private;
kbd = serio_get_drvdata(serio);
if (kbd == NULL) {
BUG();
return;
Expand All @@ -245,20 +245,20 @@ static void hil_kbd_disconnect(struct serio *serio)
kfree(kbd);
}

static void hil_kbd_connect(struct serio *serio, struct serio_driver *drv)
static int hil_kbd_connect(struct serio *serio, struct serio_driver *drv)
{
struct hil_kbd *kbd;
uint8_t did, *idd;
int i;

if (serio->type != (SERIO_HIL_MLC | SERIO_HIL)) return;

if (!(kbd = kmalloc(sizeof(struct hil_kbd), GFP_KERNEL))) return;
kbd = kmalloc(sizeof(*kbd), GFP_KERNEL);
if (!kbd)
return -ENOMEM;
memset(kbd, 0, sizeof(struct hil_kbd));

if (serio_open(serio, drv)) goto bail0;

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

Expand Down Expand Up @@ -342,19 +342,31 @@ static void hil_kbd_connect(struct serio *serio, struct serio_driver *drv)
down(&(kbd->sem));
up(&(kbd->sem));

return;
return 0;
bail1:
serio_close(serio);
bail0:
kfree(kbd);
serio_set_drvdata(serio, NULL);
return -EIO;
}

static struct serio_device_id hil_kbd_ids[] = {
{
.type = SERIO_HIL_MLC,
.proto = SERIO_HIL,
.id = SERIO_ANY,
.extra = SERIO_ANY,
},
{ 0 }
};

struct serio_driver hil_kbd_serio_drv = {
.driver = {
.name = "hil_kbd",
},
.description = "HP HIL keyboard driver",
.id_table = hil_kbd_ids,
.connect = hil_kbd_connect,
.disconnect = hil_kbd_disconnect,
.interrupt = hil_kbd_interrupt
Expand Down
2 changes: 1 addition & 1 deletion drivers/input/keyboard/hilkbd.c
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
#include <linux/errno.h>
#include <linux/input.h>
#include <linux/init.h>
#include <linux/irq.h>
#include <linux/interrupt.h>
#include <linux/hil.h>
#include <linux/spinlock.h>

Expand Down
33 changes: 21 additions & 12 deletions drivers/input/mouse/hil_ptr.c
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,7 @@ static irqreturn_t hil_ptr_interrupt(struct serio *serio,
hil_packet packet;
int idx;

ptr = (struct hil_ptr *)serio->private;
ptr = serio_get_drvdata(serio);
if (ptr == NULL) {
BUG();
return IRQ_HANDLED;
Expand Down Expand Up @@ -227,7 +227,7 @@ static void hil_ptr_disconnect(struct serio *serio)
{
struct hil_ptr *ptr;

ptr = (struct hil_ptr *)serio->private;
ptr = serio_get_drvdata(serio);
if (ptr == NULL) {
BUG();
return;
Expand All @@ -238,21 +238,19 @@ static void hil_ptr_disconnect(struct serio *serio)
kfree(ptr);
}

static void hil_ptr_connect(struct serio *serio, struct serio_driver *driver)
static int hil_ptr_connect(struct serio *serio, struct serio_driver *driver)
{
struct hil_ptr *ptr;
char *txt;
unsigned int i, naxsets, btntype;
uint8_t did, *idd;

if (serio->type != (SERIO_HIL_MLC | SERIO_HIL)) return;

if (!(ptr = kmalloc(sizeof(struct hil_ptr), GFP_KERNEL))) return;
if (!(ptr = kmalloc(sizeof(struct hil_ptr), GFP_KERNEL))) return -ENOMEM;
memset(ptr, 0, sizeof(struct hil_ptr));

if (serio_open(serio, driver)) goto bail0;

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

Expand Down Expand Up @@ -380,23 +378,34 @@ static void hil_ptr_connect(struct serio *serio, struct serio_driver *driver)
(btntype == BTN_MOUSE) ? "HIL mouse":"HIL tablet or touchpad",
did);

return;
return 0;
bail1:
serio_close(serio);
bail0:
kfree(ptr);
return;
serio_set_drvdata(serio, NULL);
return -ENODEV;
}

static struct serio_device_id hil_ptr_ids[] = {
{
.type = SERIO_HIL_MLC,
.proto = SERIO_HIL,
.id = SERIO_ANY,
.extra = SERIO_ANY,
},
{ 0 }
};

static struct serio_driver hil_ptr_serio_driver = {
.driver = {
.name = "hil_ptr",
},
.description = "HP HIL mouse/tablet driver",
.connect = hil_ptr_connect,
.disconnect = hil_ptr_disconnect,
.interrupt = hil_ptr_interrupt
.id_table = hil_ptr_ids,
.connect = hil_ptr_connect,
.disconnect = hil_ptr_disconnect,
.interrupt = hil_ptr_interrupt
};

static int __init hil_ptr_init(void)
Expand Down
13 changes: 6 additions & 7 deletions drivers/input/serio/gscps2.c
Original file line number Diff line number Diff line change
Expand Up @@ -211,9 +211,6 @@ static void gscps2_reset(struct gscps2port *ps2port)
writeb(0xff, addr+GSC_RESET);
gscps2_flush(ps2port);
spin_unlock_irqrestore(&ps2port->lock, flags);

/* enable it */
gscps2_enable(ps2port, ENABLE);
}

static LIST_HEAD(ps2port_list);
Expand Down Expand Up @@ -307,6 +304,9 @@ static int gscps2_open(struct serio *port)

gscps2_reset(ps2port);

/* enable it */
gscps2_enable(ps2port, ENABLE);

gscps2_interrupt(0, NULL, NULL);

return 0;
Expand Down Expand Up @@ -370,8 +370,6 @@ static int __init gscps2_probe(struct parisc_device *dev)
serio->port_data = ps2port;
serio->dev.parent = &dev->dev;

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

ret = -EBUSY;
if (request_irq(dev->irq, gscps2_interrupt, SA_SHIRQ, ps2port->port->name, ps2port))
goto fail_miserably;
Expand All @@ -396,15 +394,16 @@ static int __init gscps2_probe(struct parisc_device *dev)

serio_register_port(ps2port->port);

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

return 0;

fail:
free_irq(dev->irq, ps2port);

fail_miserably:
list_del(&ps2port->node);
iounmap(ps2port->addr);
release_mem_region(dev->hpa, GSC_STATUS + 4);
release_mem_region(dev->hpa.start, GSC_STATUS + 4);

fail_nomem:
kfree(ps2port);
Expand Down
14 changes: 11 additions & 3 deletions drivers/input/serio/hil_mlc.c
Original file line number Diff line number Diff line change
Expand Up @@ -801,7 +801,8 @@ static int hil_mlc_serio_open(struct serio *serio) {
struct hil_mlc_serio_map *map;
struct hil_mlc *mlc;

if (serio->private != NULL) return -EBUSY;
if (serio_get_drvdata(serio) != NULL)
return -EBUSY;

map = serio->port_data;
if (map == NULL) {
Expand Down Expand Up @@ -832,11 +833,18 @@ static void hil_mlc_serio_close(struct serio *serio) {
return;
}

serio->private = NULL;
serio_set_drvdata(serio, NULL);
serio->drv = NULL;
/* TODO wake up interruptable */
}

static struct serio_device_id hil_mlc_serio_id = {
.type = SERIO_HIL_MLC,
.proto = SERIO_HIL,
.extra = SERIO_ANY,
.id = SERIO_ANY,
};

int hil_mlc_register(hil_mlc *mlc) {
int i;
unsigned long flags;
Expand Down Expand Up @@ -867,7 +875,7 @@ int hil_mlc_register(hil_mlc *mlc) {
mlc_serio = kmalloc(sizeof(*mlc_serio), GFP_KERNEL);
mlc->serio[i] = mlc_serio;
memset(mlc_serio, 0, sizeof(*mlc_serio));
mlc_serio->type = SERIO_HIL | SERIO_HIL_MLC;
mlc_serio->id = hil_mlc_serio_id;
mlc_serio->write = hil_mlc_serio_write;
mlc_serio->open = hil_mlc_serio_open;
mlc_serio->close = hil_mlc_serio_close;
Expand Down
Loading

0 comments on commit 6ab0f5c

Please sign in to comment.