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

media: dvb-frontends: tda18271c2dd: Constify static structs

Constify a number of static structs that were not modified. In order to
be able to do that, const input arguments to a couple of functions that
not modify their argument. This allows the compiler to put them in
read-only memory, resulting in about 6k memory being read-only, and the
resulting module is 400 bytes smaller.

Before:
text data bss dec hex filename
15492 6873 0 22365 575d drivers/media/dvb-frontends/tda18271c2dd.ko

After:
text data bss dec hex filename
21021 897 0 21918 559e drivers/media/dvb-frontends/tda18271c2dd.ko

Signed-off-by: Rikard Falkeborn <rikard.falkeborn@gmail.com>
Signed-off-by: Sean Young <sean@mess.org>
Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>

authored by

Rikard Falkeborn and committed by
Mauro Carvalho Chehab
2d4ffef1 cf580e11

+30 -33
+19 -22
drivers/media/dvb-frontends/tda18271c2dd.c
··· 198 198 state->m_bFMInput = (ulFMInput == 2); 199 199 } 200 200 201 - static bool SearchMap1(struct SMap Map[], 202 - u32 Frequency, u8 *pParam) 201 + static bool SearchMap1(const struct SMap map[], u32 frequency, u8 *param) 203 202 { 204 203 int i = 0; 205 204 206 - while ((Map[i].m_Frequency != 0) && (Frequency > Map[i].m_Frequency)) 205 + while ((map[i].m_Frequency != 0) && (frequency > map[i].m_Frequency)) 207 206 i += 1; 208 - if (Map[i].m_Frequency == 0) 207 + if (map[i].m_Frequency == 0) 209 208 return false; 210 - *pParam = Map[i].m_Param; 209 + *param = map[i].m_Param; 211 210 return true; 212 211 } 213 212 214 - static bool SearchMap2(struct SMapI Map[], 215 - u32 Frequency, s32 *pParam) 213 + static bool SearchMap2(const struct SMapI map[], u32 frequency, s32 *param) 216 214 { 217 215 int i = 0; 218 216 219 - while ((Map[i].m_Frequency != 0) && 220 - (Frequency > Map[i].m_Frequency)) 217 + while ((map[i].m_Frequency != 0) && 218 + (frequency > map[i].m_Frequency)) 221 219 i += 1; 222 - if (Map[i].m_Frequency == 0) 220 + if (map[i].m_Frequency == 0) 223 221 return false; 224 - *pParam = Map[i].m_Param; 222 + *param = map[i].m_Param; 225 223 return true; 226 224 } 227 225 228 - static bool SearchMap3(struct SMap2 Map[], u32 Frequency, 229 - u8 *pParam1, u8 *pParam2) 226 + static bool SearchMap3(const struct SMap2 map[], u32 frequency, u8 *param1, 227 + u8 *param2) 230 228 { 231 229 int i = 0; 232 230 233 - while ((Map[i].m_Frequency != 0) && 234 - (Frequency > Map[i].m_Frequency)) 231 + while ((map[i].m_Frequency != 0) && 232 + (frequency > map[i].m_Frequency)) 235 233 i += 1; 236 - if (Map[i].m_Frequency == 0) 234 + if (map[i].m_Frequency == 0) 237 235 return false; 238 - *pParam1 = Map[i].m_Param1; 239 - *pParam2 = Map[i].m_Param2; 236 + *param1 = map[i].m_Param1; 237 + *param2 = map[i].m_Param2; 240 238 return true; 241 239 } 242 240 243 - static bool SearchMap4(struct SRFBandMap Map[], 244 - u32 Frequency, u8 *pRFBand) 241 + static bool SearchMap4(const struct SRFBandMap map[], u32 frequency, u8 *rfband) 245 242 { 246 243 int i = 0; 247 244 248 - while (i < 7 && (Frequency > Map[i].m_RF_max)) 245 + while (i < 7 && (frequency > map[i].m_RF_max)) 249 246 i += 1; 250 247 if (i == 7) 251 248 return false; 252 - *pRFBand = i; 249 + *rfband = i; 253 250 return true; 254 251 } 255 252
+11 -11
drivers/media/dvb-frontends/tda18271c2dd_maps.h
··· 6 6 HF_DVBC_8MHZ, HF_DVBC 7 7 }; 8 8 9 - static struct SStandardParam m_StandardTable[] = { 9 + static const struct SStandardParam m_StandardTable[] = { 10 10 { 0, 0, 0x00, 0x00 }, /* HF_None */ 11 11 { 6000000, 7000000, 0x1D, 0x2C }, /* HF_B, */ 12 12 { 6900000, 8000000, 0x1E, 0x2C }, /* HF_DK, */ ··· 28 28 { 0, 0, 0x00, 0x00 }, /* HF_DVBC (Unused) */ 29 29 }; 30 30 31 - static struct SMap m_BP_Filter_Map[] = { 31 + static const struct SMap m_BP_Filter_Map[] = { 32 32 { 62000000, 0x00 }, 33 33 { 84000000, 0x01 }, 34 34 { 100000000, 0x02 }, ··· 39 39 { 0, 0x00 }, /* Table End */ 40 40 }; 41 41 42 - static struct SMapI m_RF_Cal_Map[] = { 42 + static const struct SMapI m_RF_Cal_Map[] = { 43 43 { 41000000, 0x0F }, 44 44 { 43000000, 0x1C }, 45 45 { 45000000, 0x2F }, ··· 481 481 }; 482 482 483 483 484 - static struct SMap2 m_KM_Map[] = { 484 + static const struct SMap2 m_KM_Map[] = { 485 485 { 47900000, 3, 2 }, 486 486 { 61100000, 3, 1 }, 487 487 { 350000000, 3, 0 }, ··· 490 490 { 0, 0x00 }, /* Table End */ 491 491 }; 492 492 493 - static struct SMap2 m_Main_PLL_Map[] = { 493 + static const struct SMap2 m_Main_PLL_Map[] = { 494 494 { 33125000, 0x57, 0xF0 }, 495 495 { 35500000, 0x56, 0xE0 }, 496 496 { 38188000, 0x55, 0xD0 }, ··· 534 534 { 0, 0x00, 0x00 }, /* Table End */ 535 535 }; 536 536 537 - static struct SMap2 m_Cal_PLL_Map[] = { 537 + static const struct SMap2 m_Cal_PLL_Map[] = { 538 538 { 33813000, 0xDD, 0xD0 }, 539 539 { 36625000, 0xDC, 0xC0 }, 540 540 { 39938000, 0xDB, 0xB0 }, ··· 572 572 { 0, 0x00, 0x00 }, /* Table End */ 573 573 }; 574 574 575 - static struct SMap m_GainTaper_Map[] = { 575 + static const struct SMap m_GainTaper_Map[] = { 576 576 { 45400000, 0x1F }, 577 577 { 45800000, 0x1E }, 578 578 { 46200000, 0x1D }, ··· 661 661 { 0, 0x00 }, /* Table End */ 662 662 }; 663 663 664 - static struct SMap m_RF_Cal_DC_Over_DT_Map[] = { 664 + static const struct SMap m_RF_Cal_DC_Over_DT_Map[] = { 665 665 { 47900000, 0x00 }, 666 666 { 55000000, 0x00 }, 667 667 { 61100000, 0x0A }, ··· 767 767 }; 768 768 769 769 770 - static struct SMap m_IR_Meas_Map[] = { 770 + static const struct SMap m_IR_Meas_Map[] = { 771 771 { 200000000, 0x05 }, 772 772 { 400000000, 0x06 }, 773 773 { 865000000, 0x07 }, 774 774 { 0, 0x00 }, /* Table End */ 775 775 }; 776 776 777 - static struct SMap2 m_CID_Target_Map[] = { 777 + static const struct SMap2 m_CID_Target_Map[] = { 778 778 { 46000000, 0x04, 18 }, 779 779 { 52200000, 0x0A, 15 }, 780 780 { 70100000, 0x01, 40 }, ··· 790 790 { 0, 0x00, 0 }, /* Table End */ 791 791 }; 792 792 793 - static struct SRFBandMap m_RF_Band_Map[7] = { 793 + static const struct SRFBandMap m_RF_Band_Map[7] = { 794 794 { 47900000, 46000000, 0, 0}, 795 795 { 61100000, 52200000, 0, 0}, 796 796 { 152600000, 70100000, 136800000, 0},