Re: [PATCH] staging: fieldbus: anybus-s: force endiannes annotation

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

 



Thanks for the contibution! See inline.

On Sat, Apr 27, 2019 at 10:39 PM Nicholas Mc Guire <hofrat@xxxxxxxxx> wrote:
>
> While the endiannes is being handled correctly sparse was unhappy with
> the missing annotation as be16_to_cpu() expects a __be16.

Your commit message has room for improvement here. See my remarks
on your other patch:
https://lkml.org/lkml/2019/4/28/95

>
> Signed-off-by: Nicholas Mc Guire <hofrat@xxxxxxxxx>
> ---
>
> Problem reported by sparse
>
> As far as I understand sparse here the __force is actually the only
> solution possible to inform sparse that the endiannes handling is ok
>
> Patch was compile-tested with. x86_64_defconfig + FIELDBUS_DEV=m,
> HMS_ANYBUSS_BUS=m
>
> Patch is against 5.1-rc6 (localversion-next is next-20190426)
>
>  drivers/staging/fieldbus/anybuss/host.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/staging/fieldbus/anybuss/host.c b/drivers/staging/fieldbus/anybuss/host.c
> index 6227daf..278acac 100644
> --- a/drivers/staging/fieldbus/anybuss/host.c
> +++ b/drivers/staging/fieldbus/anybuss/host.c
> @@ -1348,7 +1348,7 @@ anybuss_host_common_probe(struct device *dev,
>         add_device_randomness(&val, 4);
>         regmap_bulk_read(cd->regmap, REG_FIELDBUS_TYPE, &fieldbus_type,
>                          sizeof(fieldbus_type));
> -       fieldbus_type = be16_to_cpu(fieldbus_type);
> +       fieldbus_type = be16_to_cpu((__force __be16)fieldbus_type);

Hmm... that would be cheating :)
what if you create a new local variable of type __be16?
Like so:

__be16 fieldbus_type_be;
<...>
regmap_bulk_read(cd->regmap, REG_FIELDBUS_TYPE, &fieldbus_type_be,
                          sizeof(fieldbus_type_be));
fieldbus_type = be16_to_cpu(fieldbus_type_be);

would that get sparse to shut up?

>         dev_info(dev, "Fieldbus type: %04X", fieldbus_type);
>         regmap_bulk_read(cd->regmap, REG_MODULE_SW_V, val, 2);
>         dev_info(dev, "Module SW version: %02X%02X",
> --
> 2.1.4
>
_______________________________________________
devel mailing list
devel@xxxxxxxxxxxxxxxxxxxxxx
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel



[Index of Archives]     [Linux Driver Backports]     [DMA Engine]     [Linux GPIO]     [Linux SPI]     [Video for Linux]     [Linux USB Devel]     [Linux Coverity]     [Linux Audio Users]     [Linux Kernel]     [Linux SCSI]     [Yosemite Backpacking]
  Powered by Linux