linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] HID: uclogic: make input_mapping independent of usb
@ 2015-03-13 15:42 Benjamin Tissoires
  2015-03-14 18:52 ` Nikolai Kondrashov
  0 siblings, 1 reply; 3+ messages in thread
From: Benjamin Tissoires @ 2015-03-13 15:42 UTC (permalink / raw)
  To: Nikolai Kondrashov, Jiri Kosina; +Cc: linux-input, linux-kernel

No need to retrieve the USB handle in input_mapping() when we already
do that in probe. It also allows to use the quirk without having to
add the product ID matching.

Signed-off-by: Benjamin Tissoires <benjamin.tissoires@redhat.com>
---

Nick,

no need to cc DIGImend-devel when replying on this one, I'll send the same
to DIGImend-devel as soon as I have a patchwork link.

Cheers,
Benjamin

 drivers/hid/hid-uclogic.c | 17 ++++++++---------
 1 file changed, 8 insertions(+), 9 deletions(-)

diff --git a/drivers/hid/hid-uclogic.c b/drivers/hid/hid-uclogic.c
index bdda9fd..6473e83 100644
--- a/drivers/hid/hid-uclogic.c
+++ b/drivers/hid/hid-uclogic.c
@@ -627,6 +627,7 @@ struct uclogic_drvdata {
 	__u8 *rdesc;
 	unsigned int rsize;
 	bool invert_pen_inrange;
+	bool ignore_pen_interface;
 };
 
 static __u8 *uclogic_report_fixup(struct hid_device *hdev, __u8 *rdesc,
@@ -719,16 +720,12 @@ static int uclogic_input_mapping(struct hid_device *hdev, struct hid_input *hi,
 		struct hid_field *field, struct hid_usage *usage,
 		unsigned long **bit, int *max)
 {
-	struct usb_interface *intf;
-
-	if (hdev->product == USB_DEVICE_ID_HUION_TABLET) {
-		intf = to_usb_interface(hdev->dev.parent);
+	struct uclogic_drvdata *drvdata = hid_get_drvdata(hdev);
 
-		/* discard the unused pen interface */
-		if ((intf->cur_altsetting->desc.bInterfaceNumber != 0) &&
-		    (field->application == HID_DG_PEN))
-			return -1;
-	}
+	/* discard the unused pen interface */
+	if ((drvdata->ignore_pen_interface) &&
+	    (field->application == HID_DG_PEN))
+		return -1;
 
 	/* let hid-core decide what to do */
 	return 0;
@@ -908,6 +905,8 @@ static int uclogic_probe(struct hid_device *hdev,
 				return rc;
 			}
 			drvdata->invert_pen_inrange = true;
+		} else {
+			drvdata->ignore_pen_interface = true;
 		}
 		break;
 	}
-- 
2.3.1


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH] HID: uclogic: make input_mapping independent of usb
  2015-03-13 15:42 [PATCH] HID: uclogic: make input_mapping independent of usb Benjamin Tissoires
@ 2015-03-14 18:52 ` Nikolai Kondrashov
  2015-03-15 17:09   ` Benjamin Tissoires
  0 siblings, 1 reply; 3+ messages in thread
From: Nikolai Kondrashov @ 2015-03-14 18:52 UTC (permalink / raw)
  To: Benjamin Tissoires, Jiri Kosina; +Cc: linux-input, linux-kernel

On 03/13/2015 05:42 PM, Benjamin Tissoires wrote:
> No need to retrieve the USB handle in input_mapping() when we already
> do that in probe. It also allows to use the quirk without having to
> add the product ID matching.
>
> Signed-off-by: Benjamin Tissoires <benjamin.tissoires@redhat.com>
> ---
>
> Nick,
>
> no need to cc DIGImend-devel when replying on this one, I'll send the same
> to DIGImend-devel as soon as I have a patchwork link.
>
> Cheers,
> Benjamin
>
>   drivers/hid/hid-uclogic.c | 17 ++++++++---------
>   1 file changed, 8 insertions(+), 9 deletions(-)
>
> diff --git a/drivers/hid/hid-uclogic.c b/drivers/hid/hid-uclogic.c
> index bdda9fd..6473e83 100644
> --- a/drivers/hid/hid-uclogic.c
> +++ b/drivers/hid/hid-uclogic.c
> @@ -627,6 +627,7 @@ struct uclogic_drvdata {
>   	__u8 *rdesc;
>   	unsigned int rsize;
>   	bool invert_pen_inrange;
> +	bool ignore_pen_interface;
>   };
>
>   static __u8 *uclogic_report_fixup(struct hid_device *hdev, __u8 *rdesc,
> @@ -719,16 +720,12 @@ static int uclogic_input_mapping(struct hid_device *hdev, struct hid_input *hi,
>   		struct hid_field *field, struct hid_usage *usage,
>   		unsigned long **bit, int *max)
>   {
> -	struct usb_interface *intf;
> -
> -	if (hdev->product == USB_DEVICE_ID_HUION_TABLET) {
> -		intf = to_usb_interface(hdev->dev.parent);
> +	struct uclogic_drvdata *drvdata = hid_get_drvdata(hdev);
>
> -		/* discard the unused pen interface */
> -		if ((intf->cur_altsetting->desc.bInterfaceNumber != 0) &&
> -		    (field->application == HID_DG_PEN))
> -			return -1;
> -	}
> +	/* discard the unused pen interface */
> +	if ((drvdata->ignore_pen_interface) &&
> +	    (field->application == HID_DG_PEN))
> +		return -1;
>
>   	/* let hid-core decide what to do */
>   	return 0;
> @@ -908,6 +905,8 @@ static int uclogic_probe(struct hid_device *hdev,
>   				return rc;
>   			}
>   			drvdata->invert_pen_inrange = true;
> +		} else {
> +			drvdata->ignore_pen_interface = true;
>   		}
>   		break;
>   	}

This looks fine to me logically, but the "ignore_pen_interface" name is a bit
confusing.

 From the driver code and comments it follows that "pen interface" is the USB
interface #0 and we're not ignoring it (uclogic_probe code becomes the worst
here).  I think that it is better to call it in terms of what the
"input_mapping" description says, i.e. "ignore_pen_usage".

Nick

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] HID: uclogic: make input_mapping independent of usb
  2015-03-14 18:52 ` Nikolai Kondrashov
