Re: [PATCH v2 1/2] tty: serial: msm: Add mask value for UART_DM registers

From: Stephen Boyd
Date: Wed Apr 08 2015 - 19:32:03 EST


On 04/08/15 06:28, Pramod Gurav wrote:
> diff --git a/drivers/tty/serial/msm_serial.c b/drivers/tty/serial/msm_serial.c
> index b73889c..4c1e9ea 100644
> --- a/drivers/tty/serial/msm_serial.c
> +++ b/drivers/tty/serial/msm_serial.c
> @@ -432,8 +432,13 @@ static int msm_set_baud_rate(struct uart_port *port, unsigned int baud)
> /* RX stale watermark */
> rxstale = entry->rxstale;
> watermark = UART_IPR_STALE_LSB & rxstale;
> - watermark |= UART_IPR_RXSTALE_LAST;
> - watermark |= UART_IPR_STALE_TIMEOUT_MSB & (rxstale << 2);
> + if (msm_port->is_uartdm)
> + watermark |= UART_DM_IPR_STALE_TIMEOUT_MSB & (rxstale << 2);
> + else {
> + watermark |= UART_IPR_RXSTALE_LAST;
> + watermark |= UART_IPR_STALE_TIMEOUT_MSB & (rxstale << 2);
> + }
> +
> msm_write(port, watermark, UART_IPR);
>

This could be written like so:

if (msm_port->is_uartdm) {
mask = UART_DM_IPR_STALE_TIMEOUT_MSB;
} else {
watermark |= UART_IPR_RXSTALE_LAST;
mask = UART_IPR_STALE_TIMEOUT_MSB;
}

watermark |= mask & (rxstale << 2);

so that we don't duplicate the rfr_level << 2 part.

> /* set RX watermark */
> @@ -496,9 +501,15 @@ static int msm_startup(struct uart_port *port)
>
> /* set automatic RFR level */
> data = msm_read(port, UART_MR1);
> - data &= ~UART_MR1_AUTO_RFR_LEVEL1;
> + if (msm_port->is_uartdm) {
> + data &= ~UART_DM_MR1_AUTO_RFR_LEVEL1;
> + data |= UART_DM_MR1_AUTO_RFR_LEVEL1 & (rfr_level << 2);
> + } else {
> + data &= ~UART_MR1_AUTO_RFR_LEVEL1;
> + data |= UART_MR1_AUTO_RFR_LEVEL1 & (rfr_level << 2);
> + }
> +
> data &= ~UART_MR1_AUTO_RFR_LEVEL0;
> - data |= UART_MR1_AUTO_RFR_LEVEL1 & (rfr_level << 2);
> data |= UART_MR1_AUTO_RFR_LEVEL0 & rfr_level;
> msm_write(port, data, UART_MR1);
> return 0;

This could be written like so:

if (msm_port->is_uartdm)
mask = UART_DM_MR1_AUTO_RFR_LEVEL1;
else
mask = UART_MR1_AUTO_RFR_LEVE1;

data &= ~mask;
data &= ~UART_MR1_AUTO_RFR_LEVEL0;
data |= mask & (rfr_level << 2);
data |= UART_MR1_AUTO_RFR_LEVEL0 & rfr_level;

so that we don't duplicate the rfr_level << 2 part.

--
Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum,
a Linux Foundation Collaborative Project

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/