From: Dmitry Torokhov <dmitry.torokhov@gmail.com>
To: linux-input@vger.kernel.org
Cc: Greg KH <gregkh@linuxfoundation.org>, linux-kernel@vger.kernel.org
Subject: [PATCH 4/8] Input: usbtouchscreen - move process_pkt() into main device structure
Date: Thu, 11 Jul 2024 22:18:46 -0700 [thread overview]
Message-ID: <20240712051851.3463657-4-dmitry.torokhov@gmail.com> (raw)
In-Reply-To: <20240712051851.3463657-1-dmitry.torokhov@gmail.com>
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.
Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
---
drivers/input/touchscreen/usbtouchscreen.c | 28 ++++++++++------------
1 file changed, 13 insertions(+), 15 deletions(-)
diff --git a/drivers/input/touchscreen/usbtouchscreen.c b/drivers/input/touchscreen/usbtouchscreen.c
index 3a9de3d24e75..f8a67834a695 100644
--- a/drivers/input/touchscreen/usbtouchscreen.c
+++ b/drivers/input/touchscreen/usbtouchscreen.c
@@ -68,8 +68,6 @@ struct usbtouch_device_info {
*/
bool irq_always;
- void (*process_pkt) (struct usbtouch_usb *usbtouch, unsigned char *pkt, int len);
-
/*
* used to get the packet len. possible return values:
* > 0: packet len
@@ -103,6 +101,8 @@ struct usbtouch_usb {
int x, y;
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)
/*****************************************************************************
* 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[] = {
#ifdef CONFIG_TOUCHSCREEN_USB_ELO
[DEVTYPE_ELO] = {
@@ -1070,7 +1065,6 @@ static struct usbtouch_device_info usbtouch_dev_info[] = {
.min_yc = 0x0,
.max_yc = 0x07ff,
.rept_size = 16,
- .process_pkt = usbtouch_process_multi,
.get_pkt_len = egalax_get_pkt_len,
.read_data = egalax_read_data,
.init = egalax_init,
@@ -1121,7 +1115,6 @@ static struct usbtouch_device_info usbtouch_dev_info[] = {
.min_yc = 0x0,
.max_yc = 0x07ff,
.rept_size = 8,
- .process_pkt = usbtouch_process_multi,
.get_pkt_len = eturbo_get_pkt_len,
.read_data = eturbo_read_data,
},
@@ -1177,7 +1170,6 @@ static struct usbtouch_device_info usbtouch_dev_info[] = {
.min_yc = 0x0,
.max_yc = 0x0fff,
.rept_size = 8,
- .process_pkt = usbtouch_process_multi,
.get_pkt_len = idealtek_get_pkt_len,
.read_data = idealtek_read_data,
},
@@ -1268,7 +1260,6 @@ static struct usbtouch_device_info usbtouch_dev_info[] = {
.min_yc = 0x0,
.max_yc = 0x07ff,
.rept_size = 16,
- .process_pkt = usbtouch_process_multi,
.get_pkt_len = etouch_get_pkt_len,
.read_data = etouch_read_data,
},
@@ -1378,9 +1369,15 @@ static void usbtouch_process_multi(struct usbtouch_usb *usbtouch,
usbtouch->buf_len = 0;
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
-
static void usbtouch_irq(struct urb *urb)
{
struct usbtouch_usb *usbtouch = urb->context;
@@ -1411,7 +1408,7 @@ static void usbtouch_irq(struct urb *urb)
goto exit;
}
- usbtouch->type->process_pkt(usbtouch, usbtouch->data, urb->actual_length);
+ usbtouch->process_pkt(usbtouch, usbtouch->data, urb->actual_length);
exit:
usb_mark_last_busy(interface_to_usbdev(usbtouch->interface));
@@ -1564,8 +1561,6 @@ static int usbtouch_probe(struct usb_interface *intf,
type = &usbtouch_dev_info[id->driver_info];
usbtouch->type = type;
- if (!type->process_pkt)
- type->process_pkt = usbtouch_process_pkt;
usbtouch->data_size = type->rept_size;
if (type->get_pkt_len) {
@@ -1589,6 +1584,9 @@ static int usbtouch_probe(struct usb_interface *intf,
usbtouch->buffer = kmalloc(type->rept_size, GFP_KERNEL);
if (!usbtouch->buffer)
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);
--
2.45.2.993.g49e7a77208-goog
next prev parent reply other threads:[~2024-07-12 5:19 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-07-12 5:18 [PATCH 1/8] Input: usbtouchscreen - use driver core to instantiate device attributes Dmitry Torokhov
2024-07-12 5:18 ` [PATCH 2/8] Input: usbtouchscreen - remove custom USB_DEVICE_HID_CLASS macro Dmitry Torokhov
2024-07-12 7:29 ` Greg KH
2024-07-12 5:18 ` [PATCH 3/8] Input: usbtouchscreen - move the driver ID table Dmitry Torokhov
2024-07-12 7:29 ` Greg KH
2024-07-12 5:18 ` Dmitry Torokhov [this message]
2024-07-12 7:29 ` [PATCH 4/8] Input: usbtouchscreen - move process_pkt() into main device structure Greg KH
2024-07-12 5:18 ` [PATCH 5/8] Input: usbtouchscreen - constify usbtouch_dev_info table Dmitry Torokhov
2024-07-12 7:28 ` Greg KH
2024-07-12 5:18 ` [PATCH 6/8] Input: usbtouchscreen - split device info table into individual pieces Dmitry Torokhov
2024-07-12 7:28 ` Greg KH
2024-07-12 5:18 ` [PATCH 7/8] Input: usbtouchscreen - use guard notation when acquiring mutexes Dmitry Torokhov
2024-07-12 7:28 ` Greg KH
2024-07-12 5:18 ` [PATCH 8/8] Input: usbtouchscreen - switch to using __free() cleanup facility Dmitry Torokhov
2024-07-12 7:27 ` Greg KH
2024-07-12 7:27 ` [PATCH 1/8] Input: usbtouchscreen - use driver core to instantiate device attributes Greg KH
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20240712051851.3463657-4-dmitry.torokhov@gmail.com \
--to=dmitry.torokhov@gmail.com \
--cc=gregkh@linuxfoundation.org \
--cc=linux-input@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®