All of lore.kernel.org
 help / color / mirror / Atom feed
From: Marc Kleine-Budde <mkl@pengutronix.de>
To: Sascha Hauer <s.hauer@pengutronix.de>
Cc: barebox@lists.infradead.org
Subject: Re: [PATCH 3/5] timeout: factor out wait-for-key-press loop into separate file
Date: Wed, 22 Apr 2015 09:49:53 +0200	[thread overview]
Message-ID: <553752A1.8070701@pengutronix.de> (raw)
In-Reply-To: <20150420111302.GN6325@pengutronix.de>


[-- Attachment #1.1: Type: text/plain, Size: 2090 bytes --]

On 04/20/2015 01:13 PM, Sascha Hauer wrote:
> On Mon, Apr 20, 2015 at 10:43:37AM +0200, Marc Kleine-Budde wrote:
>> This patch factors out the wait-for-key-press loop from the shell command
>> "timeout" into a sparate file, so that it can be used from C, too.
>>
>> Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
>> ---
>>  commands/Kconfig         |  1 +
>>  commands/timeout.c       | 62 ++++++++++-----------------------------------
>>  common/Kconfig           |  3 +++
>>  common/Makefile          |  1 +
>>  common/simple_timeout.c  | 66 ++++++++++++++++++++++++++++++++++++++++++++++++
>>  include/simple_timeout.h | 11 ++++++++
>>  6 files changed, 95 insertions(+), 49 deletions(-)
>>  create mode 100644 common/simple_timeout.c
>>  create mode 100644 include/simple_timeout.h
>>
>> diff --git a/commands/Kconfig b/commands/Kconfig
>> index 847ff76d1d8b..1c9083381fac 100644
>> --- a/commands/Kconfig
>> +++ b/commands/Kconfig
>> @@ -1487,6 +1487,7 @@ config CMD_READLINE
>>  config CMD_TIMEOUT
>>  	tristate
>>  	prompt "timeout"
>> +	select SIMPLE_TIMEOUT
> 
> Since the linker throws away unused functions anyway I think we don't
> need an option for this.
> 
>> +#include <clock.h>
>> +#include <command.h>
>> +#include <errno.h>
>> +#include <simple_timeout.h>
>> +#include <stdio.h>
>> +
>> +int is_simple_timeout(int timeout_s, unsigned flags, char *out_key)
> 
> I don't like the name very much since we already have a is_timeout
> function which does something completely different. Also is_xxx_timeout
> seems to imply that this function doesn't wait but only returns a
> status.
> 
> How about console_countdown() or similar?

What about the return value?

Return -EINTR + set out_key on interruption by user, return 0 otherwise?

Marc

-- 
Pengutronix e.K.                  | Marc Kleine-Budde           |
Industrial Linux Solutions        | Phone: +49-231-2826-924     |
Vertretung West/Dortmund          | Fax:   +49-5121-206917-5555 |
Amtsgericht Hildesheim, HRA 2686  | http://www.pengutronix.de   |


[-- Attachment #1.2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 801 bytes --]

[-- Attachment #2: Type: text/plain, Size: 149 bytes --]

_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

  reply	other threads:[~2015-04-22  7:50 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-04-20  8:43 [PATCH 1/5] command: timeout: remove unhandled '-t' option Marc Kleine-Budde
2015-04-20  8:43 ` [PATCH 2/5] command: timeout: add documentation for option '-v' Marc Kleine-Budde
2015-04-20  8:43 ` [PATCH 3/5] timeout: factor out wait-for-key-press loop into separate file Marc Kleine-Budde
2015-04-20 11:13   ` Sascha Hauer
2015-04-22  7:49     ` Marc Kleine-Budde [this message]
2015-04-22  8:23       ` Sascha Hauer
2015-04-22  8:27         ` Marc Kleine-Budde
2015-04-20  8:43 ` [PATCH 4/5] ubi: cdev: remove trailing newline from debug messages Marc Kleine-Budde
2015-04-20  8:43 ` [PATCH 5/5] of_path: of_find_path(): add possibility to return .bb device Marc Kleine-Budde

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=553752A1.8070701@pengutronix.de \
    --to=mkl@pengutronix.de \
    --cc=barebox@lists.infradead.org \
    --cc=s.hauer@pengutronix.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 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.