From patchwork Thu May 3 20:14:34 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Karthikeyan Ramasubramanian X-Patchwork-Id: 10379145 X-Patchwork-Delegate: agross@codeaurora.org Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id E908E60327 for ; Thu, 3 May 2018 20:15:07 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id D800329271 for ; Thu, 3 May 2018 20:15:07 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id CA51429276; Thu, 3 May 2018 20:15:07 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.8 required=2.0 tests=BAYES_00,DKIM_SIGNED, MAILING_LIST_MULTI, RCVD_IN_DNSWL_HI, T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 3E5FA29271 for ; Thu, 3 May 2018 20:15:07 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751344AbeECUPF (ORCPT ); Thu, 3 May 2018 16:15:05 -0400 Received: from smtp.codeaurora.org ([198.145.29.96]:60108 "EHLO smtp.codeaurora.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750962AbeECUPE (ORCPT ); Thu, 3 May 2018 16:15:04 -0400 Received: by smtp.codeaurora.org (Postfix, from userid 1000) id DC0DD6037B; Thu, 3 May 2018 20:15:03 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=codeaurora.org; s=default; t=1525378503; bh=mJyKFoaALga43POWT9OnprrqIv4wBFuv+sUDMZwWIn4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=LfBIzcWHfzio7kT84kPvWqfLWd9GtwTPzMI6T20vQdu4Al4xy9chOZIXzp1FFmW/I Qj62PUp2pX4ZKySPOOA619A1PM4YTbseQStebplC9lw8ns7Kze9wVX/x4WwEZJ9n+F kQ1FGsLVWnl5jQQ1e5TIMgApV1fJXhho/c8peu6U= Received: from codeaurora.org (i-global254.qualcomm.com [199.106.103.254]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-SHA256 (128/128 bits)) (No client certificate requested) (Authenticated sender: kramasub@smtp.codeaurora.org) by smtp.codeaurora.org (Postfix) with ESMTPSA id 6878A607A2; Thu, 3 May 2018 20:15:02 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=codeaurora.org; s=default; t=1525378503; bh=mJyKFoaALga43POWT9OnprrqIv4wBFuv+sUDMZwWIn4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=LfBIzcWHfzio7kT84kPvWqfLWd9GtwTPzMI6T20vQdu4Al4xy9chOZIXzp1FFmW/I Qj62PUp2pX4ZKySPOOA619A1PM4YTbseQStebplC9lw8ns7Kze9wVX/x4WwEZJ9n+F kQ1FGsLVWnl5jQQ1e5TIMgApV1fJXhho/c8peu6U= DMARC-Filter: OpenDMARC Filter v1.3.2 smtp.codeaurora.org 6878A607A2 Authentication-Results: pdx-caf-mail.web.codeaurora.org; dmarc=none (p=none dis=none) header.from=codeaurora.org Authentication-Results: pdx-caf-mail.web.codeaurora.org; spf=none smtp.mailfrom=kramasub@codeaurora.org From: Karthikeyan Ramasubramanian To: gregkh@linuxfoundation.org, jslaby@suse.com Cc: Karthikeyan Ramasubramanian , linux-arm-msm@vger.kernel.org, linux-serial@vger.kernel.org, evgreen@chromium.org, acourbot@chromium.org, swboyd@chromium.org, dianders@chromium.org, mka@chromium.org, bjorn.andersson@linaro.org Subject: [PATCH v3 2/8] tty: serial: qcom_geni_serial: Cleanup redundant code Date: Thu, 3 May 2018 14:14:34 -0600 Message-Id: <1525378480-10296-3-git-send-email-kramasub@codeaurora.org> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1525378480-10296-1-git-send-email-kramasub@codeaurora.org> References: <1525378480-10296-1-git-send-email-kramasub@codeaurora.org> Sender: linux-arm-msm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-arm-msm@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP * Remove redundant casting while using min_t * Remove redundant initialization of port_setup flag * Remove redundant error checking in get_tx_fifo_size * Remove logging redundant error code in debug messages * Remove redundant disable_irq before free_irq Signed-off-by: Karthikeyan Ramasubramanian Reviewed-by: Stephen Boyd --- drivers/tty/serial/qcom_geni_serial.c | 21 ++++++--------------- 1 file changed, 6 insertions(+), 15 deletions(-) diff --git a/drivers/tty/serial/qcom_geni_serial.c b/drivers/tty/serial/qcom_geni_serial.c index 1652b1f..2d66b30b 100644 --- a/drivers/tty/serial/qcom_geni_serial.c +++ b/drivers/tty/serial/qcom_geni_serial.c @@ -309,7 +309,7 @@ static void qcom_geni_serial_wr_char(struct uart_port *uport, int ch) if (!qcom_geni_serial_poll_bit(uport, SE_GENI_M_IRQ_STATUS, M_TX_FIFO_WATERMARK_EN, true)) break; - chars_to_write = min_t(size_t, (size_t)(count - i), avail / 2); + chars_to_write = min_t(size_t, count - i, avail / 2); uart_console_write(uport, s + i, chars_to_write, qcom_geni_serial_wr_char); writel_relaxed(M_TX_FIFO_WATERMARK_EN, uport->membase + @@ -602,7 +602,7 @@ static void qcom_geni_serial_handle_tx(struct uart_port *uport) unsigned int buf = 0; int c; - tx_bytes = min_t(size_t, remaining, (size_t)port->tx_bytes_pw); + tx_bytes = min_t(size_t, remaining, port->tx_bytes_pw); for (c = 0; c < tx_bytes ; c++) buf |= (xmit->buf[tail + c] << (c * BITS_PER_BYTE)); @@ -671,20 +671,16 @@ static irqreturn_t qcom_geni_serial_isr(int isr, void *dev) return IRQ_HANDLED; } -static int get_tx_fifo_size(struct qcom_geni_serial_port *port) +static void get_tx_fifo_size(struct qcom_geni_serial_port *port) { struct uart_port *uport; - if (!port) - return -ENODEV; - uport = &port->uport; port->tx_fifo_depth = geni_se_get_tx_fifo_depth(&port->se); port->tx_fifo_width = geni_se_get_tx_fifo_width(&port->se); port->rx_fifo_depth = geni_se_get_rx_fifo_depth(&port->se); uport->fifosize = (port->tx_fifo_depth * port->tx_fifo_width) / BITS_PER_BYTE; - return 0; } static void set_rfr_wm(struct qcom_geni_serial_port *port) @@ -706,7 +702,6 @@ static void qcom_geni_serial_shutdown(struct uart_port *uport) /* Stop the console before stopping the current tx */ console_stop(uport->cons); - disable_irq(uport->irq); free_irq(uport->irq, uport); spin_lock_irqsave(&uport->lock, flags); qcom_geni_serial_stop_tx(uport); @@ -914,7 +909,7 @@ static int __init qcom_geni_console_setup(struct console *co, char *options) port = get_port_from_line(co->index); if (IS_ERR(port)) { - pr_err("Invalid line %d(%d)\n", co->index, (int)PTR_ERR(port)); + pr_err("Invalid line %d\n", co->index); return PTR_ERR(port); } @@ -1030,16 +1025,13 @@ static int qcom_geni_serial_probe(struct platform_device *pdev) if (pdev->dev.of_node) line = of_alias_get_id(pdev->dev.of_node, "serial"); - else - line = pdev->id; if (line < 0 || line >= GENI_UART_CONS_PORTS) return -ENXIO; port = get_port_from_line(line); if (IS_ERR(port)) { - ret = PTR_ERR(port); - dev_err(&pdev->dev, "Invalid line %d(%d)\n", line, ret); - return ret; + dev_err(&pdev->dev, "Invalid line %d\n", line); + return PTR_ERR(port); } uport = &port->uport; @@ -1076,7 +1068,6 @@ static int qcom_geni_serial_probe(struct platform_device *pdev) uport->private_data = &qcom_geni_console_driver; platform_set_drvdata(pdev, port); port->handle_rx = handle_rx_console; - port->setup = false; return uart_add_one_port(&qcom_geni_console_driver, uport); }