staging: comedi: serial2002: Fix unnecessary cast styling issue
authorChris Cesare <chris.cesare@gmail.com>
Thu, 9 Jun 2016 19:39:03 +0000 (15:39 -0400)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Sat, 18 Jun 2016 04:14:16 +0000 (21:14 -0700)
checkpatch.pl warns that a cast of 1 to (long long) is unnecessary.
Remove the cast and also add code to check and make sure that
maxdata_list[chan] is not shifted too far, as suggested by Ian
Abbott.

Signed-off-by Chris Cesare <chris.cesare@gmail.com>
Reviewed-by: Ian Abbott <abbotti@mev.co.uk>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/staging/comedi/drivers/serial2002.c

index b7779468d75f5d9985682e09d9400aa0c9f9968e..0d33e520f6350f599d8e2d3b7a6a4a2e561ce960 100644 (file)
@@ -379,7 +379,10 @@ static int serial2002_setup_subdevice(struct comedi_subdevice *s,
                                range_table_list[chan] =
                                    (const struct comedi_lrange *)&range[j];
                        }
-                       maxdata_list[chan] = ((long long)1 << cfg[j].bits) - 1;
+                       if (cfg[j].bits < 32)
+                               maxdata_list[chan] = (1u << cfg[j].bits) - 1;
+                       else
+                               maxdata_list[chan] = 0xffffffff;
                        chan++;
                }
        }