From patchwork Tue Aug 21 12:16:00 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Felipe Balbi X-Patchwork-Id: 1354721 Return-Path: X-Original-To: patchwork-linux-omap@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork2.kernel.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by patchwork2.kernel.org (Postfix) with ESMTP id D389EDFB34 for ; Tue, 21 Aug 2012 12:23:51 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755733Ab2HUMUX (ORCPT ); Tue, 21 Aug 2012 08:20:23 -0400 Received: from na3sys009aog126.obsmtp.com ([74.125.149.155]:34758 "EHLO na3sys009aog126.obsmtp.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755660Ab2HUMUR (ORCPT ); Tue, 21 Aug 2012 08:20:17 -0400 Received: from mail-lpp01m010-f44.google.com ([209.85.215.44]) (using TLSv1) by na3sys009aob126.postini.com ([74.125.148.12]) with SMTP ID DSNKUDN8/zFDNxLa4NtdhLVG8MrUPykKN2gd@postini.com; Tue, 21 Aug 2012 05:20:16 PDT Received: by lahm15 with SMTP id m15so4070345lah.31 for ; Tue, 21 Aug 2012 05:20:13 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=from:to:cc:subject:date:message-id:x-mailer:in-reply-to:references :x-gm-message-state; bh=pt7j4JbjWTmUr4wpJiytZZNw73LUd/tFQBt4ug4LCVE=; b=M8CcMvT7s/m1I1KwBBvpXfvJbk2oJmelqBqK3CaQfRO2dxosp+mPJUtaag+1duMb1V ozKHxyNEISO6NnYXgu4e0jP8dw5hTnqrv6BOmPYU55PZHzG8Y9gVNWQHEK1n9FkSlYt4 6ASPKnQIUF5PZm8nnZzQTN8Kx484e3qldeXktx5M3soUNAEKhRYait9vj1N3B5FGQ/PS V/kT5ZVVzrcb+ytq2H1xjC3Kd9+p6cBb8/w2bLhbj5+t0Y/cwCb2+nwnWsRF8BWTMJYa FIteahnGLbUYPi11hycKI7MITulXE1sDYJseHGLpTtJh0lmc43wBoExIX37N+YlXPdSh fBmQ== Received: by 10.152.125.133 with SMTP id mq5mr17339742lab.12.1345551613651; Tue, 21 Aug 2012 05:20:13 -0700 (PDT) Received: from localhost (cs78217178.pp.htv.fi. [62.78.217.178]) by mx.google.com with ESMTPS id h8sm392436lbi.13.2012.08.21.05.20.12 (version=TLSv1/SSLv3 cipher=OTHER); Tue, 21 Aug 2012 05:20:12 -0700 (PDT) From: Felipe Balbi To: alan@linux.intel.com Cc: Tony Lindgren , Kevin Hilman , Linux OMAP Mailing List , Linux ARM Kernel Mailing List , linux-serial@vger.kernel.org, Linux Kernel Mailing List , Santosh Shilimkar , Shubhrajyoti Datta , Felipe Balbi Subject: [PATCH v2 02/13] serial: omap: define helpers for pdata function pointers Date: Tue, 21 Aug 2012 15:16:00 +0300 Message-Id: <1345551371-18862-3-git-send-email-balbi@ti.com> X-Mailer: git-send-email 1.7.12.rc3 In-Reply-To: <1345551371-18862-1-git-send-email-balbi@ti.com> References: <1345540555-24359-1-git-send-email-balbi@ti.com> <1345551371-18862-1-git-send-email-balbi@ti.com> X-Gm-Message-State: ALoCoQk/E3zwEJNgMKKwrGXXdNFxo/SQiJWLHNsDiqr23ILXnkt5xiVB+49RXfYmxGxpPu3sTJl8 Sender: linux-omap-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-omap@vger.kernel.org this patch is in preparation to a few other changes which will align on the prototype for function pointers passed through pdata. It also helps cleaning up the driver a little by agregating checks for pdata in a single location. Acked-by: Santosh Shilimkar Signed-off-by: Felipe Balbi --- drivers/tty/serial/omap-serial.c | 66 ++++++++++++++++++++++++++++------------ 1 file changed, 47 insertions(+), 19 deletions(-) diff --git a/drivers/tty/serial/omap-serial.c b/drivers/tty/serial/omap-serial.c index 5c0d0bc..6814a26 100644 --- a/drivers/tty/serial/omap-serial.c +++ b/drivers/tty/serial/omap-serial.c @@ -101,6 +101,40 @@ static inline void serial_omap_clear_fifos(struct uart_omap_port *up) serial_out(up, UART_FCR, 0); } +static int serial_omap_get_context_loss_count(struct uart_omap_port *up) +{ + struct omap_uart_port_info *pdata = up->pdev->dev.platform_data; + + if (!pdata->get_context_loss_count) + return 0; + + return pdata->get_context_loss_count(&up->pdev->dev); +} + +static void serial_omap_set_forceidle(struct uart_omap_port *up) +{ + struct omap_uart_port_info *pdata = up->pdev->dev.platform_data; + + if (pdata->set_forceidle) + pdata->set_forceidle(up->pdev); +} + +static void serial_omap_set_noidle(struct uart_omap_port *up) +{ + struct omap_uart_port_info *pdata = up->pdev->dev.platform_data; + + if (pdata->set_noidle) + pdata->set_noidle(up->pdev); +} + +static void serial_omap_enable_wakeup(struct uart_omap_port *up, bool enable) +{ + struct omap_uart_port_info *pdata = up->pdev->dev.platform_data; + + if (pdata->enable_wakeup) + pdata->enable_wakeup(up->pdev, enable); +} + /* * serial_omap_get_divisor - calculate divisor value * @port: uart port info @@ -177,8 +211,8 @@ static void serial_omap_stop_tx(struct uart_port *port) serial_out(up, UART_IER, up->ier); } - if (!up->use_dma && pdata && pdata->set_forceidle) - pdata->set_forceidle(up->pdev); + if (!up->use_dma && pdata) + serial_omap_set_forceidle(up); pm_runtime_mark_last_busy(&up->pdev->dev); pm_runtime_put_autosuspend(&up->pdev->dev); @@ -308,7 +342,6 @@ static inline void serial_omap_enable_ier_thri(struct uart_omap_port *up) static void serial_omap_start_tx(struct uart_port *port) { struct uart_omap_port *up = to_uart_omap_port(port); - struct omap_uart_port_info *pdata = up->pdev->dev.platform_data; struct circ_buf *xmit; unsigned int start; int ret = 0; @@ -316,8 +349,7 @@ static void serial_omap_start_tx(struct uart_port *port) if (!up->use_dma) { pm_runtime_get_sync(&up->pdev->dev); serial_omap_enable_ier_thri(up); - if (pdata && pdata->set_noidle) - pdata->set_noidle(up->pdev); + serial_omap_set_noidle(up); pm_runtime_mark_last_busy(&up->pdev->dev); pm_runtime_put_autosuspend(&up->pdev->dev); return; @@ -1648,28 +1680,26 @@ static int serial_omap_runtime_suspend(struct device *dev) if (!up) return -EINVAL; - if (!pdata || !pdata->enable_wakeup) + if (!pdata) return 0; - if (pdata->get_context_loss_count) - up->context_loss_cnt = pdata->get_context_loss_count(dev); + up->context_loss_cnt = serial_omap_get_context_loss_count(up); if (device_may_wakeup(dev)) { if (!up->wakeups_enabled) { - pdata->enable_wakeup(up->pdev, true); + serial_omap_enable_wakeup(up, true); up->wakeups_enabled = true; } } else { if (up->wakeups_enabled) { - pdata->enable_wakeup(up->pdev, false); + serial_omap_enable_wakeup(up, false); up->wakeups_enabled = false; } } /* Errata i291 */ - if (up->use_dma && pdata->set_forceidle && - (up->errata & UART_ERRATA_i291_DMA_FORCEIDLE)) - pdata->set_forceidle(up->pdev); + if (up->use_dma && (up->errata & UART_ERRATA_i291_DMA_FORCEIDLE)) + serial_omap_set_forceidle(up); up->latency = PM_QOS_CPU_DMA_LAT_DEFAULT_VALUE; schedule_work(&up->qos_work); @@ -1683,17 +1713,15 @@ static int serial_omap_runtime_resume(struct device *dev) struct omap_uart_port_info *pdata = dev->platform_data; if (up && pdata) { - if (pdata->get_context_loss_count) { - u32 loss_cnt = pdata->get_context_loss_count(dev); + u32 loss_cnt = serial_omap_get_context_loss_count(up); if (up->context_loss_cnt != loss_cnt) serial_omap_restore_context(up); - } /* Errata i291 */ - if (up->use_dma && pdata->set_noidle && - (up->errata & UART_ERRATA_i291_DMA_FORCEIDLE)) - pdata->set_noidle(up->pdev); + if ((up->errata & UART_ERRATA_i291_DMA_FORCEIDLE) && + up->use_dma) + serial_omap_set_noidle(up); up->latency = up->calc_latency; schedule_work(&up->qos_work);