All of lore.kernel.org
 help / color / mirror / Atom feed
From: Haojian Zhuang <haojian.zhuang-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
To: Tony Lindgren <tony-4v6yS6AI5VpBDgjK7y7TUQ@public.gmane.org>
Cc: devicetree-discuss-uLR06cmDAlY/bJ5BZ2RsiQ@public.gmane.org,
	linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r@public.gmane.org
Subject: Re: [PATCH v2 2/9] pinctrl: single: support gpio request and free
Date: Mon, 29 Oct 2012 09:55:48 +0800	[thread overview]
Message-ID: <CAN1soZzb-un9MqVGVy8iEzT_8ag8zQyFO=deB7=VQG2K73oouw@mail.gmail.com> (raw)
In-Reply-To: <20121022213709.GL4730-4v6yS6AI5VpBDgjK7y7TUQ@public.gmane.org>

On Tue, Oct 23, 2012 at 5:37 AM, Tony Lindgren <tony-4v6yS6AI5VpBDgjK7y7TUQ@public.gmane.org> wrote:
> * Tony Lindgren <tony-4v6yS6AI5VpBDgjK7y7TUQ@public.gmane.org> [121022 13:29]:
>> * Haojian Zhuang <haojian.zhuang-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> [121022 09:11]:
>> > --- a/drivers/pinctrl/pinctrl-single.c
>> > +++ b/drivers/pinctrl/pinctrl-single.c
>> > @@ -28,8 +28,10 @@
>> >  #define DRIVER_NAME                        "pinctrl-single"
>> >  #define PCS_MUX_PINS_NAME          "pinctrl-single,pins"
>> >  #define PCS_MUX_BITS_NAME          "pinctrl-single,bits"
>> > +#define PCS_GPIO_FUNC_NAME         "pinctrl-single,gpio-func"
>>
>> I think we can now get rid of these defines, I initially added
>> them as we had a bit hard time finding a suitable name for the
>> driver. These are only used in one location, so let's not add
>> new ones here.
>>
>> >  static int pcs_request_gpio(struct pinctrl_dev *pctldev,
>> > -                   struct pinctrl_gpio_range *range, unsigned offset)
>> > +                       struct pinctrl_gpio_range *range, unsigned pin)
>> >  {
>> > -   return -ENOTSUPP;
>> > +   struct pcs_device *pcs = pinctrl_dev_get_drvdata(pctldev);
>> > +   struct pcs_gpio_range *gpio = NULL;
>> > +   int end, mux_bytes;
>> > +   unsigned data;
>> > +
>> > +   gpio = container_of(range, struct pcs_gpio_range, range);
>> > +   if (!gpio->func_en)
>> > +           return 0;
>> > +   end = range->pin_base + range->npins - 1;
>> > +   if (pin < range->pin_base || pin > end) {
>> > +           dev_err(pctldev->dev, "pin %d isn't in the range of "
>> > +                   "%d to %d\n", pin, range->pin_base, end);
>> > +           return -EINVAL;
>> > +   }
>> > +   mux_bytes = pcs->width / BITS_PER_BYTE;
>> > +   data = pcs_readl(pcs->base + pin * mux_bytes) & ~pcs->fmask;
>> > +   data |= gpio->gpio_func;
>> > +   pcs_writel(data, pcs->base + pin * mux_bytes);
>> > +   return 0;
>> >  }
>>
>> I think I already commented on this one.. Is this safe if you don't
>> have GPIOs configured? Or should you return -ENODEV in that case?
>
> Oops also you should not use pcs_readl/pcs_writel in the driver
> directly but use pcs_read instead as you can have register width other
> than 32-bits.
>

I think you're meaning pcs->read(). I'll use this interface.

WARNING: multiple messages have this Message-ID (diff)
From: haojian.zhuang@gmail.com (Haojian Zhuang)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH v2 2/9] pinctrl: single: support gpio request and free
Date: Mon, 29 Oct 2012 09:55:48 +0800	[thread overview]
Message-ID: <CAN1soZzb-un9MqVGVy8iEzT_8ag8zQyFO=deB7=VQG2K73oouw@mail.gmail.com> (raw)
In-Reply-To: <20121022213709.GL4730@atomide.com>

