Re: [PATCH] Input : Optimize joydev_connect function

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi Anshul,

On Tue, Mar 10, 2015 at 11:36:17AM -0700, Anshul Garg wrote:
> From: Anshul Garg <aksgarg1989@xxxxxxxxx>
> 
> In joydev_connect function added check for event type before
> setting properties for that event. This will avoid dummy
> loop iterations which checks for event code even if event type
> is not set.

I do not think you'll find a device that would fit joydev's matching
rules that would benefit from this.

> 
> Signed-off-by: Anshul Garg <aksgarg1989@xxxxxxxxx>
> ---
>  drivers/input/joydev.c |   44 ++++++++++++++++++++++++--------------------
>  1 file changed, 24 insertions(+), 20 deletions(-)
> 
> diff --git a/drivers/input/joydev.c b/drivers/input/joydev.c
> index f362883..a37a26c 100644
> --- a/drivers/input/joydev.c
> +++ b/drivers/input/joydev.c
> @@ -797,27 +797,31 @@ static int joydev_connect(struct input_handler *handler, struct input_dev *dev,
>  	joydev->handle.name = dev_name(&joydev->dev);
>  	joydev->handle.handler = handler;
>  	joydev->handle.private = joydev;
> +
> +	if (test_bit(EV_ABS, dev->evbit)) {
> +		for (i = 0; i < ABS_CNT; i++)
> +			if (test_bit(i, dev->absbit)) {
> +				joydev->absmap[i] = joydev->nabs;
> +				joydev->abspam[joydev->nabs] = i;
> +				joydev->nabs++;
> +			}
> +	}
>  
> -	for (i = 0; i < ABS_CNT; i++)
> -		if (test_bit(i, dev->absbit)) {
> -			joydev->absmap[i] = joydev->nabs;
> -			joydev->abspam[joydev->nabs] = i;
> -			joydev->nabs++;
> -		}
> -
> -	for (i = BTN_JOYSTICK - BTN_MISC; i < KEY_MAX - BTN_MISC + 1; i++)
> -		if (test_bit(i + BTN_MISC, dev->keybit)) {
> -			joydev->keymap[i] = joydev->nkey;
> -			joydev->keypam[joydev->nkey] = i + BTN_MISC;
> -			joydev->nkey++;
> -		}
> -
> -	for (i = 0; i < BTN_JOYSTICK - BTN_MISC; i++)
> -		if (test_bit(i + BTN_MISC, dev->keybit)) {
> -			joydev->keymap[i] = joydev->nkey;
> -			joydev->keypam[joydev->nkey] = i + BTN_MISC;
> -			joydev->nkey++;
> -		}
> +	if (test_bit(EV_KEY, dev->evbit)) {
> +		for (i = BTN_JOYSTICK - BTN_MISC; i < KEY_MAX - BTN_MISC + 1; i++)
> +			if (test_bit(i + BTN_MISC, dev->keybit)) {
> +				joydev->keymap[i] = joydev->nkey;
> +				joydev->keypam[joydev->nkey] = i + BTN_MISC;
> +				joydev->nkey++;
> +			}
> +
> +		for (i = 0; i < BTN_JOYSTICK - BTN_MISC; i++)
> +			if (test_bit(i + BTN_MISC, dev->keybit)) {
> +				joydev->keymap[i] = joydev->nkey;
> +				joydev->keypam[joydev->nkey] = i + BTN_MISC;
> +				joydev->nkey++;
> +			}
> +	}
>  
>  	for (i = 0; i < joydev->nabs; i++) {
>  		j = joydev->abspam[i];
> -- 
> 1.7.9.5
> 
> 
> ---
> This email has been checked for viruses by Avast antivirus software.
> http://www.avast.com
> 

-- 
Dmitry
--
To unsubscribe from this list: send the line "unsubscribe linux-input" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html




[Index of Archives]     [Linux Media Devel]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [Linux Wireless Networking]     [Linux Omap]

  Powered by Linux