]> www.infradead.org Git - users/hch/configfs.git/commitdiff
can: m_can: Constify struct m_can_ops
authorChristophe JAILLET <christophe.jaillet@wanadoo.fr>
Sun, 23 Jun 2024 20:01:50 +0000 (22:01 +0200)
committerMarc Kleine-Budde <mkl@pengutronix.de>
Fri, 28 Jun 2024 07:35:13 +0000 (09:35 +0200)
'struct m_can_ops' is not modified in these drivers.

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

On a x86_64, with allmodconfig, as an example:
Before:
======
   text    data     bss     dec     hex filename
   4806     520       0    5326    14ce drivers/net/can/m_can/m_can_pci.o

After:
=====
   text    data     bss     dec     hex filename
   4862     464       0    5326    14ce drivers/net/can/m_can/m_can_pci.o

Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
Link: https://lore.kernel.org/all/a17b96d1be5341c11f263e1e45c9de1cb754e416.1719172843.git.christophe.jaillet@wanadoo.fr
Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
drivers/net/can/m_can/m_can.h
drivers/net/can/m_can/m_can_pci.c
drivers/net/can/m_can/m_can_platform.c
drivers/net/can/m_can/tcan4x5x-core.c

index 3a9edc29259385c9d6c20c27d2e450f40cb134e7..92b2bd8628e6b31370f4accbc2e28f3b2257a71d 100644 (file)
@@ -91,7 +91,7 @@ struct m_can_classdev {
 
        ktime_t irq_timer_wait;
 
-       struct m_can_ops *ops;
+       const struct m_can_ops *ops;
 
        int version;
        u32 irqstatus;
index 45400de4163d93d30e147ca04b8f47ac299ec58c..d72fe771dfc7aa768c728f817e67a87b49fd9974 100644 (file)
@@ -77,7 +77,7 @@ static int iomap_write_fifo(struct m_can_classdev *cdev, int offset,
        return 0;
 }
 
-static struct m_can_ops m_can_pci_ops = {
+static const struct m_can_ops m_can_pci_ops = {
        .read_reg = iomap_read_reg,
        .write_reg = iomap_write_reg,
        .write_fifo = iomap_write_fifo,
index df0367124b4c536d392a8d6d033d0d96d73c8ab2..983ab80260ddbfc2bd4afcb696f68c2746f3465a 100644 (file)
@@ -68,7 +68,7 @@ static int iomap_write_fifo(struct m_can_classdev *cdev, int offset,
        return 0;
 }
 
-static struct m_can_ops m_can_plat_ops = {
+static const struct m_can_ops m_can_plat_ops = {
        .read_reg = iomap_read_reg,
        .write_reg = iomap_write_reg,
        .write_fifo = iomap_write_fifo,
index d723206ac7c9592e8c373bb91e9678c05275fbde..2f73bf3abad889c222f15c39a3d43de1a1cf5fbb 100644 (file)
@@ -357,7 +357,7 @@ static int tcan4x5x_get_gpios(struct m_can_classdev *cdev,
        return 0;
 }
 
-static struct m_can_ops tcan4x5x_ops = {
+static const struct m_can_ops tcan4x5x_ops = {
        .init = tcan4x5x_init,
        .read_reg = tcan4x5x_read_reg,
        .write_reg = tcan4x5x_write_reg,