linux-input.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Dmitry Torokhov <dmitry.torokhov@gmail.com>
To: David Herrmann <dh.herrmann@gmail.com>
Cc: linux-input@vger.kernel.org,
	Peter Hutterer <peter.hutterer@who-t.net>,
	Dmitry Torokhov <dtor@google.com>
Subject: Re: [PATCH RESEND 2/5] Input: uinput - uinput_validate_absbits() cleanup
Date: Sun, 20 Jul 2014 17:34:00 -0700	[thread overview]
Message-ID: <20140721003400.GA22552@core.coreip.homeip.net> (raw)
In-Reply-To: <1405775445-4454-3-git-send-email-dh.herrmann@gmail.com>

On Sat, Jul 19, 2014 at 03:10:42PM +0200, David Herrmann wrote:
> This moves basic checks and setup from uinput_setup_device() into
> uinput_validate_absbits() to make it easier to use. This way, we can call
> it from other places without copying the boilerplate code.
> 
> Reviewed-by: Peter Hutterer <peter.hutterer@who-t.net>
> Signed-off-by: David Herrmann <dh.herrmann@gmail.com>

Applied, thank you.

> ---
>  drivers/input/misc/uinput.c | 40 +++++++++++++++++++++-------------------
>  1 file changed, 21 insertions(+), 19 deletions(-)
> 
> diff --git a/drivers/input/misc/uinput.c b/drivers/input/misc/uinput.c
> index 8569362..615324c 100644
> --- a/drivers/input/misc/uinput.c
> +++ b/drivers/input/misc/uinput.c
> @@ -311,7 +311,13 @@ static int uinput_open(struct inode *inode, struct file *file)
>  static int uinput_validate_absbits(struct input_dev *dev)
>  {
>  	unsigned int cnt;
> -	int retval = 0;
> +	int nslot;
> +
> +	if (!test_bit(EV_ABS, dev->evbit))
> +		return 0;
> +
> +	/* check if absmin/absmax/absfuzz/absflat are filled as
> +	 * told in Documentation/input/input-programming.txt */
>  
>  	for (cnt = 0; cnt < ABS_CNT; cnt++) {
>  		int min, max;
> @@ -327,8 +333,7 @@ static int uinput_validate_absbits(struct input_dev *dev)
>  				UINPUT_NAME, cnt,
>  				input_abs_get_min(dev, cnt),
>  				input_abs_get_max(dev, cnt));
> -			retval = -EINVAL;
> -			break;
> +			return -EINVAL;
>  		}
>  
>  		if (input_abs_get_flat(dev, cnt) >
> @@ -340,11 +345,18 @@ static int uinput_validate_absbits(struct input_dev *dev)
>  				input_abs_get_flat(dev, cnt),
>  				input_abs_get_min(dev, cnt),
>  				input_abs_get_max(dev, cnt));
> -			retval = -EINVAL;
> -			break;
> +			return -EINVAL;
>  		}
>  	}
> -	return retval;
> +
> +	if (test_bit(ABS_MT_SLOT, dev->absbit)) {
> +		nslot = input_abs_get_max(dev, ABS_MT_SLOT) + 1;
> +		input_mt_init_slots(dev, nslot, 0);
> +	} else if (test_bit(ABS_MT_POSITION_X, dev->absbit)) {
> +		input_set_events_per_packet(dev, 60);
> +	}
> +
> +	return 0;
>  }
>  
>  static int uinput_allocate_device(struct uinput_device *udev)
> @@ -410,19 +422,9 @@ static int uinput_setup_device(struct uinput_device *udev,
>  		input_abs_set_flat(dev, i, user_dev->absflat[i]);
>  	}
>  
> -	/* check if absmin/absmax/absfuzz/absflat are filled as
> -	 * told in Documentation/input/input-programming.txt */
> -	if (test_bit(EV_ABS, dev->evbit)) {
> -		retval = uinput_validate_absbits(dev);
> -		if (retval < 0)
> -			goto exit;
> -		if (test_bit(ABS_MT_SLOT, dev->absbit)) {
> -			int nslot = input_abs_get_max(dev, ABS_MT_SLOT) + 1;
> -			input_mt_init_slots(dev, nslot, 0);
> -		} else if (test_bit(ABS_MT_POSITION_X, dev->absbit)) {
> -			input_set_events_per_packet(dev, 60);
> -		}
> -	}
> +	retval = uinput_validate_absbits(dev);
> +	if (retval < 0)
> +		goto exit;
>  
>  	udev->state = UIST_SETUP_COMPLETE;
>  	retval = count;
> -- 
> 2.0.2
> 

-- 
Dmitry

  reply	other threads:[~2014-07-21  0:34 UTC|newest]

Thread overview: 22+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-07-19 13:10 [PATCH RESEND 0/5] Evdev Extensions David Herrmann
2014-07-19 13:10 ` [PATCH RESEND 1/5] Input: evdev - add event-mask API David Herrmann
2014-07-19 13:10 ` [PATCH RESEND 2/5] Input: uinput - uinput_validate_absbits() cleanup David Herrmann
2014-07-21  0:34   ` Dmitry Torokhov [this message]
2014-07-19 13:10 ` [PATCH RESEND 3/5] Input: uinput - add UI_GET_VERSION ioctl David Herrmann
2014-07-21  0:34   ` Dmitry Torokhov
2014-07-19 13:10 ` [PATCH RESEND 4/5] Input: uinput - add new UINPUT_DEV_SETUP ioctl David Herrmann
2014-07-21  1:01   ` Dmitry Torokhov
2014-07-21  6:22     ` David Herrmann
2014-07-21 20:11       ` Dmitry Torokhov
2014-07-21 21:08         ` David Herrmann
2014-07-19 13:10 ` [RFC RESEND 5/5] Input: evdev - add new EVIOCGABSRANGE ioctl David Herrmann
2014-08-06  1:35   ` Peter Hutterer
2014-08-08 13:26     ` David Herrmann
2014-08-08 17:47       ` Dmitry Torokhov
2014-08-10 15:21         ` David Herrmann
2014-08-10 23:17           ` Peter Hutterer
2014-08-11  0:01             ` Dmitry Torokhov
2014-08-11  2:13               ` Peter Hutterer
2014-08-11 10:02                 ` David Herrmann
2014-08-11 10:00             ` David Herrmann
2014-07-21  0:37 ` [PATCH RESEND 0/5] Evdev Extensions Dmitry Torokhov

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=20140721003400.GA22552@core.coreip.homeip.net \
    --to=dmitry.torokhov@gmail.com \
    --cc=dh.herrmann@gmail.com \
    --cc=dtor@google.com \
    --cc=linux-input@vger.kernel.org \
    --cc=peter.hutterer@who-t.net \
    /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;
as well as URLs for NNTP newsgroup(s).