From mboxrd@z Thu Jan 1 00:00:00 1970 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 bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 7FB20C25B78 for ; Tue, 28 May 2024 10:26:11 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:Content-Type:MIME-Version: References:Message-ID:In-Reply-To:Subject:cc:To:Date:From:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=2S+Rg1Q2AKQq9OFPZJKwY3HV8ChOeHUPb97GVPXsNdQ=; b=nK0U5FHLZtN0xFvV9VF2lHsRHm 5naWmF47tgdput9rwRhTtNQU6CBFZVf/AdiiEucfAzvhcmpWkFKNsp5k5bLrlHVTuVy+E4tD5M19L B36N6ZfvZ8OzJQbWb5quG0Zdouq2gHCtAxisYdOlF27HhZ8CMmCdxu6H3o3DfOapaUULDN+XLQa9/ D/4M/24m/21WEL9L6R+phneqBq9I5gYmftLNM/YGJGt6HW73FglQnk3Sfwwn2+lZ6QzEeaGdbuc+O 1tfn667xWY8ADbXos9uOPb4UuTEmbq8xv/aJXl1Nx8DL6mWBkVhzjTFNshzYRTUgegYs97m/Yqc+k F8OqR3hQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1sBu1m-00000000DhF-1Dux; Tue, 28 May 2024 10:25:58 +0000 Received: from mgamail.intel.com ([192.198.163.9]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1sBu1k-00000000Dfy-0SiU for linux-arm-kernel@lists.infradead.org; Tue, 28 May 2024 10:25:57 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1716891956; x=1748427956; h=from:date:to:cc:subject:in-reply-to:message-id: references:mime-version; bh=tgPh+RpBIfdWk/QjkJbuJ+eXr/a+KHa8hR+sOmjii/0=; b=Af3xXXHfsDLUhtzWGrVN2i02BOXYdsiz1+fQcE2TxxB5K1euIzdKZ0+0 eVe5Lg0Lv8/ohRVYecFCPWmvvW3IF0VUpQ+0iWdEsL1lw7xQRpNbwfTbv nJpo3gnbkNOdhN/L59mDsSeE2j4OXGsCGX8F6jWXedUiq+x3E98Cag7qE uln8co2JOWP5yiSVzzLYbBj0Hcrg2dlTgsUwu8WN/MJ+kPwjLpTi3Tope IzP67UOj0BOjCWnwJIyQYiZrwfbtMz1jxOISUHcDUGegkh42ji1bQgq+L PVRvyfpeTV/drE+pTFE1a8G9QCKyP5lBlwJqSlYuYEf8t5lbqDY0COk4/ A==; X-CSE-ConnectionGUID: OyP9jxwnRlG2lOQyokvGcg== X-CSE-MsgGUID: b3KFS1v3SMKGQ1eJyykkJg== X-IronPort-AV: E=McAfee;i="6600,9927,11085"; a="23892142" X-IronPort-AV: E=Sophos;i="6.08,195,1712646000"; d="scan'208";a="23892142" Received: from orviesa002.jf.intel.com ([10.64.159.142]) by fmvoesa103.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 28 May 2024 03:25:54 -0700 X-CSE-ConnectionGUID: L9RQ2n1MTXisYN38Q8FxiQ== X-CSE-MsgGUID: MMTs3l13TW2g4FLH0Q3cJQ== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.08,195,1712646000"; d="scan'208";a="65860340" Received: from ijarvine-desk1.ger.corp.intel.com (HELO localhost) ([10.245.247.144]) by orviesa002-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 28 May 2024 03:25:49 -0700 From: =?UTF-8?q?Ilpo=20J=C3=A4rvinen?= Date: Tue, 28 May 2024 13:25:45 +0300 (EEST) To: Rasmus Villemoes cc: Greg Kroah-Hartman , Jiri Slaby , Shawn Guo , Sascha Hauer , Pengutronix Kernel Team , Fabio Estevam , LKML , linux-serial , imx@lists.linux.dev, linux-arm-kernel@lists.infradead.org Subject: Re: [PATCH] serial: imx: stop casting struct uart_port to struct imx_port In-Reply-To: <20240528094022.2161066-1-linux@rasmusvillemoes.dk> Message-ID: References: <20240528094022.2161066-1-linux@rasmusvillemoes.dk> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="8323328-270992698-1716891945=:5869" X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240528_032556_192008_8747249C X-CRM114-Status: GOOD ( 18.56 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org This message is in MIME format. The first part should be readable text, while the remaining parts are likely unreadable without MIME-aware tools. --8323328-270992698-1716891945=:5869 Content-Type: text/plain; charset=ISO-8859-15 Content-Transfer-Encoding: QUOTED-PRINTABLE On Tue, 28 May 2024, Rasmus Villemoes wrote: > struct imx_port does have a struct uart_port as its first member, so > the current code works, but it is not how kernel code is usually > written. >=20 > Similar to many other serial drivers, introduce and use a > to_imx_port() helper based on container_of(). No functional change. >=20 > Signed-off-by: Rasmus Villemoes > --- Reviewed-by: Ilpo J=E4rvinen --=20 i. > drivers/tty/serial/imx.c | 41 ++++++++++++++++++++++------------------ > 1 file changed, 23 insertions(+), 18 deletions(-) >=20 > diff --git a/drivers/tty/serial/imx.c b/drivers/tty/serial/imx.c > index 2eb22594960f..f5cfe5571e0e 100644 > --- a/drivers/tty/serial/imx.c > +++ b/drivers/tty/serial/imx.c > @@ -264,6 +264,11 @@ static const struct of_device_id imx_uart_dt_ids[] = =3D { > }; > MODULE_DEVICE_TABLE(of, imx_uart_dt_ids); > =20 > +static inline struct imx_port *to_imx_port(struct uart_port *port) > +{ > + return container_of(port, struct imx_port, port); > +} > + > static inline void imx_uart_writel(struct imx_port *sport, u32 val, u32 = offset) > { > =09writel(val, sport->port.membase + offset); > @@ -377,7 +382,7 @@ static void imx_uart_disable_loopback_rs485(struct im= x_port *sport) > /* called with port.lock taken and irqs off */ > static void imx_uart_start_rx(struct uart_port *port) > { > -=09struct imx_port *sport =3D (struct imx_port *)port; > +=09struct imx_port *sport =3D to_imx_port(port); > =09unsigned int ucr1, ucr2; > =20 > =09ucr1 =3D imx_uart_readl(sport, UCR1); > @@ -401,7 +406,7 @@ static void imx_uart_start_rx(struct uart_port *port) > /* called with port.lock taken and irqs off */ > static void imx_uart_stop_tx(struct uart_port *port) > { > -=09struct imx_port *sport =3D (struct imx_port *)port; > +=09struct imx_port *sport =3D to_imx_port(port); > =09u32 ucr1, ucr4, usr2; > =20 > =09if (sport->tx_state =3D=3D OFF) > @@ -466,7 +471,7 @@ static void imx_uart_stop_tx(struct uart_port *port) > =20 > static void imx_uart_stop_rx_with_loopback_ctrl(struct uart_port *port, = bool loopback) > { > -=09struct imx_port *sport =3D (struct imx_port *)port; > +=09struct imx_port *sport =3D to_imx_port(port); > =09u32 ucr1, ucr2, ucr4, uts; > =20 > =09ucr1 =3D imx_uart_readl(sport, UCR1); > @@ -511,7 +516,7 @@ static void imx_uart_stop_rx(struct uart_port *port) > /* called with port.lock taken and irqs off */ > static void imx_uart_enable_ms(struct uart_port *port) > { > -=09struct imx_port *sport =3D (struct imx_port *)port; > +=09struct imx_port *sport =3D to_imx_port(port); > =20 > =09mod_timer(&sport->timer, jiffies); > =20 > @@ -662,7 +667,7 @@ static void imx_uart_dma_tx(struct imx_port *sport) > /* called with port.lock taken and irqs off */ > static void imx_uart_start_tx(struct uart_port *port) > { > -=09struct imx_port *sport =3D (struct imx_port *)port; > +=09struct imx_port *sport =3D to_imx_port(port); > =09struct tty_port *tport =3D &sport->port.state->port; > =09u32 ucr1; > =20 > @@ -1043,7 +1048,7 @@ static irqreturn_t imx_uart_int(int irq, void *dev_= id) > */ > static unsigned int imx_uart_tx_empty(struct uart_port *port) > { > -=09struct imx_port *sport =3D (struct imx_port *)port; > +=09struct imx_port *sport =3D to_imx_port(port); > =09unsigned int ret; > =20 > =09ret =3D (imx_uart_readl(sport, USR2) & USR2_TXDC) ? TIOCSER_TEMT : 0= ; > @@ -1058,7 +1063,7 @@ static unsigned int imx_uart_tx_empty(struct uart_p= ort *port) > /* called with port.lock taken and irqs off */ > static unsigned int imx_uart_get_mctrl(struct uart_port *port) > { > -=09struct imx_port *sport =3D (struct imx_port *)port; > +=09struct imx_port *sport =3D to_imx_port(port); > =09unsigned int ret =3D imx_uart_get_hwmctrl(sport); > =20 > =09mctrl_gpio_get(sport->gpios, &ret); > @@ -1069,7 +1074,7 @@ static unsigned int imx_uart_get_mctrl(struct uart_= port *port) > /* called with port.lock taken and irqs off */ > static void imx_uart_set_mctrl(struct uart_port *port, unsigned int mctr= l) > { > -=09struct imx_port *sport =3D (struct imx_port *)port; > +=09struct imx_port *sport =3D to_imx_port(port); > =09u32 ucr3, uts; > =20 > =09if (!(port->rs485.flags & SER_RS485_ENABLED)) { > @@ -1112,7 +1117,7 @@ static void imx_uart_set_mctrl(struct uart_port *po= rt, unsigned int mctrl) > */ > static void imx_uart_break_ctl(struct uart_port *port, int break_state) > { > -=09struct imx_port *sport =3D (struct imx_port *)port; > +=09struct imx_port *sport =3D to_imx_port(port); > =09unsigned long flags; > =09u32 ucr1; > =20 > @@ -1434,7 +1439,7 @@ static void imx_uart_disable_dma(struct imx_port *s= port) > =20 > static int imx_uart_startup(struct uart_port *port) > { > -=09struct imx_port *sport =3D (struct imx_port *)port; > +=09struct imx_port *sport =3D to_imx_port(port); > =09int retval; > =09unsigned long flags; > =09int dma_is_inited =3D 0; > @@ -1548,7 +1553,7 @@ static int imx_uart_startup(struct uart_port *port) > =20 > static void imx_uart_shutdown(struct uart_port *port) > { > -=09struct imx_port *sport =3D (struct imx_port *)port; > +=09struct imx_port *sport =3D to_imx_port(port); > =09unsigned long flags; > =09u32 ucr1, ucr2, ucr4, uts; > =20 > @@ -1622,7 +1627,7 @@ static void imx_uart_shutdown(struct uart_port *por= t) > /* called with port.lock taken and irqs off */ > static void imx_uart_flush_buffer(struct uart_port *port) > { > -=09struct imx_port *sport =3D (struct imx_port *)port; > +=09struct imx_port *sport =3D to_imx_port(port); > =09struct scatterlist *sgl =3D &sport->tx_sgl[0]; > =20 > =09if (!sport->dma_chan_tx) > @@ -1649,7 +1654,7 @@ static void > imx_uart_set_termios(struct uart_port *port, struct ktermios *termios, > =09=09 const struct ktermios *old) > { > -=09struct imx_port *sport =3D (struct imx_port *)port; > +=09struct imx_port *sport =3D to_imx_port(port); > =09unsigned long flags; > =09u32 ucr2, old_ucr2, ufcr; > =09unsigned int baud, quot; > @@ -1852,7 +1857,7 @@ imx_uart_verify_port(struct uart_port *port, struct= serial_struct *ser) > =20 > static int imx_uart_poll_init(struct uart_port *port) > { > -=09struct imx_port *sport =3D (struct imx_port *)port; > +=09struct imx_port *sport =3D to_imx_port(port); > =09unsigned long flags; > =09u32 ucr1, ucr2; > =09int retval; > @@ -1901,7 +1906,7 @@ static int imx_uart_poll_init(struct uart_port *por= t) > =20 > static int imx_uart_poll_get_char(struct uart_port *port) > { > -=09struct imx_port *sport =3D (struct imx_port *)port; > +=09struct imx_port *sport =3D to_imx_port(port); > =09if (!(imx_uart_readl(sport, USR2) & USR2_RDR)) > =09=09return NO_POLL_CHAR; > =20 > @@ -1910,7 +1915,7 @@ static int imx_uart_poll_get_char(struct uart_port = *port) > =20 > static void imx_uart_poll_put_char(struct uart_port *port, unsigned char= c) > { > -=09struct imx_port *sport =3D (struct imx_port *)port; > +=09struct imx_port *sport =3D to_imx_port(port); > =09unsigned int status; > =20 > =09/* drain */ > @@ -1932,7 +1937,7 @@ static void imx_uart_poll_put_char(struct uart_port= *port, unsigned char c) > static int imx_uart_rs485_config(struct uart_port *port, struct ktermios= *termios, > =09=09=09=09 struct serial_rs485 *rs485conf) > { > -=09struct imx_port *sport =3D (struct imx_port *)port; > +=09struct imx_port *sport =3D to_imx_port(port); > =09u32 ucr2; > =20 > =09if (rs485conf->flags & SER_RS485_ENABLED) { > @@ -1986,7 +1991,7 @@ static struct imx_port *imx_uart_ports[UART_NR]; > #if IS_ENABLED(CONFIG_SERIAL_IMX_CONSOLE) > static void imx_uart_console_putchar(struct uart_port *port, unsigned ch= ar ch) > { > -=09struct imx_port *sport =3D (struct imx_port *)port; > +=09struct imx_port *sport =3D to_imx_port(port); > =20 > =09while (imx_uart_readl(sport, imx_uart_uts_reg(sport)) & UTS_TXFULL) > =09=09barrier(); >=20 --8323328-270992698-1716891945=:5869 Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: inline _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel --8323328-270992698-1716891945=:5869--