Re: [PATCH 7/8] hwmon: (lm90) read the channel's label from device-tree

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 20/05/2022 13:01, Slawomir Stepien wrote:

>>> +static int lm90_probe_channel_from_dt(struct i2c_client *client,
>>> +				      struct device_node *child,
>>> +				      struct lm90_data *data)
>>> +{
>>> +	u32 id;
>>> +	int err;
>>> +	struct device *dev = &client->dev;
>>> +
>>> +	err = of_property_read_u32(child, "reg", &id);
>>> +	if (err) {
>>> +		dev_err(dev, "missing reg property of %pOFn\n", child);
>>> +		return err;
>>> +	}
>>> +
>>> +	if (id >= MAX_CHANNELS) {
>>> +		dev_err(dev, "invalid reg %d in %pOFn\n", id, child);
>>> +		return -EINVAL;
>>> +	}
>>> +
>>> +	err = of_property_read_string(child, "label", &data->channel_label[id]);
>>> +	if (err == -ENODATA || err == -EILSEQ) {
>>> +		dev_err(dev, "invalid label in %pOFn\n", child);
>>
>> You did not make it a required property, so why failing?
> 
> But if you have it in device-tree, then at least inform the user that there is some problem with it.

Hm, true, the missing property would return EINVAL. Sounds good then.
x


Best regards,
Krzysztof



[Index of Archives]     [LM Sensors]     [Linux Sound]     [ALSA Users]     [ALSA Devel]     [Linux Audio Users]     [Linux Media]     [Kernel]     [Gimp]     [Yosemite News]     [Linux Media]

  Powered by Linux