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

Configure Feed

Select the types of activity you want to include in your feed.

iio: dac: ltc2632: drop enum and use individual chip_info objects

Remove the ltc2632_chip_info_tbl[] array and related
ltc2632_supported_device_ids enum used for looking up chip-specific
information. Instead, use separate static const struct
ltc2632_chip_info objects for each supported chip variant.

Suggested-by: Andy Shevchenko <andriy.shevchenko@intel.com>
Reviewed-by: Andy Shevchenko <andriy.shevchenko@intel.com>
Signed-off-by: David Marinovic <david.marinovic@pupin.rs>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>

authored by

David Marinovic and committed by
Jonathan Cameron
19045d89 8a75ac8f

+142 -185
+142 -185
drivers/iio/dac/ltc2632.c
··· 48 48 int vref_mv; 49 49 }; 50 50 51 - enum ltc2632_supported_device_ids { 52 - ID_LTC2632L12, 53 - ID_LTC2632L10, 54 - ID_LTC2632L8, 55 - ID_LTC2632H12, 56 - ID_LTC2632H10, 57 - ID_LTC2632H8, 58 - ID_LTC2634L12, 59 - ID_LTC2634L10, 60 - ID_LTC2634L8, 61 - ID_LTC2634H12, 62 - ID_LTC2634H10, 63 - ID_LTC2634H8, 64 - ID_LTC2636L12, 65 - ID_LTC2636L10, 66 - ID_LTC2636L8, 67 - ID_LTC2636H12, 68 - ID_LTC2636H10, 69 - ID_LTC2636H8, 70 - }; 71 - 72 51 static int ltc2632_spi_write(struct spi_device *spi, 73 52 u8 cmd, u8 addr, u16 val, u8 shift) 74 53 { ··· 189 210 static DECLARE_LTC2632_CHANNELS(ltc2632x10, 10); 190 211 static DECLARE_LTC2632_CHANNELS(ltc2632x8, 8); 191 212 192 - static const struct ltc2632_chip_info ltc2632_chip_info_tbl[] = { 193 - [ID_LTC2632L12] = { 194 - .channels = ltc2632x12_channels, 195 - .num_channels = 2, 196 - .vref_mv = 2500, 197 - }, 198 - [ID_LTC2632L10] = { 199 - .channels = ltc2632x10_channels, 200 - .num_channels = 2, 201 - .vref_mv = 2500, 202 - }, 203 - [ID_LTC2632L8] = { 204 - .channels = ltc2632x8_channels, 205 - .num_channels = 2, 206 - .vref_mv = 2500, 207 - }, 208 - [ID_LTC2632H12] = { 209 - .channels = ltc2632x12_channels, 210 - .num_channels = 2, 211 - .vref_mv = 4096, 212 - }, 213 - [ID_LTC2632H10] = { 214 - .channels = ltc2632x10_channels, 215 - .num_channels = 2, 216 - .vref_mv = 4096, 217 - }, 218 - [ID_LTC2632H8] = { 219 - .channels = ltc2632x8_channels, 220 - .num_channels = 2, 221 - .vref_mv = 4096, 222 - }, 223 - [ID_LTC2634L12] = { 224 - .channels = ltc2632x12_channels, 225 - .num_channels = 4, 226 - .vref_mv = 2500, 227 - }, 228 - [ID_LTC2634L10] = { 229 - .channels = ltc2632x10_channels, 230 - .num_channels = 4, 231 - .vref_mv = 2500, 232 - }, 233 - [ID_LTC2634L8] = { 234 - .channels = ltc2632x8_channels, 235 - .num_channels = 4, 236 - .vref_mv = 2500, 237 - }, 238 - [ID_LTC2634H12] = { 239 - .channels = ltc2632x12_channels, 240 - .num_channels = 4, 241 - .vref_mv = 4096, 242 - }, 243 - [ID_LTC2634H10] = { 244 - .channels = ltc2632x10_channels, 245 - .num_channels = 4, 246 - .vref_mv = 4096, 247 - }, 248 - [ID_LTC2634H8] = { 249 - .channels = ltc2632x8_channels, 250 - .num_channels = 4, 251 - .vref_mv = 4096, 252 - }, 253 - [ID_LTC2636L12] = { 254 - .channels = ltc2632x12_channels, 255 - .num_channels = 8, 256 - .vref_mv = 2500, 257 - }, 258 - [ID_LTC2636L10] = { 259 - .channels = ltc2632x10_channels, 260 - .num_channels = 8, 261 - .vref_mv = 2500, 262 - }, 263 - [ID_LTC2636L8] = { 264 - .channels = ltc2632x8_channels, 265 - .num_channels = 8, 266 - .vref_mv = 2500, 267 - }, 268 - [ID_LTC2636H12] = { 269 - .channels = ltc2632x12_channels, 270 - .num_channels = 8, 271 - .vref_mv = 4096, 272 - }, 273 - [ID_LTC2636H10] = { 274 - .channels = ltc2632x10_channels, 275 - .num_channels = 8, 276 - .vref_mv = 4096, 277 - }, 278 - [ID_LTC2636H8] = { 279 - .channels = ltc2632x8_channels, 280 - .num_channels = 8, 281 - .vref_mv = 4096, 282 - }, 213 + static const struct ltc2632_chip_info ltc2632l12_chip_info = { 214 + .channels = ltc2632x12_channels, 215 + .num_channels = 2, 216 + .vref_mv = 2500, 217 + }; 218 + 219 + static const struct ltc2632_chip_info ltc2632l10_chip_info = { 220 + .channels = ltc2632x10_channels, 221 + .num_channels = 2, 222 + .vref_mv = 2500, 223 + }; 224 + 225 + static const struct ltc2632_chip_info ltc2632l8_chip_info = { 226 + .channels = ltc2632x8_channels, 227 + .num_channels = 2, 228 + .vref_mv = 2500, 229 + }; 230 + 231 + static const struct ltc2632_chip_info ltc2632h12_chip_info = { 232 + .channels = ltc2632x12_channels, 233 + .num_channels = 2, 234 + .vref_mv = 4096, 235 + }; 236 + 237 + static const struct ltc2632_chip_info ltc2632h10_chip_info = { 238 + .channels = ltc2632x10_channels, 239 + .num_channels = 2, 240 + .vref_mv = 4096, 241 + }; 242 + 243 + static const struct ltc2632_chip_info ltc2632h8_chip_info = { 244 + .channels = ltc2632x8_channels, 245 + .num_channels = 2, 246 + .vref_mv = 4096, 247 + }; 248 + 249 + static const struct ltc2632_chip_info ltc2634l12_chip_info = { 250 + .channels = ltc2632x12_channels, 251 + .num_channels = 4, 252 + .vref_mv = 2500, 253 + }; 254 + 255 + static const struct ltc2632_chip_info ltc2634l10_chip_info = { 256 + .channels = ltc2632x10_channels, 257 + .num_channels = 4, 258 + .vref_mv = 2500, 259 + }; 260 + 261 + static const struct ltc2632_chip_info ltc2634l8_chip_info = { 262 + .channels = ltc2632x8_channels, 263 + .num_channels = 4, 264 + .vref_mv = 2500, 265 + }; 266 + 267 + static const struct ltc2632_chip_info ltc2634h12_chip_info = { 268 + .channels = ltc2632x12_channels, 269 + .num_channels = 4, 270 + .vref_mv = 4096, 271 + }; 272 + 273 + static const struct ltc2632_chip_info ltc2634h10_chip_info = { 274 + .channels = ltc2632x10_channels, 275 + .num_channels = 4, 276 + .vref_mv = 4096, 277 + }; 278 + 279 + static const struct ltc2632_chip_info ltc2634h8_chip_info = { 280 + .channels = ltc2632x8_channels, 281 + .num_channels = 4, 282 + .vref_mv = 4096, 283 + }; 284 + 285 + static const struct ltc2632_chip_info ltc2636l12_chip_info = { 286 + .channels = ltc2632x12_channels, 287 + .num_channels = 8, 288 + .vref_mv = 2500, 289 + }; 290 + 291 + static const struct ltc2632_chip_info ltc2636l10_chip_info = { 292 + .channels = ltc2632x10_channels, 293 + .num_channels = 8, 294 + .vref_mv = 2500, 295 + }; 296 + 297 + static const struct ltc2632_chip_info ltc2636l8_chip_info = { 298 + .channels = ltc2632x8_channels, 299 + .num_channels = 8, 300 + .vref_mv = 2500, 301 + }; 302 + 303 + static const struct ltc2632_chip_info ltc2636h12_chip_info = { 304 + .channels = ltc2632x12_channels, 305 + .num_channels = 8, 306 + .vref_mv = 4096, 307 + }; 308 + 309 + static const struct ltc2632_chip_info ltc2636h10_chip_info = { 310 + .channels = ltc2632x10_channels, 311 + .num_channels = 8, 312 + .vref_mv = 4096, 313 + }; 314 + 315 + static const struct ltc2632_chip_info ltc2636h8_chip_info = { 316 + .channels = ltc2632x8_channels, 317 + .num_channels = 8, 318 + .vref_mv = 4096, 283 319 }; 284 320 285 321 static int ltc2632_probe(struct spi_device *spi) ··· 348 354 } 349 355 350 356 static const struct spi_device_id ltc2632_id[] = { 351 - { "ltc2632-l12", (kernel_ulong_t)&ltc2632_chip_info_tbl[ID_LTC2632L12] }, 352 - { "ltc2632-l10", (kernel_ulong_t)&ltc2632_chip_info_tbl[ID_LTC2632L10] }, 353 - { "ltc2632-l8", (kernel_ulong_t)&ltc2632_chip_info_tbl[ID_LTC2632L8] }, 354 - { "ltc2632-h12", (kernel_ulong_t)&ltc2632_chip_info_tbl[ID_LTC2632H12] }, 355 - { "ltc2632-h10", (kernel_ulong_t)&ltc2632_chip_info_tbl[ID_LTC2632H10] }, 356 - { "ltc2632-h8", (kernel_ulong_t)&ltc2632_chip_info_tbl[ID_LTC2632H8] }, 357 - { "ltc2634-l12", (kernel_ulong_t)&ltc2632_chip_info_tbl[ID_LTC2634L12] }, 358 - { "ltc2634-l10", (kernel_ulong_t)&ltc2632_chip_info_tbl[ID_LTC2634L10] }, 359 - { "ltc2634-l8", (kernel_ulong_t)&ltc2632_chip_info_tbl[ID_LTC2634L8] }, 360 - { "ltc2634-h12", (kernel_ulong_t)&ltc2632_chip_info_tbl[ID_LTC2634H12] }, 361 - { "ltc2634-h10", (kernel_ulong_t)&ltc2632_chip_info_tbl[ID_LTC2634H10] }, 362 - { "ltc2634-h8", (kernel_ulong_t)&ltc2632_chip_info_tbl[ID_LTC2634H8] }, 363 - { "ltc2636-l12", (kernel_ulong_t)&ltc2632_chip_info_tbl[ID_LTC2636L12] }, 364 - { "ltc2636-l10", (kernel_ulong_t)&ltc2632_chip_info_tbl[ID_LTC2636L10] }, 365 - { "ltc2636-l8", (kernel_ulong_t)&ltc2632_chip_info_tbl[ID_LTC2636L8] }, 366 - { "ltc2636-h12", (kernel_ulong_t)&ltc2632_chip_info_tbl[ID_LTC2636H12] }, 367 - { "ltc2636-h10", (kernel_ulong_t)&ltc2632_chip_info_tbl[ID_LTC2636H10] }, 368 - { "ltc2636-h8", (kernel_ulong_t)&ltc2632_chip_info_tbl[ID_LTC2636H8] }, 357 + { "ltc2632-l12", (kernel_ulong_t)&ltc2632l12_chip_info }, 358 + { "ltc2632-l10", (kernel_ulong_t)&ltc2632l10_chip_info }, 359 + { "ltc2632-l8", (kernel_ulong_t)&ltc2632l8_chip_info }, 360 + { "ltc2632-h12", (kernel_ulong_t)&ltc2632h12_chip_info }, 361 + { "ltc2632-h10", (kernel_ulong_t)&ltc2632h10_chip_info }, 362 + { "ltc2632-h8", (kernel_ulong_t)&ltc2632h8_chip_info }, 363 + { "ltc2634-l12", (kernel_ulong_t)&ltc2634l12_chip_info }, 364 + { "ltc2634-l10", (kernel_ulong_t)&ltc2634l10_chip_info }, 365 + { "ltc2634-l8", (kernel_ulong_t)&ltc2634l8_chip_info }, 366 + { "ltc2634-h12", (kernel_ulong_t)&ltc2634h12_chip_info }, 367 + { "ltc2634-h10", (kernel_ulong_t)&ltc2634h10_chip_info }, 368 + { "ltc2634-h8", (kernel_ulong_t)&ltc2634h8_chip_info }, 369 + { "ltc2636-l12", (kernel_ulong_t)&ltc2636l12_chip_info }, 370 + { "ltc2636-l10", (kernel_ulong_t)&ltc2636l10_chip_info }, 371 + { "ltc2636-l8", (kernel_ulong_t)&ltc2636l8_chip_info }, 372 + { "ltc2636-h12", (kernel_ulong_t)&ltc2636h12_chip_info }, 373 + { "ltc2636-h10", (kernel_ulong_t)&ltc2636h10_chip_info }, 374 + { "ltc2636-h8", (kernel_ulong_t)&ltc2636h8_chip_info }, 369 375 { } 370 376 }; 371 377 MODULE_DEVICE_TABLE(spi, ltc2632_id); 372 378 373 379 static const struct of_device_id ltc2632_of_match[] = { 374 - { 375 - .compatible = "lltc,ltc2632-l12", 376 - .data = &ltc2632_chip_info_tbl[ID_LTC2632L12] 377 - }, { 378 - .compatible = "lltc,ltc2632-l10", 379 - .data = &ltc2632_chip_info_tbl[ID_LTC2632L10] 380 - }, { 381 - .compatible = "lltc,ltc2632-l8", 382 - .data = &ltc2632_chip_info_tbl[ID_LTC2632L8] 383 - }, { 384 - .compatible = "lltc,ltc2632-h12", 385 - .data = &ltc2632_chip_info_tbl[ID_LTC2632H12] 386 - }, { 387 - .compatible = "lltc,ltc2632-h10", 388 - .data = &ltc2632_chip_info_tbl[ID_LTC2632H10] 389 - }, { 390 - .compatible = "lltc,ltc2632-h8", 391 - .data = &ltc2632_chip_info_tbl[ID_LTC2632H8] 392 - }, { 393 - .compatible = "lltc,ltc2634-l12", 394 - .data = &ltc2632_chip_info_tbl[ID_LTC2634L12] 395 - }, { 396 - .compatible = "lltc,ltc2634-l10", 397 - .data = &ltc2632_chip_info_tbl[ID_LTC2634L10] 398 - }, { 399 - .compatible = "lltc,ltc2634-l8", 400 - .data = &ltc2632_chip_info_tbl[ID_LTC2634L8] 401 - }, { 402 - .compatible = "lltc,ltc2634-h12", 403 - .data = &ltc2632_chip_info_tbl[ID_LTC2634H12] 404 - }, { 405 - .compatible = "lltc,ltc2634-h10", 406 - .data = &ltc2632_chip_info_tbl[ID_LTC2634H10] 407 - }, { 408 - .compatible = "lltc,ltc2634-h8", 409 - .data = &ltc2632_chip_info_tbl[ID_LTC2634H8] 410 - }, { 411 - .compatible = "lltc,ltc2636-l12", 412 - .data = &ltc2632_chip_info_tbl[ID_LTC2636L12] 413 - }, { 414 - .compatible = "lltc,ltc2636-l10", 415 - .data = &ltc2632_chip_info_tbl[ID_LTC2636L10] 416 - }, { 417 - .compatible = "lltc,ltc2636-l8", 418 - .data = &ltc2632_chip_info_tbl[ID_LTC2636L8] 419 - }, { 420 - .compatible = "lltc,ltc2636-h12", 421 - .data = &ltc2632_chip_info_tbl[ID_LTC2636H12] 422 - }, { 423 - .compatible = "lltc,ltc2636-h10", 424 - .data = &ltc2632_chip_info_tbl[ID_LTC2636H10] 425 - }, { 426 - .compatible = "lltc,ltc2636-h8", 427 - .data = &ltc2632_chip_info_tbl[ID_LTC2636H8] 428 - }, 380 + { .compatible = "lltc,ltc2632-l12", .data = &ltc2632l12_chip_info }, 381 + { .compatible = "lltc,ltc2632-l10", .data = &ltc2632l10_chip_info }, 382 + { .compatible = "lltc,ltc2632-l8", .data = &ltc2632l8_chip_info }, 383 + { .compatible = "lltc,ltc2632-h12", .data = &ltc2632h12_chip_info }, 384 + { .compatible = "lltc,ltc2632-h10", .data = &ltc2632h10_chip_info }, 385 + { .compatible = "lltc,ltc2632-h8", .data = &ltc2632h8_chip_info }, 386 + { .compatible = "lltc,ltc2634-l12", .data = &ltc2634l12_chip_info }, 387 + { .compatible = "lltc,ltc2634-l10", .data = &ltc2634l10_chip_info }, 388 + { .compatible = "lltc,ltc2634-l8", .data = &ltc2634l8_chip_info }, 389 + { .compatible = "lltc,ltc2634-h12", .data = &ltc2634h12_chip_info }, 390 + { .compatible = "lltc,ltc2634-h10", .data = &ltc2634h10_chip_info }, 391 + { .compatible = "lltc,ltc2634-h8", .data = &ltc2634h8_chip_info }, 392 + { .compatible = "lltc,ltc2636-l12", .data = &ltc2636l12_chip_info }, 393 + { .compatible = "lltc,ltc2636-l10", .data = &ltc2636l10_chip_info }, 394 + { .compatible = "lltc,ltc2636-l8", .data = &ltc2636l8_chip_info }, 395 + { .compatible = "lltc,ltc2636-h12", .data = &ltc2636h12_chip_info }, 396 + { .compatible = "lltc,ltc2636-h10", .data = &ltc2636h10_chip_info }, 397 + { .compatible = "lltc,ltc2636-h8", .data = &ltc2636h8_chip_info }, 429 398 { } 430 399 }; 431 400 MODULE_DEVICE_TABLE(of, ltc2632_of_match);