]> www.infradead.org Git - users/willy/xarray.git/commitdiff
usb: musb: Constify struct musb_fifo_cfg
authorChristophe JAILLET <christophe.jaillet@wanadoo.fr>
Sat, 18 Jan 2025 21:10:17 +0000 (22:10 +0100)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Mon, 3 Feb 2025 15:29:53 +0000 (16:29 +0100)
'struct musb_fifo_cfg' are not modified in these drivers.

Constifying these structures 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
  64381    5537     202   70120   111e8 drivers/usb/musb/musb_core.o

After:
=====
   text    data     bss     dec     hex filename
  64957    4929     202   70088   111c8 drivers/usb/musb/musb_core.o

Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
Link: https://lore.kernel.org/r/26e6f3e25dc8e785d0034dd7e59918e455563e60.1737234596.git.christophe.jaillet@wanadoo.fr
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Documentation/driver-api/usb/writing_musb_glue_layer.rst
drivers/usb/musb/jz4740.c
drivers/usb/musb/mediatek.c
drivers/usb/musb/mpfs.c
drivers/usb/musb/musb_core.c
drivers/usb/musb/sunxi.c
include/linux/usb/musb.h

index e755c8551bbaefe2908bb4497abb41eb71e6dab4..0bb96ecdf527b4c5da1d915fe2490c642f3206ac 100644 (file)
@@ -613,7 +613,7 @@ endpoints configuration from the hardware, so we use line 12 instruction
 to bypass reading the configuration from silicon, and rely on a
 hard-coded table that describes the endpoints configuration instead::
 
