Commit fbb1c922 authored by Dmitry Torokhov's avatar Dmitry Torokhov

Input: usbtouchscreen - move process_pkt() into main device structure

In preparation of splitting big usbtouch_dev_info table into separate
per-protocol structures and constifying them move process_pkt() from the
device info into main drvice structure and set it up in probe().
We can derive if we should use single- or multi-packet handling based
on presence of get_pkt_len() method.
Reviewed-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Link: https://lore.kernel.org/r/20240712051851.3463657-4-dmitry.torokhov@gmail.comSigned-off-by: default avatarDmitry Torokhov <dmitry.torokhov@gmail.com>
parent ca95a47e
...@@ -68,8 +68,6 @@ struct usbtouch_device_info { ...@@ -68,8 +68,6 @@ struct usbtouch_device_info {
*/ */
bool irq_always; bool irq_always;
void (*process_pkt) (struct usbtouch_usb *usbtouch, unsigned char *pkt, int len);
/* /*
* used to get the packet len. possible return values: * used to get the packet len. possible return values:
* > 0: packet len * > 0: packet len
...@@ -103,6 +101,8 @@ struct usbtouch_usb { ...@@ -103,6 +101,8 @@ struct usbtouch_usb {
int x, y; int x, y;
int touch, press; int touch, press;
void (*process_pkt)(struct usbtouch_usb *usbtouch, unsigned char *pkt, int len);
}; };
...@@ -1045,11 +1045,6 @@ static int elo_read_data(struct usbtouch_usb *dev, unsigned char *pkt) ...@@ -1045,11 +1045,6 @@ static int elo_read_data(struct usbtouch_usb *dev, unsigned char *pkt)
/***************************************************************************** /*****************************************************************************
* the different device descriptors * the different device descriptors
*/ */
#ifdef MULTI_PACKET
static void usbtouch_process_multi(struct usbtouch_usb *usbtouch,
unsigned char *pkt, int len);
#endif
static struct usbtouch_device_info usbtouch_dev_info[] = { static struct usbtouch_device_info usbtouch_dev_info[] = {
#ifdef CONFIG_TOUCHSCREEN_USB_ELO #ifdef CONFIG_TOUCHSCREEN_USB_ELO
[DEVTYPE_ELO] = { [DEVTYPE_ELO] = {
...@@ -1070,7 +1065,6 @@ static struct usbtouch_device_info usbtouch_dev_info[] = { ...@@ -1070,7 +1065,6 @@ static struct usbtouch_device_info usbtouch_dev_info[] = {
.min_yc = 0x0, .min_yc = 0x0,
.max_yc = 0x07ff, .max_yc = 0x07ff,
.rept_size = 16, .rept_size = 16,
.process_pkt = usbtouch_process_multi,
.get_pkt_len = egalax_get_pkt_len, .get_pkt_len = egalax_get_pkt_len,
.read_data = egalax_read_data, .read_data = egalax_read_data,
.init = egalax_init, .init = egalax_init,
...@@ -1121,7 +1115,6 @@ static struct usbtouch_device_info usbtouch_dev_info[] = { ...@@ -1121,7 +1115,6 @@ static struct usbtouch_device_info usbtouch_dev_info[] = {
.min_yc = 0x0, .min_yc = 0x0,
.max_yc = 0x07ff, .max_yc = 0x07ff,
.rept_size = 8, .rept_size = 8,
.process_pkt = usbtouch_process_multi,
.get_pkt_len = eturbo_get_pkt_len, .get_pkt_len = eturbo_get_pkt_len,
.read_data = eturbo_read_data, .read_data = eturbo_read_data,
}, },
...@@ -1177,7 +1170,6 @@ static struct usbtouch_device_info usbtouch_dev_info[] = { ...@@ -1177,7 +1170,6 @@ static struct usbtouch_device_info usbtouch_dev_info[] = {
.min_yc = 0x0, .min_yc = 0x0,
.max_yc = 0x0fff, .max_yc = 0x0fff,
.rept_size = 8, .rept_size = 8,
.process_pkt = usbtouch_process_multi,
.get_pkt_len = idealtek_get_pkt_len, .get_pkt_len = idealtek_get_pkt_len,
.read_data = idealtek_read_data, .read_data = idealtek_read_data,
}, },
...@@ -1268,7 +1260,6 @@ static struct usbtouch_device_info usbtouch_dev_info[] = { ...@@ -1268,7 +1260,6 @@ static struct usbtouch_device_info usbtouch_dev_info[] = {
.min_yc = 0x0, .min_yc = 0x0,
.max_yc = 0x07ff, .max_yc = 0x07ff,
.rept_size = 16, .rept_size = 16,
.process_pkt = usbtouch_process_multi,
.get_pkt_len = etouch_get_pkt_len, .get_pkt_len = etouch_get_pkt_len,
.read_data = etouch_read_data, .read_data = etouch_read_data,
}, },
...@@ -1378,9 +1369,15 @@ static void usbtouch_process_multi(struct usbtouch_usb *usbtouch, ...@@ -1378,9 +1369,15 @@ static void usbtouch_process_multi(struct usbtouch_usb *usbtouch,
usbtouch->buf_len = 0; usbtouch->buf_len = 0;
return; return;
} }
#else
static void usbtouch_process_multi(struct usbtouch_usb *usbtouch,
unsigned char *pkt, int len)
{
dev_WARN_ONCE(&usbtouch->interface->dev, 1,
"Protocol has ->get_pkt_len() without #define MULTI_PACKET");
}
#endif #endif
static void usbtouch_irq(struct urb *urb) static void usbtouch_irq(struct urb *urb)
{ {
struct usbtouch_usb *usbtouch = urb->context; struct usbtouch_usb *usbtouch = urb->context;
...@@ -1411,7 +1408,7 @@ static void usbtouch_irq(struct urb *urb) ...@@ -1411,7 +1408,7 @@ static void usbtouch_irq(struct urb *urb)
goto exit; goto exit;
} }
usbtouch->type->process_pkt(usbtouch, usbtouch->data, urb->actual_length); usbtouch->process_pkt(usbtouch, usbtouch->data, urb->actual_length);
exit: exit:
usb_mark_last_busy(interface_to_usbdev(usbtouch->interface)); usb_mark_last_busy(interface_to_usbdev(usbtouch->interface));
...@@ -1564,8 +1561,6 @@ static int usbtouch_probe(struct usb_interface *intf, ...@@ -1564,8 +1561,6 @@ static int usbtouch_probe(struct usb_interface *intf,
type = &usbtouch_dev_info[id->driver_info]; type = &usbtouch_dev_info[id->driver_info];
usbtouch->type = type; usbtouch->type = type;
if (!type->process_pkt)
type->process_pkt = usbtouch_process_pkt;
usbtouch->data_size = type->rept_size; usbtouch->data_size = type->rept_size;
if (type->get_pkt_len) { if (type->get_pkt_len) {
...@@ -1589,6 +1584,9 @@ static int usbtouch_probe(struct usb_interface *intf, ...@@ -1589,6 +1584,9 @@ static int usbtouch_probe(struct usb_interface *intf,
usbtouch->buffer = kmalloc(type->rept_size, GFP_KERNEL); usbtouch->buffer = kmalloc(type->rept_size, GFP_KERNEL);
if (!usbtouch->buffer) if (!usbtouch->buffer)
goto out_free_buffers; goto out_free_buffers;
usbtouch->process_pkt = usbtouch_process_multi;
} else {
usbtouch->process_pkt = usbtouch_process_pkt;
} }
usbtouch->irq = usb_alloc_urb(0, GFP_KERNEL); usbtouch->irq = usb_alloc_urb(0, GFP_KERNEL);
......
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