soundwire: stream: use FIELD_{GET|PREP}
authorVinod Koul <vkoul@kernel.org>
Thu, 3 Sep 2020 11:44:59 +0000 (17:14 +0530)
committerVinod Koul <vkoul@kernel.org>
Fri, 4 Sep 2020 09:16:42 +0000 (14:46 +0530)
use FIELD_{GET|PREP} in stream code to get/set field values instead of
open coding masks and shift operations.

Signed-off-by: Vinod Koul <vkoul@kernel.org>
Tested-by: Bard Liao <yung-chuan.liao@linux.intel.com>
Link: https://lore.kernel.org/r/20200903114504.1202143-5-vkoul@kernel.org
Signed-off-by: Vinod Koul <vkoul@kernel.org>
drivers/soundwire/stream.c

index e4cf484..afb95fe 100644 (file)
@@ -100,9 +100,7 @@ static int _sdw_program_slave_port_params(struct sdw_bus *bus,
                return ret;
 
        /* Program DPN_SampleCtrl2 register */
-       wbuf = (t_params->sample_interval - 1);
-       wbuf &= SDW_DPN_SAMPLECTRL_HIGH;
-       wbuf >>= SDW_REG_SHIFT(SDW_DPN_SAMPLECTRL_HIGH);
+       wbuf = FIELD_GET(SDW_DPN_SAMPLECTRL_HIGH, t_params->sample_interval - 1);
 
        ret = sdw_write(slave, addr3, wbuf);
        if (ret < 0) {
@@ -111,9 +109,8 @@ static int _sdw_program_slave_port_params(struct sdw_bus *bus,
        }
 
        /* Program DPN_HCtrl register */
-       wbuf = t_params->hstart;
-       wbuf <<= SDW_REG_SHIFT(SDW_DPN_HCTRL_HSTART);
-       wbuf |= t_params->hstop;
+       wbuf = FIELD_PREP(SDW_DPN_HCTRL_HSTART, t_params->hstart);
+       wbuf |= FIELD_PREP(SDW_DPN_HCTRL_HSTOP, t_params->hstop);
 
        ret = sdw_write(slave, addr4, wbuf);
        if (ret < 0)
@@ -157,8 +154,8 @@ static int sdw_program_slave_port_params(struct sdw_bus *bus,
        }
 
        /* Program DPN_PortCtrl register */
-       wbuf = p_params->data_mode << SDW_REG_SHIFT(SDW_DPN_PORTCTRL_DATAMODE);
-       wbuf |= p_params->flow_mode;
+       wbuf = FIELD_PREP(SDW_DPN_PORTCTRL_DATAMODE, p_params->data_mode);
+       wbuf |= FIELD_PREP(SDW_DPN_PORTCTRL_FLOWMODE, p_params->flow_mode);
 
        ret = sdw_update(s_rt->slave, addr1, 0xF, wbuf);
        if (ret < 0) {