[PATCH] parport: parport_serial: Constify some structures

Christophe JAILLET posted 1 patch 6 days, 13 hours ago
drivers/parport/parport_serial.c | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
[PATCH] parport: parport_serial: Constify some structures
Posted by Christophe JAILLET 6 days, 13 hours ago
'struct parport_pc_pci, 'struct pci_device_id' and 'struct pciserial_board'
are not modified in this driver.

Constifying these structures moves some data to a read-only section, so
increase overall security.

On a x86_64, with allmodconfig:
Before:
======
   text	   data	    bss	    dec	    hex	filename
   8125	   5232	      0	  13357	   342d	drivers/parport/parport_serial.o

After:
=====
   text	   data	    bss	    dec	    hex	filename
  12272	   1072	      0	  13344	   3420	drivers/parport/parport_serial.o

Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
---
Compile tested-only.
---
 drivers/parport/parport_serial.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/drivers/parport/parport_serial.c b/drivers/parport/parport_serial.c
index 3644997a8342..9ffbd69a32d9 100644
--- a/drivers/parport/parport_serial.c
+++ b/drivers/parport/parport_serial.c
@@ -118,7 +118,7 @@ static int netmos_parallel_init(struct pci_dev *dev, struct parport_pc_pci *par,
 	return 0;
 }
 
-static struct parport_pc_pci cards[] = {
+static const struct parport_pc_pci cards[] = {
 	/* titan_110l */		{ 1, { { 3, -1 }, } },
 	/* titan_210l */		{ 1, { { 3, -1 }, } },
 	/* netmos_9xx5_combo */		{ 1, { { 2, -1 }, }, netmos_parallel_init },
@@ -168,7 +168,7 @@ static struct parport_pc_pci cards[] = {
 	/* brainboxes_px263 */	{ 1, { { 3, -1 }, } },
 };
 
-static struct pci_device_id parport_serial_pci_tbl[] = {
+static const struct pci_device_id parport_serial_pci_tbl[] = {
 	/* PCI cards */
 	{ PCI_VENDOR_ID_TITAN, PCI_DEVICE_ID_TITAN_110L,
 	  PCI_ANY_ID, PCI_ANY_ID, 0, 0, titan_110l },
@@ -328,7 +328,7 @@ MODULE_DEVICE_TABLE(pci,parport_serial_pci_tbl);
  * Cards not tested are marked n/t
  * If you have one of these cards and it works for you, please tell me..
  */
-static struct pciserial_board pci_parport_serial_boards[] = {
+static const struct pciserial_board pci_parport_serial_boards[] = {
 	[titan_110l] = {
 		.flags		= FL_BASE1 | FL_BASE_BARS,
 		.num_ports	= 1,
@@ -619,7 +619,7 @@ struct parport_serial_private {
 static int serial_register(struct pci_dev *dev, const struct pci_device_id *id)
 {
 	struct parport_serial_private *priv = pci_get_drvdata (dev);
-	struct pciserial_board *board;
+	const struct pciserial_board *board;
 	struct serial_private *serial;
 
 	board = &pci_parport_serial_boards[id->driver_data];
-- 
2.47.0