On Tue, Oct 23, 2012 at 5:37 AM, Tony Lindgren <tony@atomide.com> wrote:
> * Tony Lindgren <tony@atomide.com> [121022 13:29]:
>> * Haojian Zhuang <haojian.zhuang@gmail.com> [121022 09:11]:
>> > --- a/drivers/pinctrl/pinctrl-single.c
>> > +++ b/drivers/pinctrl/pinctrl-single.c
>> > @@ -28,8 +28,10 @@
>> >  #define DRIVER_NAME                        "pinctrl-single"
>> >  #define PCS_MUX_PINS_NAME          "pinctrl-single,pins"
>> >  #define PCS_MUX_BITS_NAME          "pinctrl-single,bits"
>> > +#define PCS_GPIO_FUNC_NAME         "pinctrl-single,gpio-func"
>>
>> I think we can now get rid of these defines, I initially added
>> them as we had a bit hard time finding a suitable name for the
>> driver. These are only used in one location, so let's not add
>> new ones here.
>>
>> >  static int pcs_request_gpio(struct pinctrl_dev *pctldev,
>> > -                   struct pinctrl_gpio_range *range, unsigned offset)
>> > +                       struct pinctrl_gpio_range *range, unsigned pin)
>> >  {
>> > -   return -ENOTSUPP;
>> > +   struct pcs_device *pcs = pinctrl_dev_get_drvdata(pctldev);
>> > +   struct pcs_gpio_range *gpio = NULL;
>> > +   int end, mux_bytes;
>> > +   unsigned data;
>> > +
>> > +   gpio = container_of(range, struct pcs_gpio_range, range);
>> > +   if (!gpio->func_en)
>> > +           return 0;
>> > +   end = range->pin_base + range->npins - 1;
>> > +   if (pin < range->pin_base || pin > end) {
>> > +           dev_err(pctldev->dev, "pin %d isn't in the range of "
>> > +                   "%d to %d\n", pin, range->pin_base, end);
>> > +           return -EINVAL;
>> > +   }
>> > +   mux_bytes = pcs->width / BITS_PER_BYTE;
>> > +   data = pcs_readl(pcs->base + pin * mux_bytes) & ~pcs->fmask;
>> > +   data |= gpio->gpio_func;
>> > +   pcs_writel(data, pcs->base + pin * mux_bytes);
>> > +   return 0;
>> >  }
>>
>> I think I already commented on this one.. Is this safe if you don't
>> have GPIOs configured? Or should you return -ENODEV in that case?
>
> Oops also you should not use pcs_readl/pcs_writel in the driver
> directly but use pcs_read instead as you can have register width other
> than 32-bits.
>

I think you're meaning pcs->read(). I'll use this interface.

  parent reply	other threads:[~2012-10-29  1:55 UTC|newest]

Thread overview: 46+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-10-22 16:08 [PATCH v2 0/9] support pinctrl single in arch pxa/mmp Haojian Zhuang
2012-10-22 16:08 ` Haojian Zhuang
     [not found] ` <1350922139-3693-1-git-send-email-haojian.zhuang-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2012-10-22 16:08   ` [PATCH v2 1/9] ARM: mmp: select pinctrl driver Haojian Zhuang
2012-10-22 16:08     ` Haojian Zhuang
     [not found]     ` <1350922139-3693-2-git-send-email-haojian.zhuang-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2012-10-23 10:05       ` Linus Walleij
2012-10-23 10:05         ` Linus Walleij
2012-10-22 16:08   ` [PATCH v2 2/9] pinctrl: single: support gpio request and free Haojian Zhuang
2012-10-22 16:08     ` Haojian Zhuang
     [not found]     ` <1350922139-3693-3-git-send-email-haojian.zhuang-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2012-10-22 20:28       ` Tony Lindgren
2012-10-22 20:28         ` Tony Lindgren
     [not found]         ` <20121022202805.GG4730-4v6yS6AI5VpBDgjK7y7TUQ@public.gmane.org>
2012-10-22 21:37           ` Tony Lindgren
2012-10-22 21:37             ` Tony Lindgren
     [not found]             ` <20121022213709.GL4730-4v6yS6AI5VpBDgjK7y7TUQ@public.gmane.org>
