2008-02-20 12:55:15

by Jonas Bonn

[permalink] [raw]
Subject: pci_device_id cleanups


The PCI_DEVICE_TABLE patch I sent earlier doesn't necessarily make much sense by itself... here is a set of patches that apply this macro, in turn moving a lot of this data into __devinitconst which is discardable in certain situations. Hopefully the benefit of this approach is a bit clearer now.

drivers/net/3c59x.c | 2 +-
drivers/net/amd8111e.c | 2 +-
drivers/net/arcnet/com20020-pci.c | 2 +-
drivers/net/defxx.c | 2 +-
drivers/net/hamachi.c | 2 +-
drivers/net/niu.c | 2 +-
drivers/net/pasemi_mac.c | 2 +-
drivers/net/sk98lin/skge.c | 2 +-
drivers/net/skfp/skfddi.c | 2 +-
drivers/net/starfire.c | 2 +-
drivers/net/sunhme.c | 2 +-
drivers/net/tlan.c | 2 +-
drivers/net/wan/dscc4.c | 2 +-
drivers/net/wan/lmc/lmc_main.c | 2 +-
include/linux/pci.h | 9 +++++++++
15 files changed, 23 insertions(+), 14 deletions(-)


2008-02-20 12:54:28

by Jonas Bonn

[permalink] [raw]
Subject: [PATCH] [net] use PCI_DEVICE_TABLE: makes struct pci_device_id array const and adds section attribute __devinitconst

Signed-off-by: Jonas Bonn <[email protected]>
---
drivers/net/hamachi.c | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/drivers/net/hamachi.c b/drivers/net/hamachi.c
index b53f6b6..d8056e9 100644
--- a/drivers/net/hamachi.c
+++ b/drivers/net/hamachi.c
@@ -1987,7 +1987,7 @@ static void __devexit hamachi_remove_one (struct pci_dev *pdev)
}
}

