diff mbox series

[v4,3/3] scsi: ufs: core: Use is_visible to control UFS unit descriptor sysfs nodes

Message ID 20221022213650.626766-4-beanhuo@iokpp.de (mailing list archive)
State Superseded
Headers show
Series Changes for ufshcd.c | expand

Commit Message

Bean Huo Oct. 22, 2022, 9:36 p.m. UTC
From: Bean Huo <beanhuo@micron.com>

UFS Boot and Device W-LUs do not have unit descriptors, and RPMB does not
support WB, we can use is_visible() to control which nodes are visible
and which are not.

Reviewed-by: Bart Van Assche <bvanassche@acm.org>
Signed-off-by: Bean Huo <beanhuo@micron.com>
---
 drivers/ufs/core/ufs-sysfs.c | 18 ++++++++++++++++++
 1 file changed, 18 insertions(+)

Comments

Arthur Simchaev Oct. 23, 2022, 9:47 a.m. UTC | #1
> -----Original Message-----
> From: Bean Huo <beanhuo@iokpp.de>
> Sent: Sunday, October 23, 2022 12:37 AM
> To: alim.akhtar@samsung.com; Avri Altman <Avri.Altman@wdc.com>;
> asutoshd@codeaurora.org; jejb@linux.ibm.com;
> martin.petersen@oracle.com; stanley.chu@mediatek.com;
> beanhuo@micron.com; bvanassche@acm.org; tomas.winkler@intel.com;
> cang@codeaurora.org; daejun7.park@samsung.com
> Cc: linux-scsi@vger.kernel.org; linux-kernel@vger.kernel.org
> Subject: [PATCH v4 3/3] scsi: ufs: core: Use is_visible to control UFS unit
> descriptor sysfs nodes
> 
> CAUTION: This email originated from outside of Western Digital. Do not click
> on links or open attachments unless you recognize the sender and know that
> the content is safe.
> 
> 
> From: Bean Huo <beanhuo@micron.com>
> 
> UFS Boot and Device W-LUs do not have unit descriptors, and RPMB does not
> support WB, we can use is_visible() to control which nodes are visible
> and which are not.
> 
> Reviewed-by: Bart Van Assche <bvanassche@acm.org>
> Signed-off-by: Bean Huo <beanhuo@micron.com>

Reviewed-by: Arthur Simchaev <arthur.simchaev@wdc.com>
diff mbox series

Patch

diff --git a/drivers/ufs/core/ufs-sysfs.c b/drivers/ufs/core/ufs-sysfs.c
index eb6b278c4e79..883f0e44b54e 100644
--- a/drivers/ufs/core/ufs-sysfs.c
+++ b/drivers/ufs/core/ufs-sysfs.c
@@ -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,