Linux IIO development
 help / color / mirror / Atom feed
From: Jonathan Cameron <jic23@kernel.org>
To: Arthur Becker via B4 Relay <devnull+arthur.becker.sentec.com@kernel.org>
Cc: arthur.becker@sentec.com, Lars-Peter Clausen <lars@metafoo.de>,
	Rob Herring <robh@kernel.org>,
	Krzysztof Kozlowski <krzk+dt@kernel.org>,
	Conor Dooley <conor+dt@kernel.org>,
	linux-kernel@vger.kernel.org, linux-iio@vger.kernel.org,
	devicetree@vger.kernel.org
Subject: Re: [PATCH v3 1/2] iio: light: driver for Vishay VEML6040
Date: Sun, 2 Jun 2024 14:22:05 +0100	[thread overview]
Message-ID: <20240602142205.520c2635@jic23-huawei> (raw)
In-Reply-To: <20240527-veml6040-v3-1-6f3bbfd42960@sentec.com>

On Mon, 27 May 2024 17:12:08 +0200
Arthur Becker via B4 Relay <devnull+arthur.becker.sentec.com@kernel.org> wrote:

> From: Arthur Becker <arthur.becker@sentec.com>
> 
> Implements driver for the Vishay VEML6040 rgbw light sensor.
> 
> Included functionality: setting the integration time and reading the raw
> values for the four channels
> 
> Not yet implemented: setting the measurements to 'Manual Force Mode' (Auto
> measurements off, and adding a measurement trigger)
> 
> Datasheet: https://www.vishay.com/docs/84276/veml6040.pdf
> Signed-off-by: Arthur Becker <arthur.becker@sentec.com>

Hi Arthur,

A few really trivial things inline. I'd have just tidied them up whilst
applying, but I think you are doing a v4 anyway to merge the bindings
so I'll leave the requested tweaks to you.

Jonathan


> diff --git a/drivers/iio/light/veml6040.c b/drivers/iio/light/veml6040.c
> new file mode 100644
> index 000000000000..2ea00d57c38b
> --- /dev/null
> +++ b/drivers/iio/light/veml6040.c



> +static int veml6040_probe(struct i2c_client *client)
> +{
> +	struct device *dev = &client->dev;
> +	struct veml6040_data *data;
> +	struct iio_dev *indio_dev;
> +	struct regmap *regmap;
> +	int ret;
> +
> +	if (!i2c_check_functionality(client->adapter, I2C_FUNC_I2C))
> +		return dev_err_probe(dev, -EOPNOTSUPP,
> +				     "I2C adapter doesn't support plain I2C\n");
> +
> +	indio_dev = devm_iio_device_alloc(dev, sizeof(*data));
> +	if (!indio_dev)
> +		return dev_err_probe(dev, -ENOMEM,
> +				     "IIO device allocation failed\n");
> +
> +	regmap = devm_regmap_init_i2c(client, &veml6040_regmap_config);
> +	if (IS_ERR(regmap))
> +		return dev_err_probe(dev, PTR_ERR(regmap),
> +				     "Regmap setup failed\n");
> +
> +	data = iio_priv(indio_dev);
> +	i2c_set_clientdata(client, indio_dev);

I don't think this is used. If it isn't, don't set it.

> +	data->client = client;
> +	data->regmap = regmap;
> +
> +	indio_dev->name = "veml6040";
> +	indio_dev->info = &veml6040_info;
> +	indio_dev->channels = veml6040_channels;
> +	indio_dev->num_channels = ARRAY_SIZE(veml6040_channels);
> +	indio_dev->modes = INDIO_DIRECT_MODE;
> +
> +	ret = devm_regulator_get_enable(dev, "vdd");
> +	if (ret)
> +		return ret;
> +
> +	int init_config =

Generally we are still sticking to traditional C rules so keep the
local variable definition at the top of the file.
The only common exception is when cleanup.h functionality is involved and
we want to ensure ordering by moving the variable definitions into the code.

> +		FIELD_PREP(VEML6040_CONF_IT_MSK, VEML6040_CONF_IT_40_MS) |
> +		FIELD_PREP(VEML6040_CONF_AF_MSK, 0) |
> +		FIELD_PREP(VEML6040_CONF_SD_MSK, 0);
> +
> +	ret = regmap_write(regmap, VEML6040_CONF_REG, init_config);
> +	if (ret)
> +		return dev_err_probe(dev, ret,
> +				     "Could not set initial config\n");
> +
> +	ret = devm_add_action_or_reset(dev, veml6040_shutdown_action, data);
> +	if (ret)
> +		return ret;
> +
> +	return devm_iio_device_register(dev, indio_dev);
> +}

> +
> +static struct i2c_driver veml6040_driver = {
> +	.probe = veml6040_probe,
> +	.id_table = veml6040_id_table,
> +	.driver = {
> +		.name = "veml6040",
> +		.of_match_table = veml6040_of_match,
> +	},
> +};
> +

Trivial: Common practice is no new line here as the macro is
very tightly coupled to the structure.

> +module_i2c_driver(veml6040_driver);
> +
> +MODULE_DESCRIPTION("veml6040 RGBW light sensor driver");
> +MODULE_AUTHOR("Arthur Becker <arthur.becker@sentec.com>");
> +MODULE_LICENSE("GPL");
> 


  reply	other threads:[~2024-06-02 13:22 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-05-27 15:12 [PATCH v3 0/2] Add driver for Vishay VEML6040 Arthur Becker via B4 Relay
2024-05-27 15:12 ` [PATCH v3 1/2] iio: light: " Arthur Becker via B4 Relay
2024-06-02 13:22   ` Jonathan Cameron [this message]
2024-06-03 12:18     ` Arthur Becker
2024-06-03 18:22       ` Jonathan Cameron
2024-05-27 15:12 ` [PATCH v3 2/2] dt-bindings: iio: light: add VEML6040 RGBW-LS bindings Arthur Becker via B4 Relay
2024-05-27 16:30   ` Conor Dooley
2024-05-28  7:15     ` [EXTERNAL]Re: " Arthur Becker
2024-05-27 16:31   ` Krzysztof Kozlowski
2024-05-28  7:23     ` [EXTERNAL]Re: " Arthur Becker
2024-05-28 10:05       ` Jonathan Cameron
2024-05-30  9:00         ` Arthur Becker
2024-05-28 14:39       ` Rob Herring
2024-05-30  9:00         ` Arthur Becker
2024-06-02 13:16       ` Jonathan Cameron
2024-06-03  8:23         ` Arthur Becker
2024-06-03  8:25           ` Jonathan Cameron

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20240602142205.520c2635@jic23-huawei \
    --to=jic23@kernel.org \
    --cc=arthur.becker@sentec.com \
    --cc=conor+dt@kernel.org \
    --cc=devicetree@vger.kernel.org \
    --cc=devnull+arthur.becker.sentec.com@kernel.org \
    --cc=krzk+dt@kernel.org \
    --cc=lars@metafoo.de \
    --cc=linux-iio@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=robh@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox