Re: [PATCH] input: alps: fix compatibility with -funsigned-char

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

 



On Sunday 19 March 2023 18:45:08 Jason A. Donenfeld wrote:
> Might be wise to clean up a few other ones in that file? Or not. Up to
> you:
> 
> diff --git a/drivers/input/mouse/alps.c b/drivers/input/mouse/alps.c
> index 989228b5a0a4..afbf67c2488a 100644
> --- a/drivers/input/mouse/alps.c
> +++ b/drivers/input/mouse/alps.c
> @@ -852,8 +852,8 @@ static void alps_process_packet_v6(struct psmouse *psmouse)
>  			x = y = z = 0;
> 
>  		/* Divide 4 since trackpoint's speed is too fast */
> -		input_report_rel(dev2, REL_X, (char)x / 4);
> -		input_report_rel(dev2, REL_Y, -((char)y / 4));
> +		input_report_rel(dev2, REL_X, (signed char)x / 4);
> +		input_report_rel(dev2, REL_Y, -((signed char)y / 4));

Anyway, is casting here needed at all? Is not just plain -(y / 4) enough?

> 
>  		psmouse_report_standard_buttons(dev2, packet[3]);
> 
> @@ -1104,8 +1104,8 @@ static void alps_process_trackstick_packet_v7(struct psmouse *psmouse)
>  	    ((packet[3] & 0x20) << 1);
>  	z = (packet[5] & 0x3f) | ((packet[3] & 0x80) >> 1);
> 
> -	input_report_rel(dev2, REL_X, (char)x);
> -	input_report_rel(dev2, REL_Y, -((char)y));
> +	input_report_rel(dev2, REL_X, (signed char)x);
> +	input_report_rel(dev2, REL_Y, -((signed char)y));
>  	input_report_abs(dev2, ABS_PRESSURE, z);
> 
>  	psmouse_report_standard_buttons(dev2, packet[1]);
> diff --git a/drivers/input/mouse/elan_i2c_core.c b/drivers/input/mouse/elan_i2c_core.c
> index 5f0d75a45c80..43a1116c5852 100644
> --- a/drivers/input/mouse/elan_i2c_core.c
> +++ b/drivers/input/mouse/elan_i2c_core.c
> @@ -382,7 +382,7 @@ static unsigned int elan_convert_resolution(u8 val, u8 pattern)
>  	 *	((value from firmware) + 3) * 100 = dpi
>  	 */
>  	int res = pattern <= 0x01 ?
> -		(int)(char)val * 10 + 790 : ((int)(char)val + 3) * 100;
> +		(int)(signed char)val * 10 + 790 : ((int)(signed char)val + 3) * 100;
>  	/*
>  	 * We also have to convert dpi to dots/mm (*10/254 to avoid floating
>  	 * point).

Please move elantech change into separate commit/patch. As it has
nothing with alps driver. It is completely different hardware.



[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