linux-gpio.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Ian Pilcher <arequipeno@gmail.com>
To: Andy Shevchenko <andy.shevchenko@gmail.com>
Cc: "linux-gpio@vger.kernel.org" <linux-gpio@vger.kernel.org>
Subject: Re: gpiod_get() - How to get GPIO from chip & offset?
Date: Thu, 11 Aug 2022 13:22:55 -0500	[thread overview]
Message-ID: <a6aa8619-e620-929d-fd6e-8ecba2948a7b@gmail.com> (raw)
In-Reply-To: <CAHp75Vf5KsgJSM_dsLC9Gd012XWco=nrMS2Fzf_Ejz_9MnjxWQ@mail.gmail.com>

On 8/8/22 10:00, Andy Shevchenko wrote:
> On Mon, Aug 8, 2022 at 4:57 PM Andy Shevchenko
> <andy.shevchenko@gmail.com> wrote:
>> On Sun, Aug 7, 2022 at 4:57 PM Ian Pilcher <arequipeno@gmail.com> wrote:
>> Ah, looking into your driver code [1] I think you need to a) switch to
>> use existing GPIO driver, which is gpio-ich.c in your case and b) use
>> GPIO lookup tables, you may look at Simatech latest development on how
>> to achieve that. It uses some Intel chips and LEDs that are connected
>> to GPIOs.
> 
> Same for your I2C GPIO expander, why do you not use the kernel driver for it?!

That "board" module is ancient.  I originally wrote it when I installed
CentOS 6 (kernel 2.6) on my NAS.  Since then, I've only ever touched it
when something breaks - either for me or for one of a very small number
of other users.  In fact, I was running CentOS 7 on the NAS until last
week, when I decided it was finally time to move to a more modern OS.

>>> I know the offset of the GPIO on the chip, but I can't figure out how to
>>> use that.
>>
>> And you don't need to use GPIO offset, whatever it means. What you
>> need is to have a relative number of GPIO to the chip, so GPIO chip +
>> relative offset will uniquely give you the line.

I was using "offset" to refer to the relative number of the GPIO on the
chip, so we're talking about the same thing here.

>>> Ultimately, my goal is to set the direction of the GPIO from within a
>>> "board setup" module.

This turned out to be a bad idea.  It turns out to be easy to set the
GPIO direction from user space, so I'm doing it that way, regardless of
how elegant or inelegant it is.

>>> [1] https://github.com/ipilcher/n5550/blob/master/modules/n5550_board.c
>>
>> Why not try to upstream this?

Mainly because it's a super-niche use case that's never seemed worth the
trouble, as the vast majority of people just run the Thecus-provided OS.

> With the above additional remark I think you will learn a lot about
> Linux kernel programming if you try to upstream, even unsuccessfully

I'm sure that I would, possibly more than I want to.  :-)  (My goal is
not to become a kernel developer; I simply want the blinky lights on my
NAS to work.)

> (which I don't believe can happen if you listen to maintainers, e.g.
> PDx86 subsystem maintainer where your code belongs to).

Well, my own experience doesn't necessarily bear that out (see my
efforts to contribute the block device LED trigger), but point taken.

Again, thanks for the response!

-- 
========================================================================
Google                                      Where SkyNet meets Idiocracy
========================================================================

      reply	other threads:[~2022-08-11 18:23 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-08-07 14:55 gpiod_get() - How to get GPIO from chip & offset? Ian Pilcher
2022-08-08  1:54 ` Kent Gibson
2022-08-08 14:57 ` Andy Shevchenko
2022-08-08 15:00   ` Andy Shevchenko
2022-08-11 18:22     ` Ian Pilcher [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=a6aa8619-e620-929d-fd6e-8ecba2948a7b@gmail.com \
    --to=arequipeno@gmail.com \
    --cc=andy.shevchenko@gmail.com \
    --cc=linux-gpio@vger.kernel.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).