]> git.karo-electronics.de Git - karo-tx-linux.git/commitdiff
usb: gadget: composite: use kasprintf() instead of open coding it
authorJuergen Gross <jgross@suse.com>
Mon, 10 Oct 2016 10:48:36 +0000 (12:48 +0200)
committerFelipe Balbi <felipe.balbi@linux.intel.com>
Thu, 3 Nov 2016 08:38:36 +0000 (10:38 +0200)
Let's not reimplement generic kernel helpers,
instead call kasprintf().

[ felipe.balbi@linux.intel.com: better commit log ]

Signed-off-by: Juergen Gross <jgross@suse.com>
Signed-off-by: Felipe Balbi <felipe.balbi@linux.intel.com>
drivers/usb/gadget/composite.c

index 919d7d1b611c3a577e82e32314f60660f03c7665..41ab61f9b6e0b24be1dd950afdae9f4f3a179d50 100644 (file)
@@ -2387,18 +2387,8 @@ EXPORT_SYMBOL_GPL(usb_composite_setup_continue);
 
 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);
-       len++;
-       mfr = kmalloc(len, GFP_KERNEL);
-       if (!mfr)
-               return NULL;
-       snprintf(mfr, len, "%s %s with %s", init_utsname()->sysname,
-                       init_utsname()->release, gadget->name);
-       return mfr;
+       return kasprintf(GFP_KERNEL, "%s %s with %s", init_utsname()->sysname,
+                        init_utsname()->release, gadget->name);
 }
 
 void usb_composite_overwrite_options(struct usb_composite_dev *cdev,