linux-arm-kernel.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
From: "Ilpo Järvinen" <ilpo.jarvinen@linux.intel.com>
To: Rasmus Villemoes <linux@rasmusvillemoes.dk>
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
	 Jiri Slaby <jirislaby@kernel.org>,
	Shawn Guo <shawnguo@kernel.org>,
	 Sascha Hauer <s.hauer@pengutronix.de>,
	 Pengutronix Kernel Team <kernel@pengutronix.de>,
	 Fabio Estevam <festevam@gmail.com>,
	LKML <linux-kernel@vger.kernel.org>,
	 linux-serial <linux-serial@vger.kernel.org>,
	imx@lists.linux.dev,  linux-arm-kernel@lists.infradead.org
Subject: Re: [PATCH] serial: imx: stop casting struct uart_port to struct imx_port
Date: Tue, 28 May 2024 13:25:45 +0300 (EEST)	[thread overview]
Message-ID: <a38e5be1-bd59-9c49-9cbd-a38016339056@linux.intel.com> (raw)
In-Reply-To: <20240528094022.2161066-1-linux@rasmusvillemoes.dk>

[-- Attachment #1: Type: text/plain, Size: 7762 bytes --]

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.
> 
> Similar to many other serial drivers, introduce and use a
> to_imx_port() helper based on container_of(). No functional change.
> 
> Signed-off-by: Rasmus Villemoes <linux@rasmusvillemoes.dk>
> ---

Reviewed-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com>

-- 
 i.

>  drivers/tty/serial/imx.c | 41 ++++++++++++++++++++++------------------
>  1 file changed, 23 insertions(+), 18 deletions(-)
> 
> 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[] = {
>  };
>  MODULE_DEVICE_TABLE(of, imx_uart_dt_ids);
>  
> +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)
>  {
>  	writel(val, sport->port.membase + offset);
> @@ -377,7 +382,7 @@ static void imx_uart_disable_loopback_rs485(struct imx_port *sport)
>  /* called with port.lock taken and irqs off */
>  static void imx_uart_start_rx(struct uart_port *port)
>  {
> -	struct imx_port *sport = (struct imx_port *)port;
> +	struct imx_port *sport = to_imx_port(port);
>  	unsigned int ucr1, ucr2;
>  
>  	ucr1 = 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)
>  {
> -	struct imx_port *sport = (struct imx_port *)port;
> +	struct imx_port *sport = to_imx_port(port);
>  	u32 ucr1, ucr4, usr2;
>  
>  	if (sport->tx_state == OFF)
> @@ -466,7 +471,7 @@ static void imx_uart_stop_tx(struct uart_port *port)
>  
>  static void imx_uart_stop_rx_with_loopback_ctrl(struct uart_port *port, bool loopback)
>  {
> -	struct imx_port *sport = (struct imx_port *)port;
> +	struct imx_port *sport = to_imx_port(port);
>  	u32 ucr1, ucr2, ucr4, uts;
>  
>  	ucr1 = 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)
>  {
> -	struct imx_port *sport = (struct imx_port *)port;
> +	struct imx_port *sport = to_imx_port(port);
>  
>  	mod_timer(&sport->timer, jiffies);
>  
> @@ -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)
>  {
> -	struct imx_port *sport = (struct imx_port *)port;
> +	struct imx_port *sport = to_imx_port(port);
>  	struct tty_port *tport = &sport->port.state->port;
>  	u32 ucr1;
>  
> @@ -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)
>  {
> -	struct imx_port *sport = (struct imx_port *)port;
> +	struct imx_port *sport = to_imx_port(port);
>  	unsigned int ret;
>  
>  	ret = (imx_uart_readl(sport, USR2) & USR2_TXDC) ?  TIOCSER_TEMT : 0;
> @@ -1058,7 +1063,7 @@ static unsigned int imx_uart_tx_empty(struct uart_port *port)
>  /* called with port.lock taken and irqs off */
>  static unsigned int imx_uart_get_mctrl(struct uart_port *port)
>  {
> -	struct imx_port *sport = (struct imx_port *)port;
> +	struct imx_port *sport = to_imx_port(port);
>  	unsigned int ret = imx_uart_get_hwmctrl(sport);
>  
>  	mctrl_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 mctrl)
>  {
> -	struct imx_port *sport = (struct imx_port *)port;
> +	struct imx_port *sport = to_imx_port(port);
>  	u32 ucr3, uts;
>  
>  	if (!(port->rs485.flags & SER_RS485_ENABLED)) {
> @@ -1112,7 +1117,7 @@ static void imx_uart_set_mctrl(struct uart_port *port, unsigned int mctrl)
>   */
>  static void imx_uart_break_ctl(struct uart_port *port, int break_state)
>  {
> -	struct imx_port *sport = (struct imx_port *)port;
> +	struct imx_port *sport = to_imx_port(port);
>  	unsigned long flags;
>  	u32 ucr1;
>  
> @@ -1434,7 +1439,7 @@ static void imx_uart_disable_dma(struct imx_port *sport)
>  
>  static int imx_uart_startup(struct uart_port *port)
>  {
> -	struct imx_port *sport = (struct imx_port *)port;
> +	struct imx_port *sport = to_imx_port(port);
>  	int retval;
>  	unsigned long flags;
>  	int dma_is_inited = 0;
> @@ -1548,7 +1553,7 @@ static int imx_uart_startup(struct uart_port *port)
>  
>  static void imx_uart_shutdown(struct uart_port *port)
>  {
> -	struct imx_port *sport = (struct imx_port *)port;
> +	struct imx_port *sport = to_imx_port(port);
>  	unsigned long flags;
>  	u32 ucr1, ucr2, ucr4, uts;
>  
> @@ -1622,7 +1627,7 @@ static void imx_uart_shutdown(struct uart_port *port)
>  /* called with port.lock taken and irqs off */
>  static void imx_uart_flush_buffer(struct uart_port *port)
>  {
> -	struct imx_port *sport = (struct imx_port *)port;
> +	struct imx_port *sport = to_imx_port(port);
>  	struct scatterlist *sgl = &sport->tx_sgl[0];
>  
>  	if (!sport->dma_chan_tx)
> @@ -1649,7 +1654,7 @@ static void
>  imx_uart_set_termios(struct uart_port *port, struct ktermios *termios,
>  		     const struct ktermios *old)
>  {
> -	struct imx_port *sport = (struct imx_port *)port;
> +	struct imx_port *sport = to_imx_port(port);
>  	unsigned long flags;
>  	u32 ucr2, old_ucr2, ufcr;
>  	unsigned int baud, quot;
> @@ -1852,7 +1857,7 @@ imx_uart_verify_port(struct uart_port *port, struct serial_struct *ser)
>  
>  static int imx_uart_poll_init(struct uart_port *port)
>  {
> -	struct imx_port *sport = (struct imx_port *)port;
> +	struct imx_port *sport = to_imx_port(port);
>  	unsigned long flags;
>  	u32 ucr1, ucr2;
>  	int retval;
> @@ -1901,7 +1906,7 @@ static int imx_uart_poll_init(struct uart_port *port)
>  
>  static int imx_uart_poll_get_char(struct uart_port *port)
>  {
> -	struct imx_port *sport = (struct imx_port *)port;
> +	struct imx_port *sport = to_imx_port(port);
>  	if (!(imx_uart_readl(sport, USR2) & USR2_RDR))
>  		return NO_POLL_CHAR;
>  
> @@ -1910,7 +1915,7 @@ static int imx_uart_poll_get_char(struct uart_port *port)
>  
>  static void imx_uart_poll_put_char(struct uart_port *port, unsigned char c)
>  {
> -	struct imx_port *sport = (struct imx_port *)port;
> +	struct imx_port *sport = to_imx_port(port);
>  	unsigned int status;
>  
>  	/* 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,
>  				 struct serial_rs485 *rs485conf)
>  {
> -	struct imx_port *sport = (struct imx_port *)port;
> +	struct imx_port *sport = to_imx_port(port);
>  	u32 ucr2;
>  
>  	if (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 char ch)
>  {
> -	struct imx_port *sport = (struct imx_port *)port;
> +	struct imx_port *sport = to_imx_port(port);
>  
>  	while (imx_uart_readl(sport, imx_uart_uts_reg(sport)) & UTS_TXFULL)
>  		barrier();
> 

[-- Attachment #2: Type: text/plain, Size: 176 bytes --]

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

  reply	other threads:[~2024-05-28 10:26 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-05-28  9:40 [PATCH] serial: imx: stop casting struct uart_port to struct imx_port Rasmus Villemoes
2024-05-28 10:25 ` Ilpo Järvinen [this message]
2024-05-28 13:19 ` Fabio Estevam

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=a38e5be1-bd59-9c49-9cbd-a38016339056@linux.intel.com \
    --to=ilpo.jarvinen@linux.intel.com \
    --cc=festevam@gmail.com \
    --cc=gregkh@linuxfoundation.org \
    --cc=imx@lists.linux.dev \
    --cc=jirislaby@kernel.org \
    --cc=kernel@pengutronix.de \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-serial@vger.kernel.org \
    --cc=linux@rasmusvillemoes.dk \
    --cc=s.hauer@pengutronix.de \
    --cc=shawnguo@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).