linux-gpio.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
To: Bartosz Golaszewski <brgl@bgdev.pl>
Cc: Kent Gibson <warthog618@gmail.com>,
	Linus Walleij <linus.walleij@linaro.org>,
	Shuah Khan <shuah@kernel.org>,
	Geert Uytterhoeven <geert@linux-m68k.org>,
	Viresh Kumar <viresh.kumar@linaro.org>,
	linux-gpio@vger.kernel.org, linux-kernel@vger.kernel.org,
	linux-kselftest@vger.kernel.org
Subject: Re: [PATCH v13 4/7] gpio: sim: new testing module
Date: Tue, 7 Dec 2021 15:58:18 +0200	[thread overview]
Message-ID: <Ya9oehdM7nCq1oPd@smile.fi.intel.com> (raw)
In-Reply-To: <20211207093412.27833-5-brgl@bgdev.pl>

On Tue, Dec 07, 2021 at 10:34:09AM +0100, Bartosz Golaszewski wrote:
> Implement a new, modern GPIO testing module controlled by configfs
> attributes instead of module parameters. The goal of this driver is
> to provide a replacement for gpio-mockup that will be easily extensible
> with new features and doesn't require reloading the module to change
> the setup.

A couple of nit-picks, you may fix without resend.

...

> +static const char *const gpio_sim_sysfs_pull_strings[] = {
> +	[0]	= "pull-down",
> +	[1]	= "pull-up"

+ Comma

> +};
> +
> +static ssize_t gpio_sim_sysfs_pull_show(struct device *dev,
> +					struct device_attribute *attr,
> +					char *buf)
> +{
> +	struct gpio_sim_attribute *line_attr = to_gpio_sim_attr(attr);
> +	struct gpio_sim_chip *chip = dev_get_drvdata(dev);
> +	int pull;
> +
> +	mutex_lock(&chip->lock);
> +	pull = !!test_bit(line_attr->offset, chip->pull_map);
> +	mutex_unlock(&chip->lock);
> +
> +	return sysfs_emit(buf, "%s\n", gpio_sim_sysfs_pull_strings[pull]);
> +}
> +
> +static ssize_t gpio_sim_sysfs_pull_store(struct device *dev,
> +					 struct device_attribute *attr,
> +					 const char *buf, size_t len)
> +{
> +	struct gpio_sim_attribute *line_attr = to_gpio_sim_attr(attr);
> +	struct gpio_sim_chip *chip = dev_get_drvdata(dev);
> +	int ret, pull;
> +
> +	pull = sysfs_match_string(gpio_sim_sysfs_pull_strings, buf);
> +	if (pull < 0)

> +		return -EINVAL;

	return pull;

> +
> +	ret = gpio_sim_apply_pull(chip, line_attr->offset, pull);
> +	if (ret)
> +		return ret;
> +
> +	return len;
> +}

-- 
With Best Regards,
Andy Shevchenko



  reply	other threads:[~2021-12-07 13:59 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-12-07  9:34 [PATCH v13 0/7] gpio-sim: configfs-based GPIO simulator Bartosz Golaszewski
2021-12-07  9:34 ` [PATCH v13 1/7] gpiolib: provide gpiod_remove_hogs() Bartosz Golaszewski
2021-12-07  9:34 ` [PATCH v13 2/7] gpiolib: allow to specify the firmware node in struct gpio_chip Bartosz Golaszewski
2021-12-07 12:24   ` Andy Shevchenko
2021-12-07  9:34 ` [PATCH v13 3/7] gpiolib: of: make fwnode take precedence " Bartosz Golaszewski
2021-12-07 12:24   ` Andy Shevchenko
2021-12-07  9:34 ` [PATCH v13 4/7] gpio: sim: new testing module Bartosz Golaszewski
2021-12-07 13:58   ` Andy Shevchenko [this message]
2021-12-07  9:34 ` [PATCH v13 5/7] selftests: gpio: provide a helper for reading chip info Bartosz Golaszewski
2021-12-07  9:34 ` [PATCH v13 6/7] selftests: gpio: add a helper for reading GPIO line names Bartosz Golaszewski
2021-12-07  9:34 ` [PATCH v13 7/7] selftests: gpio: add test cases for gpio-sim Bartosz Golaszewski
2021-12-09  0:54 ` [PATCH v13 0/7] gpio-sim: configfs-based GPIO simulator Linus Walleij
2021-12-10 19:08   ` Bartosz Golaszewski
2021-12-13 13:01     ` Bartosz Golaszewski

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=Ya9oehdM7nCq1oPd@smile.fi.intel.com \
    --to=andriy.shevchenko@linux.intel.com \
    --cc=brgl@bgdev.pl \
    --cc=geert@linux-m68k.org \
    --cc=linus.walleij@linaro.org \
    --cc=linux-gpio@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-kselftest@vger.kernel.org \
    --cc=shuah@kernel.org \
    --cc=viresh.kumar@linaro.org \
    --cc=warthog618@gmail.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;
as well as URLs for NNTP newsgroup(s).