* [PATCH v2] pata_hpt37x: fold 'if' statement into 'switch'
@ 2011-01-10 19:31 Sergei Shtylyov
2011-01-10 19:34 ` Sergei Shtylyov
2011-01-19 1:00 ` Jeff Garzik
0 siblings, 2 replies; 3+ messages in thread
From: Sergei Shtylyov @ 2011-01-10 19:31 UTC (permalink / raw)
To: jgarzik, linux-ide; +Cc: alan
hpt37x_init_one() has a large *if* statement which should really be folded into
the *switch* statement that currently constitutes its *else* branch, reducing
one level of indentation...
Signed-off-by: Sergei Shtylyov <sshtylyov@ru.mvista.com>
---
The patch is against the recent Linus' tree plus 2 patches I posted
before:
http://marc.info/?l=linux-ide&m=129468455026976
http://marc.info/?l=linux-ide&m=129468485927420
drivers/ata/pata_hpt37x.c | 89 ++++++++++++++++++++++------------------------
1 file changed, 43 insertions(+), 46 deletions(-)
Index: linux-2.6/drivers/ata/pata_hpt37x.c
===================================================================
--- linux-2.6.orig/drivers/ata/pata_hpt37x.c
+++ linux-2.6/drivers/ata/pata_hpt37x.c
@@ -24,7 +24,7 @@
#include <linux/libata.h>
#define DRV_NAME "pata_hpt37x"
-#define DRV_VERSION "0.6.20"
+#define DRV_VERSION "0.6.21"
struct hpt_clock {
u8 xfer_speed;
@@ -838,7 +838,8 @@ static int hpt37x_init_one(struct pci_de
if (rc)
return rc;
- if (dev->device == PCI_DEVICE_ID_TTI_HPT366) {
+ switch (dev->device) {
+ case PCI_DEVICE_ID_TTI_HPT366:
/* May be a later chip in disguise. Check */
/* Older chips are in the HPT366 driver. Ignore them */
if (rev < 3)
@@ -867,50 +868,46 @@ static int hpt37x_init_one(struct pci_de
"please report (%d).\n", rev);
return -ENODEV;
}
- } else {
- switch (dev->device) {
- case PCI_DEVICE_ID_TTI_HPT372:
- /* 372N if rev >= 2 */
- if (rev >= 2)
- return -ENODEV;
- ppi[0] = &info_hpt372;
- chip_table = &hpt372a;
- break;
- case PCI_DEVICE_ID_TTI_HPT302:
- /* 302N if rev > 1 */
- if (rev > 1)
- return -ENODEV;
- ppi[0] = &info_hpt302;
- /* Check this */
- chip_table = &hpt302;
- break;
- case PCI_DEVICE_ID_TTI_HPT371:
- if (rev > 1)
- return -ENODEV;
- ppi[0] = &info_hpt302;
- chip_table = &hpt371;
- /*
- * Single channel device, master is not present
- * but the BIOS (or us for non x86) must mark it
- * absent
- */
- pci_read_config_byte(dev, 0x50, &mcr1);
- mcr1 &= ~0x04;
- pci_write_config_byte(dev, 0x50, mcr1);
- break;
- case PCI_DEVICE_ID_TTI_HPT374:
- chip_table = &hpt374;
- if (!(PCI_FUNC(dev->devfn) & 1))
- *ppi = &info_hpt374_fn0;
- else
- *ppi = &info_hpt374_fn1;
- break;
- default:
- pr_err(DRV_NAME
- ": PCI table is bogus, please report (%d).\n",
- dev->device);
- return -ENODEV;
- }
+ break;
+ case PCI_DEVICE_ID_TTI_HPT372:
+ /* 372N if rev >= 2 */
+ if (rev >= 2)
+ return -ENODEV;
+ ppi[0] = &info_hpt372;
+ chip_table = &hpt372a;
+ break;
+ case PCI_DEVICE_ID_TTI_HPT302:
+ /* 302N if rev > 1 */
+ if (rev > 1)
+ return -ENODEV;
+ ppi[0] = &info_hpt302;
+ /* Check this */
+ chip_table = &hpt302;
+ break;
+ case PCI_DEVICE_ID_TTI_HPT371:
+ if (rev > 1)
+ return -ENODEV;
+ ppi[0] = &info_hpt302;
+ chip_table = &hpt371;
+ /*
+ * Single channel device, master is not present but the BIOS
+ * (or us for non x86) must mark it absent
+ */
+ pci_read_config_byte(dev, 0x50, &mcr1);
+ mcr1 &= ~0x04;
+ pci_write_config_byte(dev, 0x50, mcr1);
+ break;
+ case PCI_DEVICE_ID_TTI_HPT374:
+ chip_table = &hpt374;
+ if (!(PCI_FUNC(dev->devfn) & 1))
+ *ppi = &info_hpt374_fn0;
+ else
+ *ppi = &info_hpt374_fn1;
+ break;
+ default:
+ pr_err(DRV_NAME ": PCI table is bogus, please report (%d).\n",
+ dev->device);
+ return -ENODEV;
}
/* Ok so this is a chip we support */
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH v2] pata_hpt37x: fold 'if' statement into 'switch'
2011-01-10 19:31 [PATCH v2] pata_hpt37x: fold 'if' statement into 'switch' Sergei Shtylyov
@ 2011-01-10 19:34 ` Sergei Shtylyov
2011-01-19 1:00 ` Jeff Garzik
1 sibling, 0 replies; 3+ messages in thread
From: Sergei Shtylyov @ 2011-01-10 19:34 UTC (permalink / raw)
To: jgarzik, linux-ide; +Cc: alan
Hello.
I wrote:
> hpt37x_init_one() has a large *if* statement which should really be folded into
> the *switch* statement that currently constitutes its *else* branch, reducing
> one level of indentation...
> Signed-off-by: Sergei Shtylyov <sshtylyov@ru.mvista.com>
Disregard "v2" in the subject -- forgot to remove it, when modifying the
previous mail. :-)
WBR, Sergei
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH v2] pata_hpt37x: fold 'if' statement into 'switch'
2011-01-10 19:31 [PATCH v2] pata_hpt37x: fold 'if' statement into 'switch' Sergei Shtylyov
2011-01-10 19:34 ` Sergei Shtylyov
@ 2011-01-19 1:00 ` Jeff Garzik
1 sibling, 0 replies; 3+ messages in thread
From: Jeff Garzik @ 2011-01-19 1:00 UTC (permalink / raw)
To: Sergei Shtylyov; +Cc: linux-ide, alan
On 01/10/2011 02:31 PM, Sergei Shtylyov wrote:
> hpt37x_init_one() has a large *if* statement which should really be folded into
> the *switch* statement that currently constitutes its *else* branch, reducing
> one level of indentation...
>
> Signed-off-by: Sergei Shtylyov<sshtylyov@ru.mvista.com>
>
> ---
> The patch is against the recent Linus' tree plus 2 patches I posted
> before:
>
> http://marc.info/?l=linux-ide&m=129468455026976
> http://marc.info/?l=linux-ide&m=129468485927420
>
> drivers/ata/pata_hpt37x.c | 89 ++++++++++++++++++++++------------------------
> 1 file changed, 43 insertions(+), 46 deletions(-)
applied this, and the prereset inherit patch
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2011-01-19 1:00 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-01-10 19:31 [PATCH v2] pata_hpt37x: fold 'if' statement into 'switch' Sergei Shtylyov
2011-01-10 19:34 ` Sergei Shtylyov
2011-01-19 1:00 ` Jeff Garzik
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).