linux-mips.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Javier Carrasco <javier.carrasco.cruz@gmail.com>
To: "Markus Elfring" <Markus.Elfring@web.de>,
	"Chris Packham" <chris.packham@alliedtelesis.co.nz>,
	linux-i2c@vger.kernel.org, linux-pm@vger.kernel.org,
	linux-mips@vger.kernel.org, devicetree@vger.kernel.org,
	"Andi Shyti" <andi.shyti@kernel.org>,
	"Conor Dooley" <conor+dt@kernel.org>,
	"Krzysztof Kozlowski" <krzk+dt@kernel.org>,
	"Lee Jones" <lee@kernel.org>, "Rob Herring" <robh@kernel.org>,
	"Sebastian Reichel" <sre@kernel.org>,
	"Thomas Bogendörfer" <tsbogend@alpha.franken.de>
Cc: LKML <linux-kernel@vger.kernel.org>,
	linux-doc@vger.kernel.org, kernel-janitors@vger.kernel.org,
	Peter Zijlstra <peterz@infradead.org>
Subject: Re: [PATCH v5 6/6] i2c: Add driver for the RTL9300 I2C controller
Date: Mon, 30 Sep 2024 10:12:08 +0200	[thread overview]
Message-ID: <23641fc9-9cdb-4a6c-a1a7-a2b49e949c04@gmail.com> (raw)
In-Reply-To: <4eb3dbbb-d3fd-43f4-b90d-9ecc222a87f6@web.de>

On 30/09/2024 09:55, Markus Elfring wrote:
>>> …
>>>> +++ b/drivers/i2c/busses/i2c-rtl9300.c
>>>> @@ -0,0 +1,422 @@
>>> …
>>>> +static int rtl9300_i2c_smbus_xfer(struct i2c_adapter *adap, u16 addr, unsigned short flags,
>>>> +                  char read_write, u8 command, int size,
>>>> +                  union i2c_smbus_data *data)
>>>> +{
>>> …
>>>> +    mutex_lock(&i2c->lock);
>>>> +    if (chan->sda_pin != i2c->sda_pin) {
>>> …
>>>> +out_unlock:
>>>> +    mutex_unlock(&i2c->lock);
>>>> +
>>>> +    return ret;
>>>> +}
>>> …
>>>
>>> Under which circumstances would you become interested to apply a statement
>>> like “guard(mutex)(&i2c->lock);”?
>>> https://elixir.bootlin.com/linux/v6.11/source/include/linux/mutex.h#L196
>>
>> At this stage I don't what to change unless Andi insists that I do.
>>
>> I can't find much mention of using guard() on https://www.kernel.org/doc/html/latest/
> 
> Do you find any other information sources more encouraging?
> 
> 
>> but I can see enough examples (although notably none in drivers/i2c) that I _think_ I can see how I could use it.
> 
> See also (for example):
> Article “Linux Kernel Development - Automatic Cleanup”
> by Javier Carrasco Cruz
> 2024-06-17
> https://javiercarrascocruz.github.io/kernel-auto-cleanup-2#2-automatic-mutex-handling
> 
> Regards,
> Markus

My personal blog is definitely NOT an official or even reliable source
of information.

Thanks for referencing it, but please look for examples of guard() in
the kernel, because there are several examples for different kind of
mutexes. For example, IIO uses them widely. And they are really nice, so
I would recommend anyone using them whenever it makes sense.

Best regards,
Javier Carrasco

      reply	other threads:[~2024-09-30  8:12 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-09-25 21:58 [PATCH v5 0/6] RTL9300 support for reboot and i2c Chris Packham
2024-09-25 21:58 ` [PATCH v5 1/6] dt-bindings: reset: syscon-reboot: Add reg property Chris Packham
2024-09-26  6:34   ` Krzysztof Kozlowski
2024-09-25 21:58 ` [PATCH v5 2/6] power: reset: syscon-reboot: Accept " Chris Packham
2024-09-26  6:35   ` Krzysztof Kozlowski
2024-09-25 21:58 ` [PATCH v5 3/6] dt-bindings: mfd: Add Realtek RTL9300 switch peripherals Chris Packham
2024-09-26  6:36   ` Krzysztof Kozlowski
2024-09-26  7:45     ` Lee Jones
2024-09-26  7:47       ` Krzysztof Kozlowski
2024-09-25 21:58 ` [PATCH v5 4/6] mips: dts: realtek: Add syscon-reboot node Chris Packham
2024-09-26  6:36   ` Krzysztof Kozlowski
2024-09-25 21:58 ` [PATCH v5 5/6] mips: dts: realtek: Add I2C controllers Chris Packham
2024-09-26  6:37   ` Krzysztof Kozlowski
2024-09-26 20:52     ` Chris Packham
2024-09-26 20:58   ` [PATCH v5] fixup! i2c: Add driver for the RTL9300 I2C controller Chris Packham
2024-09-25 21:58 ` [PATCH v5 6/6] " Chris Packham
2024-09-29  2:41   ` kernel test robot
2024-09-29  8:45   ` Markus Elfring
2024-09-29 20:17     ` Chris Packham
2024-09-30  7:55       ` Markus Elfring
2024-09-30  8:12         ` Javier Carrasco [this message]

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=23641fc9-9cdb-4a6c-a1a7-a2b49e949c04@gmail.com \
    --to=javier.carrasco.cruz@gmail.com \
    --cc=Markus.Elfring@web.de \
    --cc=andi.shyti@kernel.org \
    --cc=chris.packham@alliedtelesis.co.nz \
    --cc=conor+dt@kernel.org \
    --cc=devicetree@vger.kernel.org \
    --cc=kernel-janitors@vger.kernel.org \
    --cc=krzk+dt@kernel.org \
    --cc=lee@kernel.org \
    --cc=linux-doc@vger.kernel.org \
    --cc=linux-i2c@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mips@vger.kernel.org \
    --cc=linux-pm@vger.kernel.org \
    --cc=peterz@infradead.org \
    --cc=robh@kernel.org \
    --cc=sre@kernel.org \
    --cc=tsbogend@alpha.franken.de \
    /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;
as well as URLs for NNTP newsgroup(s).