-static struct pci_device_id hamachi_pci_tbl[] = {
+static PCI_DEVICE_TABLE(hamachi_pci_tbl) = {
{ 0x1318, 0x0911, PCI_ANY_ID, PCI_ANY_ID, },
{ 0, }
};
--
1.5.3.8

2008-02-20 12:55:42

by Jonas Bonn

[permalink] [raw]
Subject: [PATCH] Add PCI_DEVICE_TABLE macro

The definitions of struct pci_device_id arrays should generally follow
the same pattern across the entire kernel. This macro defines this
array as const and puts it into the __devinitconst section.

Signed-off-by: Jonas Bonn <[email protected]>
---
include/linux/pci.h | 9 +++++++++
1 files changed, 9 insertions(+), 0 deletions(-)

diff --git a/include/linux/pci.h b/include/linux/pci.h
index 87195b6..c7a91b1 100644
--- a/include/linux/pci.h
+++ b/include/linux/pci.h
@@ -389,6 +389,15 @@ struct pci_driver {
#define to_pci_driver(drv) container_of(drv, struct pci_driver, driver)

/**
+ * PCI_DEVICE_TABLE - macro used to describe a pci device table
+ * @_table: device table name
+ *
+ * This macro is used to create a struct pci_device_id array (a device table)
+ * in a generic manner.
+ */
+#define PCI_DEVICE_TABLE(_table) const struct pci_device_id _table[] __devinitconst
+
+/**
* PCI_DEVICE - macro used to describe a specific pci device
* @vend: the 16 bit PCI Vendor ID
* @dev: the 16 bit PCI Device ID
--
1.5.3.8

2008-02-20 12:55:59

by Jonas Bonn

[permalink] [raw]
Subject: [PATCH] [net] use PCI_DEVICE_TABLE: makes struct pci_device_id array const and adds section attribute __devinitconst

Signed-off-by: Jonas Bonn <[email protected]>
---
drivers/net/wan/lmc/lmc_main.c | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/drivers/net/wan/lmc/lmc_main.c b/drivers/net/wan/lmc/lmc_main.c
index 6635ece..e85cfe7 100644
--- a/drivers/net/wan/lmc/lmc_main.c
+++ b/drivers/net/wan/lmc/lmc_main.c
@@ -82,7 +82,7 @@ static int lmc_first_load = 0;

static int LMC_PKT_BUF_SZ = 1542;

-static struct pci_device_id lmc_pci_tbl[] = {
+static PCI_DEVICE_TABLE(lmc_pci_tbl) = {
{ PCI_VENDOR_ID_DEC, PCI_DEVICE_ID_DEC_TULIP_FAST,
PCI_VENDOR_ID_LMC, PCI_ANY_ID },
{ PCI_VENDOR_ID_DEC, PCI_DEVICE_ID_DEC_TULIP_FAST,
--
1.5.3.8

2008-02-20 12:56:29

by Jonas Bonn

[permalink] [raw]
Subject: [PATCH] [net] use PCI_DEVICE_TABLE: makes struct pci_device_id array const and adds section attribute __devinitconst

Signed-off-by: Jonas Bonn <[email protected]>
---
drivers/net/3c59x.c | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/drivers/net/3c59x.c b/drivers/net/3c59x.c
index 6f8e7d4..d2045d4 100644
--- a/drivers/net/3c59x.c
+++ b/drivers/net/3c59x.c
@@ -372,7 +372,7 @@ static struct vortex_chip_info {
};


-static struct pci_device_id vortex_pci_tbl[] = {
+static PCI_DEVICE_TABLE(vortex_pci_tbl) = {
{ 0x10B7, 0x5900, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CH_3C590 },
{ 0x10B7, 0x5920, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CH_3C592 },
{ 0x10B7, 0x5970, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CH_3C597 },
--
1.5.3.8

2008-02-20 12:56:45

by Jonas Bonn

[permalink] [raw]
Subject: [PATCH] [net] use PCI_DEVICE_TABLE: makes struct pci_device_id array const and adds section attribute __devinitconst

Signed-off-by: Jonas Bonn <[email protected]>
---
drivers/net/starfire.c | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/drivers/net/starfire.c b/drivers/net/starfire.c
index c49214f..a67bac5 100644
--- a/drivers/net/starfire.c
+++ b/drivers/net/starfire.c
@@ -337,7 +337,7 @@ enum chipset {
CH_6915 = 0,
};

-static struct pci_device_id starfire_pci_tbl[] = {
+static PCI_DEVICE_TABLE(starfire_pci_tbl) = {
{ 0x9004, 0x6915, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CH_6915 },
{ 0, }
};
--
1.5.3.8

2008-02-20 12:57:06

by Jonas Bonn

[permalink] [raw]
Subject: [PATCH] [net] use PCI_DEVICE_TABLE: makes struct pci_device_id array const and adds section attribute __devinitconst

Signed-off-by: Jonas Bonn <[email protected]>
---
drivers/net/niu.c | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/drivers/net/niu.c b/drivers/net/niu.c
index e98ce1e..ab8148a 100644
--- a/drivers/net/niu.c
+++ b/drivers/net/niu.c
@@ -62,7 +62,7 @@ static void writeq(u64 val, void __iomem *reg)
}
#endif

-static struct pci_device_id niu_pci_tbl[] = {
+static PCI_DEVICE_TABLE(niu_pci_tbl) = {
{PCI_DEVICE(PCI_VENDOR_ID_SUN, 0xabcd)},
{}
};
--
1.5.3.8

2008-02-20 12:57:34

by Jonas Bonn

[permalink] [raw]
Subject: [PATCH] [net] use PCI_DEVICE_TABLE: makes struct pci_device_id array const and adds section attribute __devinitconst

Signed-off-by: Jonas Bonn <[email protected]>
---
drivers/net/amd8111e.c | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/drivers/net/amd8111e.c b/drivers/net/amd8111e.c
index 85f7276..a4ad2fb 100644
--- a/drivers/net/amd8111e.c
+++ b/drivers/net/amd8111e.c
@@ -113,7 +113,7 @@ MODULE_PARM_DESC(coalesce, "Enable or Disable interrupt coalescing, 1: Enable, 0
module_param_array(dynamic_ipg, bool, NULL, 0);
MODULE_PARM_DESC(dynamic_ipg, "Enable or Disable dynamic IPG, 1: Enable, 0: Disable");

-static struct pci_device_id amd8111e_pci_tbl[] = {
+static PCI_DEVICE_TABLE(amd8111e_pci_tbl) = {

{ PCI_VENDOR_ID_AMD, PCI_DEVICE_ID_AMD8111E_7462,
PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0UL },
--
1.5.3.8

2008-02-20 12:57:49

by Jonas Bonn

[permalink] [raw]
Subject: [PATCH] [net] use PCI_DEVICE_TABLE: makes struct pci_device_id array const and adds section attribute __devinitconst

Signed-off-by: Jonas Bonn <[email protected]>
---
drivers/net/tlan.c | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/drivers/net/tlan.c b/drivers/net/tlan.c
index 3af5b92..bea59c6 100644
--- a/drivers/net/tlan.c
+++ b/drivers/net/tlan.c
@@ -253,7 +253,7 @@ static struct board {
{ "Compaq NetFlex-3/E", TLAN_ADAPTER_ACTIVITY_LED, 0x83 }, /* EISA card */
};

-static struct pci_device_id tlan_pci_tbl[] = {
+static PCI_DEVICE_TABLE(tlan_pci_tbl) = {
{ PCI_VENDOR_ID_COMPAQ, PCI_DEVICE_ID_COMPAQ_NETEL10,
PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0 },
{ PCI_VENDOR_ID_COMPAQ, PCI_DEVICE_ID_COMPAQ_NETEL100,
--
1.5.3.8

2008-02-20 12:58:16

by Jonas Bonn

[permalink] [raw]
Subject: [PATCH] [net] use PCI_DEVICE_TABLE: makes struct pci_device_id array const and adds section attribute __devinitconst

Signed-off-by: Jonas Bonn <[email protected]>
---
drivers/net/wan/dscc4.c | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/drivers/net/wan/dscc4.c b/drivers/net/wan/dscc4.c
index c6f26e2..16d3a4c 100644
--- a/drivers/net/wan/dscc4.c
+++ b/drivers/net/wan/dscc4.c
@@ -2048,7 +2048,7 @@ static int __init dscc4_setup(char *str)
__setup("dscc4.setup=", dscc4_setup);
#endif

-static struct pci_device_id dscc4_pci_tbl[] = {
+static PCI_DEVICE_TABLE(dscc4_pci_tbl) = {
{ PCI_VENDOR_ID_SIEMENS, PCI_DEVICE_ID_SIEMENS_DSCC4,
PCI_ANY_ID, PCI_ANY_ID, },
{ 0,}
--
1.5.3.8

2008-02-20 12:58:39

by Jonas Bonn

[permalink] [raw]
Subject: [PATCH] [net] use PCI_DEVICE_TABLE: makes struct pci_device_id array const and adds section attribute __devinitconst

Signed-off-by: Jonas Bonn <[email protected]>
---
drivers/net/arcnet/com20020-pci.c | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/drivers/net/arcnet/com20020-pci.c b/drivers/net/arcnet/com20020-pci.c
index b8c0fa6..87ee0db 100644
--- a/drivers/net/arcnet/com20020-pci.c
+++ b/drivers/net/arcnet/com20020-pci.c
@@ -141,7 +141,7 @@ static void __devexit com20020pci_remove(struct pci_dev *pdev)
free_netdev(dev);
}

-static struct pci_device_id com20020pci_id_table[] = {
+static PCI_DEVICE_TABLE(com20020pci_id_table) = {
{ 0x1571, 0xa001, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0 },
{ 0x1571, 0xa002, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0 },
{ 0x1571, 0xa003, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0 },
--
1.5.3.8

2008-02-20 12:58:54

by Jonas Bonn

[permalink] [raw]
Subject: [PATCH] [net] use PCI_DEVICE_TABLE: makes struct pci_device_id array const and adds section attribute __devinitconst

Signed-off-by: Jonas Bonn <[email protected]>
---
drivers/net/defxx.c | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/drivers/net/defxx.c b/drivers/net/defxx.c
index ddc30c4..84a3ce5 100644
--- a/drivers/net/defxx.c
+++ b/drivers/net/defxx.c
@@ -3630,7 +3630,7 @@ static int __devinit dfx_pci_register(struct pci_dev *,
const struct pci_device_id *);
static void __devexit dfx_pci_unregister(struct pci_dev *);

-static struct pci_device_id dfx_pci_table[] = {
+static PCI_DEVICE_TABLE(dfx_pci_table) = {
{ PCI_DEVICE(PCI_VENDOR_ID_DEC, PCI_DEVICE_ID_DEC_FDDI) },
{ }
};
--
1.5.3.8

2008-02-20 12:59:18

by Jonas Bonn

[permalink] [raw]
Subject: [PATCH] [net] use PCI_DEVICE_TABLE: makes struct pci_device_id array const and adds section attribute __devinitconst

Signed-off-by: Jonas Bonn <[email protected]>
---
drivers/net/sunhme.c | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/drivers/net/sunhme.c b/drivers/net/sunhme.c
index b4e7f30..beb0d27 100644
--- a/drivers/net/sunhme.c
+++ b/drivers/net/sunhme.c
@@ -3247,7 +3247,7 @@ static void __devexit happy_meal_pci_remove(struct pci_dev *pdev)
dev_set_drvdata(&pdev->dev, NULL);
}

-static struct pci_device_id happymeal_pci_ids[] = {
+static PCI_DEVICE_TABLE(happymeal_pci_ids) = {
{ PCI_DEVICE(PCI_VENDOR_ID_SUN, PCI_DEVICE_ID_SUN_HAPPYMEAL) },
{ } /* Terminating entry */
};
--
1.5.3.8

2008-02-20 12:59:40

by Jonas Bonn

[permalink] [raw]
Subject: [PATCH] [net] use PCI_DEVICE_TABLE: makes struct pci_device_id array const and adds section attribute __devinitconst

Signed-off-by: Jonas Bonn <[email protected]>
---
drivers/net/sk98lin/skge.c | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/drivers/net/sk98lin/skge.c b/drivers/net/sk98lin/skge.c
index 20890e4..eedcbeb 100644
--- a/drivers/net/sk98lin/skge.c
+++ b/drivers/net/sk98lin/skge.c
@@ -5166,7 +5166,7 @@ err_out:
#define skge_resume NULL
#endif

-static struct pci_device_id skge_pci_tbl[] = {
+static PCI_DEVICE_TABLE(skge_pci_tbl) = {
#ifdef SK98LIN_ALL_DEVICES
{ PCI_VENDOR_ID_3COM, 0x1700, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0 },
{ PCI_VENDOR_ID_3COM, 0x80eb, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0 },
--
1.5.3.8

2008-02-20 12:59:56

by Jonas Bonn

[permalink] [raw]
Subject: [PATCH] [net] use PCI_DEVICE_TABLE: makes struct pci_device_id array const and adds section attribute __devinitconst

Signed-off-by: Jonas Bonn <[email protected]>
---
drivers/net/skfp/skfddi.c | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/drivers/net/skfp/skfddi.c b/drivers/net/skfp/skfddi.c
index 7cf9b9f..2a8386b 100644
--- a/drivers/net/skfp/skfddi.c
+++ b/drivers/net/skfp/skfddi.c
@@ -150,7 +150,7 @@ extern void mac_drv_rx_mode(struct s_smc *smc, int mode);
extern void mac_drv_clear_rx_queue(struct s_smc *smc);
extern void enable_tx_irq(struct s_smc *smc, u_short queue);

-static struct pci_device_id skfddi_pci_tbl[] = {
+static PCI_DEVICE_TABLE(skfddi_pci_tbl) = {
{ PCI_VENDOR_ID_SK, PCI_DEVICE_ID_SK_FP, PCI_ANY_ID, PCI_ANY_ID, },
{ } /* Terminating entry */
};
--
1.5.3.8

2008-02-20 13:00:31

by Jonas Bonn

[permalink] [raw]
Subject: [PATCH] [net] use PCI_DEVICE_TABLE: makes struct pci_device_id array const and adds section attribute __devinitconst

Signed-off-by: Jonas Bonn <[email protected]>
---
drivers/net/pasemi_mac.c | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/drivers/net/pasemi_mac.c b/drivers/net/pasemi_mac.c
index 2e39e02..069fa7c 100644
--- a/drivers/net/pasemi_mac.c
+++ b/drivers/net/pasemi_mac.c
@@ -1648,7 +1648,7 @@ static void __devexit pasemi_mac_remove(struct pci_dev *pdev)
free_netdev(netdev);
}

-static struct pci_device_id pasemi_mac_pci_tbl[] = {
+static PCI_DEVICE_TABLE(pasemi_mac_pci_tbl) = {
{ PCI_DEVICE(PCI_VENDOR_ID_PASEMI, 0xa005) },
{ PCI_DEVICE(PCI_VENDOR_ID_PASEMI, 0xa006) },
{ },
--
1.5.3.8

2008-02-20 13:17:25

by Sam Ravnborg

[permalink] [raw]
Subject: Re: pci_device_id cleanups

On Wed, Feb 20, 2008 at 01:53:36PM +0100, Jonas Bonn wrote:
>
> The PCI_DEVICE_TABLE patch I sent earlier doesn't necessarily make
> much sense by itself... here is a set of patches that apply
> this macro, in turn moving a lot of this data into __devinitconst
> which is discardable in certain situations.
> Hopefully the benefit of this approach is a bit clearer now.
[shorter lines please..]

Can you please confirm that this does not break powerpc (64 bit)
as they have troubles with the constification..

Sam

2008-02-20 13:27:34

by Jonas Bonn

[permalink] [raw]
Subject: Re: pci_device_id cleanups

Sam Ravnborg wrote:
> On Wed, Feb 20, 2008 at 01:53:36PM +0100, Jonas Bonn wrote:
>> The PCI_DEVICE_TABLE patch I sent earlier doesn't necessarily make
>> much sense by itself... here is a set of patches that apply
>> this macro, in turn moving a lot of this data into __devinitconst
>> which is discardable in certain situations.
>> Hopefully the benefit of this approach is a bit clearer now.
> [shorter lines please..]

Sorry...

>
> Can you please confirm that this does not break powerpc (64 bit)
> as they have troubles with the constification..

I do not have access to any PowerPC machine... Olof Johansson built the
tree I posted earlier on PowerPC; there's nothing really new here except
the wrapping of the definition in a macro.

But of course, it would great if someone could confirm this...

>
> Sam
>

2008-02-20 13:55:46

by Sam Ravnborg

[permalink] [raw]
Subject: PowerPC toolchain for x86 [Was: pci_device_id cleanups]

On Wed, Feb 20, 2008 at 02:27:19PM +0100, Jonas Bonn wrote:
> Sam Ravnborg wrote:
> >On Wed, Feb 20, 2008 at 01:53:36PM +0100, Jonas Bonn wrote:
> >>The PCI_DEVICE_TABLE patch I sent earlier doesn't necessarily make
> >>much sense by itself... here is a set of patches that apply
> >>this macro, in turn moving a lot of this data into __devinitconst
> >>which is discardable in certain situations.
> >>Hopefully the benefit of this approach is a bit clearer now.
> >[shorter lines please..]
>
> Sorry...
>
> >
> >Can you please confirm that this does not break powerpc (64 bit)
> >as they have troubles with the constification..
>
> I do not have access to any PowerPC machine... Olof Johansson built the
> tree I posted earlier on PowerPC; there's nothing really new here except
> the wrapping of the definition in a macro.
And you added const and a specific section.
Exactly what could break on PowerPC.

To do the build break check is easy.
Google for "crosstool" and build your own powerpc toolchain.

Andrew has something precompiled somewhere but I lost the link.


Sam

2008-02-20 14:03:43

by Jonas Bonn

[permalink] [raw]
Subject: Re: PowerPC toolchain for x86 [Was: pci_device_id cleanups]



Sam Ravnborg wrote:
> On Wed, Feb 20, 2008 at 02:27:19PM +0100, Jonas Bonn wrote:
>> Sam Ravnborg wrote:
>>> On Wed, Feb 20, 2008 at 01:53:36PM +0100, Jonas Bonn wrote:
>>>> The PCI_DEVICE_TABLE patch I sent earlier doesn't necessarily make
>>>> much sense by itself... here is a set of patches that apply
>>>> this macro, in turn moving a lot of this data into __devinitconst
>>>> which is discardable in certain situations.
>>>> Hopefully the benefit of this approach is a bit clearer now.
>>> [shorter lines please..]
>> Sorry...
>>
>>> Can you please confirm that this does not break powerpc (64 bit)
>>> as they have troubles with the constification..
>> I do not have access to any PowerPC machine... Olof Johansson built the
>> tree I posted earlier on PowerPC; there's nothing really new here except
>> the wrapping of the definition in a macro.
> And you added const and a specific section.

No... once the macro is expanded the code is exactly the same as that
which built cleanly on powerpc previously (which Olof, built, I mean)...
nothing new here.

> Exactly what could break on PowerPC.
>
> To do the build break check is easy.
> Google for "crosstool" and build your own powerpc toolchain.
>

Thanks... I'll throw together a cross compiler and see what I can do.

/Jonas

> Andrew has something precompiled somewhere but I lost the link.
>
>
> Sam
>