All of lore.kernel.org
 help / color / mirror / Atom feed
From: Baruch Siach <baruch-NswTu9S1W3P6gbPvEgmw2w@public.gmane.org>
To: "Pietrek,
	Markus" <Markus.Pietrek-BU0Y/NROKIiELgA04lAiVw@public.gmane.org>
Cc: "spi-devel-general-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f@public.gmane.org"
	<spi-devel-general-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f@public.gmane.org>
Subject: Re: [PATCH] spi_board_info_cmdline.c: unknown command line options are ignored and all options have a name instead of being anonymous
Date: Thu, 4 Feb 2010 07:58:21 +0200	[thread overview]
Message-ID: <20100204055820.GA4378@jasper.tkos.co.il> (raw)
In-Reply-To: <95F51F4B902CAC40AF459205F6322F0171E8D499AC-76KB/CMpcTeJqUQdFWzYuOuPKLVQfWtC@public.gmane.org>

On Tue, Feb 02, 2010 at 04:08:57PM +0100, Pietrek, Markus wrote:
> Hi Barauch,
> 
> as requested a more open approach for the command line options

Thanks. You should also update the cs_high option in the Kconfig help text.

baruch

> 
> Signed-off-by: Markus Pietrek <markus.pietrek-BU0Y/NROKIiELgA04lAiVw@public.gmane.org>
> ---
>  drivers/spi/Kconfig                  |    2 +-
>  drivers/spi/spi_board_info_cmdline.c |   92 +++++++++++++++------------------
>  2 files changed, 43 insertions(+), 51 deletions(-)
> 
> diff --git a/drivers/spi/Kconfig b/drivers/spi/Kconfig
> index 85e88fa..c8f3bbe 100644
> --- a/drivers/spi/Kconfig
> +++ b/drivers/spi/Kconfig
> @@ -327,7 +327,7 @@ config SPI_BOARD_INFO_CMDLINE
>            The syntax is:
>           spi_board_info=<devcfg>[,<devcfg>...]
>           with <devcfg> as
> -         <devname>[:<max_speed_hz>[:<bus_num>[:<chip_select>[:<irq>[:<opt>[:<opt>...]]]]]]
> +         <devname>[:max_speed_hz=<int>][:bus_num=<int>][:chip_select=<int>][:irq=<int>][:cs_gpio=<int>][:<opt>][:<opt>]...
>            and <opt> as one of
>            cpha,cpol,mode0,mode1,mode2,mode3,cs,lsb,3wire,loop,no_cs,ready
> 
> diff --git a/drivers/spi/spi_board_info_cmdline.c b/drivers/spi/spi_board_info_cmdline.c
> index 765a941..1d86f87 100644
> --- a/drivers/spi/spi_board_info_cmdline.c
> +++ b/drivers/spi/spi_board_info_cmdline.c
> @@ -65,57 +65,49 @@ static int __init spi_board_info_register_device(char *dev)
>                 if (next)
>                         *next++ = '\0';
> 
> -               if (strlen(opt) > 0) {
> -                       switch (num) {
> -                           case 0:
> -                               strncpy(info->modalias, opt, ARRAY_SIZE(info->modalias));
> -                               info->modalias[ARRAY_SIZE(info->modalias)-1]=0;
> -                               break;
> -                           case 1:
> -                               info->max_speed_hz = simple_strtoul(opt, NULL, 10);
> -                               break;
> -                           case 2:
> -                               info->bus_num = simple_strtoul(opt, NULL, 10);
> -                               break;
> -                           case 3:
> -                               info->chip_select = simple_strtoul(opt, NULL, 10);
> -                               break;
> -                           case 4:
> +               if (!num) {
> +                       /* name of device */
> +                       strncpy(info->modalias, opt, ARRAY_SIZE(info->modalias));
> +                       info->modalias[ARRAY_SIZE(info->modalias)-1]=0;
> +               } else {
> +                       if (!strcmp(opt, "cpha"))
> +                               info->mode |= SPI_CPHA;
> +                       else if (!strcmp(opt, "cpol"))
> +                               info->mode |= SPI_CPOL;
> +                       else if (!strcmp(opt, "mode0"))
> +                               info->mode |= SPI_MODE_0;
> +                       else if (!strcmp(opt, "mode1"))
> +                               info->mode |= SPI_MODE_1;
> +                       else if (!strcmp(opt, "mode2"))
> +                               info->mode |= SPI_MODE_2;
> +                       else if (!strcmp(opt, "mode3"))
> +                               info->mode |= SPI_MODE_3;
> +                       else if (!strcmp(opt, "cs_high"))
> +                               info->mode |= SPI_CS_HIGH;
> +                       else if (!strcmp(opt, "lsb"))
> +                               info->mode |= SPI_LSB_FIRST;
> +                       else if (!strcmp(opt, "3wire"))
> +                               info->mode |= SPI_3WIRE;
> +                       else if (!strcmp(opt, "loop"))
> +                               info->mode |= SPI_LOOP;
> +                       else if (!strcmp(opt, "no_cs"))
> +                               info->mode |= SPI_NO_CS;
> +                       else if (!strcmp(opt, "ready"))
> +                               info->mode |= SPI_READY;
> +                       else if (!strncmp(opt, "chip_select=", 12))
> +                               info->chip_select = simple_strtoul(&opt[12], NULL, 10);
> +                       else if (!strncmp(opt, "cs_gpio=", 8))
> +                               /* defines the GPIO to be used as chipselect for spi_gpio.c */
> +                               info->controller_data = (void*) simple_strtol(&opt[8], NULL, 10);
> +                       else if (!strncmp(opt, "bus_num=", 8))
> +                               info->bus_num = simple_strtoul(&opt[8], NULL, 10);
> +                       else if (!strncmp(opt, "max_speed_hz=", 13))
> +                               info->max_speed_hz = simple_strtoul(&opt[13], NULL, 10);
> +                       else if (!strncmp(opt, "irq=", 4))
>                                 info->irq = simple_strtoul(opt, NULL, 10);
> -                               break;
> -                           default:
> -                               if (!strcmp(opt, "cpha"))
> -                                       info->mode |= SPI_CPHA;
> -                               else if (!strcmp(opt, "cpol"))
> -                                       info->mode |= SPI_CPOL;
> -                               else if (!strcmp(opt, "mode0"))
> -                                       info->mode |= SPI_MODE_0;
> -                               else if (!strcmp(opt, "mode1"))
> -                                       info->mode |= SPI_MODE_1;
> -                               else if (!strcmp(opt, "mode2"))
> -                                       info->mode |= SPI_MODE_2;
> -                               else if (!strcmp(opt, "mode3"))
> -                                       info->mode |= SPI_MODE_3;
> -                               else if (!strcmp(opt, "cs"))
> -                                       info->mode |= SPI_CS_HIGH;
> -                               else if (!strcmp(opt, "lsb"))
> -                                       info->mode |= SPI_LSB_FIRST;
> -                               else if (!strcmp(opt, "3wire"))
> -                                       info->mode |= SPI_3WIRE;
> -                               else if (!strcmp(opt, "loop"))
> -                                       info->mode |= SPI_LOOP;
> -                               else if (!strcmp(opt, "no_cs"))
> -                                       info->mode |= SPI_NO_CS;
> -                               else if (!strcmp(opt, "ready"))
> -                                       info->mode |= SPI_READY;
> -                               else {
> -                                       pr_err(DRIVER_NAME ": Don't know value %s\n", opt);
> -                                       kfree(info);
> -                                       return -1;
> -                               }
> -
> -                               break;
> -                       }
> +                       else
> +                               pr_err(DRIVER_NAME ": Unknown option %s, ignoring\n", opt);
> +                       break;
>                 }
> 
>                 /* next option */
> --
> 1.5.4.3
> 
> _____________________________________
> 
> Amtsgericht Mannheim
> HRB 110 300
> Gesch?ftsf?hrer: Dieter Baur, Ramona Maurer
> _____________________________________
> 
> Important Note:
> - This e-mail may contain trade secrets or privileged, undisclosed or otherwise confidential information.
> - If you have received this e-mail in error, you are hereby notified that any review, copying or distribution of it is strictly prohibited.
> - Please inform us immediately and destroy the original transmittal.
> 
> Thank you for your cooperation.

-- 
                                                     ~. .~   Tk Open Systems
=}------------------------------------------------ooO--U--Ooo------------{=
   - baruch-NswTu9S1W3P6gbPvEgmw2w@public.gmane.org - tel: +972.2.679.5364, http://www.tkos.co.il -

------------------------------------------------------------------------------
The Planet: dedicated and managed hosting, cloud storage, colocation
Stay online with enterprise data centers and the best network in the business
Choose flexible plans and management services without long-term contracts
Personal 24x7 support from experience hosting pros just a phone call away.
http://p.sf.net/sfu/theplanet-com

      parent reply	other threads:[~2010-02-04  5:58 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-01-29 13:48 [PATCH] added drivers/spi/spi_board_info_cmdline for setting up an spi_board_info structure on commandline Pietrek, Markus
     [not found] ` <95F51F4B902CAC40AF459205F6322F0171E8D49880-76KB/CMpcTeJqUQdFWzYuOuPKLVQfWtC@public.gmane.org>
2010-01-30 23:06   ` Baruch Siach
2010-02-02 15:08     ` [PATCH] spi_board_info_cmdline.c: unknown command line options are ignored and all options have a name instead of being anonymous Pietrek, Markus
     [not found]       ` <95F51F4B902CAC40AF459205F6322F0171E8D499AC-76KB/CMpcTeJqUQdFWzYuOuPKLVQfWtC@public.gmane.org>
2010-02-03 17:39         ` Grant Likely
2010-02-04  5:58         ` Baruch Siach [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=20100204055820.GA4378@jasper.tkos.co.il \
    --to=baruch-nswtu9s1w3p6gbpvegmw2w@public.gmane.org \
    --cc=Markus.Pietrek-BU0Y/NROKIiELgA04lAiVw@public.gmane.org \
    --cc=spi-devel-general-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f@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.