lkml.org 
[lkml]   [2019]   [Feb]   [7]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
SubjectRe: [PATCH V14 3/5] i2c: tegra: Add DMA support
From
Date
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.

\
 
 \ /
  Last update: 2019-02-07 21:23    [W:0.376 / U:0.408 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site