From patchwork Tue Feb 2 15:08:57 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Pietrek, Markus" X-Patchwork-Id: 76387 Received: from lists.sourceforge.net (lists.sourceforge.net [216.34.181.88]) by demeter.kernel.org (8.14.3/8.14.3) with ESMTP id o12F9HJZ018789 for ; Tue, 2 Feb 2010 15:09:53 GMT Received: from localhost ([127.0.0.1] helo=sfs-ml-3.v29.ch3.sourceforge.com) by sfs-ml-3.v29.ch3.sourceforge.com with esmtp (Exim 4.69) (envelope-from ) id 1NcKNI-0004E3-Qu; Tue, 02 Feb 2010 15:09:08 +0000 Received: from sfi-mx-4.v28.ch3.sourceforge.com ([172.29.28.124] helo=mx.sourceforge.net) by sfs-ml-3.v29.ch3.sourceforge.com with esmtp (Exim 4.69) (envelope-from ) id 1NcKNH-0004Du-Er for spi-devel-general@lists.sourceforge.net; Tue, 02 Feb 2010 15:09:07 +0000 Received-SPF: pass (sfi-mx-4.v28.ch3.sourceforge.com: domain of emtrion.de designates 80.150.99.69 as permitted sender) client-ip=80.150.99.69; envelope-from=Markus.Pietrek@emtrion.de; helo=mail3.emtrion.de; Received: from mail3.emtrion.de ([80.150.99.69]) by sfi-mx-4.v28.ch3.sourceforge.com with esmtp (Exim 4.69) id 1NcKNF-0005xd-Qz for spi-devel-general@lists.sourceforge.net; Tue, 02 Feb 2010 15:09:07 +0000 Received: from BMK019S01.emtrion.local ([fe80::4a1:cedc:cab6:e9ce]) by BMK019S01.emtrion.local ([fe80::4a1:cedc:cab6:e9ce%10]) with mapi; Tue, 2 Feb 2010 16:08:57 +0100 From: "Pietrek, Markus" To: Baruch Siach Date: Tue, 2 Feb 2010 16:08:57 +0100 Thread-Topic: [PATCH] spi_board_info_cmdline.c: unknown command line options are ignored and all options have a name instead of being anonymous Thread-Index: AcqiAOSRoXdA4yjgScavOcrRG7CmVQCGFpeQ Message-ID: <95F51F4B902CAC40AF459205F6322F0171E8D499AC@BMK019S01.emtrion.local> References: <95F51F4B902CAC40AF459205F6322F0171E8D49880@BMK019S01.emtrion.local> <20100130230629.GA2634@tarshish> In-Reply-To: <20100130230629.GA2634@tarshish> Accept-Language: de-DE Content-Language: de-DE X-MS-Has-Attach: X-MS-TNEF-Correlator: acceptlanguage: de-DE x-tm-as-product-ver: SMEX-8.0.0.1307-6.000.1038-17168.007 x-tm-as-result: No--40.895200-8.000000-31 x-tm-as-user-approved-sender: No x-tm-as-user-blocked-sender: No MIME-Version: 1.0 X-Spam-Score: -1.5 (-) X-Spam-Report: Spam Filtering performed by mx.sourceforge.net. See http://spamassassin.org/tag/ for more details. -1.5 SPF_CHECK_PASS SPF reports sender host as permitted sender for sender-domain -0.0 SPF_PASS SPF: sender matches SPF record X-Headers-End: 1NcKNF-0005xd-Qz Cc: "spi-devel-general@lists.sourceforge.net" Subject: [spi-devel-general] [PATCH] spi_board_info_cmdline.c: unknown command line options are ignored and all options have a name instead of being anonymous X-BeenThere: spi-devel-general@lists.sourceforge.net X-Mailman-Version: 2.1.9 Precedence: list List-Id: Linux SPI core/device drivers discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: spi-devel-general-bounces@lists.sourceforge.net X-Greylist: IP, sender and recipient auto-whitelisted, not delayed by milter-greylist-4.2.3 (demeter.kernel.org [140.211.167.41]); Tue, 02 Feb 2010 15:09:53 +0000 (UTC) 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=[,...] with as - [:[:[:[:[:[:...]]]]]] + [:max_speed_hz=][:bus_num=][:chip_select=][:irq=][:cs_gpio=][:][:]... and 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 */