Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

dmaengine: idxd: Simplify WQ attribute visibility checks

The functions that check if WQ attributes are invisible are almost
duplicate. Define a helper to simplify these functions and future
WQ attribute visibility checks as well.

Signed-off-by: Fenghua Yu <fenghua.yu@intel.com>
Reviewed-by: Dave Jiang <dave.jiang@intel.com>
Link: https://lore.kernel.org/r/20230712174436.3435088-1-fenghua.yu@intel.com
Signed-off-by: Vinod Koul <vkoul@kernel.org>

authored by

Fenghua Yu and committed by
Vinod Koul
97b1185f cae701b9

+5 -15
+5 -15
drivers/dma/idxd/sysfs.c
··· 1288 1288 NULL, 1289 1289 }; 1290 1290 1291 - static bool idxd_wq_attr_op_config_invisible(struct attribute *attr, 1292 - struct idxd_device *idxd) 1293 - { 1294 - return attr == &dev_attr_wq_op_config.attr && 1295 - !idxd->hw.wq_cap.op_config; 1296 - } 1291 + /* A WQ attr is invisible if the feature is not supported in WQCAP. */ 1292 + #define idxd_wq_attr_invisible(name, cap_field, a, idxd) \ 1293 + ((a) == &dev_attr_wq_##name.attr && !(idxd)->hw.wq_cap.cap_field) 1297 1294 1298 1295 static bool idxd_wq_attr_max_batch_size_invisible(struct attribute *attr, 1299 1296 struct idxd_device *idxd) ··· 1300 1303 idxd->data->type == IDXD_TYPE_IAX; 1301 1304 } 1302 1305 1303 - static bool idxd_wq_attr_wq_prs_disable_invisible(struct attribute *attr, 1304 - struct idxd_device *idxd) 1305 - { 1306 - return attr == &dev_attr_wq_prs_disable.attr && 1307 - !idxd->hw.wq_cap.wq_prs_support; 1308 - } 1309 - 1310 1306 static umode_t idxd_wq_attr_visible(struct kobject *kobj, 1311 1307 struct attribute *attr, int n) 1312 1308 { ··· 1307 1317 struct idxd_wq *wq = confdev_to_wq(dev); 1308 1318 struct idxd_device *idxd = wq->idxd; 1309 1319 1310 - if (idxd_wq_attr_op_config_invisible(attr, idxd)) 1320 + if (idxd_wq_attr_invisible(op_config, op_config, attr, idxd)) 1311 1321 return 0; 1312 1322 1313 1323 if (idxd_wq_attr_max_batch_size_invisible(attr, idxd)) 1314 1324 return 0; 1315 1325 1316 - if (idxd_wq_attr_wq_prs_disable_invisible(attr, idxd)) 1326 + if (idxd_wq_attr_invisible(prs_disable, wq_prs_support, attr, idxd)) 1317 1327 return 0; 1318 1328 1319 1329 return attr->mode;