Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

irda: Convert function pointer arrays and uses to const

Making things const is a good thing.

(x86-64 defconfig with all irda)
$ size net/irda/built-in.o*
text data bss dec hex filename
109276 1868 244 111388 1b31c net/irda/built-in.o.new
108828 2316 244 111388 1b31c net/irda/built-in.o.old

Signed-off-by: Joe Perches <joe@perches.com>
Signed-off-by: David S. Miller <davem@davemloft.net>

authored by

Joe Perches and committed by
David S. Miller
785c20a0 22bbf5f3

+18 -16
+3 -3
include/net/irda/parameters.h
··· 71 71 PV_TYPE type, PI_HANDLER func); 72 72 73 73 typedef struct { 74 - PI_HANDLER func; /* Handler for this parameter identifier */ 74 + const PI_HANDLER func; /* Handler for this parameter identifier */ 75 75 PV_TYPE type; /* Data type for this parameter */ 76 76 } pi_minor_info_t; 77 77 78 78 typedef struct { 79 - pi_minor_info_t *pi_minor_call_table; 79 + const pi_minor_info_t *pi_minor_call_table; 80 80 int len; 81 81 } pi_major_info_t; 82 82 83 83 typedef struct { 84 - pi_major_info_t *tables; 84 + const pi_major_info_t *tables; 85 85 int len; 86 86 __u8 pi_mask; 87 87 int pi_major_offset;
+4 -4
net/irda/ircomm/ircomm_param.c
··· 61 61 static int ircomm_param_dce(void *instance, irda_param_t *param, int get); 62 62 static int ircomm_param_poll(void *instance, irda_param_t *param, int get); 63 63 64 - static pi_minor_info_t pi_minor_call_table_common[] = { 64 + static const pi_minor_info_t pi_minor_call_table_common[] = { 65 65 { ircomm_param_service_type, PV_INT_8_BITS }, 66 66 { ircomm_param_port_type, PV_INT_8_BITS }, 67 67 { ircomm_param_port_name, PV_STRING } 68 68 }; 69 - static pi_minor_info_t pi_minor_call_table_non_raw[] = { 69 + static const pi_minor_info_t pi_minor_call_table_non_raw[] = { 70 70 { ircomm_param_data_rate, PV_INT_32_BITS | PV_BIG_ENDIAN }, 71 71 { ircomm_param_data_format, PV_INT_8_BITS }, 72 72 { ircomm_param_flow_control, PV_INT_8_BITS }, ··· 74 74 { ircomm_param_enq_ack, PV_INT_16_BITS }, 75 75 { ircomm_param_line_status, PV_INT_8_BITS } 76 76 }; 77 - static pi_minor_info_t pi_minor_call_table_9_wire[] = { 77 + static const pi_minor_info_t pi_minor_call_table_9_wire[] = { 78 78 { ircomm_param_dte, PV_INT_8_BITS }, 79 79 { ircomm_param_dce, PV_INT_8_BITS }, 80 80 { ircomm_param_poll, PV_NO_VALUE }, 81 81 }; 82 82 83 - static pi_major_info_t pi_major_call_table[] = { 83 + static const pi_major_info_t pi_major_call_table[] = { 84 84 { pi_minor_call_table_common, 3 }, 85 85 { pi_minor_call_table_non_raw, 6 }, 86 86 { pi_minor_call_table_9_wire, 3 }
+4 -2
net/irda/irttp.c
··· 71 71 LINK_STATUS link, LOCK_STATUS lock); 72 72 73 73 /* Information for parsing parameters in IrTTP */ 74 - static pi_minor_info_t pi_minor_call_table[] = { 74 + static const pi_minor_info_t pi_minor_call_table[] = { 75 75 { NULL, 0 }, /* 0x00 */ 76 76 { irttp_param_max_sdu_size, PV_INTEGER | PV_BIG_ENDIAN } /* 0x01 */ 77 77 }; 78 - static pi_major_info_t pi_major_call_table[] = { { pi_minor_call_table, 2 } }; 78 + static const pi_major_info_t pi_major_call_table[] = { 79 + { pi_minor_call_table, 2 } 80 + }; 79 81 static pi_param_info_t param_info = { pi_major_call_table, 1, 0x0f, 4 }; 80 82 81 83 /************************ GLOBAL PROCEDURES ************************/
+4 -4
net/irda/parameters.c
··· 52 52 static int irda_param_unpack(__u8 *buf, char *fmt, ...); 53 53 54 54 /* Parameter value call table. Must match PV_TYPE */ 55 - static PV_HANDLER pv_extract_table[] = { 55 + static const PV_HANDLER pv_extract_table[] = { 56 56 irda_extract_integer, /* Handler for any length integers */ 57 57 irda_extract_integer, /* Handler for 8 bits integers */ 58 58 irda_extract_integer, /* Handler for 16 bits integers */ ··· 62 62 irda_extract_no_value /* Handler for no value parameters */ 63 63 }; 64 64 65 - static PV_HANDLER pv_insert_table[] = { 65 + static const PV_HANDLER pv_insert_table[] = { 66 66 irda_insert_integer, /* Handler for any length integers */ 67 67 irda_insert_integer, /* Handler for 8 bits integers */ 68 68 irda_insert_integer, /* Handler for 16 bits integers */ ··· 449 449 int irda_param_insert(void *self, __u8 pi, __u8 *buf, int len, 450 450 pi_param_info_t *info) 451 451 { 452 - pi_minor_info_t *pi_minor_info; 452 + const pi_minor_info_t *pi_minor_info; 453 453 __u8 pi_minor; 454 454 __u8 pi_major; 455 455 int type; ··· 504 504 static int irda_param_extract(void *self, __u8 *buf, int len, 505 505 pi_param_info_t *info) 506 506 { 507 - pi_minor_info_t *pi_minor_info; 507 + const pi_minor_info_t *pi_minor_info; 508 508 __u8 pi_minor; 509 509 __u8 pi_major; 510 510 int type;
+3 -3
net/irda/qos.c
··· 122 122 { 800000, 400000, 160000, 80000 }, /* 16000000 bps */ 123 123 }; 124 124 125 - static pi_minor_info_t pi_minor_call_table_type_0[] = { 125 + static const pi_minor_info_t pi_minor_call_table_type_0[] = { 126 126 { NULL, 0 }, 127 127 /* 01 */{ irlap_param_baud_rate, PV_INTEGER | PV_LITTLE_ENDIAN }, 128 128 { NULL, 0 }, ··· 134 134 /* 08 */{ irlap_param_link_disconnect, PV_INT_8_BITS } 135 135 }; 136 136 137 - static pi_minor_info_t pi_minor_call_table_type_1[] = { 137 + static const pi_minor_info_t pi_minor_call_table_type_1[] = { 138 138 { NULL, 0 }, 139 139 { NULL, 0 }, 140 140 /* 82 */{ irlap_param_max_turn_time, PV_INT_8_BITS }, ··· 144 144 /* 86 */{ irlap_param_min_turn_time, PV_INT_8_BITS }, 145 145 }; 146 146 147 - static pi_major_info_t pi_major_call_table[] = { 147 + static const pi_major_info_t pi_major_call_table[] = { 148 148 { pi_minor_call_table_type_0, 9 }, 149 149 { pi_minor_call_table_type_1, 7 }, 150 150 };