Linux GPIO subsystem development
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Bartosz Golaszewski" <bartosz.golaszewski@oss.qualcomm.com>
Cc: linux-gpio@vger.kernel.org
Subject: Re: [PATCH RFC] gpio: sim: access sysfs attributes as const
Date: Fri, 16 Oct 2026 08:19:13 +0000	[thread overview]
Message-ID: <sashiko-outbox-174010@kernel.org> (raw)
In-Reply-To: <20261016-gpio-sim-const-sysfs-attr-v1-1-5d2f832890d6@oss.qualcomm.com>

Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [Low] gpio-sim: incomplete sysfs attribute constification
--

commit 055dde35eca9fff8d54ca501f4fca6d98889dfd8
Author: Bartosz Golaszewski <bartosz.golaszewski@oss.qualcomm.com>

gpio: sim: access sysfs attributes as const

Use the const variant of constainer_of() to access struct
gpio_sim_attribute which wraps the dynamically allocated sysfs
attributes for value and pull of simulated GPIO lines in line with the
currently preferred approach.

> diff --git a/drivers/gpio/gpio-sim.c b/drivers/gpio/gpio-sim.c
> index 0c73bec042670..e0ae586cd08d8 100644
> --- a/drivers/gpio/gpio-sim.c
> +++ b/drivers/gpio/gpio-sim.c
> @@ -59,10 +59,10 @@ struct gpio_sim_attribute {
>  	unsigned int offset;
>  };
>  
> -static struct gpio_sim_attribute *
> +static const struct gpio_sim_attribute *
>  to_gpio_sim_attr(struct device_attribute *dev_attr)

[Severity: Low]
Does this function signature need to be updated to take a const
struct device_attribute *dev_attr?

Since dev_attr is still non-const here, the container_of_const macro will
evaluate its non-const branch, resulting in a non-const pointer that gets
implicitly cast to const by the return statement. This makes the generic type
selection of container_of_const largely redundant.

>  {
> -	return container_of(dev_attr, struct gpio_sim_attribute, dev_attr);
> +	return container_of_const(dev_attr, struct gpio_sim_attribute, dev_attr);
>  }

[ ... ]

> @@ -272,7 +272,7 @@ static void gpio_sim_dbg_show(struct seq_file *seq, struct gpio_chip *gc)
>  static ssize_t gpio_sim_sysfs_val_show(struct device *dev,
>  				       struct device_attribute *attr, char *buf)

[Severity: Low]
Should these sysfs callback signatures be updated to accept a const struct
device_attribute *attr?

The callbacks still accept a non-const attr parameter, meaning the refactoring
to const attributes is incomplete.

For a full migration, the callback signatures should accept const struct
device_attribute *attr and be assigned to the appropriate show_const /
store_const function pointers in the attribute definition.

>  {
> -	struct gpio_sim_attribute *line_attr = to_gpio_sim_attr(attr);
> +	const struct gpio_sim_attribute *line_attr = to_gpio_sim_attr(attr);
>  	struct gpio_sim_chip *chip = dev_get_drvdata(dev);
>  	int val;

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20261016-gpio-sim-const-sysfs-attr-v1-1-5d2f832890d6@oss.qualcomm.com?part=1

  reply	other threads:[~2026-10-16  8:19 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-10-16  8:13 [PATCH RFC] gpio: sim: access sysfs attributes as const Bartosz Golaszewski
2026-10-16  8:19 ` sashiko-bot [this message]
2026-10-16  8:54   ` Bartosz Golaszewski
2026-10-16  9:07 ` Thomas Weißschuh

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=sashiko-outbox-174010@kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=bartosz.golaszewski@oss.qualcomm.com \
    --cc=linux-gpio@vger.kernel.org \
    --cc=sashiko-reviews@lists.linux.dev \
    /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