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: amplifiers: hmc425a: use pointers in match table

Change the match table to use pointers instead of device ids.
Remove type from state as it is not used anymore.

Also make the chip_info structures const.

Signed-off-by: Dumitru Ceclan <mitrutzceclan@gmail.com>
Reviewed-by: Nuno Sa <nuno.sa@analog.com>
Link: https://lore.kernel.org/r/20240220153553.2432-4-mitrutzceclan@gmail.com
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>

authored by

Dumitru Ceclan and committed by
Jonathan Cameron
09ac57ac 2edb2257

+16 -15
+16 -15
drivers/iio/amplifiers/hmc425a.c
··· 41 41 42 42 struct hmc425a_state { 43 43 struct mutex lock; /* protect sensor state */ 44 - struct hmc425a_chip_info *chip_info; 44 + const struct hmc425a_chip_info *chip_info; 45 45 struct gpio_descs *gpios; 46 - enum hmc425a_type type; 47 46 u32 gain; 48 47 }; 49 48 50 49 static int gain_dB_to_code(struct hmc425a_state *st, int val, int val2, int *code) 51 50 { 52 - struct hmc425a_chip_info *inf = st->chip_info; 51 + const struct hmc425a_chip_info *inf = st->chip_info; 53 52 int gain; 54 53 55 54 if (val < 0) ··· 205 206 HMC425A_CHAN(0), 206 207 }; 207 208 208 - /* Match table for of_platform binding */ 209 - static const struct of_device_id hmc425a_of_match[] = { 210 - { .compatible = "adi,hmc425a", .data = (void *)ID_HMC425A }, 211 - { .compatible = "adi,hmc540s", .data = (void *)ID_HMC540S }, 212 - { .compatible = "adi,adrf5740", .data = (void *)ID_ADRF5740 }, 213 - {}, 214 - }; 215 - MODULE_DEVICE_TABLE(of, hmc425a_of_match); 216 - 217 - static struct hmc425a_chip_info hmc425a_chip_info_tbl[] = { 209 + static const struct hmc425a_chip_info hmc425a_chip_info_tbl[] = { 218 210 [ID_HMC425A] = { 219 211 .name = "hmc425a", 220 212 .channels = hmc425a_channels, ··· 252 262 return -ENOMEM; 253 263 254 264 st = iio_priv(indio_dev); 255 - st->type = (uintptr_t)device_get_match_data(&pdev->dev); 256 265 257 - st->chip_info = &hmc425a_chip_info_tbl[st->type]; 266 + st->chip_info = device_get_match_data(&pdev->dev); 258 267 indio_dev->num_channels = st->chip_info->num_channels; 259 268 indio_dev->channels = st->chip_info->channels; 260 269 indio_dev->name = st->chip_info->name; ··· 284 295 285 296 return devm_iio_device_register(&pdev->dev, indio_dev); 286 297 } 298 + 299 + /* Match table for of_platform binding */ 300 + static const struct of_device_id hmc425a_of_match[] = { 301 + { .compatible = "adi,hmc425a", 302 + .data = &hmc425a_chip_info_tbl[ID_HMC425A]}, 303 + { .compatible = "adi,hmc540s", 304 + .data = &hmc425a_chip_info_tbl[ID_HMC540S]}, 305 + { .compatible = "adi,adrf5740", 306 + .data = &hmc425a_chip_info_tbl[ID_ADRF5740]}, 307 + {} 308 + }; 309 + MODULE_DEVICE_TABLE(of, hmc425a_of_match); 287 310 288 311 static struct platform_driver hmc425a_driver = { 289 312 .driver = {