* [PATCH 1/3] staging: make PCI device id constant
@ 2010-01-09 23:18 Németh Márton
2010-01-09 23:41 ` Arjan van de Ven
2010-01-15 1:36 ` patch staging-make-pci-device-id-constant.patch added to gregkh-2.6 tree gregkh
0 siblings, 2 replies; 4+ messages in thread
From: Németh Márton @ 2010-01-09 23:18 UTC (permalink / raw)
To: Greg Kroah-Hartman; +Cc: devel, LKML, Julia Lawall, cocci
From: Márton Németh <nm127@freemail.hu>
The id_table field of the struct pci_driver is constant in <linux/pci.h>
so it is worth to make the initialization data also constant.
The semantic match that finds this kind of pattern is as follows:
(http://coccinelle.lip6.fr/)
// <smpl>
@r@
disable decl_init,const_decl_init;
identifier I1, I2, x;
@@
struct I1 {
...
const struct I2 *x;
...
};
@s@
identifier r.I1, y;
identifier r.x, E;
@@
struct I1 y = {
.x = E,
};
@c@
identifier r.I2;
identifier s.E;
@@
const struct I2 E[] = ... ;
@depends on !c@
identifier r.I2;
identifier s.E;
@@
+ const
struct I2 E[] = ...;
// </smpl>
Signed-off-by: Márton Németh <nm127@freemail.hu>
Cc: Julia Lawall <julia@diku.dk>
Cc: cocci@diku.dk
---
diff -u -p a/drivers/staging/sm7xx/smtcfb.c b/drivers/staging/sm7xx/smtcfb.c
--- a/drivers/staging/sm7xx/smtcfb.c 2010-01-07 19:08:46.000000000 +0100
+++ b/drivers/staging/sm7xx/smtcfb.c 2010-01-08 09:56:41.000000000 +0100
@@ -1103,7 +1103,7 @@ static int __init smtcfb_pci_probe(struc
/* Jason (08/11/2009) PCI_DRV wrapper essential structs */
-static struct pci_device_id smtcfb_pci_table[] = {
+static const struct pci_device_id smtcfb_pci_table[] = {
{0x126f, 0x710, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0},
{0x126f, 0x712, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0},
{0x126f, 0x720, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0},
diff -u -p a/drivers/staging/sep/sep_driver.c b/drivers/staging/sep/sep_driver.c
--- a/drivers/staging/sep/sep_driver.c 2010-01-07 19:08:46.000000000 +0100
+++ b/drivers/staging/sep/sep_driver.c 2010-01-08 09:57:33.000000000 +0100
@@ -2586,7 +2586,7 @@ end_function:
return error;
}
-static struct pci_device_id sep_pci_id_tbl[] = {
+static const struct pci_device_id sep_pci_id_tbl[] = {
{PCI_DEVICE(PCI_VENDOR_ID_INTEL, 0x080c)},
{0}
};
diff -u -p a/drivers/staging/vme/bridges/vme_tsi148.c b/drivers/staging/vme/bridges/vme_tsi148.c
--- a/drivers/staging/vme/bridges/vme_tsi148.c 2010-01-07 19:08:46.000000000 +0100
+++ b/drivers/staging/vme/bridges/vme_tsi148.c 2010-01-08 10:26:28.000000000 +0100
@@ -80,7 +80,7 @@ struct mutex vme_int; /*
static char driver_name[] = "vme_tsi148";
-static struct pci_device_id tsi148_ids[] = {
+static const struct pci_device_id tsi148_ids[] = {
{ PCI_DEVICE(PCI_VENDOR_ID_TUNDRA, PCI_DEVICE_ID_TUNDRA_TSI148) },
{ },
};
diff -u -p a/drivers/staging/vme/bridges/vme_ca91cx42.c b/drivers/staging/vme/bridges/vme_ca91cx42.c
--- a/drivers/staging/vme/bridges/vme_ca91cx42.c 2010-01-07 19:08:46.000000000 +0100
+++ b/drivers/staging/vme/bridges/vme_ca91cx42.c 2010-01-08 10:26:58.000000000 +0100
@@ -56,7 +56,7 @@ struct mutex vme_int; /*
static char driver_name[] = "vme_ca91cx42";
-static struct pci_device_id ca91cx42_ids[] = {
+static const struct pci_device_id ca91cx42_ids[] = {
{ PCI_DEVICE(PCI_VENDOR_ID_TUNDRA, PCI_DEVICE_ID_TUNDRA_CA91C142) },
{ },
};
diff -u -p a/drivers/staging/phison/phison.c b/drivers/staging/phison/phison.c
--- a/drivers/staging/phison/phison.c 2010-01-07 19:08:45.000000000 +0100
+++ b/drivers/staging/phison/phison.c 2010-01-08 10:27:46.000000000 +0100
@@ -69,7 +69,7 @@ static int phison_init_one(struct pci_de
return ret;
}
-static struct pci_device_id phison_pci_tbl[] = {
+static const struct pci_device_id phison_pci_tbl[] = {
{ PCI_VENDOR_ID_PHISON, PCI_DEVICE_ID_PS5000, PCI_ANY_ID, PCI_ANY_ID,
PCI_CLASS_STORAGE_IDE << 8, 0xffff00, 0 },
{ 0, },
diff -u -p a/drivers/staging/rar/rar_driver.c b/drivers/staging/rar/rar_driver.c
--- a/drivers/staging/rar/rar_driver.c 2010-01-07 19:08:45.000000000 +0100
+++ b/drivers/staging/rar/rar_driver.c 2010-01-08 11:11:53.000000000 +0100
@@ -70,7 +70,7 @@ static void __exit rar_exit_handler(void
*/
static int __devinit rar_probe(struct pci_dev *pdev, const struct pci_device_id *ent);
-static struct pci_device_id rar_pci_id_tbl[] = {
+static const struct pci_device_id rar_pci_id_tbl[] = {
{ PCI_DEVICE(PCI_VENDOR_ID_INTEL, 0x4110) },
{ 0 }
};
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH 1/3] staging: make PCI device id constant
2010-01-09 23:18 [PATCH 1/3] staging: make PCI device id constant Németh Márton
@ 2010-01-09 23:41 ` Arjan van de Ven
2010-01-09 23:43 ` Greg KH
2010-01-15 1:36 ` patch staging-make-pci-device-id-constant.patch added to gregkh-2.6 tree gregkh
1 sibling, 1 reply; 4+ messages in thread
From: Arjan van de Ven @ 2010-01-09 23:41 UTC (permalink / raw)
To: Németh Márton
Cc: Greg Kroah-Hartman, devel, LKML, Julia Lawall, cocci
On Sun, 10 Jan 2010 00:18:26 +0100
Németh Márton <nm127@freemail.hu> wrote:
> From: Márton Németh <nm127@freemail.hu>
>
> The id_table field of the struct pci_driver is constant in
> <linux/pci.h> so it is worth to make the initialization data also
> constant.
the PCI ID table can get written too via sysfs... making it const
breaks that...
--
Arjan van de Ven Intel Open Source Technology Centre
For development, discussion and tips for power savings,
visit http://www.lesswatts.org
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH 1/3] staging: make PCI device id constant
2010-01-09 23:41 ` Arjan van de Ven
@ 2010-01-09 23:43 ` Greg KH
0 siblings, 0 replies; 4+ messages in thread
From: Greg KH @ 2010-01-09 23:43 UTC (permalink / raw)
To: Arjan van de Ven
Cc: Németh Márton, devel, LKML, Julia Lawall, cocci
On Sat, Jan 09, 2010 at 03:41:15PM -0800, Arjan van de Ven wrote:
> On Sun, 10 Jan 2010 00:18:26 +0100
> Németh Márton <nm127@freemail.hu> wrote:
>
> > From: Márton Németh <nm127@freemail.hu>
> >
> > The id_table field of the struct pci_driver is constant in
> > <linux/pci.h> so it is worth to make the initialization data also
> > constant.
>
>
> the PCI ID table can get written too via sysfs... making it const
> breaks that...
It shouldn't, I thought that was what we used the dynids field in the
pci_driver structure :)
thanks,
greg k-h
^ permalink raw reply [flat|nested] 4+ messages in thread
* patch staging-make-pci-device-id-constant.patch added to gregkh-2.6 tree
2010-01-09 23:18 [PATCH 1/3] staging: make PCI device id constant Németh Márton
2010-01-09 23:41 ` Arjan van de Ven
@ 2010-01-15 1:36 ` gregkh
1 sibling, 0 replies; 4+ messages in thread
From: gregkh @ 2010-01-15 1:36 UTC (permalink / raw)
To: nm127, gregkh, julia, linux-kernel
This is a note to let you know that I've just added the patch titled
Subject: staging: make PCI device id constant
to my gregkh-2.6 tree. Its filename is
staging-make-pci-device-id-constant.patch
This tree can be found at
http://www.kernel.org/pub/linux/kernel/people/gregkh/gregkh-2.6/patches/
>From nm127@freemail.hu Thu Jan 14 17:08:52 2010
From: Németh Márton <nm127@freemail.hu>
Date: Sun, 10 Jan 2010 00:18:26 +0100
Subject: staging: make PCI device id constant
To: Greg Kroah-Hartman <gregkh@suse.de>
Cc: devel@driverdev.osuosl.org, Julia Lawall <julia@diku.dk>, LKML <linux-kernel@vger.kernel.org>, cocci@diku.dk
Message-ID: <4B490EC2.7050703@freemail.hu>
From: Németh Márton <nm127@freemail.hu>
The id_table field of the struct pci_driver is constant in <linux/pci.h>
so it is worth to make the initialization data also constant.
The semantic match that finds this kind of pattern is as follows:
(http://coccinelle.lip6.fr/)
// <smpl>
@r@
disable decl_init,const_decl_init;
identifier I1, I2, x;
@@
struct I1 {
...
const struct I2 *x;
...
};
@s@
identifier r.I1, y;
identifier r.x, E;
@@
struct I1 y = {
.x = E,
};
@c@
identifier r.I2;
identifier s.E;
@@
const struct I2 E[] = ... ;
@depends on !c@
identifier r.I2;
identifier s.E;
@@
+ const
struct I2 E[] = ...;
// </smpl>
Signed-off-by: Németh Márton <nm127@freemail.hu>
Cc: Julia Lawall <julia@diku.dk>
Cc: cocci@diku.dk
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
---
drivers/staging/phison/phison.c | 2 +-
drivers/staging/rar/rar_driver.c | 2 +-
drivers/staging/sep/sep_driver.c | 2 +-
drivers/staging/sm7xx/smtcfb.c | 2 +-
drivers/staging/vme/bridges/vme_ca91cx42.c | 2 +-
drivers/staging/vme/bridges/vme_tsi148.c | 2 +-
6 files changed, 6 insertions(+), 6 deletions(-)
--- a/drivers/staging/phison/phison.c
+++ b/drivers/staging/phison/phison.c
@@ -69,7 +69,7 @@ static int phison_init_one(struct pci_de
return ret;
}
-static struct pci_device_id phison_pci_tbl[] = {
+static const struct pci_device_id phison_pci_tbl[] = {
{ PCI_VENDOR_ID_PHISON, PCI_DEVICE_ID_PS5000, PCI_ANY_ID, PCI_ANY_ID,
PCI_CLASS_STORAGE_IDE << 8, 0xffff00, 0 },
{ 0, },
--- a/drivers/staging/rar/rar_driver.c
+++ b/drivers/staging/rar/rar_driver.c
@@ -71,7 +71,7 @@ static void __exit rar_exit_handler(void
static int __devinit rar_probe(struct pci_dev *pdev,
const struct pci_device_id *ent);
-static struct pci_device_id rar_pci_id_tbl[] = {
+static const struct pci_device_id rar_pci_id_tbl[] = {
{ PCI_DEVICE(PCI_VENDOR_ID_INTEL, 0x4110) },
{ 0 }
};
--- a/drivers/staging/sep/sep_driver.c
+++ b/drivers/staging/sep/sep_driver.c
@@ -2587,7 +2587,7 @@ end_function:
return error;
}
-static struct pci_device_id sep_pci_id_tbl[] = {
+static const struct pci_device_id sep_pci_id_tbl[] = {
{PCI_DEVICE(PCI_VENDOR_ID_INTEL, 0x080c)},
{0}
};
--- a/drivers/staging/sm7xx/smtcfb.c
+++ b/drivers/staging/sm7xx/smtcfb.c
@@ -1103,7 +1103,7 @@ static int __init smtcfb_pci_probe(struc
/* Jason (08/11/2009) PCI_DRV wrapper essential structs */
-static struct pci_device_id smtcfb_pci_table[] = {
+static const struct pci_device_id smtcfb_pci_table[] = {
{0x126f, 0x710, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0},
{0x126f, 0x712, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0},
{0x126f, 0x720, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0},
--- a/drivers/staging/vme/bridges/vme_ca91cx42.c
+++ b/drivers/staging/vme/bridges/vme_ca91cx42.c
@@ -61,7 +61,7 @@ static struct mutex vme_int; /*
static char driver_name[] = "vme_ca91cx42";
-static struct pci_device_id ca91cx42_ids[] = {
+static const struct pci_device_id ca91cx42_ids[] = {
{ PCI_DEVICE(PCI_VENDOR_ID_TUNDRA, PCI_DEVICE_ID_TUNDRA_CA91C142) },
{ },
};
--- a/drivers/staging/vme/bridges/vme_tsi148.c
+++ b/drivers/staging/vme/bridges/vme_tsi148.c
@@ -81,7 +81,7 @@ static struct mutex vme_int; /*
static char driver_name[] = "vme_tsi148";
-static struct pci_device_id tsi148_ids[] = {
+static const struct pci_device_id tsi148_ids[] = {
{ PCI_DEVICE(PCI_VENDOR_ID_TUNDRA, PCI_DEVICE_ID_TUNDRA_TSI148) },
{ },
};
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2010-01-15 1:38 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-01-09 23:18 [PATCH 1/3] staging: make PCI device id constant Németh Márton
2010-01-09 23:41 ` Arjan van de Ven
2010-01-09 23:43 ` Greg KH
2010-01-15 1:36 ` patch staging-make-pci-device-id-constant.patch added to gregkh-2.6 tree gregkh
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox