[PATCH] usb/gadget: f_mass_storage: style corrections, cleanup & simplification

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Fix spacing, improve error code returned, remove unused #define,
use strtobool() instead of kstrtou8().

Signed-off-by: Andrzej Pietrasiewicz <andrzej.p@xxxxxxxxxxx>
Signed-off-by: Kyungmin Park <kyungmin.park@xxxxxxxxxxx>
---

Hi Felipe,

These are corrections after Michal's review.

I did post this eralier but as a resent patch 14/14 for the v6 series on
configfs in mass storage. However, at that time you had already applied the
original version, so I should have posted it as a separate patch. Which I'm
doing now. Most changes are trivial, the last change is a little less trivial,
but still parseable at a first glance. Can you still accept it for this merge window?

Rebased onto your testing.

AP

 drivers/usb/gadget/f_mass_storage.c |   37 +++++++++++++++++------------------
 1 files changed, 18 insertions(+), 19 deletions(-)

diff --git a/drivers/usb/gadget/f_mass_storage.c b/drivers/usb/gadget/f_mass_storage.c
index 6b5f451..8fa8b1f 100644
--- a/drivers/usb/gadget/f_mass_storage.c
+++ b/drivers/usb/gadget/f_mass_storage.c
@@ -3209,9 +3209,9 @@ static void fsg_lun_attr_release(struct config_item *item)
 }
 
 static struct configfs_item_operations fsg_lun_item_ops = {
-	.release	= fsg_lun_attr_release,
-	.show_attribute = fsg_lun_opts_attr_show,
-	.store_attribute = fsg_lun_opts_attr_store,
+	.release		= fsg_lun_attr_release,
+	.show_attribute		= fsg_lun_opts_attr_show,
+	.store_attribute	= fsg_lun_opts_attr_store,
 };
 
 static ssize_t fsg_lun_opts_file_show(struct fsg_lun_opts *opts, char *page)
@@ -3323,8 +3323,6 @@ static struct config_item_type fsg_lun_type = {
 	.ct_owner	= THIS_MODULE,
 };
 
-#define MAX_NAME_LEN	40
-
 static struct config_group *fsg_lun_make(struct config_group *group,
 					 const char *name)
 {
@@ -3348,7 +3346,8 @@ static struct config_group *fsg_lun_make(struct config_group *group,
 
 	fsg_opts = to_fsg_opts(&group->cg_item);
 	if (num >= FSG_MAX_LUNS)
-		return ERR_PTR(-ENODEV);
+		return ERR_PTR(-ERANGE);
+
 	mutex_lock(&fsg_opts->lock);
 	if (fsg_opts->refcnt || fsg_opts->common->luns[num]) {
 		ret = -EBUSY;
@@ -3364,7 +3363,6 @@ static struct config_group *fsg_lun_make(struct config_group *group,
 	memset(&config, 0, sizeof(config));
 	config.removable = true;
 
-
 	ret = fsg_common_create_lun(fsg_opts->common, &config, num, name,
 				    (const char **)&group->cg_item.ci_name);
 	if (ret) {
@@ -3418,9 +3416,9 @@ static void fsg_attr_release(struct config_item *item)
 }
 
 static struct configfs_item_operations fsg_item_ops = {
-	.release	= fsg_attr_release,
-	.show_attribute = fsg_opts_attr_show,
-	.store_attribute = fsg_opts_attr_store,
+	.release		= fsg_attr_release,
+	.show_attribute		= fsg_opts_attr_show,
+	.store_attribute	= fsg_opts_attr_store,
 };
 
 static ssize_t fsg_opts_stall_show(struct fsg_opts *opts, char *page)
@@ -3438,22 +3436,23 @@ static ssize_t fsg_opts_stall_store(struct fsg_opts *opts, const char *page,
 				    size_t len)
 {
 	int ret;
-	u8 num;
+	bool stall;
 
 	mutex_lock(&opts->lock);
+
 	if (opts->refcnt) {
-		ret = -EBUSY;
-		goto end;
+		mutex_unlock(&opts->lock);
+		return -EBUSY;
 	}
-	ret = kstrtou8(page, 0, &num);
-	if (ret)
-		goto end;
 
-	opts->common->can_stall = num != 0;
-	ret = len;
+	ret = strtobool(page, &stall);
+	if (!ret) {
+		opts->common->can_stall = stall;
+		ret = len;
+	}
 
-end:
 	mutex_unlock(&opts->lock);
+
 	return ret;
 }
 
-- 
1.7.0.4

--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html




[Index of Archives]     [Linux Media]     [Linux Input]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [Old Linux USB Devel Archive]

  Powered by Linux