diff options
| author | Colin Ian King <colin.king@canonical.com> | 2017-07-10 11:08:32 -0400 |
|---|---|---|
| committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2017-07-17 11:23:16 -0400 |
| commit | caa97be1a2052f2dfc026c3fe5ef62f620782f24 (patch) | |
| tree | a8a42967d957c7ea6f05153ca9c691e1bdf75469 /drivers/char | |
| parent | 2dee584bc9e3c75afc2c85f107e516c58a8efaf3 (diff) | |
char/mwave: make some arrays static const to make object code smaller
Don't populate arrays on the stack but make them static. Makes
the object code smaller. Also remove temporary variables that
have hard coded array sizes and just use ARRAY_SIZE instead and
wrap some lines that are wider than 80 chars to clean up some
checkpatch warnings.
Before:
text data bss dec hex filename
11141 2008 64 13213 339d drivers/char/mwave/smapi.o
After:
text data bss dec hex filename
10697 2352 64 13113 3339 drivers/char/mwave/smapi.o
Signed-off-by: Colin Ian King <colin.king@canonical.com>
Acked-by: Arnd Bergmann <arnd@arndb.de>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'drivers/char')
| -rw-r--r-- | drivers/char/mwave/smapi.c | 48 |
1 files changed, 25 insertions, 23 deletions
diff --git a/drivers/char/mwave/smapi.c b/drivers/char/mwave/smapi.c index 8c5411a8f33f..691f5898bb32 100644 --- a/drivers/char/mwave/smapi.c +++ b/drivers/char/mwave/smapi.c | |||
| @@ -128,10 +128,11 @@ int smapi_query_DSP_cfg(SMAPI_DSP_SETTINGS * pSettings) | |||
| 128 | { | 128 | { |
| 129 | int bRC = -EIO; | 129 | int bRC = -EIO; |
| 130 | unsigned short usAX, usBX, usCX, usDX, usDI, usSI; | 130 | unsigned short usAX, usBX, usCX, usDX, usDI, usSI; |
| 131 | unsigned short ausDspBases[] = { 0x0030, 0x4E30, 0x8E30, 0xCE30, 0x0130, 0x0350, 0x0070, 0x0DB0 }; | 131 | static const unsigned short ausDspBases[] = { |
| 132 | unsigned short ausUartBases[] = { 0x03F8, 0x02F8, 0x03E8, 0x02E8 }; | 132 | 0x0030, 0x4E30, 0x8E30, 0xCE30, |
| 133 | unsigned short numDspBases = 8; | 133 | 0x0130, 0x0350, 0x0070, 0x0DB0 }; |
| 134 | unsigned short numUartBases = 4; | 134 | static const unsigned short ausUartBases[] = { |
| 135 | 0x03F8, 0x02F8, 0x03E8, 0x02E8 }; | ||
| 135 | 136 | ||
| 136 | PRINTK_1(TRACE_SMAPI, "smapi::smapi_query_DSP_cfg entry\n"); | 137 | PRINTK_1(TRACE_SMAPI, "smapi::smapi_query_DSP_cfg entry\n"); |
| 137 | 138 | ||
| @@ -148,7 +149,7 @@ int smapi_query_DSP_cfg(SMAPI_DSP_SETTINGS * pSettings) | |||
| 148 | pSettings->bDSPEnabled = ((usCX & 0x0001) != 0); | 149 | pSettings->bDSPEnabled = ((usCX & 0x0001) != 0); |
| 149 | pSettings->usDspIRQ = usSI & 0x00FF; | 150 | pSettings->usDspIRQ = usSI & 0x00FF; |
| 150 | pSettings->usDspDMA = (usSI & 0xFF00) >> 8; | 151 | pSettings->usDspDMA = (usSI & 0xFF00) >> 8; |
| 151 | if ((usDI & 0x00FF) < numDspBases) { | 152 | if ((usDI & 0x00FF) < ARRAY_SIZE(ausDspBases)) { |
| 152 | pSettings->usDspBaseIO = ausDspBases[usDI & 0x00FF]; | 153 | pSettings->usDspBaseIO = ausDspBases[usDI & 0x00FF]; |
| 153 | } else { | 154 | } else { |
| 154 | pSettings->usDspBaseIO = 0; | 155 | pSettings->usDspBaseIO = 0; |
| @@ -176,7 +177,7 @@ int smapi_query_DSP_cfg(SMAPI_DSP_SETTINGS * pSettings) | |||
| 176 | 177 | ||
| 177 | pSettings->bModemEnabled = ((usCX & 0x0001) != 0); | 178 | pSettings->bModemEnabled = ((usCX & 0x0001) != 0); |
| 178 | pSettings->usUartIRQ = usSI & 0x000F; | 179 | pSettings->usUartIRQ = usSI & 0x000F; |
| 179 | if (((usSI & 0xFF00) >> 8) < numUartBases) { | 180 | if (((usSI & 0xFF00) >> 8) < ARRAY_SIZE(ausUartBases)) { |
| 180 | pSettings->usUartBaseIO = ausUartBases[(usSI & 0xFF00) >> 8]; | 181 | pSettings->usUartBaseIO = ausUartBases[(usSI & 0xFF00) >> 8]; |
| 181 | } else { | 182 | } else { |
| 182 | pSettings->usUartBaseIO = 0; | 183 | pSettings->usUartBaseIO = 0; |
| @@ -205,15 +206,16 @@ int smapi_set_DSP_cfg(void) | |||
| 205 | int bRC = -EIO; | 206 | int bRC = -EIO; |
| 206 | int i; | 207 | int i; |
| 207 | unsigned short usAX, usBX, usCX, usDX, usDI, usSI; | 208 | unsigned short usAX, usBX, usCX, usDX, usDI, usSI; |
| 208 | unsigned short ausDspBases[] = { 0x0030, 0x4E30, 0x8E30, 0xCE30, 0x0130, 0x0350, 0x0070, 0x0DB0 }; | 209 | static const unsigned short ausDspBases[] = { |
| 209 | unsigned short ausUartBases[] = { 0x03F8, 0x02F8, 0x03E8, 0x02E8 }; | 210 | 0x0030, 0x4E30, 0x8E30, 0xCE30, |
| 210 | unsigned short ausDspIrqs[] = { 5, 7, 10, 11, 15 }; | 211 | 0x0130, 0x0350, 0x0070, 0x0DB0 }; |
| 211 | unsigned short ausUartIrqs[] = { 3, 4 }; | 212 | static const unsigned short ausUartBases[] = { |
| 212 | 213 | 0x03F8, 0x02F8, 0x03E8, 0x02E8 }; | |
| 213 | unsigned short numDspBases = 8; | 214 | static const unsigned short ausDspIrqs[] = { |
| 214 | unsigned short numUartBases = 4; | 215 | 5, 7, 10, 11, 15 }; |
| 215 | unsigned short numDspIrqs = 5; | 216 | static const unsigned short ausUartIrqs[] = { |
| 216 | unsigned short numUartIrqs = 2; | 217 | 3, 4 }; |
| 218 | |||
| 217 | unsigned short dspio_index = 0, uartio_index = 0; | 219 | unsigned short dspio_index = 0, uartio_index = 0; |
| 218 | 220 | ||
| 219 | PRINTK_5(TRACE_SMAPI, | 221 | PRINTK_5(TRACE_SMAPI, |
| @@ -221,11 +223,11 @@ int smapi_set_DSP_cfg(void) | |||
| 221 | mwave_3780i_irq, mwave_3780i_io, mwave_uart_irq, mwave_uart_io); | 223 | mwave_3780i_irq, mwave_3780i_io, mwave_uart_irq, mwave_uart_io); |
| 222 | 224 | ||
| 223 | if (mwave_3780i_io) { | 225 | if (mwave_3780i_io) { |
| 224 | for (i = 0; i < numDspBases; i++) { | 226 | for (i = 0; i < ARRAY_SIZE(ausDspBases); i++) { |
| 225 | if (mwave_3780i_io == ausDspBases[i]) | 227 | if (mwave_3780i_io == ausDspBases[i]) |
| 226 | break; | 228 | break; |
| 227 | } | 229 | } |
| 228 | if (i == numDspBases) { | 230 | if (i == ARRAY_SIZE(ausDspBases)) { |
| 229 | PRINTK_ERROR(KERN_ERR_MWAVE "smapi::smapi_set_DSP_cfg: Error: Invalid mwave_3780i_io address %x. Aborting.\n", mwave_3780i_io); | 231 | PRINTK_ERROR(KERN_ERR_MWAVE "smapi::smapi_set_DSP_cfg: Error: Invalid mwave_3780i_io address %x. Aborting.\n", mwave_3780i_io); |
| 230 | return bRC; | 232 | return bRC; |
| 231 | } | 233 | } |
| @@ -233,22 +235,22 @@ int smapi_set_DSP_cfg(void) | |||
| 233 | } | 235 | } |
| 234 | 236 | ||
| 235 | if (mwave_3780i_irq) { | 237 | if (mwave_3780i_irq) { |
| 236 | for (i = 0; i < numDspIrqs; i++) { | 238 | for (i = 0; i < ARRAY_SIZE(ausDspIrqs); i++) { |
| 237 | if (mwave_3780i_irq == ausDspIrqs[i]) | 239 | if (mwave_3780i_irq == ausDspIrqs[i]) |
| 238 | break; | 240 | break; |
| 239 | } | 241 | } |
| 240 | if (i == numDspIrqs) { | 242 | if (i == ARRAY_SIZE(ausDspIrqs)) { |
| 241 | PRINTK_ERROR(KERN_ERR_MWAVE "smapi::smapi_set_DSP_cfg: Error: Invalid mwave_3780i_irq %x. Aborting.\n", mwave_3780i_irq); | 243 | PRINTK_ERROR(KERN_ERR_MWAVE "smapi::smapi_set_DSP_cfg: Error: Invalid mwave_3780i_irq %x. Aborting.\n", mwave_3780i_irq); |
| 242 | return bRC; | 244 | return bRC; |
| 243 | } | 245 | } |
| 244 | } | 246 | } |
| 245 | 247 | ||
| 246 | if (mwave_uart_io) { | 248 | if (mwave_uart_io) { |
| 247 | for (i = 0; i < numUartBases; i++) { | 249 | for (i = 0; i < ARRAY_SIZE(ausUartBases); i++) { |
| 248 | if (mwave_uart_io == ausUartBases[i]) | 250 | if (mwave_uart_io == ausUartBases[i]) |
| 249 | break; | 251 | break; |
| 250 | } | 252 | } |
| 251 | if (i == numUartBases) { | 253 | if (i == ARRAY_SIZE(ausUartBases)) { |
| 252 | PRINTK_ERROR(KERN_ERR_MWAVE "smapi::smapi_set_DSP_cfg: Error: Invalid mwave_uart_io address %x. Aborting.\n", mwave_uart_io); | 254 | PRINTK_ERROR(KERN_ERR_MWAVE "smapi::smapi_set_DSP_cfg: Error: Invalid mwave_uart_io address %x. Aborting.\n", mwave_uart_io); |
| 253 | return bRC; | 255 | return bRC; |
| 254 | } | 256 | } |
| @@ -257,11 +259,11 @@ int smapi_set_DSP_cfg(void) | |||
| 257 | 259 | ||
| 258 | 260 | ||
| 259 | if (mwave_uart_irq) { | 261 | if (mwave_uart_irq) { |
| 260 | for (i = 0; i < numUartIrqs; i++) { | 262 | for (i = 0; i < ARRAY_SIZE(ausUartIrqs); i++) { |
| 261 | if (mwave_uart_irq == ausUartIrqs[i]) | 263 | if (mwave_uart_irq == ausUartIrqs[i]) |
| 262 | break; | 264 | break; |
| 263 | } | 265 | } |
| 264 | if (i == numUartIrqs) { | 266 | if (i == ARRAY_SIZE(ausUartIrqs)) { |
| 265 | PRINTK_ERROR(KERN_ERR_MWAVE "smapi::smapi_set_DSP_cfg: Error: Invalid mwave_uart_irq %x. Aborting.\n", mwave_uart_irq); | 267 | PRINTK_ERROR(KERN_ERR_MWAVE "smapi::smapi_set_DSP_cfg: Error: Invalid mwave_uart_irq %x. Aborting.\n", mwave_uart_irq); |
| 266 | return bRC; | 268 | return bRC; |
| 267 | } | 269 | } |
