[Linux-parport] [PATCH] add const to some static variables

Marko Kohtala marko.kohtala at luukku.com
Mon Jan 10 13:41:57 EST 2005


This is only a cleanup. Should not really change anything except move some 
read-only data to read-only section.

Please comment.

# This is a BitKeeper generated diff -Nru style patch.
#
# ChangeSet
#   2005/01/09 23:42:01+02:00 kohtala at kohtala.home.org
#   Add some missing "const" from static variables in parport driver.
#
# drivers/parport/probe.c
#   2005/01/09 23:41:49+02:00 kohtala at kohtala.home.org +3 -3
#   Add some missing "const"
#
# drivers/parport/parport_pc.c
#   2005/01/09 23:41:49+02:00 kohtala at kohtala.home.org +22 -16
#   Add some missing "const"
#
diff -Nru a/drivers/parport/parport_pc.c b/drivers/parport/parport_pc.c
--- a/drivers/parport/parport_pc.c	2005-01-10 07:57:49 +02:00
+++ b/drivers/parport/parport_pc.c	2005-01-10 07:57:49 +02:00
@@ -1160,7 +1160,7 @@

  /* GCC is not inlining extern inline function later overwriten to non-inline,
     so we use outlined_ variants here.  */
-static struct parport_operations parport_pc_ops =
+static const struct parport_operations parport_pc_ops =
  {
  	.write_data	= parport_pc_write_data,
  	.read_data	= parport_pc_read_data,
@@ -1202,10 +1202,11 @@
  static void __devinit show_parconfig_smsc37c669(int io, int key)
  {
  	int cr1,cr4,cra,cr23,cr26,cr27,i=0;
-	static const char *modes[]={ "SPP and Bidirectional (PS/2)",	
-				     "EPP and SPP",
-				     "ECP",
-				     "ECP and EPP" };
+	static const char *const modes[]={
+		"SPP and Bidirectional (PS/2)",	
+		"EPP and SPP",
+		"ECP",
+		"ECP and EPP" };

  	outb(key,io);
  	outb(key,io);
@@ -1279,7 +1280,7 @@
  static void __devinit show_parconfig_winbond(int io, int key)
  {
  	int cr30,cr60,cr61,cr70,cr74,crf0,i=0;
-	static const char *modes[] = {
+	static const char *const modes[] = {
  		"Standard (SPP) and Bidirectional(PS/2)", /* 0 */
  		"EPP-1.9 and SPP",
  		"ECP",
@@ -1288,7 +1289,9 @@
  		"EPP-1.7 and SPP",		/* 5 */
  		"undefined!",
  		"ECP and EPP-1.7" };
-	static char *irqtypes[] = { "pulsed low, high-Z", "follows nACK" };
+	static char *const irqtypes[] = {
+		"pulsed low, high-Z",
+		"follows nACK" };
  		
  	/* The registers are called compatible-PnP because the
             register layout is modelled after ISA-PnP, the access
@@ -2383,7 +2386,8 @@

  /* ITE support maintained by Rich Liu <richliu at poorman.org> */
  static int __devinit sio_ite_8872_probe (struct pci_dev *pdev, int autoirq,
-					 int autodma, struct parport_pc_via_data *via)
+					 int autodma,
+					 const struct parport_pc_via_data *via)
  {
  	short inta_addr[6] = { 0x2A0, 0x2C0, 0x220, 0x240, 0x1E0 };
  	struct resource *base_res;
@@ -2491,7 +2495,7 @@
  static int __initdata parport_init_mode = 0;

  /* Data for two known VIA chips */
-static struct parport_pc_via_data via_686a_data __devinitdata = {
+static const struct parport_pc_via_data via_686a_data __devinitdata = {
  	0x51,
  	0x50,
  	0x85,
@@ -2500,7 +2504,7 @@
  	0xF0,
  	0xE6
  };
-static struct parport_pc_via_data via_8231_data __devinitdata = {
+static const struct parport_pc_via_data via_8231_data __devinitdata = {
  	0x45,
  	0x44,
  	0x50,
@@ -2511,7 +2515,8 @@
  };

  static int __devinit sio_via_probe (struct pci_dev *pdev, int autoirq,
-					 int autodma, struct parport_pc_via_data *via)
+				    int autodma,
+				    const struct parport_pc_via_data *via)
  {
  	u8 tmp, tmp2, siofunc;
  	u8 ppcontrol = 0;
@@ -2680,9 +2685,10 @@
  };

  /* each element directly indexed from enum list, above */
-static struct parport_pc_superio {
-	int (*probe) (struct pci_dev *pdev, int autoirq, int autodma, struct 
parport_pc_via_data *via);
-	struct parport_pc_via_data *via;
+static const struct parport_pc_superio {
+	int (*probe) (struct pci_dev *pdev, int autoirq, int autodma,
+		      const struct parport_pc_via_data *via);
+	const struct parport_pc_via_data *via;
  } parport_pc_superio_info[] __devinitdata = {
  	{ sio_via_probe, &via_686a_data, },
  	{ sio_via_probe, &via_8231_data, },
@@ -2745,7 +2751,7 @@

  /* each element directly indexed from enum list, above
   * (but offset by last_sio) */
-static struct parport_pc_pci {
+static const struct parport_pc_pci {
  	int numports;
  	struct { /* BAR (base address registers) numbers in the config
                      space header */
@@ -2819,7 +2825,7 @@
          /* netmos_9715 */               { 2, { { 0, 1 }, { 2, 3 },} }, /* 
untested */
  };

-static struct pci_device_id parport_pc_pci_tbl[] = {
+static const struct pci_device_id parport_pc_pci_tbl[] = {
  	/* Super-IO onboard chips */
  	{ 0x1106, 0x0686, PCI_ANY_ID, PCI_ANY_ID, 0, 0, sio_via_686a },
  	{ 0x1106, 0x8231, PCI_ANY_ID, PCI_ANY_ID, 0, 0, sio_via_8231 },
diff -Nru a/drivers/parport/probe.c b/drivers/parport/probe.c
--- a/drivers/parport/probe.c	2005-01-10 07:57:49 +02:00
+++ b/drivers/parport/probe.c	2005-01-10 07:57:49 +02:00
@@ -11,9 +11,9 @@
  #include <linux/string.h>
  #include <asm/uaccess.h>

-static struct {
-	char *token;
-	char *descr;
+static const struct {
+	const char *token;
+	const char *descr;
  } classes[] = {
  	{ "",            "Legacy device" },
  	{ "PRINTER",     "Printer" },



More information about the Linux-parport mailing list