From: "Kryštof Černý" <cleverline1mc@gmail.com>
To: Krzysztof Kozlowski <krzk@kernel.org>
Cc: Rob Herring <robh@kernel.org>, Conor Dooley <conor+dt@kernel.org>,
Stefan Wahren <stefan.wahren@chargebyte.com>,
Ben Gardner <bgardner@wabtec.com>,
linux-kernel@vger.kernel.org, devicetree@vger.kernel.org
Subject: Re: [PATCH v2 1/3] w1: ds2482: Add regulator support
Date: Sun, 24 Nov 2024 11:22:00 +0100 [thread overview]
Message-ID: <c8f40177-1d81-4c8e-8319-e78623cded42@gmail.com> (raw)
In-Reply-To: <2ff7omfp752zdtzozcle5jn7nsyonsbqgjefrx5t4lncoer5bw@wb76uxg26ugg>
> On Fri, Nov 22, 2024 at 09:53:57AM +0100, Kryštof Černý wrote:
>> Adds a support for attaching a supply regulator.
>>
>> Signed-off-by: Kryštof Černý <cleverline1mc@gmail.com>
>> ---
>> drivers/w1/masters/ds2482.c | 21 +++++++++++++++++++++
>> 1 file changed, 21 insertions(+)
>>
>> diff --git a/drivers/w1/masters/ds2482.c b/drivers/w1/masters/ds2482.c
>> index a2ecbb863c57f38bffc8e3cd463db1940e603179..3fb35e92fc1587dc4e609c0061fa5057e0027a80 100644
>> --- a/drivers/w1/masters/ds2482.c
>> +++ b/drivers/w1/masters/ds2482.c
>> @@ -15,6 +15,7 @@
>> #include <linux/slab.h>
>> #include <linux/i2c.h>
>> #include <linux/delay.h>
>> +#include <linux/regulator/consumer.h>
>>
>> #include <linux/w1.h>
>>
>> @@ -117,6 +118,9 @@ struct ds2482_data {
>> u8 channel;
>> u8 read_prt; /* see DS2482_PTR_CODE_xxx */
>> u8 reg_config;
>> +
>> + /* reference to the optional regulator */
>
> Drop comment, obvious.
I will drop all the other comments, as they seem to have the same level
of "obviousness" as this one to me.
>
>> + struct regulator *vcc_reg;
>
> Missing indentation after type - see earlier lines.
struct will be removed with switching to devm_regulator_get_enable().
>
>> };
>>
>>
>> @@ -445,6 +449,7 @@ static int ds2482_probe(struct i2c_client *client)
>> int err = -ENODEV;
>> int temp1;
>> int idx;
>> + int ret;
>>
>> if (!i2c_check_functionality(client->adapter,
>> I2C_FUNC_SMBUS_WRITE_BYTE_DATA |
>> @@ -457,6 +462,18 @@ static int ds2482_probe(struct i2c_client *client)
>> goto exit;
>> }
>>
>> + /* Get the vcc regulator */
>> + data->vcc_reg = devm_regulator_get(&client->dev, "vcc");
>> + if (IS_ERR(data->vcc_reg))
>> + return PTR_ERR(data->vcc_reg);
>> +
>> + /* Enable the vcc regulator */
>> + ret = regulator_enable(data->vcc_reg);
>
> You wanted devm_regulator_get_enable().
>
> ... but your comment also suggests devm_regulator_get_enable_optional().
>
This is a good point, my implementation is based on observation of a few
other drivers and it's not needed in this case. This will reduce the
amount of changes.
I think my wording was not correct. By optionally I meant that most
hardware designs do not use a separate power supply regulator, so they
do not need to specify one, but the device needs power to function.
My current view is that it should not be optional after all, so I would
go with devm_regulator_get_enable(). Could you please tell me your view
on this?
>
> Best regards,
> Krzysztof
>
Thank you very much for the review,
Kryštof Černý
next prev parent reply other threads:[~2024-11-24 10:22 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-11-22 8:53 [PATCH v2 0/3] Add support for attaching a regulator to w1: ds2482 Kryštof Černý via B4 Relay
2024-11-22 8:53 ` [PATCH v2 1/3] w1: ds2482: Add regulator support Kryštof Černý via B4 Relay
2024-11-23 16:32 ` Krzysztof Kozlowski
2024-11-24 10:22 ` Kryštof Černý [this message]
2024-11-24 10:50 ` Krzysztof Kozlowski
2024-11-22 8:53 ` [PATCH v2 2/3] w1: ds2482: Fix datasheet URL Kryštof Černý via B4 Relay
2024-11-22 8:53 ` [PATCH v2 3/3] dt-bindings: w1: ds2482: Add vcc-supply property Kryštof Černý via B4 Relay
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=c8f40177-1d81-4c8e-8319-e78623cded42@gmail.com \
--to=cleverline1mc@gmail.com \
--cc=bgardner@wabtec.com \
--cc=conor+dt@kernel.org \
--cc=devicetree@vger.kernel.org \
--cc=krzk@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=robh@kernel.org \
--cc=stefan.wahren@chargebyte.com \
/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
all inboxes | Powered by JetHome®