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

phy: phy-brcm-usb: Constify static structs

A number of structs were not modified and can therefore be made const
to allow the compiler to put them in read-only memory.

In order to do so, update a few functions that don't modify there input
to take pointers to const.

Before:
text data bss dec hex filename
15511 6448 64 22023 5607 drivers/phy/broadcom/phy-brcm-usb.o

After:
text data bss dec hex filename
16058 5936 64 22058 562a drivers/phy/broadcom/phy-brcm-usb.o

Signed-off-by: Rikard Falkeborn <rikard.falkeborn@gmail.com>
Link: https://lore.kernel.org/r/20200516120441.7627-4-rikard.falkeborn@gmail.com
Signed-off-by: Kishon Vijay Abraham I <kishon@ti.com>

authored by

Rikard Falkeborn and committed by
Kishon Vijay Abraham I
c79cc3d5 cbe72af1

+8 -8
+8 -8
drivers/phy/broadcom/phy-brcm-usb.c
··· 39 39 u8 optional_reg; 40 40 }; 41 41 42 - static struct value_to_name_map brcm_dr_mode_to_name[] = { 42 + static const struct value_to_name_map brcm_dr_mode_to_name[] = { 43 43 { USB_CTLR_MODE_HOST, "host" }, 44 44 { USB_CTLR_MODE_DEVICE, "peripheral" }, 45 45 { USB_CTLR_MODE_DRD, "drd" }, 46 46 { USB_CTLR_MODE_TYPEC_PD, "typec-pd" } 47 47 }; 48 48 49 - static struct value_to_name_map brcm_dual_mode_to_name[] = { 49 + static const struct value_to_name_map brcm_dual_mode_to_name[] = { 50 50 { 0, "host" }, 51 51 { 1, "device" }, 52 52 { 2, "auto" }, ··· 138 138 return 0; 139 139 } 140 140 141 - static struct phy_ops brcm_usb_phy_ops = { 141 + static const struct phy_ops brcm_usb_phy_ops = { 142 142 .init = brcm_usb_phy_init, 143 143 .exit = brcm_usb_phy_exit, 144 144 .owner = THIS_MODULE, ··· 170 170 return ERR_PTR(-ENODEV); 171 171 } 172 172 173 - static int name_to_value(struct value_to_name_map *table, int count, 173 + static int name_to_value(const struct value_to_name_map *table, int count, 174 174 const char *name, int *value) 175 175 { 176 176 int x; ··· 185 185 return -EINVAL; 186 186 } 187 187 188 - static const char *value_to_name(struct value_to_name_map *table, int count, 188 + static const char *value_to_name(const struct value_to_name_map *table, int count, 189 189 int value) 190 190 { 191 191 if (value >= count) ··· 252 252 .attrs = brcm_usb_phy_attrs, 253 253 }; 254 254 255 - static struct match_chip_info chip_info_7216 = { 255 + static const struct match_chip_info chip_info_7216 = { 256 256 .init_func = &brcm_usb_dvr_init_7216, 257 257 .required_regs = { 258 258 BRCM_REGS_CTRL, ··· 262 262 }, 263 263 }; 264 264 265 - static struct match_chip_info chip_info_7211b0 = { 265 + static const struct match_chip_info chip_info_7211b0 = { 266 266 .init_func = &brcm_usb_dvr_init_7211b0, 267 267 .required_regs = { 268 268 BRCM_REGS_CTRL, ··· 275 275 .optional_reg = BRCM_REGS_BDC_EC, 276 276 }; 277 277 278 - static struct match_chip_info chip_info_7445 = { 278 + static const struct match_chip_info chip_info_7445 = { 279 279 .init_func = &brcm_usb_dvr_init_7445, 280 280 .required_regs = { 281 281 BRCM_REGS_CTRL,