From patchwork Thu Nov 5 14:35:08 2009 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Magnus Damm X-Patchwork-Id: 57893 Received: from vger.kernel.org (vger.kernel.org [209.132.176.167]) by demeter.kernel.org (8.14.2/8.14.2) with ESMTP id nA5EeNic012621 for ; Thu, 5 Nov 2009 14:40:23 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1757583AbZKEOkO (ORCPT ); Thu, 5 Nov 2009 09:40:14 -0500 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S1757331AbZKEOkN (ORCPT ); Thu, 5 Nov 2009 09:40:13 -0500 Received: from mail-bw0-f227.google.com ([209.85.218.227]:42342 "EHLO mail-bw0-f227.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1757110AbZKEOkL (ORCPT ); Thu, 5 Nov 2009 09:40:11 -0500 Received: by mail-bw0-f227.google.com with SMTP id 27so43541bwz.21 for ; Thu, 05 Nov 2009 06:40:16 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:received:from:to:cc:date:message-id :in-reply-to:references:subject; bh=TMzMtO/ad+iIh0EaPfzXEhnlE0K+0LerfUYOp+p7/ig=; b=qaUpKdzJWTyUjEXkAOYzI4QhFJDZJXS1D10UX2zGNj3N6jz/laH+6b2j2PufK4jRaf HhJsi04ysQtMYRnamQfVw/p8XRuSLH4kGoG8T9dQCP5Jj0yae2DPlAdoZUObnddbTpfO Y4R2i8+IyhMnXRr0U1WUhiuBweSQr43gOPwEg= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=from:to:cc:date:message-id:in-reply-to:references:subject; b=e//bo7Zt5r3Xgi4ee0b+1ZbYo0DLZhGC5/hgQRykN/t9H6zEnYX1bm0Es41cR2fSmH mYm1CQo46wF2WvzlgjmkscVIYa3/vZetBtJNDIDQtMQzweG3nKIX2jsXLSN5G7f/nMfq Of3+3b6LxDrdoqqAxDfKmcgIBdn/A1y3CAKOE= Received: by 10.204.3.220 with SMTP id 28mr3165102bko.4.1257432016449; Thu, 05 Nov 2009 06:40:16 -0800 (PST) Received: from rxone.opensource.se (49.14.32.202.bf.2iij.net [202.32.14.49]) by mx.google.com with ESMTPS id 15sm679337fxm.6.2009.11.05.06.40.13 (version=TLSv1/SSLv3 cipher=RC4-MD5); Thu, 05 Nov 2009 06:40:15 -0800 (PST) From: Magnus Damm To: linux-sh@vger.kernel.org Cc: Magnus Damm , lethal@linux-sh.org Date: Thu, 05 Nov 2009 23:35:08 +0900 Message-Id: <20091105143508.9902.22192.sendpatchset@rxone.opensource.se> In-Reply-To: <20091105143447.9902.4608.sendpatchset@rxone.opensource.se> References: <20091105143447.9902.4608.sendpatchset@rxone.opensource.se> Subject: [PATCH 02/05] Driver Core: Early platform driver buffer Sender: linux-sh-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-sh@vger.kernel.org --- 0001/drivers/base/platform.c +++ work/drivers/base/platform.c 2009-11-05 23:18:06.000000000 +0900 @@ -1000,7 +1000,7 @@ static __initdata LIST_HEAD(early_platfo int __init early_platform_driver_register(struct early_platform_driver *epdrv, char *buf) { - unsigned long index; + char *tmp; int n; /* Simply add the driver to the end of the global list. @@ -1019,13 +1019,28 @@ int __init early_platform_driver_registe if (buf && !strncmp(buf, epdrv->pdrv->driver.name, n)) { list_move(&epdrv->list, &early_platform_driver_list); - if (!strcmp(buf, epdrv->pdrv->driver.name)) + /* Allow passing parameters after device name */ + if (buf[n] == '\0' || buf[n] == ',') epdrv->requested_id = -1; - else if (buf[n] == '.' && strict_strtoul(&buf[n + 1], 10, - &index) == 0) - epdrv->requested_id = index; - else - epdrv->requested_id = EARLY_PLATFORM_ID_ERROR; + else { + epdrv->requested_id = simple_strtoul(&buf[n + 1], + &tmp, 10); + + if (buf[n] != '.' || (tmp == &buf[n + 1])) { + epdrv->requested_id = EARLY_PLATFORM_ID_ERROR; + n = 0; + } else + n += strcspn(&buf[n + 1], ",") + 1; + } + + if (buf[n] == ',') + n++; + + if (epdrv->bufsize) { + memcpy(epdrv->buffer, &buf[n], + min_t(int, epdrv->bufsize, strlen(&buf[n]) + 1)); + epdrv->buffer[epdrv->bufsize - 1] = '\0'; + } } return 0; --- 0001/include/linux/platform_device.h +++ work/include/linux/platform_device.h 2009-11-05 22:24:51.000000000 +0900 @@ -83,6 +83,8 @@ struct early_platform_driver { struct platform_driver *pdrv; struct list_head list; int requested_id; + char *buffer; + int bufsize; }; #define EARLY_PLATFORM_ID_UNSET -2 @@ -102,21 +104,29 @@ extern int early_platform_driver_probe(c int nr_probe, int user_only); extern void early_platform_cleanup(void); +#define early_platform_init(class_string, platdrv) \ + early_platform_init_buffer(class_string, platdrv, NULL, 0) #ifndef MODULE -#define early_platform_init(class_string, platform_driver) \ +#define early_platform_init_buffer(class_string, platdrv, buf, bufsiz) \ static __initdata struct early_platform_driver early_driver = { \ .class_str = class_string, \ - .pdrv = platform_driver, \ + .buffer = buf, \ + .bufsize = bufsiz, \ + .pdrv = platdrv, \ .requested_id = EARLY_PLATFORM_ID_UNSET, \ }; \ -static int __init early_platform_driver_setup_func(char *buf) \ +static int __init early_platform_driver_setup_func(char *buffer) \ { \ - return early_platform_driver_register(&early_driver, buf); \ + return early_platform_driver_register(&early_driver, buffer); \ } \ early_param(class_string, early_platform_driver_setup_func) #else /* MODULE */ -#define early_platform_init(class_string, platform_driver) +#define early_platform_init_buffer(class_string, platdrv, buf, bufsiz) \ +static inline char *early_platform_driver_setup_func(void) \ +{ \ + return bufsiz ? buf : NULL; \ +} #endif /* MODULE */ #endif /* _PLATFORM_DEVICE_H_ */