Commit cb26d236 authored by Jonathan Cameron's avatar Jonathan Cameron
Browse files

iio:chemical:sgp30: Use local variable dev to simplify code



This cleans up the code at bit, but is primarily here as a precusor
to the next patch. I've only done this for the two functions
which use the dev pointer repeatedly.

Signed-off-by: default avatarJonathan Cameron <Jonathan.Cameron@huawei.com>
Reviewed-by: default avatarAndy Shevchenko <andy.shevchenko@gmail.com>
Cc: Andreas Brauchli <andreas.brauchli@sensirion.com>
Link: https://lore.kernel.org/r/20200910173242.621168-27-jic23@kernel.org
parent a867e898
Loading
Loading
Loading
Loading
+10 −10
Original line number Diff line number Diff line
@@ -409,6 +409,7 @@ static int sgp_read_raw(struct iio_dev *indio_dev,
static int sgp_check_compat(struct sgp_data *data,
			    unsigned int product_id)
{
	struct device *dev = &data->client->dev;
	const struct sgp_version *supported_versions;
	u16 ix, num_fs;
	u16 product, generation, major, minor;
@@ -416,21 +417,20 @@ static int sgp_check_compat(struct sgp_data *data,
	/* driver does not match product */
	generation = SGP_VERS_GEN(data);
	if (generation != 0) {
		dev_err(&data->client->dev,
		dev_err(dev,
			"incompatible product generation %d != 0", generation);
		return -ENODEV;
	}

	product = SGP_VERS_PRODUCT(data);
	if (product != product_id) {
		dev_err(&data->client->dev,
			"sensor reports a different product: 0x%04hx\n",
		dev_err(dev, "sensor reports a different product: 0x%04hx\n",
			product);
		return -ENODEV;
	}

	if (SGP_VERS_RESERVED(data))
		dev_warn(&data->client->dev, "reserved bit is set\n");
		dev_warn(dev, "reserved bit is set\n");

	/* engineering samples are not supported: no interface guarantees */
	if (SGP_VERS_ENG_BIT(data))
@@ -456,8 +456,7 @@ static int sgp_check_compat(struct sgp_data *data,
		    minor >= supported_versions[ix].minor)
			return 0;
	}
	dev_err(&data->client->dev, "unsupported sgp version: %d.%d\n",
		major, minor);
	dev_err(dev, "unsupported sgp version: %d.%d\n", major, minor);

	return -ENODEV;
}
@@ -499,17 +498,18 @@ static const struct of_device_id sgp_dt_ids[] = {
static int sgp_probe(struct i2c_client *client,
		     const struct i2c_device_id *id)
{
	struct device *dev = &client->dev;
	struct iio_dev *indio_dev;
	struct sgp_data *data;
	const struct of_device_id *of_id;
	unsigned long product_id;
	int ret;

	indio_dev = devm_iio_device_alloc(&client->dev, sizeof(*data));
	indio_dev = devm_iio_device_alloc(dev, sizeof(*data));
	if (!indio_dev)
		return -ENOMEM;

	of_id = of_match_device(sgp_dt_ids, &client->dev);
	of_id = of_match_device(sgp_dt_ids, dev);
	if (of_id)
		product_id = (unsigned long)of_id->data;
	else
@@ -541,9 +541,9 @@ static int sgp_probe(struct i2c_client *client,

	sgp_init(data);

	ret = devm_iio_device_register(&client->dev, indio_dev);
	ret = devm_iio_device_register(dev, indio_dev);
	if (ret) {
		dev_err(&client->dev, "failed to register iio device\n");
		dev_err(dev, "failed to register iio device\n");
		return ret;
	}