Commit 9d266e79 authored by Bean Huo's avatar Bean Huo Committed by Martin K. Petersen

scsi: ufs: core: Use is_visible to control UFS unit descriptor sysfs nodes

UFS Boot and Device W-LUs do not have unit descriptors and RPMB does not
support WB. Use is_visible() to control which nodes are visible and which
are not.
Signed-off-by: default avatarBean Huo <beanhuo@micron.com>
Link: https://lore.kernel.org/r/20221025222430.277768-4-beanhuo@iokpp.deReviewed-by: default avatarBart Van Assche <bvanassche@acm.org>
Reviewed-by: default avatarArthur Simchaev <arthur.simchaev@wdc.com>
Signed-off-by: default avatarMartin K. Petersen <martin.petersen@oracle.com>
parent dca899bc
......@@ -1285,9 +1285,27 @@ static struct attribute *ufs_sysfs_unit_descriptor[] = {
NULL,
};
static umode_t ufs_unit_descriptor_is_visible(struct kobject *kobj, struct attribute *attr, int n)
{
struct device *dev = container_of(kobj, struct device, kobj);
struct scsi_device *sdev = to_scsi_device(dev);
u8 lun = ufshcd_scsi_to_upiu_lun(sdev->lun);
umode_t mode = attr->mode;
if (lun == UFS_UPIU_BOOT_WLUN || lun == UFS_UPIU_UFS_DEVICE_WLUN)
/* Boot and device WLUN have no unit descriptors */
mode = 0;
if (lun == UFS_UPIU_RPMB_WLUN && attr == &dev_attr_wb_buf_alloc_units.attr)
mode = 0;
return mode;
}
const struct attribute_group ufs_sysfs_unit_descriptor_group = {
.name = "unit_descriptor",
.attrs = ufs_sysfs_unit_descriptor,
.is_visible = ufs_unit_descriptor_is_visible,
};
static ssize_t dyn_cap_needed_attribute_show(struct device *dev,
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment