linux-i2c.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Thomas Richard <thomas.richard@bootlin.com>
To: Bartosz Golaszewski <brgl@bgdev.pl>
Cc: Lee Jones <lee@kernel.org>,
	Linus Walleij <linus.walleij@linaro.org>,
	Andi Shyti <andi.shyti@kernel.org>,
	Wim Van Sebroeck <wim@linux-watchdog.org>,
	Guenter Roeck <linux@roeck-us.net>,
	linux-kernel@vger.kernel.org, linux-gpio@vger.kernel.org,
	linux-i2c@vger.kernel.org, linux-watchdog@vger.kernel.org,
	thomas.petazzoni@bootlin.com, blake.vermeer@keysight.com
Subject: Re: [PATCH 2/5] gpio: Congatec Board Controller gpio driver
Date: Mon, 19 Aug 2024 18:11:27 +0200	[thread overview]
Message-ID: <34ba62f8-dc90-4a8a-914d-30df35d2956a@bootlin.com> (raw)
In-Reply-To: <CAMRc=MeC4q3BGxycxnOZCC8nD7p=8AO9rQasb5Gd4T1E+aKvHA@mail.gmail.com>

>> +static int cgbc_gpio_get(struct gpio_chip *chip, unsigned int offset)
>> +{
>> +       struct cgbc_gpio_data *gpio = gpiochip_get_data(chip);
>> +       struct cgbc_device_data *cgbc = gpio->cgbc;
>> +       int ret;
>> +       u8 val;
>> +
> 
> Can you use scoped_guard() here and elsewhere?

Hi Bartosz,

Thanks for the review.

For the next iteration I added scoped_guard() in cgbc_gpio_get(), and
guard() in cgbc_gpio_set(), cgbc_gpio_direction_input(), and
cgbc_gpio_direction_output().

> 
>> +       mutex_lock(&gpio->lock);
>> +
>> +       ret = cgbc_gpio_cmd(cgbc, CGBC_GPIO_CMD_GET, (offset > 7) ? 1 : 0, 0, &val);
>> +
>> +       mutex_unlock(&gpio->lock);
>> +
>> +       offset %= 8;
>> +
>> +       if (ret)
>> +               return ret;

...

>> +static int cgbc_gpio_probe(struct platform_device *pdev)
>> +{
>> +       struct device *dev = &pdev->dev;
>> +       struct cgbc_device_data *cgbc = dev_get_drvdata(dev->parent);
>> +       struct cgbc_gpio_data *gpio;
>> +       struct gpio_chip *chip;
>> +       int ret;
>> +
>> +       gpio = devm_kzalloc(dev, sizeof(*gpio), GFP_KERNEL);
>> +       if (!gpio)
>> +               return -ENOMEM;
>> +
>> +       gpio->cgbc = cgbc;
>> +
>> +       platform_set_drvdata(pdev, gpio);
>> +
>> +       chip = &gpio->chip;
>> +       chip->label = dev_name(&pdev->dev);
>> +       chip->owner = THIS_MODULE;
>> +       chip->parent = dev;
>> +       chip->base = -1;
>> +       chip->direction_input = cgbc_gpio_direction_input;
>> +       chip->direction_output = cgbc_gpio_direction_output;
>> +       chip->get_direction = cgbc_gpio_get_direction;
>> +       chip->get = cgbc_gpio_get;
>> +       chip->set = cgbc_gpio_set;
>> +       chip->ngpio = CGBC_GPIO_NGPIO;
>> +
>> +       mutex_init(&gpio->lock);
> 
> Please use devm_mutex_init() so that it gets cleaned up at exit. It's
> not strictly necessary but helps with lock debugging.

Fixed in the next iteration.

Regards,

Thomas

-- 
Thomas Richard, Bootlin
Embedded Linux and Kernel engineering
https://bootlin.com


  reply	other threads:[~2024-08-19 16:11 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-08-09 14:52 [PATCH 0/5] Congatec Board Controller drivers Thomas Richard
2024-08-09 14:52 ` [PATCH 1/5] mfd: add Congatec Board Controller mfd driver Thomas Richard
2024-08-22 10:38   ` Lee Jones
2024-09-10 15:41     ` Thomas Richard
2024-09-12 14:13       ` Lee Jones
2024-09-13  8:30         ` Thomas Richard
2024-09-17  8:09           ` Lee Jones
2024-08-09 14:52 ` [PATCH 2/5] gpio: Congatec Board Controller gpio driver Thomas Richard
2024-08-14  9:16   ` Bartosz Golaszewski
2024-08-19 16:11     ` Thomas Richard [this message]
2024-08-09 14:52 ` [PATCH 3/5] i2c: Congatec Board Controller i2c bus driver Thomas Richard
2024-08-13 23:24   ` Andi Shyti
2024-09-06 13:29     ` Thomas Richard
2024-09-09 19:29       ` Andi Shyti
2024-08-09 14:52 ` [PATCH 4/5] watchdog: Congatec Board Controller watchdog timer driver Thomas Richard
2024-08-09 16:27   ` Guenter Roeck
2024-09-02 13:38     ` Thomas Richard
2024-08-09 14:52 ` [PATCH 5/5] MAINTAINERS: Add entry for Congatec Board Controller Thomas Richard
2024-08-13 23:26   ` Andi Shyti

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=34ba62f8-dc90-4a8a-914d-30df35d2956a@bootlin.com \
    --to=thomas.richard@bootlin.com \
    --cc=andi.shyti@kernel.org \
    --cc=blake.vermeer@keysight.com \
    --cc=brgl@bgdev.pl \
    --cc=lee@kernel.org \
    --cc=linus.walleij@linaro.org \
    --cc=linux-gpio@vger.kernel.org \
    --cc=linux-i2c@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-watchdog@vger.kernel.org \
    --cc=linux@roeck-us.net \
    --cc=thomas.petazzoni@bootlin.com \
    --cc=wim@linux-watchdog.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;
as well as URLs for NNTP newsgroup(s).