From patchwork Fri Jun 25 13:41:41 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Govindraj.R" X-Patchwork-Id: 108066 X-Patchwork-Delegate: khilman@deeprootsystems.com Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by demeter.kernel.org (8.14.4/8.14.3) with ESMTP id o5PDfj6T024889 for ; Fri, 25 Jun 2010 13:41:45 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755971Ab0FYNlo (ORCPT ); Fri, 25 Jun 2010 09:41:44 -0400 Received: from bear.ext.ti.com ([192.94.94.41]:57616 "EHLO bear.ext.ti.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755516Ab0FYNln (ORCPT ); Fri, 25 Jun 2010 09:41:43 -0400 Received: from dlep33.itg.ti.com ([157.170.170.112]) by bear.ext.ti.com (8.13.7/8.13.7) with ESMTP id o5PDfgSe018573 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Fri, 25 Jun 2010 08:41:42 -0500 Received: from dbdmail.itg.ti.com (localhost [127.0.0.1]) by dlep33.itg.ti.com (8.13.7/8.13.7) with ESMTP id o5PDfdhx021662; Fri, 25 Jun 2010 08:41:40 -0500 (CDT) Received: from 10.24.255.17 (SquirrelMail authenticated user x0100947); by dbdmail.itg.ti.com with HTTP; Fri, 25 Jun 2010 19:11:41 +0530 (IST) Message-ID: <17901.10.24.255.17.1277473301.squirrel@dbdmail.itg.ti.com> In-Reply-To: <87zkykxdqe.fsf@deeprootsystems.com> References: <61551.192.168.10.88.1277384156.squirrel@dbdmail.itg.ti.com> <87zkykxdqe.fsf@deeprootsystems.com> Date: Fri, 25 Jun 2010 19:11:41 +0530 (IST) Subject: [pm-wip/uart][PATCH] Serial: Avoid populating uart_list in early init phase 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]); Fri, 25 Jun 2010 13:41:45 +0000 (UTC) diff --git a/arch/arm/mach-omap2/serial.c b/arch/arm/mach-omap2/serial.c index 24b8c60..246ae02 100644 --- a/arch/arm/mach-omap2/serial.c +++ b/arch/arm/mach-omap2/serial.c @@ -97,6 +97,13 @@ struct omap_uart_state { #endif }; +struct uart_oh { + struct list_head node; + struct omap_hwmod *oh; + int uart_num; +}; + +static LIST_HEAD(uart_oh_list); static LIST_HEAD(uart_list); static u8 num_uarts; @@ -593,39 +600,32 @@ static void serial_out_override(struct uart_port *up, int offset, int value) void __init omap_serial_early_init(void) { - int i = 0; + struct omap_hwmod *oh; + struct uart_oh *uoh; + char oh_name[MAX_UART_HWMOD_NAME_LEN]; do { - char oh_name[MAX_UART_HWMOD_NAME_LEN]; - struct omap_hwmod *oh; - struct omap_uart_state *uart; + uoh = kzalloc(sizeof(struct uart_oh), GFP_KERNEL); + if (WARN_ON(!uoh)) + return; snprintf(oh_name, MAX_UART_HWMOD_NAME_LEN, - "uart%d", i + 1); + "uart%d", num_uarts + 1); oh = omap_hwmod_lookup(oh_name); if (!oh) break; - - uart = kzalloc(sizeof(struct omap_uart_state), GFP_KERNEL); - if (WARN_ON(!uart)) - return; - - uart->oh = oh; - uart->num = i++; - list_add_tail(&uart->node, &uart_list); - num_uarts++; - /* * NOTE: omap_hwmod_init() has not yet been called, - * so no hwmod functions will work yet. - */ - - /* + * so no hwmod functions will work yet. * 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 + * is ready. Therefore, don't allow idle here */ - uart->oh->flags |= HWMOD_INIT_NO_IDLE; + oh->flags |= HWMOD_INIT_NO_IDLE; + uoh->oh = oh; + uoh->uart_num = num_uarts; + list_add_tail(&uoh->node, &uart_oh_list); + num_uarts++; } while (1); } @@ -645,6 +645,7 @@ void __init omap_serial_init_port(int port) struct omap_uart_state *uart; struct omap_hwmod *oh; struct omap_device *od; + struct uart_oh *uoh; void *pdata = NULL; u32 pdata_size = 0; char *name; @@ -663,6 +664,17 @@ void __init omap_serial_init_port(int port) if (WARN_ON(port >= num_uarts)) return; + uart = kzalloc(sizeof(struct omap_uart_state), GFP_KERNEL); + if (WARN_ON(!uart)) + return; + + uart->num = port; + list_add_tail(&uart->node, &uart_list); + list_for_each_entry(uoh, &uart_oh_list, node) + if (port == uoh->uart_num) + break; + + uart->oh = uoh->oh; list_for_each_entry(uart, &uart_list, node) if (port == uart->num) break; @@ -781,8 +793,8 @@ void __init omap_serial_init_port(int port) */ void __init omap_serial_init(void) { - struct omap_uart_state *uart; + struct uart_oh *uoh; - list_for_each_entry(uart, &uart_list, node) - omap_serial_init_port(uart->num); + list_for_each_entry(uoh, &uart_oh_list, node) + omap_serial_init_port(uoh->uart_num); }