-    static struct musb_fifo_cfg jz4740_musb_fifo_cfg[] = {
+    static const struct musb_fifo_cfg jz4740_musb_fifo_cfg[] = {
        { .hw_ep_num = 1, .style = FIFO_TX, .maxpacket = 512, },
        { .hw_ep_num = 1, .style = FIFO_RX, .maxpacket = 512, },
        { .hw_ep_num = 2, .style = FIFO_TX, .maxpacket = 64, },
index acdeb1117cd3f66ecc9c911d284ef2c836d5eb76..df56c972986f7c4f5174a227f35c7e1ac9afa7ca 100644 (file)
@@ -59,7 +59,7 @@ static irqreturn_t jz4740_musb_interrupt(int irq, void *__hci)
        return IRQ_NONE;
 }
 
-static struct musb_fifo_cfg jz4740_musb_fifo_cfg[] = {
+static const struct musb_fifo_cfg jz4740_musb_fifo_cfg[] = {
        { .hw_ep_num = 1, .style = FIFO_TX, .maxpacket = 512, },
        { .hw_ep_num = 1, .style = FIFO_RX, .maxpacket = 512, },
        { .hw_ep_num = 2, .style = FIFO_TX, .maxpacket = 64, },
@@ -205,7 +205,7 @@ static const struct musb_hdrc_platform_data jz4740_musb_pdata = {
        .platform_ops   = &jz4740_musb_ops,
 };
 
-static struct musb_fifo_cfg jz4770_musb_fifo_cfg[] = {
+static const struct musb_fifo_cfg jz4770_musb_fifo_cfg[] = {
        { .hw_ep_num = 1, .style = FIFO_TX, .maxpacket = 512, },
        { .hw_ep_num = 1, .style = FIFO_RX, .maxpacket = 512, },
        { .hw_ep_num = 2, .style = FIFO_TX, .maxpacket = 512, },
index aa988d74b58d0fb7473cb91d998c1234ef0a000c..c6cbe718b1da2f8525b08d123f2dce1718d68572 100644 (file)
@@ -365,7 +365,7 @@ static const struct musb_platform_ops mtk_musb_ops = {
 #define MTK_MUSB_MAX_EP_NUM    8
 #define MTK_MUSB_RAM_BITS      11
 
-static struct musb_fifo_cfg mtk_musb_mode_cfg[] = {
+static const struct musb_fifo_cfg mtk_musb_mode_cfg[] = {
        { .hw_ep_num = 1, .style = FIFO_TX, .maxpacket = 512, },
        { .hw_ep_num = 1, .style = FIFO_RX, .maxpacket = 512, },
        { .hw_ep_num = 2, .style = FIFO_TX, .maxpacket = 512, },
index 7edc8429b274907b0424fa31edafb05805e62925..71e4271cba75fe8894530832be9c69f482dbfe51 100644 (file)
@@ -29,7 +29,7 @@ struct mpfs_glue {
        struct clk *clk;
 };
 
-static struct musb_fifo_cfg mpfs_musb_mode_cfg[] = {
+static const struct musb_fifo_cfg mpfs_musb_mode_cfg[] = {
        { .hw_ep_num = 1, .style = FIFO_TX, .maxpacket = 512, },
        { .hw_ep_num = 1, .style = FIFO_RX, .maxpacket = 512, },
        { .hw_ep_num = 2, .style = FIFO_TX, .maxpacket = 512, },
index 7f349f5e781df481c44e84a02e8c93cf3279132d..96fa700eaed174d000de71c6f41cdcbeac8ee9f0 100644 (file)
@@ -1271,7 +1271,7 @@ MODULE_PARM_DESC(fifo_mode, "initial endpoint configuration");
  */
 
 /* mode 0 - fits in 2KB */
-static struct musb_fifo_cfg mode_0_cfg[] = {
+static const struct musb_fifo_cfg mode_0_cfg[] = {
 { .hw_ep_num = 1, .style = FIFO_TX,   .maxpacket = 512, },
 { .hw_ep_num = 1, .style = FIFO_RX,   .maxpacket = 512, },
 { .hw_ep_num = 2, .style = FIFO_RXTX, .maxpacket = 512, },
@@ -1280,7 +1280,7 @@ static struct musb_fifo_cfg mode_0_cfg[] = {
 };
 
 /* mode 1 - fits in 4KB */
-static struct musb_fifo_cfg mode_1_cfg[] = {
+static const struct musb_fifo_cfg mode_1_cfg[] = {
 { .hw_ep_num = 1, .style = FIFO_TX,   .maxpacket = 512, .mode = BUF_DOUBLE, },
 { .hw_ep_num = 1, .style = FIFO_RX,   .maxpacket = 512, .mode = BUF_DOUBLE, },
 { .hw_ep_num = 2, .style = FIFO_RXTX, .maxpacket = 512, .mode = BUF_DOUBLE, },
@@ -1289,7 +1289,7 @@ static struct musb_fifo_cfg mode_1_cfg[] = {
 };
 
 /* mode 2 - fits in 4KB */
-static struct musb_fifo_cfg mode_2_cfg[] = {
+static const struct musb_fifo_cfg mode_2_cfg[] = {
 { .hw_ep_num = 1, .style = FIFO_TX,   .maxpacket = 512, },
 { .hw_ep_num = 1, .style = FIFO_RX,   .maxpacket = 512, },
 { .hw_ep_num = 2, .style = FIFO_TX,   .maxpacket = 512, },
@@ -1299,7 +1299,7 @@ static struct musb_fifo_cfg mode_2_cfg[] = {
 };
 
 /* mode 3 - fits in 4KB */
-static struct musb_fifo_cfg mode_3_cfg[] = {
+static const struct musb_fifo_cfg mode_3_cfg[] = {
 { .hw_ep_num = 1, .style = FIFO_TX,   .maxpacket = 512, .mode = BUF_DOUBLE, },
 { .hw_ep_num = 1, .style = FIFO_RX,   .maxpacket = 512, .mode = BUF_DOUBLE, },
 { .hw_ep_num = 2, .style = FIFO_TX,   .maxpacket = 512, },
@@ -1309,7 +1309,7 @@ static struct musb_fifo_cfg mode_3_cfg[] = {
 };
 
 /* mode 4 - fits in 16KB */
-static struct musb_fifo_cfg mode_4_cfg[] = {
+static const struct musb_fifo_cfg mode_4_cfg[] = {
 { .hw_ep_num =  1, .style = FIFO_TX,   .maxpacket = 512, },
 { .hw_ep_num =  1, .style = FIFO_RX,   .maxpacket = 512, },
 { .hw_ep_num =  2, .style = FIFO_TX,   .maxpacket = 512, },
@@ -1340,7 +1340,7 @@ static struct musb_fifo_cfg mode_4_cfg[] = {
 };
 
 /* mode 5 - fits in 8KB */
-static struct musb_fifo_cfg mode_5_cfg[] = {
+static const struct musb_fifo_cfg mode_5_cfg[] = {
 { .hw_ep_num =  1, .style = FIFO_TX,   .maxpacket = 512, },
 { .hw_ep_num =  1, .style = FIFO_RX,   .maxpacket = 512, },
 { .hw_ep_num =  2, .style = FIFO_TX,   .maxpacket = 512, },
@@ -1447,7 +1447,7 @@ fifo_setup(struct musb *musb, struct musb_hw_ep  *hw_ep,
        return offset + (maxpacket << ((c_size & MUSB_FIFOSZ_DPB) ? 1 : 0));
 }
 
-static struct musb_fifo_cfg ep0_cfg = {
+static const struct musb_fifo_cfg ep0_cfg = {
        .style = FIFO_RXTX, .maxpacket = 64,
 };
 
index eac1cde86be3fdc9a31cc0debe07fd18aa79cb36..a6bd3e968cc7337af4b9467bd3295483546b0a79 100644 (file)
@@ -629,7 +629,7 @@ static const struct musb_platform_ops sunxi_musb_ops = {
 #define SUNXI_MUSB_RAM_BITS    11
 
 /* Allwinner OTG supports up to 5 endpoints */
-static struct musb_fifo_cfg sunxi_musb_mode_cfg_5eps[] = {
+static const struct musb_fifo_cfg sunxi_musb_mode_cfg_5eps[] = {
        MUSB_EP_FIFO_SINGLE(1, FIFO_TX, 512),
        MUSB_EP_FIFO_SINGLE(1, FIFO_RX, 512),
        MUSB_EP_FIFO_SINGLE(2, FIFO_TX, 512),
@@ -643,7 +643,7 @@ static struct musb_fifo_cfg sunxi_musb_mode_cfg_5eps[] = {
 };
 
 /* H3/V3s OTG supports only 4 endpoints */
-static struct musb_fifo_cfg sunxi_musb_mode_cfg_4eps[] = {
+static const struct musb_fifo_cfg sunxi_musb_mode_cfg_4eps[] = {
        MUSB_EP_FIFO_SINGLE(1, FIFO_TX, 512),
        MUSB_EP_FIFO_SINGLE(1, FIFO_RX, 512),
        MUSB_EP_FIFO_SINGLE(2, FIFO_TX, 512),
index 3963e55e88a310e5dbdf2cfb8880e7e4493119aa..fbdef950f06caae6776d091c788b7e9ecbe174cc 100644 (file)
@@ -61,7 +61,7 @@ struct musb_hdrc_eps_bits {
 };
 
 struct musb_hdrc_config {
-       struct musb_fifo_cfg    *fifo_cfg;      /* board fifo configuration */
+       const struct musb_fifo_cfg      *fifo_cfg;      /* board fifo configuration */
        unsigned                fifo_cfg_size;  /* size of the fifo configuration */
 
        /* MUSB configuration-specific details */