diff mbox

[1/2,v3] scsi: ufs: introduce static sysfs entries

Message ID 20171220191631.50329-1-jaegeuk@kernel.org (mailing list archive)
State Accepted
Headers show

Commit Message

Jaegeuk Kim Dec. 20, 2017, 7:16 p.m. UTC
From: Jaegeuk Kim <jaegeuk@google.com>

This patch introduces attribute group to show existing sysfs entries.

Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Jaegeuk Kim <jaegeuk@google.com>
---

Change log from v1:
 - use ATTRIBUTE_GROUPS and sysfs_create_groups()

 drivers/scsi/ufs/ufshcd.c | 46 +++++++++++++++++-----------------------------
 drivers/scsi/ufs/ufshcd.h |  2 --
 2 files changed, 17 insertions(+), 31 deletions(-)

Comments

Bart Van Assche Dec. 20, 2017, 7:20 p.m. UTC | #1
On Wed, 2017-12-20 at 11:16 -0800, Jaegeuk Kim wrote:
> From: Jaegeuk Kim <jaegeuk@google.com>


Hello Jaegeuk,

For future patch series submissions, please include a cover letter that explains
the purpose of the patch series and please also document the changes between the
different versions of the patch series in the cover letter.

Thanks,

Bart.
Jaegeuk Kim Dec. 20, 2017, 8:16 p.m. UTC | #2
Hi Bart,

On 12/20, Bart Van Assche wrote:
> On Wed, 2017-12-20 at 11:16 -0800, Jaegeuk Kim wrote:
> > From: Jaegeuk Kim <jaegeuk@google.com>
> 
> Hello Jaegeuk,
> 
> For future patch series submissions, please include a cover letter that explains
> the purpose of the patch series and please also document the changes between the
> different versions of the patch series in the cover letter.

Yup, I'll be aware of it. Thank you for the advice.

Thanks,
Martin K. Petersen Dec. 21, 2017, 2:37 a.m. UTC | #3
>> For future patch series submissions, please include a cover letter
>> that explains the purpose of the patch series and please also
>> document the changes between the different versions of the patch
>> series in the cover letter.
>
> Yup, I'll be aware of it. Thank you for the advice.

These look good to me.

Greg: Jaegeuk didn't carry over your review tags (despite the pretty
modest tweaks). Can I add your Reviewed-by: to these two when I queue
them up?
Greg KH Dec. 21, 2017, 7:59 a.m. UTC | #4
On Wed, Dec 20, 2017 at 09:37:39PM -0500, Martin K. Petersen wrote:
> 
> >> For future patch series submissions, please include a cover letter
> >> that explains the purpose of the patch series and please also
> >> document the changes between the different versions of the patch
> >> series in the cover letter.
> >
> > Yup, I'll be aware of it. Thank you for the advice.
> 
> These look good to me.
> 
> Greg: Jaegeuk didn't carry over your review tags (despite the pretty
> modest tweaks). Can I add your Reviewed-by: to these two when I queue
> them up?

Yes, please do, they look fine to me.

greg k-h
Greg KH Dec. 21, 2017, 7:59 a.m. UTC | #5
On Wed, Dec 20, 2017 at 11:16:30AM -0800, Jaegeuk Kim wrote:
> From: Jaegeuk Kim <jaegeuk@google.com>
> 
> This patch introduces attribute group to show existing sysfs entries.
> 
> Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
> Signed-off-by: Jaegeuk Kim <jaegeuk@google.com>
> ---
> 
> Change log from v1:
>  - use ATTRIBUTE_GROUPS and sysfs_create_groups()

Nice change, thanks.

Reviewed-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
diff mbox

Patch

diff --git a/drivers/scsi/ufs/ufshcd.c b/drivers/scsi/ufs/ufshcd.c
index 011c3369082c..1e8a6a3e1f39 100644
--- a/drivers/scsi/ufs/ufshcd.c
+++ b/drivers/scsi/ufs/ufshcd.c
@@ -7605,7 +7605,7 @@  static inline ssize_t ufshcd_pm_lvl_store(struct device *dev,
 	return count;
 }
 
