From patchwork Tue Nov 22 10:21:14 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bartosz Golaszewski X-Patchwork-Id: 627588 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 43718C433FE for ; Tue, 22 Nov 2022 10:22:22 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233397AbiKVKWU (ORCPT ); Tue, 22 Nov 2022 05:22:20 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43926 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233085AbiKVKVx (ORCPT ); Tue, 22 Nov 2022 05:21:53 -0500 Received: from mail-wr1-x430.google.com (mail-wr1-x430.google.com [IPv6:2a00:1450:4864:20::430]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 70258205E8 for ; Tue, 22 Nov 2022 02:21:45 -0800 (PST) Received: by mail-wr1-x430.google.com with SMTP id g12so23938473wrs.10 for ; Tue, 22 Nov 2022 02:21:45 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bgdev-pl.20210112.gappssmtp.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=DkZacf9TX3zvyVeUrL+nHxYirMYsPuTeW+Zo+lEbcT0=; b=n46/Bzxpis8t8nDSvP5/hO7IKMa4gViNFmxoDwApmrQQ6Ykxt19O5+rHwlaAUQAqZk iuYeqvWzkokkzx6wJYg6HzRUZ897kPhbw2m5ptzMlfGq7urRU5jxt+psRLdHW1a231Rf XycpjPPCw2gIksQVYCZQ0xIiAXy+LIdCiWrDzIIIeXSOtaNa8+10/itmrVumwmBRNAqd SqKulZuEBarl6TGWAMSGdR6U1PmVk0svLGKx71c3mCkJnIwjsW7HIDLd7q0q740QUMfL OmZOuRsoM3GixuE9AEMvYBY1YxJLXGcstJMLvOqFRY8U65iry7NJ3dg8h58d1D3CbI9q 9/Ag== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=DkZacf9TX3zvyVeUrL+nHxYirMYsPuTeW+Zo+lEbcT0=; b=EsWepvZ4leCRR49Rz4wbpJa7rdLigdbumeO+aobo/yi03d/BTsEmNsCGKIjqIxrkOn 53+5MT8fUN6s0m6WyOuz87Kgy0MrDe8s8tFwtmfWNwNZXaLyCILi2R+6JKqVm9BzP0nf vedZUzQ2HC9NwcTgsF3vmiqhqkYwxvFzN6slkm720ezb36ig/JEVk8aDtCPHbaK+I3B+ UEPNhoMT30G32EbUM+Q115qAPgdQWlDRGiI3UoorXH76G2/uMOvb8QkuvPSYQQuHL474 UlPsjWDJ3GJ+ajOFSafAnNzUKCwXF+11lKhMjaDJhNB+A1oAhYJqsYutWOalBt/ltAUu 7jnw== X-Gm-Message-State: ANoB5pntovwo/rA6Pu3LMvB7urtTL/YsyW+2RZxgnwa6ZlvKpFYdacRZ 04j91gxG2gdsZ7J4mMpd7rGxVg== X-Google-Smtp-Source: AA0mqf79F6mX4CkVqrYCXZQP8pXylPsPd3TBFWNdCA10kLpH21KcxpRq8wxFJEhVQSNwXsNadYHyBQ== X-Received: by 2002:a5d:4484:0:b0:241:9b26:d18e with SMTP id j4-20020a5d4484000000b002419b26d18emr13311986wrq.548.1669112504996; Tue, 22 Nov 2022 02:21:44 -0800 (PST) Received: from brgl-uxlite.home ([2a01:cb1d:334:ac00:e011:9e81:66f1:3415]) by smtp.gmail.com with ESMTPSA id o3-20020a5d4083000000b002366e8eee11sm13432873wrp.101.2022.11.22.02.21.44 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 22 Nov 2022 02:21:44 -0800 (PST) From: Bartosz Golaszewski To: Andy Gross , Bjorn Andersson , Konrad Dybcio , Greg Kroah-Hartman , Jiri Slaby , Srinivas Kandagatla , Vinod Koul , Alex Elder , =?utf-8?q?Ilp?= =?utf-8?q?o_J=C3=A4rvinen?= Cc: linux-kernel@vger.kernel.org, linux-arm-msm@vger.kernel.org, linux-serial@vger.kernel.org, Bartosz Golaszewski , Konrad Dybcio Subject: [PATCH v2 04/15] tty: serial: qcom-geni-serial: improve the to_dev_port() macro Date: Tue, 22 Nov 2022 11:21:14 +0100 Message-Id: <20221122102125.142075-5-brgl@bgdev.pl> X-Mailer: git-send-email 2.37.2 In-Reply-To: <20221122102125.142075-1-brgl@bgdev.pl> References: <20221122102125.142075-1-brgl@bgdev.pl> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-arm-msm@vger.kernel.org From: Bartosz Golaszewski The member we want to resolve in struct qcom_geni_serial_port is called uport so we don't need an additional redundant parameter in this macro. While at it: turn the macro into a static inline function. Signed-off-by: Bartosz Golaszewski Reviewed-by: Konrad Dybcio --- drivers/tty/serial/qcom_geni_serial.c | 36 ++++++++++++++------------- 1 file changed, 19 insertions(+), 17 deletions(-) diff --git a/drivers/tty/serial/qcom_geni_serial.c b/drivers/tty/serial/qcom_geni_serial.c index 97ee7c074b79..e4139718e084 100644 --- a/drivers/tty/serial/qcom_geni_serial.c +++ b/drivers/tty/serial/qcom_geni_serial.c @@ -133,8 +133,10 @@ static const struct uart_ops qcom_geni_uart_pops; static struct uart_driver qcom_geni_console_driver; static struct uart_driver qcom_geni_uart_driver; -#define to_dev_port(ptr, member) \ - container_of(ptr, struct qcom_geni_serial_port, member) +static inline struct qcom_geni_serial_port *to_dev_port(struct uart_port *uport) +{ + return container_of(uport, struct qcom_geni_serial_port, uport); +} static struct qcom_geni_serial_port qcom_geni_uart_ports[GENI_UART_PORTS] = { [0] = { @@ -175,7 +177,7 @@ static struct qcom_geni_serial_port qcom_geni_console_port = { static int qcom_geni_serial_request_port(struct uart_port *uport) { struct platform_device *pdev = to_platform_device(uport->dev); - struct qcom_geni_serial_port *port = to_dev_port(uport, uport); + struct qcom_geni_serial_port *port = to_dev_port(uport); uport->membase = devm_platform_ioremap_resource(pdev, 0); if (IS_ERR(uport->membase)) @@ -212,7 +214,7 @@ static void qcom_geni_serial_set_mctrl(struct uart_port *uport, unsigned int mctrl) { u32 uart_manual_rfr = 0; - struct qcom_geni_serial_port *port = to_dev_port(uport, uport); + struct qcom_geni_serial_port *port = to_dev_port(uport); if (uart_console(uport)) return; @@ -253,7 +255,7 @@ static bool qcom_geni_serial_poll_bit(struct uart_port *uport, struct qcom_geni_private_data *private_data = uport->private_data; if (private_data->drv) { - port = to_dev_port(uport, uport); + port = to_dev_port(uport); baud = port->baud; if (!baud) baud = 115200; @@ -506,7 +508,7 @@ static int handle_rx_console(struct uart_port *uport, u32 bytes, bool drop) u32 i; unsigned char buf[sizeof(u32)]; struct tty_port *tport; - struct qcom_geni_serial_port *port = to_dev_port(uport, uport); + struct qcom_geni_serial_port *port = to_dev_port(uport); tport = &uport->state->port; for (i = 0; i < bytes; ) { @@ -549,7 +551,7 @@ static int handle_rx_console(struct uart_port *uport, u32 bytes, bool drop) static int handle_rx_uart(struct uart_port *uport, u32 bytes, bool drop) { struct tty_port *tport; - struct qcom_geni_serial_port *port = to_dev_port(uport, uport); + struct qcom_geni_serial_port *port = to_dev_port(uport); u32 num_bytes_pw = port->tx_fifo_width / BITS_PER_BYTE; u32 words = ALIGN(bytes, num_bytes_pw) / num_bytes_pw; int ret; @@ -598,7 +600,7 @@ static void qcom_geni_serial_stop_tx(struct uart_port *uport) { u32 irq_en; u32 status; - struct qcom_geni_serial_port *port = to_dev_port(uport, uport); + struct qcom_geni_serial_port *port = to_dev_port(uport); irq_en = readl(uport->membase + SE_GENI_M_IRQ_EN); irq_en &= ~(M_CMD_DONE_EN | M_TX_FIFO_WATERMARK_EN); @@ -627,7 +629,7 @@ static void qcom_geni_serial_handle_rx(struct uart_port *uport, bool drop) u32 last_word_byte_cnt; u32 last_word_partial; u32 total_bytes; - struct qcom_geni_serial_port *port = to_dev_port(uport, uport); + struct qcom_geni_serial_port *port = to_dev_port(uport); status = readl(uport->membase + SE_GENI_RX_FIFO_STATUS); word_cnt = status & RX_FIFO_WC_MSK; @@ -649,7 +651,7 @@ static void qcom_geni_serial_stop_rx(struct uart_port *uport) { u32 irq_en; u32 status; - struct qcom_geni_serial_port *port = to_dev_port(uport, uport); + struct qcom_geni_serial_port *port = to_dev_port(uport); u32 s_irq_status; irq_en = readl(uport->membase + SE_GENI_S_IRQ_EN); @@ -687,7 +689,7 @@ static void qcom_geni_serial_start_rx(struct uart_port *uport) { u32 irq_en; u32 status; - struct qcom_geni_serial_port *port = to_dev_port(uport, uport); + struct qcom_geni_serial_port *port = to_dev_port(uport); status = readl(uport->membase + SE_GENI_STATUS); if (status & S_GENI_CMD_ACTIVE) @@ -707,7 +709,7 @@ static void qcom_geni_serial_start_rx(struct uart_port *uport) static void qcom_geni_serial_handle_tx(struct uart_port *uport, bool done, bool active) { - struct qcom_geni_serial_port *port = to_dev_port(uport, uport); + struct qcom_geni_serial_port *port = to_dev_port(uport); struct circ_buf *xmit = &uport->state->xmit; size_t avail; size_t remaining; @@ -803,7 +805,7 @@ static irqreturn_t qcom_geni_serial_isr(int isr, void *dev) struct uart_port *uport = dev; bool drop_rx = false; struct tty_port *tport = &uport->state->port; - struct qcom_geni_serial_port *port = to_dev_port(uport, uport); + struct qcom_geni_serial_port *port = to_dev_port(uport); if (uport->suspended) return IRQ_NONE; @@ -869,7 +871,7 @@ static void qcom_geni_serial_shutdown(struct uart_port *uport) static int qcom_geni_serial_port_setup(struct uart_port *uport) { - struct qcom_geni_serial_port *port = to_dev_port(uport, uport); + struct qcom_geni_serial_port *port = to_dev_port(uport); u32 rxstale = DEFAULT_BITS_PER_CHAR * STALE_TIMEOUT; u32 proto; u32 pin_swap; @@ -917,7 +919,7 @@ static int qcom_geni_serial_port_setup(struct uart_port *uport) static int qcom_geni_serial_startup(struct uart_port *uport) { int ret; - struct qcom_geni_serial_port *port = to_dev_port(uport, uport); + struct qcom_geni_serial_port *port = to_dev_port(uport); if (!port->setup) { ret = qcom_geni_serial_port_setup(uport); @@ -1003,7 +1005,7 @@ static void qcom_geni_serial_set_termios(struct uart_port *uport, u32 stop_bit_len; unsigned int clk_div; u32 ser_clk_cfg; - struct qcom_geni_serial_port *port = to_dev_port(uport, uport); + struct qcom_geni_serial_port *port = to_dev_port(uport); unsigned long clk_rate; u32 ver, sampling_rate; unsigned int avg_bw_core; @@ -1288,7 +1290,7 @@ static struct uart_driver qcom_geni_uart_driver = { static void qcom_geni_serial_pm(struct uart_port *uport, unsigned int new_state, unsigned int old_state) { - struct qcom_geni_serial_port *port = to_dev_port(uport, uport); + struct qcom_geni_serial_port *port = to_dev_port(uport); /* If we've never been called, treat it as off */ if (old_state == UART_PM_STATE_UNDEFINED)