drivers/mmc/host/bcm2835.c:1343:3-16: opportunity for str_enabled_disabled(host -> dma_dev)

From: kernel test robot

Date: Thu Sep 17 2026 - 10:51:37 EST


tree: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git master
head: 238650ef6c7c7cca08e032527329424c9fbd70e5
commit: 5608386899d9de8030980bce3d05bded28f9bfb8 mmc: bcm2835: DMA mapping improvements
date: 9 weeks ago
config: riscv-randconfig-r2104-20260917 (https://download.01.org/0day-ci/archive/20260917/202609171525.Y5oqkp1i-lkp@xxxxxxxxx/config)
compiler: clang version 24.0.0git (https://github.com/llvm/llvm-project c20428cbb5f551d54520d492b1d27011e4076f5b)
rustc: rustc 1.96.0 (ac68faa20 2026-05-25)

If you fix the issue in a separate patch/commit (i.e. not just a new version of
the same patch/commit), kindly add following tags
| Fixes: 5608386899d9 ("mmc: bcm2835: DMA mapping improvements")
| Reported-by: kernel test robot <lkp@xxxxxxxxx>
| Closes: https://lore.kernel.org/oe-kbuild-all/202609171525.Y5oqkp1i-lkp@xxxxxxxxx/

cocci warnings: (new ones prefixed by >>)
>> drivers/mmc/host/bcm2835.c:1343:3-16: opportunity for str_enabled_disabled(host -> dma_dev)

vim +1343 drivers/mmc/host/bcm2835.c

1256
1257 static int bcm2835_add_host(struct bcm2835_host *host)
1258 {
1259 struct mmc_host *mmc = mmc_from_priv(host);
1260 struct device *dev = &host->pdev->dev;
1261 char pio_limit_string[20];
1262 int ret;
1263
1264 if (!mmc->f_max || mmc->f_max > host->max_clk)
1265 mmc->f_max = host->max_clk;
1266 mmc->f_min = host->max_clk / SDCDIV_MAX_CDIV;
1267
1268 mmc->max_busy_timeout = ~0 / (mmc->f_max / 1000);
1269
1270 dev_dbg(dev, "f_max %d, f_min %d, max_busy_timeout %d\n",
1271 mmc->f_max, mmc->f_min, mmc->max_busy_timeout);
1272
1273 /* host controller capabilities */
1274 mmc->caps |= MMC_CAP_SD_HIGHSPEED | MMC_CAP_MMC_HIGHSPEED |
1275 MMC_CAP_NEEDS_POLL | MMC_CAP_HW_RESET | MMC_CAP_CMD23;
1276
1277 spin_lock_init(&host->lock);
1278 mutex_init(&host->mutex);
1279
1280 if (!host->dma_chan_rxtx) {
1281 dev_warn(dev, "unable to initialise DMA channel. Falling back to PIO\n");
1282 } else {
1283 host->dma_cfg_tx.src_addr_width = DMA_SLAVE_BUSWIDTH_4_BYTES;
1284 host->dma_cfg_tx.dst_addr_width = DMA_SLAVE_BUSWIDTH_4_BYTES;
1285 host->dma_cfg_tx.direction = DMA_MEM_TO_DEV;
1286 host->dma_cfg_tx.src_addr = 0;
1287 host->dma_cfg_tx.dst_addr = host->phys_addr + SDDATA;
1288
1289 host->dma_cfg_rx.src_addr_width = DMA_SLAVE_BUSWIDTH_4_BYTES;
1290 host->dma_cfg_rx.dst_addr_width = DMA_SLAVE_BUSWIDTH_4_BYTES;
1291 host->dma_cfg_rx.direction = DMA_DEV_TO_MEM;
1292 host->dma_cfg_rx.src_addr = host->phys_addr + SDDATA;
1293 host->dma_cfg_rx.dst_addr = 0;
1294
1295 if (!dmaengine_slave_config(host->dma_chan_rxtx,
1296 &host->dma_cfg_tx) &&
1297 !dmaengine_slave_config(host->dma_chan_rxtx,
1298 &host->dma_cfg_rx)) {
1299 host->dma_dev =
1300 dmaengine_get_dma_device(host->dma_chan_rxtx);
1301 }
1302 }
1303
1304 mmc->max_segs = 128;
1305 mmc->max_req_size = 524288;
1306 if (host->dma_dev) {
1307 mmc->max_req_size = min_t(size_t, mmc->max_req_size,
1308 dma_max_mapping_size(host->dma_dev));
1309 }
1310 mmc->max_seg_size = mmc->max_req_size;
1311 mmc->max_blk_size = 1024;
1312 mmc->max_blk_count = 65535;
1313
1314 /* report supported voltage ranges */
1315 mmc->ocr_avail = MMC_VDD_32_33 | MMC_VDD_33_34;
1316
1317 INIT_WORK(&host->dma_work, bcm2835_dma_complete_work);
1318 INIT_DELAYED_WORK(&host->timeout_work, bcm2835_timeout);
1319
1320 /* Set interrupt enables */
1321 host->hcfg = SDHCFG_BUSY_IRPT_EN;
1322
1323 bcm2835_reset_internal(host);
1324
1325 ret = request_threaded_irq(host->irq, bcm2835_irq,
1326 bcm2835_threaded_irq,
1327 0, mmc_hostname(mmc), host);
1328 if (ret) {
1329 dev_err(dev, "failed to request IRQ %d: %d\n", host->irq, ret);
1330 return ret;
1331 }
1332
1333 ret = mmc_add_host(mmc);
1334 if (ret) {
1335 free_irq(host->irq, host);
1336 return ret;
1337 }
1338
1339 pio_limit_string[0] = '\0';
1340 if (host->dma_dev && (PIO_THRESHOLD > 0))
1341 sprintf(pio_limit_string, " (>%d)", PIO_THRESHOLD);
1342 dev_info(dev, "loaded - DMA %s%s\n",
> 1343 host->dma_dev ? "enabled" : "disabled", pio_limit_string);
1344
1345 return 0;
1346 }
1347

--
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki