Re: [PATCH 1/1] AVR32 PATA driver

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

 



Kristoffer Nyborg Gregertsen wrote:
On Tuesday 07 August 2007 17:54:09 Alan Cox wrote:
 +static int pata_at32_get_pio_mask(void)

+{
+	switch (max_pio) {
+	case 0:
+		return 0x01;
+	case 1:
+		return 0x03;
+	case 2:
+		return 0x07;
+	case 3:
+		return 0x0f;
+	case 4:
+		return 0x1f;
+	default:
+		return 0x01;
What is wrong with just using  (1 << max_pio) - 1 as the range is only
0-4 anyway.

Since max_pio is a module argument it may be invalid. Perhaps:

if (0 <= max_pio && max_pio <= 4)
	return (1 << max_pio) - 1;
else
	return 0x01;

Or is it common to trust the module arguments to be sane?

Well, a higher level issue, you should not have a max_pio module parameter at all. Other drivers do not have such a thing.

	Jeff



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

[Index of Archives]     [Linux Filesystems]     [Linux SCSI]     [Linux RAID]     [Git]     [Kernel Newbies]     [Linux Newbie]     [Security]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Samba]     [Device Mapper]

  Powered by Linux