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

iio:light:tsl2563 use generic fw accessors

Replace of_property_read_u32() with device_property_read_u32(),
when reading the amstaos,cover-comp-gain.This opens up the
possibility of passing the properties during platform instantiation
of the device by a suitable populated struct property_entry.
Additionally, a minor change in logic is added to remove the
of_node present check.

Signed-off-by: Vaishnav M A <vaishnav@beagleboard.org>
Link: https://lore.kernel.org/r/20201018203552.GA816421@ubuntu
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>

authored by

Vaishnav M A and committed by
Jonathan Cameron
d884da1a 41a4b8f1

+9 -7
+9 -7
drivers/iio/light/tsl2563.c
··· 12 12 */ 13 13 14 14 #include <linux/module.h> 15 + #include <linux/mod_devicetable.h> 16 + #include <linux/property.h> 15 17 #include <linux/i2c.h> 16 18 #include <linux/interrupt.h> 17 19 #include <linux/irq.h> ··· 705 703 struct iio_dev *indio_dev; 706 704 struct tsl2563_chip *chip; 707 705 struct tsl2563_platform_data *pdata = client->dev.platform_data; 708 - struct device_node *np = client->dev.of_node; 709 706 int err = 0; 710 707 u8 id = 0; 711 708 ··· 739 738 chip->calib0 = tsl2563_calib_from_sysfs(CALIB_BASE_SYSFS); 740 739 chip->calib1 = tsl2563_calib_from_sysfs(CALIB_BASE_SYSFS); 741 740 742 - if (pdata) 741 + if (pdata) { 743 742 chip->cover_comp_gain = pdata->cover_comp_gain; 744 - else if (np) 745 - of_property_read_u32(np, "amstaos,cover-comp-gain", 746 - &chip->cover_comp_gain); 747 - else 748 - chip->cover_comp_gain = 1; 743 + } else { 744 + err = device_property_read_u32(&client->dev, "amstaos,cover-comp-gain", 745 + &chip->cover_comp_gain); 746 + if (err) 747 + chip->cover_comp_gain = 1; 748 + } 749 749 750 750 dev_info(&client->dev, "model %d, rev. %d\n", id >> 4, id & 0x0f); 751 751 indio_dev->name = client->name;