* [PATCH] Use ARRAY_SIZE() macro in i386 relocs.c file @ 2006-12-17 19:15 Robert P. J. Day 2006-12-19 18:11 ` [PATCH] Add pci class code for SATA Conke Hu 0 siblings, 1 reply; 8+ messages in thread From: Robert P. J. Day @ 2006-12-17 19:15 UTC (permalink / raw) To: Linux kernel mailing list; +Cc: trivial, Riley Change the explicit code in the relocs.c file to use ARRAY_SIZE() and add a definition of ARRAY_SIZE() since this is a userspace program and wouldn't include kernel.h. Signed-off-by: Robert P. J. Day <rpjday@mindspring.com> --- As Randy Dunlap pointed out, the relocs.c file is a userspace file and wouldn't include kernel.h so it should be fixed manually to use ARRAY_SIZE(). I'm submitting this patch for that single file simply because this file represents the *single* exception to being able to globally make the change throughout the entire source tree, so taking this file out of the equation means I don't have to constantly treat it as the exception, if that's all right. diff --git a/arch/i386/boot/compressed/relocs.c b/arch/i386/boot/compressed/relocs.c index 468da89..5b642f4 100644 --- a/arch/i386/boot/compressed/relocs.c +++ b/arch/i386/boot/compressed/relocs.c @@ -11,6 +11,7 @@ #include <endian.h> #define MAX_SHDRS 100 +#define ARRAY_SIZE(x) (sizeof(x) / sizeof((x)[0])) static Elf32_Ehdr ehdr; static Elf32_Shdr shdr[MAX_SHDRS]; static Elf32_Sym *symtab[MAX_SHDRS]; @@ -69,7 +70,7 @@ static const char *sym_type(unsigned type) #undef SYM_TYPE }; const char *name = "unknown sym type name"; - if (type < sizeof(type_name)/sizeof(type_name[0])) { + if (type < ARRAY_SIZE(type_name)) { name = type_name[type]; } return name; @@ -85,7 +86,7 @@ static const char *sym_bind(unsigned bind) #undef SYM_BIND }; const char *name = "unknown sym bind name"; - if (bind < sizeof(bind_name)/sizeof(bind_name[0])) { + if (bind < ARRAY_SIZE(bind_name)) { name = bind_name[bind]; } return name; @@ -102,7 +103,7 @@ static const char *sym_visibility(unsigned visibility) #undef SYM_VISIBILITY }; const char *name = "unknown sym visibility name"; - if (visibility < sizeof(visibility_name)/sizeof(visibility_name[0])) { + if (visibility < ARRAY_SIZE(visibility_name)) { name = visibility_name[visibility]; } return name; @@ -126,7 +127,7 @@ static const char *rel_type(unsigned type) #undef REL_TYPE }; const char *name = "unknown type rel type name"; - if (type < sizeof(type_name)/sizeof(type_name[0])) { + if (type < ARRAY_SIZE(type_name)) { name = type_name[type]; } return name; ^ permalink raw reply related [flat|nested] 8+ messages in thread
* [PATCH] Add pci class code for SATA 2006-12-17 19:15 [PATCH] Use ARRAY_SIZE() macro in i386 relocs.c file Robert P. J. Day @ 2006-12-19 18:11 ` Conke Hu 2006-12-19 19:32 ` Jeff Garzik 0 siblings, 1 reply; 8+ messages in thread From: Conke Hu @ 2006-12-19 18:11 UTC (permalink / raw) To: Linux kernel mailing list Add pci class code 0x0106 for SATA to pci_ids.h signed-off-by: conke.hu@gmail.com -------------------- --- linux-2.6.20-rc1/include/linux/pci_ids.h.orig 2006-12-20 01:58:30.000000000 +0800 +++ linux-2.6.20-rc1/include/linux/pci_ids.h 2006-12-20 01:59:07.000000000 +0800 @@ -15,6 +15,7 @@ #define PCI_CLASS_STORAGE_FLOPPY 0x0102 #define PCI_CLASS_STORAGE_IPI 0x0103 #define PCI_CLASS_STORAGE_RAID 0x0104 +#define PCI_CLASS_STORAGE_SATA 0x0106 #define PCI_CLASS_STORAGE_SAS 0x0107 #define PCI_CLASS_STORAGE_OTHER 0x0180 ^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH] Add pci class code for SATA 2006-12-19 18:11 ` [PATCH] Add pci class code for SATA Conke Hu @ 2006-12-19 19:32 ` Jeff Garzik 2006-12-20 3:13 ` Conke Hu 0 siblings, 1 reply; 8+ messages in thread From: Jeff Garzik @ 2006-12-19 19:32 UTC (permalink / raw) To: conke.hu; +Cc: Linux kernel mailing list Conke Hu wrote: > Add pci class code 0x0106 for SATA to pci_ids.h > > signed-off-by: conke.hu@gmail.com > -------------------- > --- linux-2.6.20-rc1/include/linux/pci_ids.h.orig 2006-12-20 > 01:58:30.000000000 +0800 > +++ linux-2.6.20-rc1/include/linux/pci_ids.h 2006-12-20 > 01:59:07.000000000 +0800 > @@ -15,6 +15,7 @@ > #define PCI_CLASS_STORAGE_FLOPPY 0x0102 > #define PCI_CLASS_STORAGE_IPI 0x0103 > #define PCI_CLASS_STORAGE_RAID 0x0104 > +#define PCI_CLASS_STORAGE_SATA 0x0106 > #define PCI_CLASS_STORAGE_SAS 0x0107 > #define PCI_CLASS_STORAGE_OTHER 0x0180 Two comments: 1) I think "_SATA" is an inaccurate description. It should be _AHCI AFAICS. 2) Typically we don't add constants unless they are used somewhere... Jeff ^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH] Add pci class code for SATA 2006-12-19 19:32 ` Jeff Garzik @ 2006-12-20 3:13 ` Conke Hu 2006-12-20 3:41 ` Conke Hu 0 siblings, 1 reply; 8+ messages in thread From: Conke Hu @ 2006-12-20 3:13 UTC (permalink / raw) To: Jeff Garzik, Alan, Andrew Morton; +Cc: Linux kernel mailing list On 12/20/06, Jeff Garzik <jeff@garzik.org> wrote: > Conke Hu wrote: > > Add pci class code 0x0106 for SATA to pci_ids.h > > > > signed-off-by: conke.hu@gmail.com > > -------------------- > > --- linux-2.6.20-rc1/include/linux/pci_ids.h.orig 2006-12-20 > > 01:58:30.000000000 +0800 > > +++ linux-2.6.20-rc1/include/linux/pci_ids.h 2006-12-20 > > 01:59:07.000000000 +0800 > > @@ -15,6 +15,7 @@ > > #define PCI_CLASS_STORAGE_FLOPPY 0x0102 > > #define PCI_CLASS_STORAGE_IPI 0x0103 > > #define PCI_CLASS_STORAGE_RAID 0x0104 > > +#define PCI_CLASS_STORAGE_SATA 0x0106 > > #define PCI_CLASS_STORAGE_SAS 0x0107 > > #define PCI_CLASS_STORAGE_OTHER 0x0180 > > Two comments: > > 1) I think "_SATA" is an inaccurate description. It should be _AHCI AFAICS. > > 2) Typically we don't add constants unless they are used somewhere... > > Jeff > Hi Jeff, According to PCI spec 3.0, 0x0106 means SATA controller, 0x010601 means AHCI and 0x010600 means vendor specific SATA controller. Pls see the following table (PCI spec 3.0 P296): Base Class Sub-Class Interface Meaning -------------------------------------------------------- 00h 00h SCSI bus controller ------------------------------------------------ 01h xxh IDE controller ----------------------------------------------- 02h 00h Floppy disk controller ----------------------------------------------------- 03h 00h IPI bus controller -------------------------------------------------- 04h 00h RAID controller 01h ------------------------------------------------ 20h ATA controller with ADMA interface 05h --------------------------------------------------- 30h ATA controller with ADMA interface ------------------------------------------------------------------- 00h Serial ATA controller–vendor specific interface 06h ----------------------------------------------------------------- 01h Serial ATA controller–AHCI 1.0 interface ------------------------------------------------------------------------- 07h 00h Serial Attached SCSI (SAS) controller --------------------------------------------------------------------- 80h 00h Other mass storage controller ------------------------------------------------------------------------------ So, I think, the following macro is correct: #define PCI_CLASS_STORAGE_SATA 0x0106 If you would define AHCI class code, it should be 0x010601, not 0x0106: #define PCI_CLASS_STORAGE_SATA_AHCI 0x010601 And, I think that PCI_CLASS_STORAGE_SATA had better be added to pci_ids.h since the class code 0x0106 is used more than once. e.g. ahci.c uses the magic number 0x0106 twice, and it might be used more in future. Best regards, Conke ^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH] Add pci class code for SATA 2006-12-20 3:13 ` Conke Hu @ 2006-12-20 3:41 ` Conke Hu 2006-12-20 3:52 ` Conke Hu 0 siblings, 1 reply; 8+ messages in thread From: Conke Hu @ 2006-12-20 3:41 UTC (permalink / raw) To: Jeff Garzik, Alan, Andrew Morton; +Cc: Linux kernel mailing list On 12/20/06, Conke Hu <conke.hu@gmail.com> wrote: > On 12/20/06, Jeff Garzik <jeff@garzik.org> wrote: > > Conke Hu wrote: > > > Add pci class code 0x0106 for SATA to pci_ids.h > > > > > > signed-off-by: conke.hu@gmail.com > > > -------------------- > > > --- linux-2.6.20-rc1/include/linux/pci_ids.h.orig 2006-12-20 > > > 01:58:30.000000000 +0800 > > > +++ linux-2.6.20-rc1/include/linux/pci_ids.h 2006-12-20 > > > 01:59:07.000000000 +0800 > > > @@ -15,6 +15,7 @@ > > > #define PCI_CLASS_STORAGE_FLOPPY 0x0102 > > > #define PCI_CLASS_STORAGE_IPI 0x0103 > > > #define PCI_CLASS_STORAGE_RAID 0x0104 > > > +#define PCI_CLASS_STORAGE_SATA 0x0106 > > > #define PCI_CLASS_STORAGE_SAS 0x0107 > > > #define PCI_CLASS_STORAGE_OTHER 0x0180 > > > > Two comments: > > > > 1) I think "_SATA" is an inaccurate description. It should be _AHCI AFAICS. > > > > 2) Typically we don't add constants unless they are used somewhere... > > > > Jeff > > > > Hi Jeff, > According to PCI spec 3.0, 0x0106 means SATA controller, 0x010601 > means AHCI and 0x010600 means vendor specific SATA controller. Pls see > the following table (PCI spec 3.0 P296): > > Base Class Sub-Class Interface Meaning > -------------------------------------------------------- > 00h 00h SCSI bus controller > ------------------------------------------------ > 01h xxh IDE controller > ----------------------------------------------- > 02h 00h Floppy disk controller > ----------------------------------------------------- > 03h 00h IPI bus controller > -------------------------------------------------- > 04h 00h RAID controller > 01h ------------------------------------------------ > 20h ATA controller with ADMA interface > 05h --------------------------------------------------- > 30h ATA controller with ADMA interface > ------------------------------------------------------------------- > 00h Serial ATA controller–vendor specific interface > 06h ----------------------------------------------------------------- > 01h Serial ATA controller–AHCI 1.0 interface > ------------------------------------------------------------------------- > 07h 00h Serial Attached SCSI (SAS) controller > --------------------------------------------------------------------- > 80h 00h Other mass storage controller > ------------------------------------------------------------------------------ > > > So, I think, the following macro is correct: > #define PCI_CLASS_STORAGE_SATA 0x0106 > If you would define AHCI class code, it should be 0x010601, not 0x0106: > #define PCI_CLASS_STORAGE_SATA_AHCI 0x010601 > > And, I think that PCI_CLASS_STORAGE_SATA had better be added to > pci_ids.h since the class code 0x0106 is used more than once. e.g. > ahci.c uses the magic number 0x0106 twice, and it might be used more > in future. > > Best regards, > Conke > Here is a patch to show more details: ----------------------------------- diff -Nur linux-2.6.20-rc1.orig/drivers/ata/ahci.c linux-2.6.20-rc1/drivers/ata/ahci.c --- linux-2.6.20-rc1.orig/drivers/ata/ahci.c 2006-12-20 10:25:00.000000000 +0800 +++ linux-2.6.20-rc1/drivers/ata/ahci.c 2006-12-20 10:13:24.000000000 +0800 @@ -418,7 +418,7 @@ /* Generic, PCI class code for AHCI */ { PCI_ANY_ID, PCI_ANY_ID, PCI_ANY_ID, PCI_ANY_ID, - 0x010601, 0xffffff, board_ahci }, + PCI_CLASS_STORAGE_SATA<<8|1, 0xffffff, board_ahci }, { } /* terminate list */ }; @@ -1586,11 +1586,11 @@ speed_s = "?"; pci_read_config_word(pdev, 0x0a, &cc); - if (cc == 0x0101) + if (cc == PCI_CLASS_STORAGE_IDE) scc_s = "IDE"; - else if (cc == 0x0106) + else if (cc == PCI_CLASS_STORAGE_SATA) scc_s = "SATA"; - else if (cc == 0x0104) + else if (cc == PCI_CLASS_STORAGE_RAID) scc_s = "RAID"; else scc_s = "unknown"; diff -Nur linux-2.6.20-rc1.orig/include/linux/pci_ids.h linux-2.6.20-rc1/include/linux/pci_ids.h --- linux-2.6.20-rc1.orig/include/linux/pci_ids.h 2006-12-20 10:24:51.000000000 +0800 +++ linux-2.6.20-rc1/include/linux/pci_ids.h 2006-12-20 10:08:15.000000000 +0800 @@ -15,6 +15,7 @@ #define PCI_CLASS_STORAGE_FLOPPY 0x0102 #define PCI_CLASS_STORAGE_IPI 0x0103 #define PCI_CLASS_STORAGE_RAID 0x0104 +#define PCI_CLASS_STORAGE_SATA 0x0106 #define PCI_CLASS_STORAGE_SAS 0x0107 #define PCI_CLASS_STORAGE_OTHER 0x018 ^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH] Add pci class code for SATA 2006-12-20 3:41 ` Conke Hu @ 2006-12-20 3:52 ` Conke Hu 2006-12-20 3:58 ` Randy Dunlap 2007-01-08 2:29 ` Jeff Garzik 0 siblings, 2 replies; 8+ messages in thread From: Conke Hu @ 2006-12-20 3:52 UTC (permalink / raw) To: Jeff Garzik, Alan, Andrew Morton; +Cc: Linux kernel mailing list On 12/20/06, Conke Hu <conke.hu@gmail.com> wrote: > On 12/20/06, Conke Hu <conke.hu@gmail.com> wrote: > > On 12/20/06, Jeff Garzik <jeff@garzik.org> wrote: > > > Conke Hu wrote: > > > > Add pci class code 0x0106 for SATA to pci_ids.h > > > > > > > > signed-off-by: conke.hu@gmail.com > > > > -------------------- > > > > --- linux-2.6.20-rc1/include/linux/pci_ids.h.orig 2006-12-20 > > > > 01:58:30.000000000 +0800 > > > > +++ linux-2.6.20-rc1/include/linux/pci_ids.h 2006-12-20 > > > > 01:59:07.000000000 +0800 > > > > @@ -15,6 +15,7 @@ > > > > #define PCI_CLASS_STORAGE_FLOPPY 0x0102 > > > > #define PCI_CLASS_STORAGE_IPI 0x0103 > > > > #define PCI_CLASS_STORAGE_RAID 0x0104 > > > > +#define PCI_CLASS_STORAGE_SATA 0x0106 > > > > #define PCI_CLASS_STORAGE_SAS 0x0107 > > > > #define PCI_CLASS_STORAGE_OTHER 0x0180 > > > > > > Two comments: > > > > > > 1) I think "_SATA" is an inaccurate description. It should be _AHCI AFAICS. > > > > > > 2) Typically we don't add constants unless they are used somewhere... > > > > > > Jeff > > > > > > > Hi Jeff, > > According to PCI spec 3.0, 0x0106 means SATA controller, 0x010601 > > means AHCI and 0x010600 means vendor specific SATA controller. Pls see > > the following table (PCI spec 3.0 P296): > > > > Base Class Sub-Class Interface Meaning > > -------------------------------------------------------- > > 00h 00h SCSI bus controller > > ------------------------------------------------ > > 01h xxh IDE controller > > ----------------------------------------------- > > 02h 00h Floppy disk controller > > ----------------------------------------------------- > > 03h 00h IPI bus controller > > -------------------------------------------------- > > 04h 00h RAID controller > > 01h ------------------------------------------------ > > 20h ATA controller with ADMA interface > > 05h --------------------------------------------------- > > 30h ATA controller with ADMA interface > > ------------------------------------------------------------------- > > 00h Serial ATA controller–vendor specific interface > > 06h ----------------------------------------------------------------- > > 01h Serial ATA controller–AHCI 1.0 interface > > ------------------------------------------------------------------------- > > 07h 00h Serial Attached SCSI (SAS) controller > > --------------------------------------------------------------------- > > 80h 00h Other mass storage controller > > ------------------------------------------------------------------------------ > > > > > > So, I think, the following macro is correct: > > #define PCI_CLASS_STORAGE_SATA 0x0106 > > If you would define AHCI class code, it should be 0x010601, not 0x0106: > > #define PCI_CLASS_STORAGE_SATA_AHCI 0x010601 > > > > And, I think that PCI_CLASS_STORAGE_SATA had better be added to > > pci_ids.h since the class code 0x0106 is used more than once. e.g. > > ahci.c uses the magic number 0x0106 twice, and it might be used more > > in future. > > > > Best regards, > > Conke > > > > > Here is a patch to show more details: > ----------------------------------- > diff -Nur linux-2.6.20-rc1.orig/drivers/ata/ahci.c > linux-2.6.20-rc1/drivers/ata/ahci.c > --- linux-2.6.20-rc1.orig/drivers/ata/ahci.c 2006-12-20 10:25:00.000000000 +0800 > +++ linux-2.6.20-rc1/drivers/ata/ahci.c 2006-12-20 10:13:24.000000000 +0800 > @@ -418,7 +418,7 @@ > > /* Generic, PCI class code for AHCI */ > { PCI_ANY_ID, PCI_ANY_ID, PCI_ANY_ID, PCI_ANY_ID, > - 0x010601, 0xffffff, board_ahci }, > + PCI_CLASS_STORAGE_SATA<<8|1, 0xffffff, board_ahci }, > > { } /* terminate list */ > }; > @@ -1586,11 +1586,11 @@ > speed_s = "?"; > > pci_read_config_word(pdev, 0x0a, &cc); > - if (cc == 0x0101) > + if (cc == PCI_CLASS_STORAGE_IDE) > scc_s = "IDE"; > - else if (cc == 0x0106) > + else if (cc == PCI_CLASS_STORAGE_SATA) > scc_s = "SATA"; > - else if (cc == 0x0104) > + else if (cc == PCI_CLASS_STORAGE_RAID) > scc_s = "RAID"; > else > scc_s = "unknown"; > diff -Nur linux-2.6.20-rc1.orig/include/linux/pci_ids.h > linux-2.6.20-rc1/include/linux/pci_ids.h > --- linux-2.6.20-rc1.orig/include/linux/pci_ids.h 2006-12-20 > 10:24:51.000000000 +0800 > +++ linux-2.6.20-rc1/include/linux/pci_ids.h 2006-12-20 10:08:15.000000000 +0800 > @@ -15,6 +15,7 @@ > #define PCI_CLASS_STORAGE_FLOPPY 0x0102 > #define PCI_CLASS_STORAGE_IPI 0x0103 > #define PCI_CLASS_STORAGE_RAID 0x0104 > +#define PCI_CLASS_STORAGE_SATA 0x0106 > #define PCI_CLASS_STORAGE_SAS 0x0107 > #define PCI_CLASS_STORAGE_OTHER 0x018 > or, pls see this one: ------------------------ diff -Nur linux-2.6.20-rc1.orig/drivers/ata/ahci.c linux-2.6.20-rc1/drivers/ata/ahci.c --- linux-2.6.20-rc1.orig/drivers/ata/ahci.c 2006-12-20 10:25:00.000000000 +0800 +++ linux-2.6.20-rc1/drivers/ata/ahci.c 2006-12-20 11:45:45.000000000 +0800 @@ -418,7 +418,7 @@ /* Generic, PCI class code for AHCI */ { PCI_ANY_ID, PCI_ANY_ID, PCI_ANY_ID, PCI_ANY_ID, - 0x010601, 0xffffff, board_ahci }, + PCI_CLASS_STORAGE_SATA_AHCI, 0xffffff, board_ahci }, { } /* terminate list */ }; @@ -1586,11 +1586,11 @@ speed_s = "?"; pci_read_config_word(pdev, 0x0a, &cc); - if (cc == 0x0101) + if (cc == PCI_CLASS_STORAGE_IDE) scc_s = "IDE"; - else if (cc == 0x0106) + else if (cc == PCI_CLASS_STORAGE_SATA) scc_s = "SATA"; - else if (cc == 0x0104) + else if (cc == PCI_CLASS_STORAGE_RAID) scc_s = "RAID"; else scc_s = "unknown"; diff -Nur linux-2.6.20-rc1.orig/include/linux/pci_ids.h linux-2.6.20-rc1/include/linux/pci_ids.h --- linux-2.6.20-rc1.orig/include/linux/pci_ids.h 2006-12-20 10:24:51.000000000 +0800 +++ linux-2.6.20-rc1/include/linux/pci_ids.h 2006-12-20 11:45:07.000000000 +0800 @@ -15,6 +15,8 @@ #define PCI_CLASS_STORAGE_FLOPPY 0x0102 #define PCI_CLASS_STORAGE_IPI 0x0103 #define PCI_CLASS_STORAGE_RAID 0x0104 +#define PCI_CLASS_STORAGE_SATA 0x0106 +#define PCI_CLASS_STORAGE_SATA_AHCI 0x010601 #define PCI_CLASS_STORAGE_SAS 0x0107 #define PCI_CLASS_STORAGE_OTHER 0x0180 BTW, the 2 patches above are just my suggestion, not formal patch. If either of them is acceptible, I will send out a formal patch. Thanks! Conke ^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH] Add pci class code for SATA 2006-12-20 3:52 ` Conke Hu @ 2006-12-20 3:58 ` Randy Dunlap 2007-01-08 2:29 ` Jeff Garzik 1 sibling, 0 replies; 8+ messages in thread From: Randy Dunlap @ 2006-12-20 3:58 UTC (permalink / raw) To: Conke Hu; +Cc: Jeff Garzik, Alan, Andrew Morton, Linux kernel mailing list On Wed, 20 Dec 2006 11:52:44 +0800 Conke Hu wrote: > On 12/20/06, Conke Hu <conke.hu@gmail.com> wrote: > > On 12/20/06, Conke Hu <conke.hu@gmail.com> wrote: > > > On 12/20/06, Jeff Garzik <jeff@garzik.org> wrote: > > > > Conke Hu wrote: > > > > > Add pci class code 0x0106 for SATA to pci_ids.h > > > > > > > > > > signed-off-by: conke.hu@gmail.com > > > > > -------------------- > > > > > --- linux-2.6.20-rc1/include/linux/pci_ids.h.orig 2006-12-20 > > > > > 01:58:30.000000000 +0800 > > > > > +++ linux-2.6.20-rc1/include/linux/pci_ids.h 2006-12-20 > > > > > 01:59:07.000000000 +0800 > > > > > @@ -15,6 +15,7 @@ > > > > > #define PCI_CLASS_STORAGE_FLOPPY 0x0102 > > > > > #define PCI_CLASS_STORAGE_IPI 0x0103 > > > > > #define PCI_CLASS_STORAGE_RAID 0x0104 > > > > > +#define PCI_CLASS_STORAGE_SATA 0x0106 > > > > > #define PCI_CLASS_STORAGE_SAS 0x0107 > > > > > #define PCI_CLASS_STORAGE_OTHER 0x0180 > > > > > > > > Two comments: > > > > > > > > 1) I think "_SATA" is an inaccurate description. It should be _AHCI AFAICS. > > > > > > > > 2) Typically we don't add constants unless they are used somewhere... > > > > > > > > Jeff > > > > > > > > > > Hi Jeff, > > > According to PCI spec 3.0, 0x0106 means SATA controller, 0x010601 > > > means AHCI and 0x010600 means vendor specific SATA controller. Pls see > > > the following table (PCI spec 3.0 P296): > > > > > > Base Class Sub-Class Interface Meaning > > > -------------------------------------------------------- > > > 00h 00h SCSI bus controller > > > ------------------------------------------------ > > > 01h xxh IDE controller > > > ----------------------------------------------- > > > 02h 00h Floppy disk controller > > > ----------------------------------------------------- > > > 03h 00h IPI bus controller > > > -------------------------------------------------- > > > 04h 00h RAID controller > > > 01h ------------------------------------------------ > > > 20h ATA controller with ADMA interface > > > 05h --------------------------------------------------- > > > 30h ATA controller with ADMA interface > > > ------------------------------------------------------------------- > > > 00h Serial ATA controller–vendor specific interface > > > 06h ----------------------------------------------------------------- > > > 01h Serial ATA controller–AHCI 1.0 interface > > > ------------------------------------------------------------------------- > > > 07h 00h Serial Attached SCSI (SAS) controller > > > --------------------------------------------------------------------- > > > 80h 00h Other mass storage controller > > > ------------------------------------------------------------------------------ > > > > > > > > > So, I think, the following macro is correct: > > > #define PCI_CLASS_STORAGE_SATA 0x0106 > > > If you would define AHCI class code, it should be 0x010601, not 0x0106: > > > #define PCI_CLASS_STORAGE_SATA_AHCI 0x010601 > > > > > > And, I think that PCI_CLASS_STORAGE_SATA had better be added to > > > pci_ids.h since the class code 0x0106 is used more than once. e.g. > > > ahci.c uses the magic number 0x0106 twice, and it might be used more > > > in future. > > > > > > Best regards, > > > Conke > > > > > > > > > Here is a patch to show more details: > > ----------------------------------- > > diff -Nur linux-2.6.20-rc1.orig/drivers/ata/ahci.c > > linux-2.6.20-rc1/drivers/ata/ahci.c > > --- linux-2.6.20-rc1.orig/drivers/ata/ahci.c 2006-12-20 10:25:00.000000000 +0800 > > +++ linux-2.6.20-rc1/drivers/ata/ahci.c 2006-12-20 10:13:24.000000000 +0800 > > @@ -418,7 +418,7 @@ > > > > /* Generic, PCI class code for AHCI */ > > { PCI_ANY_ID, PCI_ANY_ID, PCI_ANY_ID, PCI_ANY_ID, > > - 0x010601, 0xffffff, board_ahci }, > > + PCI_CLASS_STORAGE_SATA<<8|1, 0xffffff, board_ahci }, > > > > { } /* terminate list */ > > }; > > @@ -1586,11 +1586,11 @@ > > speed_s = "?"; > > > > pci_read_config_word(pdev, 0x0a, &cc); > > - if (cc == 0x0101) > > + if (cc == PCI_CLASS_STORAGE_IDE) > > scc_s = "IDE"; > > - else if (cc == 0x0106) > > + else if (cc == PCI_CLASS_STORAGE_SATA) > > scc_s = "SATA"; > > - else if (cc == 0x0104) > > + else if (cc == PCI_CLASS_STORAGE_RAID) > > scc_s = "RAID"; > > else > > scc_s = "unknown"; > > diff -Nur linux-2.6.20-rc1.orig/include/linux/pci_ids.h > > linux-2.6.20-rc1/include/linux/pci_ids.h > > --- linux-2.6.20-rc1.orig/include/linux/pci_ids.h 2006-12-20 > > 10:24:51.000000000 +0800 > > +++ linux-2.6.20-rc1/include/linux/pci_ids.h 2006-12-20 10:08:15.000000000 +0800 > > @@ -15,6 +15,7 @@ > > #define PCI_CLASS_STORAGE_FLOPPY 0x0102 > > #define PCI_CLASS_STORAGE_IPI 0x0103 > > #define PCI_CLASS_STORAGE_RAID 0x0104 > > +#define PCI_CLASS_STORAGE_SATA 0x0106 > > #define PCI_CLASS_STORAGE_SAS 0x0107 > > #define PCI_CLASS_STORAGE_OTHER 0x018 > > > > > or, pls see this one: > ------------------------ > diff -Nur linux-2.6.20-rc1.orig/drivers/ata/ahci.c > linux-2.6.20-rc1/drivers/ata/ahci.c > --- linux-2.6.20-rc1.orig/drivers/ata/ahci.c 2006-12-20 10:25:00.000000000 +0800 > +++ linux-2.6.20-rc1/drivers/ata/ahci.c 2006-12-20 11:45:45.000000000 +0800 > @@ -418,7 +418,7 @@ > > /* Generic, PCI class code for AHCI */ > { PCI_ANY_ID, PCI_ANY_ID, PCI_ANY_ID, PCI_ANY_ID, > - 0x010601, 0xffffff, board_ahci }, > + PCI_CLASS_STORAGE_SATA_AHCI, 0xffffff, board_ahci }, > > { } /* terminate list */ > }; > @@ -1586,11 +1586,11 @@ > speed_s = "?"; > > pci_read_config_word(pdev, 0x0a, &cc); > - if (cc == 0x0101) > + if (cc == PCI_CLASS_STORAGE_IDE) > scc_s = "IDE"; > - else if (cc == 0x0106) > + else if (cc == PCI_CLASS_STORAGE_SATA) > scc_s = "SATA"; > - else if (cc == 0x0104) > + else if (cc == PCI_CLASS_STORAGE_RAID) > scc_s = "RAID"; > else > scc_s = "unknown"; > diff -Nur linux-2.6.20-rc1.orig/include/linux/pci_ids.h > linux-2.6.20-rc1/include/linux/pci_ids.h > --- linux-2.6.20-rc1.orig/include/linux/pci_ids.h 2006-12-20 > 10:24:51.000000000 +0800 > +++ linux-2.6.20-rc1/include/linux/pci_ids.h 2006-12-20 11:45:07.000000000 +0800 > @@ -15,6 +15,8 @@ > #define PCI_CLASS_STORAGE_FLOPPY 0x0102 > #define PCI_CLASS_STORAGE_IPI 0x0103 > #define PCI_CLASS_STORAGE_RAID 0x0104 > +#define PCI_CLASS_STORAGE_SATA 0x0106 > +#define PCI_CLASS_STORAGE_SATA_AHCI 0x010601 > #define PCI_CLASS_STORAGE_SAS 0x0107 > #define PCI_CLASS_STORAGE_OTHER 0x0180 > > > BTW, the 2 patches above are just my suggestion, not formal patch. If > either of them is acceptible, I will send out a formal patch. Thanks! I prefer these changes... Thanks. --- ~Randy ^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH] Add pci class code for SATA 2006-12-20 3:52 ` Conke Hu 2006-12-20 3:58 ` Randy Dunlap @ 2007-01-08 2:29 ` Jeff Garzik 1 sibling, 0 replies; 8+ messages in thread From: Jeff Garzik @ 2007-01-08 2:29 UTC (permalink / raw) To: Conke Hu; +Cc: Alan, Andrew Morton, Linux kernel mailing list Conke Hu wrote: > or, pls see this one: > ------------------------ > diff -Nur linux-2.6.20-rc1.orig/drivers/ata/ahci.c > linux-2.6.20-rc1/drivers/ata/ahci.c > --- linux-2.6.20-rc1.orig/drivers/ata/ahci.c 2006-12-20 > 10:25:00.000000000 +0800 > +++ linux-2.6.20-rc1/drivers/ata/ahci.c 2006-12-20 11:45:45.000000000 > +0800 > @@ -418,7 +418,7 @@ > > /* Generic, PCI class code for AHCI */ > { PCI_ANY_ID, PCI_ANY_ID, PCI_ANY_ID, PCI_ANY_ID, > - 0x010601, 0xffffff, board_ahci }, > + PCI_CLASS_STORAGE_SATA_AHCI, 0xffffff, board_ahci }, > > { } /* terminate list */ > }; > @@ -1586,11 +1586,11 @@ > speed_s = "?"; > > pci_read_config_word(pdev, 0x0a, &cc); > - if (cc == 0x0101) > + if (cc == PCI_CLASS_STORAGE_IDE) > scc_s = "IDE"; > - else if (cc == 0x0106) > + else if (cc == PCI_CLASS_STORAGE_SATA) > scc_s = "SATA"; > - else if (cc == 0x0104) > + else if (cc == PCI_CLASS_STORAGE_RAID) > scc_s = "RAID"; > else > scc_s = "unknown"; > diff -Nur linux-2.6.20-rc1.orig/include/linux/pci_ids.h > linux-2.6.20-rc1/include/linux/pci_ids.h > --- linux-2.6.20-rc1.orig/include/linux/pci_ids.h 2006-12-20 > 10:24:51.000000000 +0800 > +++ linux-2.6.20-rc1/include/linux/pci_ids.h 2006-12-20 > 11:45:07.000000000 +0800 > @@ -15,6 +15,8 @@ > #define PCI_CLASS_STORAGE_FLOPPY 0x0102 > #define PCI_CLASS_STORAGE_IPI 0x0103 > #define PCI_CLASS_STORAGE_RAID 0x0104 > +#define PCI_CLASS_STORAGE_SATA 0x0106 > +#define PCI_CLASS_STORAGE_SATA_AHCI 0x010601 > #define PCI_CLASS_STORAGE_SAS 0x0107 > #define PCI_CLASS_STORAGE_OTHER 0x0180 > > > BTW, the 2 patches above are just my suggestion, not formal patch. If > either of them is acceptible, I will send out a formal patch. Thanks! The above seems OK to me... Jeff ^ permalink raw reply [flat|nested] 8+ messages in thread
end of thread, other threads:[~2007-01-08 2:29 UTC | newest] Thread overview: 8+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2006-12-17 19:15 [PATCH] Use ARRAY_SIZE() macro in i386 relocs.c file Robert P. J. Day 2006-12-19 18:11 ` [PATCH] Add pci class code for SATA Conke Hu 2006-12-19 19:32 ` Jeff Garzik 2006-12-20 3:13 ` Conke Hu 2006-12-20 3:41 ` Conke Hu 2006-12-20 3:52 ` Conke Hu 2006-12-20 3:58 ` Randy Dunlap 2007-01-08 2:29 ` Jeff Garzik
This is an external index of several public inboxes, see mirroring instructions on how to clone and mirror all data and code used by this external index.