From patchwork Mon May 24 13:08:42 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Govindraj.R" X-Patchwork-Id: 101867 X-Patchwork-Delegate: khilman@deeprootsystems.com Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by demeter.kernel.org (8.14.3/8.14.3) with ESMTP id o4OD8kCd007030 for ; Mon, 24 May 2010 13:08:46 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754561Ab0EXNIp (ORCPT ); Mon, 24 May 2010 09:08:45 -0400 Received: from comal.ext.ti.com ([198.47.26.152]:44634 "EHLO comal.ext.ti.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753073Ab0EXNIo (ORCPT ); Mon, 24 May 2010 09:08:44 -0400 Received: from dlep35.itg.ti.com ([157.170.170.118]) by comal.ext.ti.com (8.13.7/8.13.7) with ESMTP id o4OD8hLr008077 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Mon, 24 May 2010 08:08:43 -0500 Received: from webmail.ti.com (localhost [127.0.0.1]) by dlep35.itg.ti.com (8.13.7/8.13.7) with ESMTP id o4OD8e7d027986; Mon, 24 May 2010 08:08:42 -0500 (CDT) Received: from 192.168.10.88 (proxying for 10.24.255.18) (SquirrelMail authenticated user x0100947); by dbdmail.itg.ti.com with HTTP; Mon, 24 May 2010 18:38:42 +0530 (IST) Message-ID: <48383.192.168.10.88.1274706522.squirrel@dbdmail.itg.ti.com> In-Reply-To: <39979.192.168.10.88.1274431258.squirrel@dbdmail.itg.ti.com> References: <39979.192.168.10.88.1274431258.squirrel@dbdmail.itg.ti.com> Date: Mon, 24 May 2010 18:38:42 +0530 (IST) Subject: [pm-wip/uart][PATCH] Serial: Avoid using hwmod lookup using name string From: "Govindraj.R" To: linux-omap@vger.kernel.org Cc: "Kevin Hilman" User-Agent: SquirrelMail/1.4.3a X-Mailer: SquirrelMail/1.4.3a MIME-Version: 1.0 X-Priority: 3 (Normal) Importance: Normal Sender: linux-omap-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-omap@vger.kernel.org X-Greylist: IP, sender and recipient auto-whitelisted, not delayed by milter-greylist-4.2.3 (demeter.kernel.org [140.211.167.41]); Mon, 24 May 2010 13:08:46 +0000 (UTC) diff --git a/arch/arm/mach-omap2/serial.c b/arch/arm/mach-omap2/serial.c index da9fee6..dc04139 100644 --- a/arch/arm/mach-omap2/serial.c +++ b/arch/arm/mach-omap2/serial.c @@ -55,8 +55,6 @@ */ #define DEFAULT_TIMEOUT 0 -#define MAX_UART_HWMOD_NAME_LEN 16 - struct omap_uart_state { int num; int can_sleep; @@ -568,52 +566,48 @@ static void serial_out_override(struct uart_port *up, int offset, int value) } #endif -void __init omap_serial_early_init(void) +static int omap_serial_port_init(struct omap_hwmod *oh, void *user) { - int i = 0; + struct omap_uart_state *uart; + static int i; - do { - char oh_name[MAX_UART_HWMOD_NAME_LEN]; - struct omap_hwmod *oh; - struct omap_uart_state *uart; + uart = kzalloc(sizeof(struct omap_uart_state), GFP_KERNEL); + if (WARN_ON(!uart)) + return -ENOMEM; - snprintf(oh_name, MAX_UART_HWMOD_NAME_LEN, - "uart%d", i + 1); - oh = omap_hwmod_lookup(oh_name); - if (!oh) - break; + uart->oh = oh; + uart->num = i++; + list_add_tail(&uart->node, &uart_list); + num_uarts++; - uart = kzalloc(sizeof(struct omap_uart_state), GFP_KERNEL); - if (WARN_ON(!uart)) - return; + /* + * NOTE: omap_hwmod_init() has not yet been called, + * so no hwmod functions will work yet. + */ - uart->oh = oh; - uart->num = i++; - list_add_tail(&uart->node, &uart_list); - num_uarts++; + /* + * During UART early init, device need to be probed + * to determine SoC specific init before omap_device + * is ready. Therefore, don't allow idle here + */ + uart->oh->flags |= HWMOD_INIT_NO_IDLE; - /* - * NOTE: omap_hwmod_init() has not yet been called, - * so no hwmod functions will work yet. - */ + /* + * Since UART hwmod is idle/enabled inside the + * idle loop, interrupts are already disabled and + * thus no locking is needed. Since the mutex-based + * locking in hwmod might sleep, allowing locking + * may introduce problems. + */ + uart->oh->flags |= HWMOD_NO_IDLE_LOCKING; - /* - * During UART early init, device need to be probed - * to determine SoC specific init before omap_device - * is ready. Therefore, don't allow idle here - */ - uart->oh->flags |= HWMOD_INIT_NO_IDLE; - - /* - * Since UART hwmod is idle/enabled inside the - * idle loop, interrupts are already disabled and - * thus no locking is needed. Since the mutex-based - * locking in hwmod might sleep, allowing locking - * may introduce problems. - */ - uart->oh->flags |= HWMOD_NO_IDLE_LOCKING; + return 0; +} - } while (1); +void __init omap_serial_early_init(void) +{ + omap_hwmod_for_each_by_class("uart", + omap_serial_port_init, NULL); } /**