Commit d884da1a authored by Vaishnav M A's avatar Vaishnav M A Committed by Jonathan Cameron
Browse files

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: default avatarVaishnav M A <vaishnav@beagleboard.org>
Link: https://lore.kernel.org/r/20201018203552.GA816421@ubuntu


Signed-off-by: default avatarJonathan Cameron <Jonathan.Cameron@huawei.com>
parent 41a4b8f1
Loading
Loading
Loading
Loading
+9 −7
Original line number Original line Diff line number Diff line
@@ -12,6 +12,8 @@
 */
 */


#include <linux/module.h>
#include <linux/module.h>
#include <linux/mod_devicetable.h>
#include <linux/property.h>
#include <linux/i2c.h>
#include <linux/i2c.h>
#include <linux/interrupt.h>
#include <linux/interrupt.h>
#include <linux/irq.h>
#include <linux/irq.h>
@@ -703,7 +705,6 @@ static int tsl2563_probe(struct i2c_client *client,
	struct iio_dev *indio_dev;
	struct iio_dev *indio_dev;
	struct tsl2563_chip *chip;
	struct tsl2563_chip *chip;
	struct tsl2563_platform_data *pdata = client->dev.platform_data;
	struct tsl2563_platform_data *pdata = client->dev.platform_data;
	struct device_node *np = client->dev.of_node;
	int err = 0;
	int err = 0;
	u8 id = 0;
	u8 id = 0;


@@ -738,13 +739,14 @@ static int tsl2563_probe(struct i2c_client *client,
	chip->calib0 = tsl2563_calib_from_sysfs(CALIB_BASE_SYSFS);
	chip->calib0 = tsl2563_calib_from_sysfs(CALIB_BASE_SYSFS);
	chip->calib1 = tsl2563_calib_from_sysfs(CALIB_BASE_SYSFS);
	chip->calib1 = tsl2563_calib_from_sysfs(CALIB_BASE_SYSFS);


	if (pdata)
	if (pdata) {
		chip->cover_comp_gain = pdata->cover_comp_gain;
		chip->cover_comp_gain = pdata->cover_comp_gain;
	else if (np)
	} else {
		of_property_read_u32(np, "amstaos,cover-comp-gain",
		err = device_property_read_u32(&client->dev, "amstaos,cover-comp-gain",
					       &chip->cover_comp_gain);
					       &chip->cover_comp_gain);
	else
		if (err)
			chip->cover_comp_gain = 1;
			chip->cover_comp_gain = 1;
	}


	dev_info(&client->dev, "model %d, rev. %d\n", id >> 4, id & 0x0f);
	dev_info(&client->dev, "model %d, rev. %d\n", id >> 4, id & 0x0f);
	indio_dev->name = client->name;
	indio_dev->name = client->name;