diff mbox series

[v13,1/2] usb: gadget: configfs: add explicit gi variable

Message ID 1635229309-2821-2-git-send-email-quic_linyyuan@quicinc.com (mailing list archive)
State New, archived
Headers show
Series usb: gadget: configfs: add some trace event | expand

Commit Message

Linyu Yuan Oct. 26, 2021, 6:21 a.m. UTC
first it will make ussage of to_gadget_info()  consistent,
and gi will be used in following patch as trace event
call argument.

Signed-off-by: Linyu Yuan <quic_linyyuan@quicinc.com>
---
 drivers/usb/gadget/configfs.c | 39 +++++++++++++++++++++++----------------
 1 file changed, 23 insertions(+), 16 deletions(-)

Comments

Greg KH Oct. 26, 2021, 6:31 a.m. UTC | #1
On Tue, Oct 26, 2021 at 02:21:48PM +0800, Linyu Yuan wrote:
> first it will make ussage of to_gadget_info()  consistent,
> and gi will be used in following patch as trace event
> call argument.

Your subject line is odd, it does not make much sense.

And this changelog text also is not very descriptive (and you have an
extra ' ' in it).

Please read the kernel documentation for how to write a good subject
line and changelog text and have one of your coworkers review it before
sending it out again.

thanks,

greg k-h
diff mbox series

Patch

diff --git a/drivers/usb/gadget/configfs.c b/drivers/usb/gadget/configfs.c
index 36c611d..97ed9d3 100644
--- a/drivers/usb/gadget/configfs.c
+++ b/drivers/usb/gadget/configfs.c
@@ -127,20 +127,22 @@  static int usb_string_copy(const char *s, char **s_copy)
 	return 0;
 }
 
-#define GI_DEVICE_DESC_SIMPLE_R_u8(__name)	\
+#define GI_DEVICE_DESC_SIMPLE_R_u8(__name)		\
 static ssize_t gadget_dev_desc_##__name##_show(struct config_item *item, \
-			char *page)	\
-{	\
-	return sprintf(page, "0x%02x\n", \
-		to_gadget_info(item)->cdev.desc.__name); \
+			char *page)			\
+{							\
+	struct gadget_info *gi = to_gadget_info(item);	\
+	return sprintf(page, "0x%02x\n",		\
+			gi->cdev.desc.__name); 		\
 }
 
-#define GI_DEVICE_DESC_SIMPLE_R_u16(__name)	\
+#define GI_DEVICE_DESC_SIMPLE_R_u16(__name)		\
 static ssize_t gadget_dev_desc_##__name##_show(struct config_item *item, \
-			char *page)	\
-{	\
-	return sprintf(page, "0x%04x\n", \
-		le16_to_cpup(&to_gadget_info(item)->cdev.desc.__name)); \
+			char *page)			\
+{							\
+	struct gadget_info *gi = to_gadget_info(item);	\
+	return sprintf(page, "0x%04x\n",		\
+		le16_to_cpup(&gi->cdev.desc.__name));	\
 }
 
 
@@ -148,25 +150,27 @@  static ssize_t gadget_dev_desc_##__name##_show(struct config_item *item, \
 static ssize_t gadget_dev_desc_##_name##_store(struct config_item *item, \
 		const char *page, size_t len)		\
 {							\
+	struct gadget_info *gi = to_gadget_info(item);	\
 	u8 val;						\
 	int ret;					\
 	ret = kstrtou8(page, 0, &val);			\
 	if (ret)					\
 		return ret;				\
-	to_gadget_info(item)->cdev.desc._name = val;	\
+	gi->cdev.desc._name = val;			\
 	return len;					\
 }
 
-#define GI_DEVICE_DESC_SIMPLE_W_u16(_name)	\
+#define GI_DEVICE_DESC_SIMPLE_W_u16(_name)		\
 static ssize_t gadget_dev_desc_##_name##_store(struct config_item *item, \
 		const char *page, size_t len)		\
 {							\
+	struct gadget_info *gi = to_gadget_info(item);	\
 	u16 val;					\
 	int ret;					\
 	ret = kstrtou16(page, 0, &val);			\
 	if (ret)					\
 		return ret;				\
-	to_gadget_info(item)->cdev.desc._name = cpu_to_le16p(&val);	\
+	gi->cdev.desc._name = cpu_to_le16p(&val);	\
 	return len;					\
 }
 
@@ -199,6 +203,7 @@  static ssize_t is_valid_bcd(u16 bcd_val)
 static ssize_t gadget_dev_desc_bcdDevice_store(struct config_item *item,
 		const char *page, size_t len)
 {
+	struct gadget_info *gi = to_gadget_info(item);
 	u16 bcdDevice;
 	int ret;
 
@@ -209,13 +214,14 @@  static ssize_t gadget_dev_desc_bcdDevice_store(struct config_item *item,
 	if (ret)
 		return ret;
 
-	to_gadget_info(item)->cdev.desc.bcdDevice = cpu_to_le16(bcdDevice);
+	gi->cdev.desc.bcdDevice = cpu_to_le16(bcdDevice);
 	return len;
 }
 
 static ssize_t gadget_dev_desc_bcdUSB_store(struct config_item *item,
 		const char *page, size_t len)
 {
+	struct gadget_info *gi = to_gadget_info(item);
 	u16 bcdUSB;
 	int ret;
 
@@ -226,7 +232,7 @@  static ssize_t gadget_dev_desc_bcdUSB_store(struct config_item *item,
 	if (ret)
 		return ret;
 
-	to_gadget_info(item)->cdev.desc.bcdUSB = cpu_to_le16(bcdUSB);
+	gi->cdev.desc.bcdUSB = cpu_to_le16(bcdUSB);
 	return len;
 }
 
@@ -305,7 +311,8 @@  static ssize_t gadget_dev_desc_UDC_store(struct config_item *item,
 static ssize_t gadget_dev_desc_max_speed_show(struct config_item *item,
 					      char *page)
 {
-	enum usb_device_speed speed = to_gadget_info(item)->composite.max_speed;
+	struct gadget_info *gi = to_gadget_info(item);
+	enum usb_device_speed speed = gi->composite.max_speed;
 
 	return sprintf(page, "%s\n", usb_speed_string(speed));
 }