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: frequency: adf4371: make use of spi_get_device_match_data()

To use spi_get_device_match_data(), add the chip_info structure to the
of_device_id table which is always a good thing to do.

While at it, added dedicated variables for each chip (instead of the
harder to maintain array) and added a new string variable for the part
name.

Signed-off-by: Nuno Sa <nuno.sa@analog.com>
Link: https://patch.msgid.link/20241009-dev-adf4371-minor-improv-v1-1-97f4f22ed941@analog.com
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>

authored by

Nuno Sa and committed by
Jonathan Cameron
f1a5d779 3eb27cf1

+20 -16
+20 -16
drivers/iio/frequency/adf4371.c
··· 150 150 }; 151 151 152 152 struct adf4371_chip_info { 153 + const char *name; 153 154 unsigned int num_channels; 154 155 const struct iio_chan_spec *channels; 155 156 }; ··· 445 444 ADF4371_CHANNEL(ADF4371_CH_RF32), 446 445 }; 447 446 448 - static const struct adf4371_chip_info adf4371_chip_info[] = { 449 - [ADF4371] = { 450 - .channels = adf4371_chan, 451 - .num_channels = 4, 452 - }, 453 - [ADF4372] = { 454 - .channels = adf4371_chan, 455 - .num_channels = 3, 456 - } 447 + static const struct adf4371_chip_info adf4371_chip_info = { 448 + .name = "adf4371", 449 + .channels = adf4371_chan, 450 + .num_channels = 4, 451 + }; 452 + 453 + static const struct adf4371_chip_info adf4372_chip_info = { 454 + .name = "adf4372", 455 + .channels = adf4371_chan, 456 + .num_channels = 3, 457 457 }; 458 458 459 459 static int adf4371_reg_access(struct iio_dev *indio_dev, ··· 544 542 545 543 static int adf4371_probe(struct spi_device *spi) 546 544 { 547 - const struct spi_device_id *id = spi_get_device_id(spi); 548 545 struct iio_dev *indio_dev; 549 546 struct adf4371_state *st; 550 547 struct regmap *regmap; ··· 566 565 st->regmap = regmap; 567 566 mutex_init(&st->lock); 568 567 569 - st->chip_info = &adf4371_chip_info[id->driver_data]; 570 - indio_dev->name = id->name; 568 + st->chip_info = spi_get_device_match_data(spi); 569 + if (!st->chip_info) 570 + return -ENODEV; 571 + 572 + indio_dev->name = st->chip_info->name; 571 573 indio_dev->info = &adf4371_info; 572 574 indio_dev->modes = INDIO_DIRECT_MODE; 573 575 indio_dev->channels = st->chip_info->channels; ··· 592 588 } 593 589 594 590 static const struct spi_device_id adf4371_id_table[] = { 595 - { "adf4371", ADF4371 }, 596 - { "adf4372", ADF4372 }, 591 + { "adf4371", (kernel_ulong_t)&adf4371_chip_info }, 592 + { "adf4372", (kernel_ulong_t)&adf4372_chip_info }, 597 593 {} 598 594 }; 599 595 MODULE_DEVICE_TABLE(spi, adf4371_id_table); 600 596 601 597 static const struct of_device_id adf4371_of_match[] = { 602 - { .compatible = "adi,adf4371" }, 603 - { .compatible = "adi,adf4372" }, 598 + { .compatible = "adi,adf4371", .data = &adf4371_chip_info }, 599 + { .compatible = "adi,adf4372", .data = &adf4372_chip_info}, 604 600 { }, 605 601 }; 606 602 MODULE_DEVICE_TABLE(of, adf4371_of_match);