From: Sascha Hauer <s.hauer@pengutronix.de>
To: Antony Pavlov <antonynpavlov@gmail.com>
Cc: barebox@lists.infradead.org
Subject: Re: [PATCH 3/5] sandbox: parse libftdi options
Date: Thu, 19 Oct 2017 13:52:25 +0200 [thread overview]
Message-ID: <20171019115225.ohwrhrx4sjitu64i@pengutronix.de> (raw)
In-Reply-To: <20171019145540.27c3a3b9752b836f97043e1c@gmail.com>
On Thu, Oct 19, 2017 at 02:55:40PM +0300, Antony Pavlov wrote:
> On Mon, 16 Oct 2017 16:06:18 +0200
> Sascha Hauer <s.hauer@pengutronix.de> wrote:
>
> > On Mon, Oct 16, 2017 at 05:10:11PM +0300, Antony Pavlov wrote:
> > > On Mon, 16 Oct 2017 10:21:58 +0200
> > > Sascha Hauer <s.hauer@pengutronix.de> wrote:
> > >
> > > > On Tue, Oct 10, 2017 at 03:26:29PM +0300, Antony Pavlov wrote:
> > > > > Signed-off-by: Antony Pavlov <antonynpavlov@gmail.com>
> > > > > ---
> > > > > arch/sandbox/Makefile | 2 +-
> > > > > arch/sandbox/os/common.c | 12 ++++++--
> > > > > arch/sandbox/os/ftdi.c | 79 +++++++++++++++++++++++++++++++++++++++++++++++-
> > > > > 3 files changed, 89 insertions(+), 4 deletions(-)
> > > > >
> > > > > diff --git a/arch/sandbox/os/ftdi.c b/arch/sandbox/os/ftdi.c
> > > > > index 34e9165787..e3e46ed12d 100644
> > > > > --- a/arch/sandbox/os/ftdi.c
> > > > > +++ b/arch/sandbox/os/ftdi.c
> > > > > @@ -20,6 +20,7 @@
> > > > > #include <unistd.h>
> > > > > #include <ftdi.h>
> > > > > #include <errno.h>
> > > > > +#include <string.h>
> > > > > #include <mach/linux.h>
> > > > >
> > > > > #define FTDI_VID 0x0403 /* Vendor Id */
> > > > > @@ -38,6 +39,8 @@ struct ft2232_bitbang {
> > > > >
> > > > > static struct ft2232_bitbang ftbb;
> > > > >
> > > > > +extern const char *libftdi_options;
> > > > > +
> > > > > static inline int ftdi_flush(struct ftdi_context *ftdi)
> > > > > {
> > > > > uint8_t buf[1];
> > > > > @@ -116,6 +119,67 @@ void barebox_libftdi1_gpio_set_value(struct ft2232_bitbang *ftbb,
> > > > > ftbb->odata &= ~BIT(off);
> > > > > }
> > > > >
> > > > > +/* This is a somewhat hacked function similar in some ways to strtok().
> > > > > + * It will look for needle with a subsequent '=' in haystack, return a copy of
> > > > > + * needle and remove everything from the first occurrence of needle to the next
> > > > > + * delimiter from haystack.
> > > > > + */
> > > > > +static char *extract_param(const char *const *haystack, const char *needle,
> > > > > + const char *delim)
> > > > > +{
> > > >
> > > > Parsing comma separated option lists is something we do more than once.
> > > > Right now we already have parseopt_b and parseopt_hu. Would be nice to
> > > > have this function alongside with the existing functions. Also
> > > > parseopt_* look simpler to follow, it may be worth adopting the code for
> > > > this function.
> > >
> > > At the moment the parseopt_* functions are in the fs/parseopt.c file.
> > > Adding the parseopt_ul() for parsing u32 option value in arch/sandbox/os/ftdi.c
> > > will lead to moving fs/parseopt.c file to common code, e.g. to lib/.
> > >
> > > Is it ok to add 'obj-y += parseopt.o' to the lib/Makefile file?
> >
> > obj-y should be fine. ATM fs/parseopt.c is always compiled aswell.
>
> Currently parseopt_hu() returns void and has no explicit flag for parsing error
> situation. I think that it is reasonable to use explicit error flag in new
> parseopt_ul() for parsing u32 option value, e.g. use function return value
> as an error flag.
>
> Any suggestion?
Yes, returning an error is a good idea and given that the return value
is currently unused this is a good place.
Sascha
--
Pengutronix e.K. | |
Industrial Linux Solutions | http://www.pengutronix.de/ |
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0 |
Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917-5555 |
_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox
next prev parent reply other threads:[~2017-10-19 11:52 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-10-10 12:26 [PATCH 0/5] sandbox: add gpio support with libftdi1 Antony Pavlov
2017-10-10 12:26 ` [PATCH 1/5] sandbox: avoid symbol conflict for {open,read,close}dir Antony Pavlov
2017-10-10 12:26 ` [PATCH 2/5] sandbox: add gpio support with libftdi1 Antony Pavlov
2017-10-16 7:56 ` Sascha Hauer
2017-10-10 12:26 ` [PATCH 3/5] sandbox: parse libftdi options Antony Pavlov
2017-10-16 8:21 ` Sascha Hauer
2017-10-16 14:10 ` Antony Pavlov
2017-10-16 14:06 ` Sascha Hauer
2017-10-19 11:55 ` Antony Pavlov
2017-10-19 11:52 ` Sascha Hauer [this message]
2017-10-10 12:26 ` [PATCH 4/5] sandbox_defconfig: enable gpio, spi, i2c and led stuff Antony Pavlov
2017-10-10 12:26 ` [PATCH 5/5] sandbox: dts: add i2c and spi libftdi1 bit-bang example Antony Pavlov
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=20171019115225.ohwrhrx4sjitu64i@pengutronix.de \
--to=s.hauer@pengutronix.de \
--cc=antonynpavlov@gmail.com \
--cc=barebox@lists.infradead.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