RE: [PATCH 0/4] serial: 8250: Fixes for Oxford Semiconductor 950 UARTs

From: Maciej W. Rozycki
Date: Sat Jun 26 2021 - 00:13:29 EST


On Tue, 15 Jun 2021, David Laight wrote:

> > As I have noted above there is a data type signedness difference between
> > `mcr_mask' and UART_MCR_CLKSEL. So we have the value of 0x80 (128).
> > Once bitwise-complemented it becomes 0xffffff7f (-129). Once assigned to
> > `mcr_mask' however it becomes 0x7f (127), which is considered an unsafe
> > conversion between signed and unsigned integers by GCC, which is why the
> > compiler complains about it.
>
> Blame the iso C standards committee for making integer promotions
> 'value preserving' instead of 'sign preserving' as they were in K&R C.
>
> Try using ^ 0xffu instead of ~.

Hmm, this is probably the least horrible way to paper it over, thanks.
Even using a temporary variable (let alone a cast) does not help as GCC
sees through it, and I've given up on converting <linux/serial_reg.h> to
have e.g.:

#define UART_MCR_CLKSEL _UL(0x80) /* Divide clock by 4 (TI16C752, EFR[4]=1) */

as I find that too messy with many of the comments wrapping up. And using
a GCC pragma would require a messy compiler version check.

I have posted an update with a path-of-least-resistance fix then along
with the 4/4 as v2 of this series.

Maciej