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: temperature: ltc2983: explicitly set the name in chip_info

Getting the part name with 'spi_get_device_id(spi)->name' is not a very
good pattern. Hence, explicitly add the name in the struct chip_info and
use that instead.

Signed-off-by: Nuno Sa <nuno.sa@analog.com>
Link: https://lore.kernel.org/r/20240222-ltc2983-misc-improv-v1-4-cf7d4457e98c@analog.com
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>

authored by

Nuno Sa and committed by
Jonathan Cameron
5cad30ab dccdff35

+15 -5
+15 -5
drivers/iio/temperature/ltc2983.c
··· 207 207 container_of(_sensor, struct ltc2983_temp, sensor) 208 208 209 209 struct ltc2983_chip_info { 210 + const char *name; 210 211 unsigned int max_channels_nr; 211 212 bool has_temp; 212 213 bool has_eeprom; ··· 1606 1605 struct ltc2983_data *st; 1607 1606 struct iio_dev *indio_dev; 1608 1607 struct gpio_desc *gpio; 1609 - const char *name = spi_get_device_id(spi)->name; 1610 1608 int ret; 1611 1609 1612 1610 indio_dev = devm_iio_device_alloc(&spi->dev, sizeof(*st)); ··· 1655 1655 return ret; 1656 1656 1657 1657 ret = devm_request_irq(&spi->dev, spi->irq, ltc2983_irq_handler, 1658 - IRQF_TRIGGER_RISING, name, st); 1658 + IRQF_TRIGGER_RISING, st->info->name, st); 1659 1659 if (ret) { 1660 1660 dev_err(&spi->dev, "failed to request an irq, %d", ret); 1661 1661 return ret; ··· 1670 1670 return ret; 1671 1671 } 1672 1672 1673 - indio_dev->name = name; 1673 + indio_dev->name = st->info->name; 1674 1674 indio_dev->num_channels = st->iio_channels; 1675 1675 indio_dev->channels = st->iio_chan; 1676 1676 indio_dev->modes = INDIO_DIRECT_MODE; ··· 1701 1701 ltc2983_resume); 1702 1702 1703 1703 static const struct ltc2983_chip_info ltc2983_chip_info_data = { 1704 + .name = "ltc2983", 1704 1705 .max_channels_nr = 20, 1705 1706 }; 1706 1707 1707 1708 static const struct ltc2983_chip_info ltc2984_chip_info_data = { 1709 + .name = "ltc2984", 1708 1710 .max_channels_nr = 20, 1709 1711 .has_eeprom = true, 1710 1712 }; 1711 1713 1712 1714 static const struct ltc2983_chip_info ltc2986_chip_info_data = { 1715 + .name = "ltc2986", 1716 + .max_channels_nr = 10, 1717 + .has_temp = true, 1718 + .has_eeprom = true, 1719 + }; 1720 + 1721 + static const struct ltc2983_chip_info ltm2985_chip_info_data = { 1722 + .name = "ltm2985", 1713 1723 .max_channels_nr = 10, 1714 1724 .has_temp = true, 1715 1725 .has_eeprom = true, ··· 1729 1719 { "ltc2983", (kernel_ulong_t)&ltc2983_chip_info_data }, 1730 1720 { "ltc2984", (kernel_ulong_t)&ltc2984_chip_info_data }, 1731 1721 { "ltc2986", (kernel_ulong_t)&ltc2986_chip_info_data }, 1732 - { "ltm2985", (kernel_ulong_t)&ltc2986_chip_info_data }, 1722 + { "ltm2985", (kernel_ulong_t)&ltm2985_chip_info_data }, 1733 1723 {}, 1734 1724 }; 1735 1725 MODULE_DEVICE_TABLE(spi, ltc2983_id_table); ··· 1738 1728 { .compatible = "adi,ltc2983", .data = &ltc2983_chip_info_data }, 1739 1729 { .compatible = "adi,ltc2984", .data = &ltc2984_chip_info_data }, 1740 1730 { .compatible = "adi,ltc2986", .data = &ltc2986_chip_info_data }, 1741 - { .compatible = "adi,ltm2985", .data = &ltc2986_chip_info_data }, 1731 + { .compatible = "adi,ltm2985", .data = &ltm2985_chip_info_data }, 1742 1732 {}, 1743 1733 }; 1744 1734 MODULE_DEVICE_TABLE(of, ltc2983_of_match);