Commit 69b2cc30 authored by Andy Shevchenko's avatar Andy Shevchenko Committed by Greg Kroah-Hartman

serial: max3100: Extract to_max3100_port() helper macro

Instead of using container_of() explicitly, introduce a helper macro.
This saves a lot of lines of code.
Signed-off-by: default avatarAndy Shevchenko <andriy.shevchenko@linux.intel.com>
Reviewed-by: default avatarHugo Villeneuve <hvilleneuve@dimonoff.com>
Link: https://lore.kernel.org/r/20240409144721.638326-8-andriy.shevchenko@linux.intel.comSigned-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent 1d01740e
...@@ -16,6 +16,7 @@ ...@@ -16,6 +16,7 @@
/* 4 MAX3100s should be enough for everyone */ /* 4 MAX3100s should be enough for everyone */
#define MAX_MAX3100 4 #define MAX_MAX3100 4
#include <linux/container_of.h>
#include <linux/delay.h> #include <linux/delay.h>
#include <linux/slab.h> #include <linux/slab.h>
#include <linux/device.h> #include <linux/device.h>
...@@ -110,6 +111,8 @@ struct max3100_port { ...@@ -110,6 +111,8 @@ struct max3100_port {
struct timer_list timer; struct timer_list timer;
}; };
#define to_max3100_port(port) container_of(port, struct max3100_port, port)
static struct max3100_port *max3100s[MAX_MAX3100]; /* the chips */ static struct max3100_port *max3100s[MAX_MAX3100]; /* the chips */
static DEFINE_MUTEX(max3100s_lock); /* race on probe */ static DEFINE_MUTEX(max3100s_lock); /* race on probe */
...@@ -320,9 +323,7 @@ static irqreturn_t max3100_irq(int irqno, void *dev_id) ...@@ -320,9 +323,7 @@ static irqreturn_t max3100_irq(int irqno, void *dev_id)
static void max3100_enable_ms(struct uart_port *port) static void max3100_enable_ms(struct uart_port *port)
{ {
struct max3100_port *s = container_of(port, struct max3100_port *s = to_max3100_port(port);
struct max3100_port,
port);
mod_timer(&s->timer, jiffies); mod_timer(&s->timer, jiffies);
dev_dbg(&s->spi->dev, "%s\n", __func__); dev_dbg(&s->spi->dev, "%s\n", __func__);
...@@ -330,9 +331,7 @@ static void max3100_enable_ms(struct uart_port *port) ...@@ -330,9 +331,7 @@ static void max3100_enable_ms(struct uart_port *port)
static void max3100_start_tx(struct uart_port *port) static void max3100_start_tx(struct uart_port *port)
{ {
struct max3100_port *s = container_of(port, struct max3100_port *s = to_max3100_port(port);
struct max3100_port,
port);
dev_dbg(&s->spi->dev, "%s\n", __func__); dev_dbg(&s->spi->dev, "%s\n", __func__);
...@@ -341,9 +340,7 @@ static void max3100_start_tx(struct uart_port *port) ...@@ -341,9 +340,7 @@ static void max3100_start_tx(struct uart_port *port)
static void max3100_stop_rx(struct uart_port *port) static void max3100_stop_rx(struct uart_port *port)
{ {
struct max3100_port *s = container_of(port, struct max3100_port *s = to_max3100_port(port);
struct max3100_port,
port);
dev_dbg(&s->spi->dev, "%s\n", __func__); dev_dbg(&s->spi->dev, "%s\n", __func__);
...@@ -357,9 +354,7 @@ static void max3100_stop_rx(struct uart_port *port) ...@@ -357,9 +354,7 @@ static void max3100_stop_rx(struct uart_port *port)
static unsigned int max3100_tx_empty(struct uart_port *port) static unsigned int max3100_tx_empty(struct uart_port *port)
{ {
struct max3100_port *s = container_of(port, struct max3100_port *s = to_max3100_port(port);
struct max3100_port,
port);
dev_dbg(&s->spi->dev, "%s\n", __func__); dev_dbg(&s->spi->dev, "%s\n", __func__);
...@@ -370,9 +365,7 @@ static unsigned int max3100_tx_empty(struct uart_port *port) ...@@ -370,9 +365,7 @@ static unsigned int max3100_tx_empty(struct uart_port *port)
static unsigned int max3100_get_mctrl(struct uart_port *port) static unsigned int max3100_get_mctrl(struct uart_port *port)
{ {
struct max3100_port *s = container_of(port, struct max3100_port *s = to_max3100_port(port);
struct max3100_port,
port);
dev_dbg(&s->spi->dev, "%s\n", __func__); dev_dbg(&s->spi->dev, "%s\n", __func__);
...@@ -384,9 +377,7 @@ static unsigned int max3100_get_mctrl(struct uart_port *port) ...@@ -384,9 +377,7 @@ static unsigned int max3100_get_mctrl(struct uart_port *port)
static void max3100_set_mctrl(struct uart_port *port, unsigned int mctrl) static void max3100_set_mctrl(struct uart_port *port, unsigned int mctrl)
{ {
struct max3100_port *s = container_of(port, struct max3100_port *s = to_max3100_port(port);
struct max3100_port,
port);
int loopback, rts; int loopback, rts;
dev_dbg(&s->spi->dev, "%s\n", __func__); dev_dbg(&s->spi->dev, "%s\n", __func__);
...@@ -412,9 +403,7 @@ static void ...@@ -412,9 +403,7 @@ static void
max3100_set_termios(struct uart_port *port, struct ktermios *termios, max3100_set_termios(struct uart_port *port, struct ktermios *termios,
const struct ktermios *old) const struct ktermios *old)
{ {
struct max3100_port *s = container_of(port, struct max3100_port *s = to_max3100_port(port);
struct max3100_port,
port);
unsigned int baud = port->uartclk / 16; unsigned int baud = port->uartclk / 16;
unsigned int baud230400 = (baud == 230400) ? 1 : 0; unsigned int baud230400 = (baud == 230400) ? 1 : 0;
unsigned cflag; unsigned cflag;
...@@ -530,9 +519,7 @@ max3100_set_termios(struct uart_port *port, struct ktermios *termios, ...@@ -530,9 +519,7 @@ max3100_set_termios(struct uart_port *port, struct ktermios *termios,
static void max3100_shutdown(struct uart_port *port) static void max3100_shutdown(struct uart_port *port)
{ {
struct max3100_port *s = container_of(port, struct max3100_port *s = to_max3100_port(port);
struct max3100_port,
port);
u16 rx; u16 rx;
dev_dbg(&s->spi->dev, "%s\n", __func__); dev_dbg(&s->spi->dev, "%s\n", __func__);
...@@ -557,9 +544,7 @@ static void max3100_shutdown(struct uart_port *port) ...@@ -557,9 +544,7 @@ static void max3100_shutdown(struct uart_port *port)
static int max3100_startup(struct uart_port *port) static int max3100_startup(struct uart_port *port)
{ {
struct max3100_port *s = container_of(port, struct max3100_port *s = to_max3100_port(port);
struct max3100_port,
port);
char b[12]; char b[12];
int ret; int ret;
...@@ -605,9 +590,7 @@ static int max3100_startup(struct uart_port *port) ...@@ -605,9 +590,7 @@ static int max3100_startup(struct uart_port *port)
static const char *max3100_type(struct uart_port *port) static const char *max3100_type(struct uart_port *port)
{ {
struct max3100_port *s = container_of(port, struct max3100_port *s = to_max3100_port(port);
struct max3100_port,
port);
dev_dbg(&s->spi->dev, "%s\n", __func__); dev_dbg(&s->spi->dev, "%s\n", __func__);
...@@ -616,18 +599,14 @@ static const char *max3100_type(struct uart_port *port) ...@@ -616,18 +599,14 @@ static const char *max3100_type(struct uart_port *port)
static void max3100_release_port(struct uart_port *port) static void max3100_release_port(struct uart_port *port)
{ {
struct max3100_port *s = container_of(port, struct max3100_port *s = to_max3100_port(port);
struct max3100_port,
port);
dev_dbg(&s->spi->dev, "%s\n", __func__); dev_dbg(&s->spi->dev, "%s\n", __func__);
} }
static void max3100_config_port(struct uart_port *port, int flags) static void max3100_config_port(struct uart_port *port, int flags)
{ {
struct max3100_port *s = container_of(port, struct max3100_port *s = to_max3100_port(port);
struct max3100_port,
port);
dev_dbg(&s->spi->dev, "%s\n", __func__); dev_dbg(&s->spi->dev, "%s\n", __func__);
...@@ -638,9 +617,7 @@ static void max3100_config_port(struct uart_port *port, int flags) ...@@ -638,9 +617,7 @@ static void max3100_config_port(struct uart_port *port, int flags)
static int max3100_verify_port(struct uart_port *port, static int max3100_verify_port(struct uart_port *port,
struct serial_struct *ser) struct serial_struct *ser)
{ {
struct max3100_port *s = container_of(port, struct max3100_port *s = to_max3100_port(port);
struct max3100_port,
port);
int ret = -EINVAL; int ret = -EINVAL;
dev_dbg(&s->spi->dev, "%s\n", __func__); dev_dbg(&s->spi->dev, "%s\n", __func__);
...@@ -652,18 +629,14 @@ static int max3100_verify_port(struct uart_port *port, ...@@ -652,18 +629,14 @@ static int max3100_verify_port(struct uart_port *port,
static void max3100_stop_tx(struct uart_port *port) static void max3100_stop_tx(struct uart_port *port)
{ {
struct max3100_port *s = container_of(port, struct max3100_port *s = to_max3100_port(port);
struct max3100_port,
port);
dev_dbg(&s->spi->dev, "%s\n", __func__); dev_dbg(&s->spi->dev, "%s\n", __func__);
} }
static int max3100_request_port(struct uart_port *port) static int max3100_request_port(struct uart_port *port)
{ {
struct max3100_port *s = container_of(port, struct max3100_port *s = to_max3100_port(port);
struct max3100_port,
port);
dev_dbg(&s->spi->dev, "%s\n", __func__); dev_dbg(&s->spi->dev, "%s\n", __func__);
return 0; return 0;
...@@ -671,9 +644,7 @@ static int max3100_request_port(struct uart_port *port) ...@@ -671,9 +644,7 @@ static int max3100_request_port(struct uart_port *port)
static void max3100_break_ctl(struct uart_port *port, int break_state) static void max3100_break_ctl(struct uart_port *port, int break_state)
{ {
struct max3100_port *s = container_of(port, struct max3100_port *s = to_max3100_port(port);
struct max3100_port,
port);
dev_dbg(&s->spi->dev, "%s\n", __func__); dev_dbg(&s->spi->dev, "%s\n", __func__);
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment