Re: [PATCH V14 3/5] i2c: tegra: Add DMA support

From: Dmitry Osipenko
Date: Thu Feb 07 2019 - 15:22:57 EST


07.02.2019 22:14, Dmitry Osipenko ÐÐÑÐÑ:
> 06.02.2019 22:16, Sowjanya Komatineni ÐÐÑÐÑ:
>> +static void tegra_i2c_config_fifo_trig(struct tegra_i2c_dev *i2c_dev,
>> + size_t len)
>> +{
>> + u32 val = 0, reg;
>> + u8 dma_burst = 0;

There is no need to set dma_burst to zero as well. In general you only need to initialize variables if code uses the uninitialized variable.

>> + struct dma_slave_config slv_config = {0};
>> + struct dma_chan *chan;
>> + int ret;
>> + unsigned long reg_offset;
>> +
>> + if (i2c_dev->hw->has_mst_fifo)
>> + reg = I2C_MST_FIFO_CONTROL;
>> + else
>> + reg = I2C_FIFO_CONTROL;
>> +
>> + if (i2c_dev->is_curr_dma_xfer) {
>> + if (len & 0xF)
>> + dma_burst = 1;
>> + else if (len & 0x10)
>> + dma_burst = 4;
>> + else
>> + dma_burst = 8;

In this case compiler just ignores the first initialization because it is explicitly initialized later on in the code path that actually uses the dma_burst variable. Avoiding unnecessary initialization helps to keep code a bit more clean.