drivers/misc: Constify static structs
Subsystems (3)
cover drivers/misc: Constify static structs
Constify some static structs that are not modified to allow the compiler to put them in read-only memory. The patches are independent of each other.
Rikard Falkeborn (4):
misc: rtsx_usb: Constify struct usb_device_id
misc: genwqe: Constify struct pci_error_handlers
mei: hdcp: Constify struct mei_cl_device_id
mic: vop: Constify static structs
drivers/misc/cardreader/rtsx_usb.c | 2 +- drivers/misc/genwqe/card_base.c | 2 +- drivers/misc/mei/hdcp/mei_hdcp.c | 2 +- drivers/misc/mic/vop/vop_main.c | 4 ++-- 4 files changed, 5 insertions(+), 5 deletions(-)
Signature · 1 line
2.27.0
PATCH 1/4 misc: rtsx_usb: Constify struct usb_device_id
rtsx_usb_usb_ids is never modified and can therefore be made const to allow the compiler to put it in read-only memory.
Before:
text data bss dec hex filename 21513 4160 128 25801 64c9 drivers/misc/cardreader/rtsx_usb.o
After:
text data bss dec hex filename 21673 4000 128 25801 64c9 drivers/misc/cardreader/rtsx_usb.o
--- drivers/misc/cardreader/rtsx_usb.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/misc/cardreader/rtsx_usb.c +1 -1
@@ -759,7 +759,7 @@ static int rtsx_usb_post_reset(struct usb_interface *intf)return 0 ; } -static struct usb_device_id rtsx_usb_usb_ids[] = { +static const struct usb_device_id rtsx_usb_usb_ids[] = { {USB_DEVICE (0x0BDA ,0x0129 ) }, {USB_DEVICE (0x0BDA ,0x0139 ) }, {USB_DEVICE (0x0BDA ,0x0140 ) },
Signature · 1 line
2.27.0
PATCH 2/4 misc: genwqe: Constify struct pci_error_handlers
In reply to Rikard Falkeborngenwqe_err_handler is never modified, so it can be made const to allow the compiler to put it in read-only memory.
Before:
text data bss dec hex filename
20174 6104 2464 28742 7046 drivers/misc/genwqe/card_base.o
After:
text data bss dec hex filename
20270 6008 2464 28742 7046 drivers/misc/genwqe/card_base.o
--- drivers/misc/genwqe/card_base.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/misc/genwqe/card_base.c +1 -1
@@ -1324,7 +1324,7 @@ static int genwqe_sriov_configure(struct pci_dev *dev, int numvfs)return 0 ; } -static struct pci_error_handlers genwqe_err_handler = { +static const struct pci_error_handlers genwqe_err_handler = { .error_detected = genwqe_err_error_detected, .mmio_enabled = genwqe_err_result_none, .slot_reset = genwqe_err_slot_reset,
Signature · 1 line
2.27.0
Re: [PATCH 2/4] misc: genwqe: Constify struct pci_error_handlers
Quoted 29 lines · Rikard Falkeborn
genwqe_err_handleris never modified, so it can be made const to allow the compiler to put it in read-only memory.Before:
text data bss dec hex filename
20174 6104 2464 28742 7046drivers/misc/genwqe/card_base.oAfter:
text data bss dec hex filename
20270 6008 2464 28742 7046drivers/misc/genwqe/card_base.oSigned-off-by Rikard Falkeborn <[email protected]>--- drivers/misc/genwqe/card_base.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)drivers/misc/genwqe/card_base.c +1
-1@@ -1324,7 +1324,7 @@ static int genwqe_sriov_configure(struct pci_dev *dev, int numvfs)return 0 ; } -static struct pci_error_handlers genwqe_err_handler = { +static const struct pci_error_handlers genwqe_err_handler = { .error_detected = genwqe_err_error_detected, .mmio_enabled = genwqe_err_result_none,
Quoted 1 line
.slot_reset =
genwqe_err_slot_reset,
Good idea. Thanks for the contribution.
PATCH 3/4 mei: hdcp: Constify struct mei_cl_device_id
In reply to Rikard Falkebornmei_hdcp_tbl[] is never modified and can be made const to allow the compiler to put it in read-only memory.
Before:
text data bss dec hex filename
15844 5416 0 21260 530c drivers/misc/mei/hdcp/mei_hdcp.o
After:
text data bss dec hex filename
16004 5256 0 21260 530c drivers/misc/mei/hdcp/mei_hdcp.o
--- drivers/misc/mei/hdcp/mei_hdcp.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/misc/mei/hdcp/mei_hdcp.c +1 -1
@@ -852,7 +852,7 @@ static int mei_hdcp_remove(struct mei_cl_device *cldev)#define MEI_UUID_HDCP GUID_INIT(0xB638AB7E, 0x94E2, 0x4EA2, 0xA5, \ 0x52, 0xD1, 0xC5, 0x4B, 0x62, 0x7F, 0x04) -static struct mei_cl_device_id mei_hdcp_tbl[] = { +static const struct mei_cl_device_id mei_hdcp_tbl[] = { { .uuid =MEI_UUID_HDCP , .version =MEI_CL_VERSION_ANY }, { } };
Signature · 1 line
2.27.0
PATCH 4/4 mic: vop: Constify static structs
In reply to Rikard Falkebornvop_vq_config_ops and id_table[] are never modified so make them const to allow the compiler to put them in read-only memory.
Before:
text data bss dec hex filename 14889 4065 192 19146 4aca drivers/misc/mic/vop/vop_main.o
After:
text data bss dec hex filename 15113 3841 192 19146 4aca drivers/misc/mic/vop/vop_main.o
--- drivers/misc/mic/vop/vop_main.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/misc/mic/vop/vop_main.c +2 -2
@@ -438,7 +438,7 @@ static int vop_find_vqs(struct virtio_device *dev, unsigned nvqs,/* * The config ops structure as defined by virtio config */ -static struct virtio_config_ops vop_vq_config_ops = { +static const struct virtio_config_ops vop_vq_config_ops = { .get_features = vop_get_features, .finalize_features = vop_finalize_features, .get = vop_get,
@@ -763,7 +763,7 @@ static void vop_driver_remove(struct vop_device *vpdev)kfree (vi); } -static struct vop_device_id id_table[] = { +static const struct vop_device_id id_table[] = { {VOP_DEV_TRNSP ,VOP_DEV_ANY_ID }, {0 }, };
Signature · 1 line
2.27.0