Re: [PATCH 19/21] usb/gadget: Provide a default implementation of default manufacturer string

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

 



On 08/29/2012 11:05 PM, Michal Nazarewicz wrote:
Sebastian Andrzej Siewior<bigeasy@xxxxxxxxxxxxx>  writes:
Some gadgets provide custom entry here. Some may override it with an
etntry that is also created by composite if there was no value sumbitted
at all.
This patch removes all "custom manufacturer" strings which are the same
as these which are created by composite. Then it moves the creation of
the default manufacturer string to usb_composite_overwrite_options() in
case no command line argument has been used and the entry is still an
empty string.
By doing this we get rid of the global variable "manufacturer" in
composite.

It's actually called "composite_manufacturer". :)

Ach you right.

Signed-off-by: Sebastian Andrzej Siewior<bigeasy@xxxxxxxxxxxxx>

Acked-by: Michal Nazarewicz<mina86@xxxxxxxxxx>


diff --git a/drivers/usb/gadget/composite.c b/drivers/usb/gadget/composite.c
index b477d9e..20a1ace 100644
--- a/drivers/usb/gadget/composite.c
+++ b/drivers/usb/gadget/composite.c

@@ -1672,6 +1628,28 @@ void usb_composite_setup_continue(struct usb_composite_dev *cdev)
  	spin_unlock_irqrestore(&cdev->lock, flags);
  }

+static char *composite_default_mfr(struct usb_gadget *gadget)
+{
+	char *mfr;
+	int len;
+
+	len = snprintf(NULL, 0, "%s %s with %s", init_utsname()->sysname,
+			init_utsname()->release, gadget->name);

I'd probably explicitly sum strlen() of the strings, but either is fine.

+	if (len<  0)
+		return NULL;

Can that even happen?
According to the man page, yes. Looking at the code no. So, let me
remove this.


+	len = min(32, len + 1);

Is min really needed here?  Just do ++len and let allocator worry. ;)

Okay.

+	mfr = kmalloc(len, GFP_KERNEL);
+	if (!mfr)
+		return NULL;
+	len = snprintf(mfr, len, "%s %s with %s", init_utsname()->sysname,
+			init_utsname()->release, gadget->name);
+	if (len<  0) {

Again, can that even happen?

Not according to current code. I get rid of it.

Sebastian
--
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