public inbox for u-boot@lists.denx.de
 help / color / mirror / Atom feed
From: Detlev Zundel <dzu@denx.de>
To: u-boot@lists.denx.de
Subject: [U-Boot] [RFC] gpio command: return value on write, additional actions
Date: Thu, 07 Jul 2011 12:15:12 +0200	[thread overview]
Message-ID: <m2oc16jt1r.fsf@ohwell.denx.de> (raw)
In-Reply-To: <20110706103600.9EBFF1579E11@gemini.denx.de> (Wolfgang Denk's message of "Wed, 06 Jul 2011 12:36:00 +0200")

Hi Wolfgang,

> Dear Detlev Zundel,
>
> In message <m2aacrlsen.fsf@ohwell.denx.de> you wrote:
>> 
>> > I'd say clear/set/toggle are changeable, don't see any legit
>> > return-value-usage here. For 100% backward compatibility, one could
>> > leave them as they are and use 0|1 as new actions with return 0, as
>> > proposed.
>
> Hm... I think it would be beneficial to bee able to get information
> about the current settings. For "clear" and "set" the result is known,
> but for "toggle" it would be helpful if we returned the current port
> state.  Eventually we should add a "test" command (or "read" ?) that
> returns the current setting?

In general the "current state" actually are three things:

1. Port Mode: Disabled (i.e. not connected to an external pin), Input,
   Output
2. Port output value
3. (Actually read-in) input value

The current commands mix these aspects, i.e. they implicitely change the
port mode.  Differentiating between 2 and 3 will not always be possible
but is - I've seen that on e.g. an i.mx31.

>> > So these variants:
>> >   gpio clear|0 => set to output, write 0, return success
>> >   gpio set|1   => set to output, write 1, return success
>> >   gpio toggle  => (set to output), toggle output, return success
>> >   gpio input   => set to input, return pin value
>> >   gpio value   => return current pin/latch/whatever value
>> 
>> I'd propose to fix the commands to be sensible now.  Actually I believe
>> that they should not be in heavy use "in the wild" and so we should take
>> the opportunity and declare the current behaviour as buggy and fix it.
>> Rather now than later ;)
>
> Agreed.
>
>> Actually I would expect the "output" commands to return true when they
>> were able to do what was requestes from them, i.e. drive the requested
>> value to the output.  I guess this cannot be done in the general case,
>> but for a "weak output" that can be read back, this would be the most
>> sensible thing to do.
>
> For consistency I would prefer to have all commands return the same
> type of information, i. e. either an error status (like we do with all
> other commands - any result values would then have to be passed as
> environment settings), or we return the current port state (also for
> the "output" commands -  see my comments for "toggle").

Actually I would prefer to return an error status for all cases and
return "valuable information" in the environment so we can easily use it
subsequently.  As we do not have a back-tick operator in the shell, I
believe that return codes are only useful as error codes.

Cheers
  Detlev

-- 
``The number of UNIX installations has grown to 10,
with more expected.''     Unix Programmers Manual -- 1972
The number of UNIX variants has grown to dozens,
with more expected.                               -- 2001
--
DENX Software Engineering GmbH,      MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich,  Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-40 Fax: (+49)-8142-66989-80 Email: dzu at denx.de

  reply	other threads:[~2011-07-07 10:15 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-07-05 16:59 [U-Boot] [RFC] gpio command: return value on write, additional actions Andreas Pretzsch
2011-07-05 17:44 ` Mike Frysinger
2011-07-05 19:15   ` Andreas Pretzsch
2011-07-05 19:33     ` Mike Frysinger
2011-07-06  8:33     ` Detlev Zundel
2011-07-06 10:36       ` Wolfgang Denk
2011-07-07 10:15         ` Detlev Zundel [this message]
2011-07-20 18:22           ` Andreas Pretzsch
2011-07-14 20:07         ` Mike Frysinger
2011-07-15  7:39           ` Detlev Zundel
2011-07-18 18:08             ` Mike Frysinger

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=m2oc16jt1r.fsf@ohwell.denx.de \
    --to=dzu@denx.de \
    --cc=u-boot@lists.denx.de \
    /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