2012-10-29  1:55               ` Haojian Zhuang [this message]
2012-10-29  1:55                 ` Haojian Zhuang
2012-10-29  1:58           ` Haojian Zhuang
2012-10-29  1:58             ` Haojian Zhuang
2012-10-22 16:08   ` [PATCH v2 3/9] pinctrl: single: support pinconf generic Haojian Zhuang
2012-10-22 16:08     ` Haojian Zhuang
2012-10-22 16:08   ` [PATCH v2 4/9] ARM: dts: support pinctrl single in pxa910 Haojian Zhuang
2012-10-22 16:08     ` Haojian Zhuang
2012-10-22 16:08   ` [PATCH v2 5/9] document: devicetree: bind pinconf with pin-single Haojian Zhuang
2012-10-22 16:08     ` Haojian Zhuang
     [not found]     ` <1350922139-3693-6-git-send-email-haojian.zhuang-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2012-10-22 22:44       ` Stephen Warren
2012-10-22 22:44         ` Stephen Warren
     [not found]         ` <5085CC3F.30708-3lzwWm7+Weoh9ZMKESR00Q@public.gmane.org>
2012-10-31 16:58           ` Haojian Zhuang
2012-10-31 16:58             ` Haojian Zhuang
     [not found]             ` <CAN1soZy8xXGs8zEiZV0kV0dGVdXfZ9ogx83sFgPG76d0i8yH4A-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2012-10-31 22:26               ` Stephen Warren
2012-10-31 22:26                 ` Stephen Warren
     [not found]                 ` <5091A5AA.7000207-3lzwWm7+Weoh9ZMKESR00Q@public.gmane.org>
2012-10-31 22:51                   ` Haojian Zhuang
2012-10-31 22:51                     ` Haojian Zhuang
     [not found]                     ` <CAN1soZyc8Kox__yOER82Oe5OtaLJWYAoMzgWGhEonTfdf11MqQ-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2012-11-01  0:25                       ` Tony Lindgren
2012-11-01  0:25                         ` Tony Lindgren
2012-10-22 16:08   ` [PATCH v2 6/9] tty: pxa: configure pin Haojian Zhuang
2012-10-22 16:08     ` Haojian Zhuang
     [not found]     ` <1350922139-3693-7-git-send-email-haojian.zhuang-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2012-10-23 10:07       ` Linus Walleij
2012-10-23 10:07         ` Linus Walleij
2012-10-22 16:08   ` [PATCH v2 7/9] i2c: pxa: use devm_kzalloc Haojian Zhuang
2012-10-22 16:08     ` Haojian Zhuang
2012-10-22 16:08   ` [PATCH v2 8/9] i2c: pxa: configure pinmux Haojian Zhuang
2012-10-22 16:08     ` Haojian Zhuang
     [not found]     ` <1350922139-3693-9-git-send-email-haojian.zhuang-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2012-10-23 10:07       ` Linus Walleij
2012-10-23 10:07         ` Linus Walleij
2012-10-22 16:08   ` [PATCH v2 9/9] pinctrl: single: dump pinmux register value Haojian Zhuang
2012-10-22 16:08     ` Haojian Zhuang
     [not found]     ` <1350922139-3693-10-git-send-email-haojian.zhuang-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2012-10-22 22:27       ` Tony Lindgren
2012-10-22 22:27         ` Tony Lindgren

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='CAN1soZzb-un9MqVGVy8iEzT_8ag8zQyFO=deB7=VQG2K73oouw@mail.gmail.com' \
    --to=haojian.zhuang-re5jqeeqqe8avxtiumwx3w@public.gmane.org \
    --cc=devicetree-discuss-uLR06cmDAlY/bJ5BZ2RsiQ@public.gmane.org \
    --cc=linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r@public.gmane.org \
    --cc=tony-4v6yS6AI5VpBDgjK7y7TUQ@public.gmane.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.