-static ssize_t ufshcd_rpm_lvl_show(struct device *dev,
+static ssize_t rpm_lvl_show(struct device *dev,
 		struct device_attribute *attr, char *buf)
 {
 	struct ufs_hba *hba = dev_get_drvdata(dev);
@@ -7634,24 +7634,13 @@  static ssize_t ufshcd_rpm_lvl_show(struct device *dev,
 	return curr_len;
 }
 
-static ssize_t ufshcd_rpm_lvl_store(struct device *dev,
+static ssize_t rpm_lvl_store(struct device *dev,
 		struct device_attribute *attr, const char *buf, size_t count)
 {
 	return ufshcd_pm_lvl_store(dev, attr, buf, count, true);
 }
 
-static void ufshcd_add_rpm_lvl_sysfs_nodes(struct ufs_hba *hba)
-{
-	hba->rpm_lvl_attr.show = ufshcd_rpm_lvl_show;
-	hba->rpm_lvl_attr.store = ufshcd_rpm_lvl_store;
-	sysfs_attr_init(&hba->rpm_lvl_attr.attr);
-	hba->rpm_lvl_attr.attr.name = "rpm_lvl";
-	hba->rpm_lvl_attr.attr.mode = 0644;
-	if (device_create_file(hba->dev, &hba->rpm_lvl_attr))
-		dev_err(hba->dev, "Failed to create sysfs for rpm_lvl\n");
-}
-
-static ssize_t ufshcd_spm_lvl_show(struct device *dev,
+static ssize_t spm_lvl_show(struct device *dev,
 		struct device_attribute *attr, char *buf)
 {
 	struct ufs_hba *hba = dev_get_drvdata(dev);
@@ -7680,33 +7669,32 @@  static ssize_t ufshcd_spm_lvl_show(struct device *dev,
 	return curr_len;
 }
 
-static ssize_t ufshcd_spm_lvl_store(struct device *dev,
+static ssize_t spm_lvl_store(struct device *dev,
 		struct device_attribute *attr, const char *buf, size_t count)
 {
 	return ufshcd_pm_lvl_store(dev, attr, buf, count, false);
 }
 
-static void ufshcd_add_spm_lvl_sysfs_nodes(struct ufs_hba *hba)
-{
-	hba->spm_lvl_attr.show = ufshcd_spm_lvl_show;
-	hba->spm_lvl_attr.store = ufshcd_spm_lvl_store;
-	sysfs_attr_init(&hba->spm_lvl_attr.attr);
-	hba->spm_lvl_attr.attr.name = "spm_lvl";
-	hba->spm_lvl_attr.attr.mode = 0644;
-	if (device_create_file(hba->dev, &hba->spm_lvl_attr))
-		dev_err(hba->dev, "Failed to create sysfs for spm_lvl\n");
-}
+static DEVICE_ATTR_RW(rpm_lvl);
+static DEVICE_ATTR_RW(spm_lvl);
+
+static struct attribute *ufshcd_attrs[] = {
+	&dev_attr_rpm_lvl.attr,
+	&dev_attr_spm_lvl.attr,
+	NULL
+};
+
+ATTRIBUTE_GROUPS(ufshcd);
 
 static inline void ufshcd_add_sysfs_nodes(struct ufs_hba *hba)
 {
-	ufshcd_add_rpm_lvl_sysfs_nodes(hba);
-	ufshcd_add_spm_lvl_sysfs_nodes(hba);
+	if (sysfs_create_groups(&hba->dev->kobj, ufshcd_groups))
+		dev_err(hba->dev, "Failed to create sysfs default groups\n");
 }
 
 static inline void ufshcd_remove_sysfs_nodes(struct ufs_hba *hba)
 {
-	device_remove_file(hba->dev, &hba->rpm_lvl_attr);
-	device_remove_file(hba->dev, &hba->spm_lvl_attr);
+	sysfs_remove_groups(&hba->dev->kobj, ufshcd_groups);
 }
 
 /**
diff --git a/drivers/scsi/ufs/ufshcd.h b/drivers/scsi/ufs/ufshcd.h
index 1332e544da92..56e26eb15185 100644
--- a/drivers/scsi/ufs/ufshcd.h
+++ b/drivers/scsi/ufs/ufshcd.h
@@ -526,8 +526,6 @@  struct ufs_hba {
 	enum ufs_pm_level rpm_lvl;
 	/* Desired UFS power management level during system PM */
 	enum ufs_pm_level spm_lvl;
-	struct device_attribute rpm_lvl_attr;
-	struct device_attribute spm_lvl_attr;
 	int pm_op_in_progress;
 
 	struct ufshcd_lrb *lrb;