@ 2015-03-15 17:09   ` Benjamin Tissoires
  0 siblings, 0 replies; 3+ messages in thread
From: Benjamin Tissoires @ 2015-03-15 17:09 UTC (permalink / raw)
  To: Nikolai Kondrashov
  Cc: Benjamin Tissoires, Jiri Kosina, linux-input, linux-kernel


----- Original Message -----
> From: "Nikolai Kondrashov" <spbnick@gmail.com>
> To: "Benjamin Tissoires" <benjamin.tissoires@redhat.com>, "Jiri Kosina" <jkosina@suse.cz>
> Cc: linux-input@vger.kernel.org, linux-kernel@vger.kernel.org
> Sent: Saturday, March 14, 2015 2:52:20 PM
> Subject: Re: [PATCH] HID: uclogic: make input_mapping independent of usb
> 
> On 03/13/2015 05:42 PM, Benjamin Tissoires wrote:
> > No need to retrieve the USB handle in input_mapping() when we already
> > do that in probe. It also allows to use the quirk without having to
> > add the product ID matching.
> >
> > Signed-off-by: Benjamin Tissoires <benjamin.tissoires@redhat.com>
> > ---
> >
> > Nick,
> >
> > no need to cc DIGImend-devel when replying on this one, I'll send the same
> > to DIGImend-devel as soon as I have a patchwork link.
> >
> > Cheers,
> > Benjamin
> >
> >   drivers/hid/hid-uclogic.c | 17 ++++++++---------
> >   1 file changed, 8 insertions(+), 9 deletions(-)
> >
> > diff --git a/drivers/hid/hid-uclogic.c b/drivers/hid/hid-uclogic.c
> > index bdda9fd..6473e83 100644
> > --- a/drivers/hid/hid-uclogic.c
> > +++ b/drivers/hid/hid-uclogic.c
> > @@ -627,6 +627,7 @@ struct uclogic_drvdata {
> >   	__u8 *rdesc;
> >   	unsigned int rsize;
> >   	bool invert_pen_inrange;
> > +	bool ignore_pen_interface;
> >   };
> >
> >   static __u8 *uclogic_report_fixup(struct hid_device *hdev, __u8 *rdesc,
> > @@ -719,16 +720,12 @@ static int uclogic_input_mapping(struct hid_device
> > *hdev, struct hid_input *hi,
> >   		struct hid_field *field, struct hid_usage *usage,
> >   		unsigned long **bit, int *max)
> >   {
> > -	struct usb_interface *intf;
> > -
> > -	if (hdev->product == USB_DEVICE_ID_HUION_TABLET) {
> > -		intf = to_usb_interface(hdev->dev.parent);
> > +	struct uclogic_drvdata *drvdata = hid_get_drvdata(hdev);
> >
> > -		/* discard the unused pen interface */
> > -		if ((intf->cur_altsetting->desc.bInterfaceNumber != 0) &&
> > -		    (field->application == HID_DG_PEN))
> > -			return -1;
> > -	}
> > +	/* discard the unused pen interface */
> > +	if ((drvdata->ignore_pen_interface) &&
> > +	    (field->application == HID_DG_PEN))
> > +		return -1;
> >
> >   	/* let hid-core decide what to do */
> >   	return 0;
> > @@ -908,6 +905,8 @@ static int uclogic_probe(struct hid_device *hdev,
> >   				return rc;
> >   			}
> >   			drvdata->invert_pen_inrange = true;
> > +		} else {
> > +			drvdata->ignore_pen_interface = true;
> >   		}
> >   		break;
> >   	}
> 
> This looks fine to me logically, but the "ignore_pen_interface" name is a bit
> confusing.
> 
>  From the driver code and comments it follows that "pen interface" is the USB
> interface #0 and we're not ignoring it (uclogic_probe code becomes the worst
> here).  I think that it is better to call it in terms of what the
> "input_mapping" description says, i.e. "ignore_pen_usage".
> 

Sure, ignore_pen_usage is perfectly fine. Will do a v2 this afternoon hopefully.

Cheers,
Benjamin

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2015-03-15 17:09 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-03-13 15:42 [PATCH] HID: uclogic: make input_mapping independent of usb Benjamin Tissoires
2015-03-14 18:52 ` Nikolai Kondrashov
2015-03-15 17:09   ` Benjamin Tissoires

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).