Skip to contentSkip to conversation

usb: gadget: f_uac1: fix coding style warnings

PATCH In review Sameeksha Sankpal 2 participants 2 messages Nov 21, 2025 USB

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 usb: gadget: f_uac1: fix coding style warnings

Fix several checkpatch.pl warnings in f_uac1.c including:
- replace NULL comparisons with !ptr
- remove unnecessary parentheses around simple equality checks
- remove a redundant 'else' after a return statement
- clean up superfluous blank lines
- use 'unsigned int' instead of bare 'unsigned'
- enclose a macro with complex value (USBDHDR) in parentheses

These changes clean up coding style and improve readability without altering the behavior of the driver.

---
 drivers/usb/gadget/function/f_uac1.c | 24 +++++++++---------------
 1 file changed, 9 insertions(+), 15 deletions(-)
drivers/usb/gadget/function/f_uac1.c +9 -15
index 9da9fb4e1239..d2c6fb18ce16 100644
@@ -446,13 +446,13 @@ static int audio_notify(struct g_audio *audio, int unit_id, int cs)
 	}
 
 	req = usb_ep_alloc_request(uac1->int_ep, GFP_ATOMIC);
-	if (req == NULL) {
+	if (!req) {
 		ret = -ENOMEM;
 		goto err_dec_int_count;
 	}
 
 	msg = kmalloc(sizeof(*msg), GFP_ATOMIC);
-	if (msg == NULL) {
+	if (!msg) {
 		ret = -ENOMEM;
 		goto err_free_request;
 	}
@@ -496,8 +496,8 @@ in_rq_cur(struct usb_function *fn, const struct usb_ctrlrequest *cr)
 	u8 control_selector = w_value >> 8;
 	int value = -EOPNOTSUPP;
 
-	if ((FUIN_EN(opts) && (entity_id == USB_IN_FU_ID)) ||
-			(FUOUT_EN(opts) && (entity_id == USB_OUT_FU_ID))) {
+	if ((FUIN_EN(opts) && entity_id == USB_IN_FU_ID) ||
+			(FUOUT_EN(opts) && entity_id == USB_OUT_FU_ID)) {
 		unsigned int is_playback = 0;
 
 		if (FUIN_EN(opts) && (entity_id == USB_IN_FU_ID))
@@ -547,8 +547,8 @@ in_rq_min(struct usb_function *fn, const struct usb_ctrlrequest *cr)
 	u8 control_selector = w_value >> 8;
 	int value = -EOPNOTSUPP;
 
-	if ((FUIN_EN(opts) && (entity_id == USB_IN_FU_ID)) ||
-			(FUOUT_EN(opts) && (entity_id == USB_OUT_FU_ID))) {
+	if ((FUIN_EN(opts) && entity_id == USB_IN_FU_ID) ||
+			(FUOUT_EN(opts) && entity_id == USB_OUT_FU_ID)) {
 		unsigned int is_playback = 0;
 
 		if (FUIN_EN(opts) && (entity_id == USB_IN_FU_ID))
@@ -714,11 +714,6 @@ out_rq_cur_complete(struct usb_ep *ep, struct usb_request *req)
 			u_audio_set_volume(audio, is_playback, volume);
 
 			return;
-		} else {
-			dev_err(&audio->gadget->dev,
-				"%s:%d control_selector=%d TODO!\n",
-				__func__, __LINE__, control_selector);
-			usb_ep_set_halt(ep);
 		}
 	} else {
 		dev_err(&audio->gadget->dev,
@@ -930,7 +925,7 @@ f_audio_setup(struct usb_function *f, const struct usb_ctrlrequest *ctrl)
 	return value;
 }
 
-static int f_audio_set_alt(struct usb_function *f, unsigned intf, unsigned alt)
+static int f_audio_set_alt(struct usb_function *f, unsigned int intf, unsigned int alt)
 {
 	struct usb_composite_dev *cdev = f->config->cdev;
 	struct usb_gadget *gadget = cdev->gadget;
@@ -984,7 +979,7 @@ static int f_audio_set_alt(struct usb_function *f, unsigned intf, unsigned alt)
 	return ret;
 }
 
-static int f_audio_get_alt(struct usb_function *f, unsigned intf)
+static int f_audio_get_alt(struct usb_function *f, unsigned int intf)
 {
 	struct usb_composite_dev *cdev = f->config->cdev;
 	struct usb_gadget *gadget = cdev->gadget;
@@ -1004,7 +999,6 @@ static int f_audio_get_alt(struct usb_function *f, unsigned intf)
 	return -EINVAL;
 }
 
-
 static void f_audio_disable(struct usb_function *f)
 {
 	struct f_uac1 *uac1 = func_to_uac1(f);
@@ -1079,7 +1073,7 @@ uac1_ac_header_descriptor *build_ac_header_desc(struct f_uac1_opts *opts)
 }
 
 /* Use macro to overcome line length limitation */
-#define USBDHDR(p) (struct usb_descriptor_header *)(p)
+#define USBDHDR(p) ((struct usb_descriptor_header *)(p))
 
 static void setup_descriptor(struct f_uac1_opts *opts)
 {
Signature · 1 line
2.43.0
maintainer
#1 lore raw
Quoted 8 lines · Sameeksha Sankpal

Fix several checkpatch.pl warnings in f_uac1.c including:
- replace NULL comparisons with !ptr
- remove unnecessary parentheses around simple equality checks
- remove a redundant 'else' after a return statement
- clean up superfluous blank lines
- use 'unsigned int' instead of bare 'unsigned'
- enclose a macro with complex value (USBDHDR) in parentheses

Quoted 4 lines

These changes clean up coding style and improve readability without altering the behavior of the driver.

Please do not do coding style cleanups all in one patch, nor for subsystems that maintainers do not explicitly state they want them for, as it can cause unneeded constant churn.

please do this in drivers/staging/ first.

thanks,

greg k-h