Commit 05ca3828 authored by Dmitry Torokhov's avatar Dmitry Torokhov

Input: iforce - introduce start and stop io transport ops

Add start_io() and stop_io() transport methods so that core
does not have to know the details.
Tested-by: default avatarTim Schumacher <timschumi@gmx.de>
Signed-off-by: default avatarDmitry Torokhov <dmitry.torokhov@gmail.com>
parent 93817584
......@@ -185,15 +185,7 @@ static int iforce_open(struct input_dev *dev)
{
struct iforce *iforce = input_get_drvdata(dev);
switch (iforce->bus) {
#ifdef CONFIG_JOYSTICK_IFORCE_USB
case IFORCE_USB:
iforce->irq->dev = iforce->usbdev;
if (usb_submit_urb(iforce->irq, GFP_KERNEL))
return -EIO;
break;
#endif
}
iforce->xport_ops->start_io(iforce);
if (test_bit(EV_FF, dev->evbit)) {
/* Enable force feedback */
......@@ -226,20 +218,7 @@ static void iforce_close(struct input_dev *dev)
!test_bit(IFORCE_XMIT_RUNNING, iforce->xmit_flags));
}
switch (iforce->bus) {
#ifdef CONFIG_JOYSTICK_IFORCE_USB
case IFORCE_USB:
usb_kill_urb(iforce->irq);
usb_kill_urb(iforce->out);
usb_kill_urb(iforce->ctrl);
break;
#endif
#ifdef CONFIG_JOYSTICK_IFORCE_232
case IFORCE_232:
//TODO: Wait for the last packets to be sent
break;
#endif
}
iforce->xport_ops->stop_io(iforce);
}
int iforce_init_device(struct iforce *iforce)
......
......@@ -83,9 +83,22 @@ static int iforce_serio_get_id(struct iforce *iforce, u8 *packet)
return -(iforce->edata[0] != packet[0]);
}
static int iforce_serio_start_io(struct iforce *iforce)
{
/* No special handling required */
return 0;
}
static void iforce_serio_stop_io(struct iforce *iforce)
{
//TODO: Wait for the last packets to be sent
}
static const struct iforce_xport_ops iforce_serio_xport_ops = {
.xmit = iforce_serio_xmit,
.get_id = iforce_serio_get_id,
.start_io = iforce_serio_start_io,
.stop_io = iforce_serio_stop_io,
};
static void iforce_serio_write_wakeup(struct serio *serio)
......
......@@ -103,9 +103,26 @@ static int iforce_usb_get_id(struct iforce *iforce, u8 *packet)
return -(iforce->edata[0] != packet[0]);
}
static int iforce_usb_start_io(struct iforce *iforce)
{
if (usb_submit_urb(iforce->irq, GFP_KERNEL))
return -EIO;
return 0;
}
static void iforce_usb_stop_io(struct iforce *iforce)
{
usb_kill_urb(iforce->irq);
usb_kill_urb(iforce->out);
usb_kill_urb(iforce->ctrl);
}
static const struct iforce_xport_ops iforce_usb_xport_ops = {
.xmit = iforce_usb_xmit,
.get_id = iforce_usb_get_id,
.start_io = iforce_usb_start_io,
.stop_io = iforce_usb_stop_io,
};
static void iforce_usb_irq(struct urb *urb)
......
......@@ -98,6 +98,8 @@ struct iforce;
struct iforce_xport_ops {
void (*xmit)(struct iforce *iforce);
int (*get_id)(struct iforce *iforce, u8* id);
int (*start_io)(struct iforce *iforce);
void (*stop_io)(struct iforce *iforce);
};
struct iforce {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment