[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <031c895d-4694-96c2-62bb-e43a49001cd9@wolfvision.net>
Date: Tue, 22 Nov 2022 08:39:14 +0100
From: Gerald Loacker <gerald.loacker@...fvision.net>
To: Andy Shevchenko <andriy.shevchenko@...ux.intel.com>
Cc: linux-iio@...r.kernel.org, devicetree@...r.kernel.org,
linux-kernel@...r.kernel.org, Jonathan Cameron <jic23@...nel.org>,
Lars-Peter Clausen <lars@...afoo.de>,
Rob Herring <robh+dt@...nel.org>,
Krzysztof Kozlowski <krzysztof.kozlowski+dt@...aro.org>,
Nikita Yushchenko <nikita.yoush@...entembedded.com>,
Jakob Hauser <jahau@...ketmail.com>,
Michael Riesch <michael.riesch@...fvision.net>
Subject: Re: [PATCH v2 2/2] iio: magnetometer: add ti tmag5273 driver
Am 21.11.2022 um 19:40 schrieb Andy Shevchenko:
> On Mon, Nov 21, 2022 at 06:24:18PM +0100, Gerald Loacker wrote:
>> Am 21.11.2022 um 15:04 schrieb Andy Shevchenko:
>>> On Mon, Nov 21, 2022 at 01:35:42PM +0100, Gerald Loacker wrote:
>
> ...
>
>>>> + if (!device_property_read_string(data->dev, "ti,angle-measurement",
>>>> + &angle_measurement)) {
>>>> + if (!strcmp(angle_measurement, "off"))
>>>> + data->angle_measurement = TMAG5273_ANGLE_EN_OFF;
>>>> + else if (!strcmp(angle_measurement, "x-y"))
>>>> + data->angle_measurement = TMAG5273_ANGLE_EN_X_Y;
>>>> + else if (!strcmp(angle_measurement, "y-z"))
>>>> + data->angle_measurement = TMAG5273_ANGLE_EN_Y_Z;
>>>> + else if (!strcmp(angle_measurement, "x-z"))
>>>> + data->angle_measurement = TMAG5273_ANGLE_EN_X_Z;
>>>> + else
>>>> + dev_warn(data->dev,
>>>> + "failed to read angle-measurement\n");
>>>
>>> Can't you use match_string()?
>>>
>>
>> Yes, I will use match_string().
>>
>>> And you actually can do a bit differently, can you?
>>>
>>> angle_measurement = "...default...";
>>> if (device_property_...)
>>> dev_warn(data->dev, "failed to read angle-measurement\n");
>>
>> I think we shouldn't warn here, as angle_measurement isn't a required
>> property. Besides that I will do it this way.
>>
>>> ret = match_string();
>>> if (ret < 0)
>>> dev_warn(data->dev, "invalid angle-measurement value\n");
>>> else
>>> data->angle_measurement = ret;
>>>
>>>> + }
>
> After looking into DT patch I think you can even use
> device_property_match_string(),
>
> ...
>
device_property_match_string() is searching only for one string, so here
match_string() you suggested before fits better.
Regards,
Gerald
Powered by blists - more mailing lists