current code only works because struct uart_port
is the first member on the uart_omap_port structure.
If, for whatever reason, someone puts another
member as the first of the structure, that cast
won't work anymore. In order to be safe, let's use
a container_of() which, for now, gets optimized into
a cast anyway.
Tested-by: Shubhrajyoti D <shubhrajyoti@ti.com>
Acked-by: Santosh Shilimkar <santosh.shilimkar@ti.com>
Signed-off-by: Felipe Balbi <balbi@ti.com>
Acked-by: Tony Lindgren <tony@atomide.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
struct work_struct qos_work;
};
struct work_struct qos_work;
};
+#define to_uart_omap_port(p) ((container_of((p), struct uart_omap_port, port)))
+
#endif /* __OMAP_SERIAL_H__ */
#endif /* __OMAP_SERIAL_H__ */
static void serial_omap_enable_ms(struct uart_port *port)
{
static void serial_omap_enable_ms(struct uart_port *port)
{
- struct uart_omap_port *up = (struct uart_omap_port *)port;
+ struct uart_omap_port *up = to_uart_omap_port(port);
dev_dbg(up->port.dev, "serial_omap_enable_ms+%d\n", up->port.line);
dev_dbg(up->port.dev, "serial_omap_enable_ms+%d\n", up->port.line);
static void serial_omap_stop_tx(struct uart_port *port)
{
static void serial_omap_stop_tx(struct uart_port *port)
{
- struct uart_omap_port *up = (struct uart_omap_port *)port;
+ struct uart_omap_port *up = to_uart_omap_port(port);
struct omap_uart_port_info *pdata = up->pdev->dev.platform_data;
if (up->use_dma &&
struct omap_uart_port_info *pdata = up->pdev->dev.platform_data;
if (up->use_dma &&
static void serial_omap_stop_rx(struct uart_port *port)
{
static void serial_omap_stop_rx(struct uart_port *port)
{
- struct uart_omap_port *up = (struct uart_omap_port *)port;
+ struct uart_omap_port *up = to_uart_omap_port(port);
pm_runtime_get_sync(&up->pdev->dev);
if (up->use_dma)
pm_runtime_get_sync(&up->pdev->dev);
if (up->use_dma)
static void serial_omap_start_tx(struct uart_port *port)
{
static void serial_omap_start_tx(struct uart_port *port)
{
- struct uart_omap_port *up = (struct uart_omap_port *)port;
+ struct uart_omap_port *up = to_uart_omap_port(port);
struct omap_uart_port_info *pdata = up->pdev->dev.platform_data;
struct circ_buf *xmit;
unsigned int start;
struct omap_uart_port_info *pdata = up->pdev->dev.platform_data;
struct circ_buf *xmit;
unsigned int start;
static unsigned int serial_omap_tx_empty(struct uart_port *port)
{
static unsigned int serial_omap_tx_empty(struct uart_port *port)
{
- struct uart_omap_port *up = (struct uart_omap_port *)port;
+ struct uart_omap_port *up = to_uart_omap_port(port);
unsigned long flags = 0;
unsigned int ret = 0;
unsigned long flags = 0;
unsigned int ret = 0;
static unsigned int serial_omap_get_mctrl(struct uart_port *port)
{
static unsigned int serial_omap_get_mctrl(struct uart_port *port)
{
- struct uart_omap_port *up = (struct uart_omap_port *)port;
+ struct uart_omap_port *up = to_uart_omap_port(port);
unsigned int status;
unsigned int ret = 0;
unsigned int status;
unsigned int ret = 0;
static void serial_omap_set_mctrl(struct uart_port *port, unsigned int mctrl)
{
static void serial_omap_set_mctrl(struct uart_port *port, unsigned int mctrl)
{
- struct uart_omap_port *up = (struct uart_omap_port *)port;
+ struct uart_omap_port *up = to_uart_omap_port(port);
unsigned char mcr = 0;
dev_dbg(up->port.dev, "serial_omap_set_mctrl+%d\n", up->port.line);
unsigned char mcr = 0;
dev_dbg(up->port.dev, "serial_omap_set_mctrl+%d\n", up->port.line);
static void serial_omap_break_ctl(struct uart_port *port, int break_state)
{
static void serial_omap_break_ctl(struct uart_port *port, int break_state)
{
- struct uart_omap_port *up = (struct uart_omap_port *)port;
+ struct uart_omap_port *up = to_uart_omap_port(port);
unsigned long flags = 0;
dev_dbg(up->port.dev, "serial_omap_break_ctl+%d\n", up->port.line);
unsigned long flags = 0;
dev_dbg(up->port.dev, "serial_omap_break_ctl+%d\n", up->port.line);
static int serial_omap_startup(struct uart_port *port)
{
static int serial_omap_startup(struct uart_port *port)
{
- struct uart_omap_port *up = (struct uart_omap_port *)port;
+ struct uart_omap_port *up = to_uart_omap_port(port);
unsigned long flags = 0;
int retval;
unsigned long flags = 0;
int retval;
static void serial_omap_shutdown(struct uart_port *port)
{
static void serial_omap_shutdown(struct uart_port *port)
{
- struct uart_omap_port *up = (struct uart_omap_port *)port;
+ struct uart_omap_port *up = to_uart_omap_port(port);
unsigned long flags = 0;
dev_dbg(up->port.dev, "serial_omap_shutdown+%d\n", up->port.line);
unsigned long flags = 0;
dev_dbg(up->port.dev, "serial_omap_shutdown+%d\n", up->port.line);
serial_omap_set_termios(struct uart_port *port, struct ktermios *termios,
struct ktermios *old)
{
serial_omap_set_termios(struct uart_port *port, struct ktermios *termios,
struct ktermios *old)
{
- struct uart_omap_port *up = (struct uart_omap_port *)port;
+ struct uart_omap_port *up = to_uart_omap_port(port);
unsigned char cval = 0;
unsigned char efr = 0;
unsigned long flags = 0;
unsigned char cval = 0;
unsigned char efr = 0;
unsigned long flags = 0;
serial_omap_pm(struct uart_port *port, unsigned int state,
unsigned int oldstate)
{
serial_omap_pm(struct uart_port *port, unsigned int state,
unsigned int oldstate)
{
- struct uart_omap_port *up = (struct uart_omap_port *)port;
+ struct uart_omap_port *up = to_uart_omap_port(port);
unsigned char efr;
dev_dbg(up->port.dev, "serial_omap_pm+%d\n", up->port.line);
unsigned char efr;
dev_dbg(up->port.dev, "serial_omap_pm+%d\n", up->port.line);
static void serial_omap_config_port(struct uart_port *port, int flags)
{
static void serial_omap_config_port(struct uart_port *port, int flags)
{
- struct uart_omap_port *up = (struct uart_omap_port *)port;
+ struct uart_omap_port *up = to_uart_omap_port(port);
dev_dbg(up->port.dev, "serial_omap_config_port+%d\n",
up->port.line);
dev_dbg(up->port.dev, "serial_omap_config_port+%d\n",
up->port.line);
static const char *
serial_omap_type(struct uart_port *port)
{
static const char *
serial_omap_type(struct uart_port *port)
{
- struct uart_omap_port *up = (struct uart_omap_port *)port;
+ struct uart_omap_port *up = to_uart_omap_port(port);
dev_dbg(up->port.dev, "serial_omap_type+%d\n", up->port.line);
return up->name;
dev_dbg(up->port.dev, "serial_omap_type+%d\n", up->port.line);
return up->name;
static void serial_omap_poll_put_char(struct uart_port *port, unsigned char ch)
{
static void serial_omap_poll_put_char(struct uart_port *port, unsigned char ch)
{
- struct uart_omap_port *up = (struct uart_omap_port *)port;
+ struct uart_omap_port *up = to_uart_omap_port(port);
pm_runtime_get_sync(&up->pdev->dev);
wait_for_xmitr(up);
pm_runtime_get_sync(&up->pdev->dev);
wait_for_xmitr(up);
static int serial_omap_poll_get_char(struct uart_port *port)
{
static int serial_omap_poll_get_char(struct uart_port *port)
{
- struct uart_omap_port *up = (struct uart_omap_port *)port;
+ struct uart_omap_port *up = to_uart_omap_port(port);
unsigned int status;
pm_runtime_get_sync(&up->pdev->dev);
unsigned int status;
pm_runtime_get_sync(&up->pdev->dev);
static void serial_omap_console_putchar(struct uart_port *port, int ch)
{
static void serial_omap_console_putchar(struct uart_port *port, int ch)
{
- struct uart_omap_port *up = (struct uart_omap_port *)port;
+ struct uart_omap_port *up = to_uart_omap_port(port);
wait_for_xmitr(up);
serial_out(up, UART_TX, ch);
wait_for_xmitr(up);
serial_out(up, UART_TX, ch);
static void uart_tx_dma_callback(int lch, u16 ch_status, void *data)
{
static void uart_tx_dma_callback(int lch, u16 ch_status, void *data)
{
- struct uart_omap_port *up = (struct uart_omap_port *)data;
+ struct uart_omap_port *up = data;
struct circ_buf *xmit = &up->port.state->xmit;
xmit->tail = (xmit->tail + up->uart_dma.tx_buf_size) & \
struct circ_buf *xmit = &up->port.state->xmit;
xmit->tail = (xmit->tail + up->uart_dma.tx_buf_size) & \