devres: Improve devm_kasprintf()/kvasprintf() support
authorGeert Uytterhoeven <geert+renesas@glider.be>
Wed, 20 Aug 2014 13:26:35 +0000 (15:26 +0200)
committerSimon Horman <horms+renesas@verge.net.au>
Fri, 5 Dec 2014 01:43:58 +0000 (10:43 +0900)
  - Add devm_kasprintf()/kvasprintf(), introduced by commit
    75f2a4ead5d5890ada9c2663a70fb58613c0d9f2 ("devres: Add
    devm_kasprintf and devm_kvasprintf API"), to
    Documentation/driver-model/devres.txt,
  - Improve kernel doc: the string is not an existing formatted string,
    but is formatted into the newly-allocated buffer,
  - Add a __printf() annotation to devm_kasprintf(), so the compiler
    will verify the format string argument types.

Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
(cherry picked from commit bef59c5024be687ef4f228915af9961307a779ab)
Signed-off-by: Simon Horman <horms+renesas@verge.net.au>
Conflicts:
Documentation/driver-model/devres.txt
drivers/base/devres.c

Documentation/driver-model/devres.txt
drivers/base/devres.c
include/linux/device.h

index 4f7897e..1fd8a2a 100644 (file)
@@ -287,6 +287,12 @@ REGULATOR
   devm_regulator_bulk_get()
   devm_regulator_register()
 
+  devm_mdiobus_free()
+
+MEM
+  devm_kasprintf()
+  devm_kvasprintf()
+
 CLOCK
   devm_clk_get()
   devm_clk_put()
index e4d2a75..c8d295a 100644 (file)
@@ -791,13 +791,13 @@ void * devm_kmalloc(struct device *dev, size_t size, gfp_t gfp)
 EXPORT_SYMBOL_GPL(devm_kmalloc);
 
 /**
- * devm_kvasprintf - Allocate resource managed space
- *                     for the formatted string.
+ * devm_kvasprintf - Allocate resource managed space and format a string
+ *                  into that.
  * @dev: Device to allocate memory for
  * @gfp: the GFP mask used in the devm_kmalloc() call when
  *       allocating memory
- * @fmt: the formatted string to duplicate
- * @ap: the list of tokens to be placed in the formatted string
+ * @fmt: The printf()-style format string
+ * @ap: Arguments for the format string
  * RETURNS:
  * Pointer to allocated string on success, NULL on failure.
  */
@@ -823,12 +823,13 @@ char *devm_kvasprintf(struct device *dev, gfp_t gfp, const char *fmt,
 EXPORT_SYMBOL(devm_kvasprintf);
 
 /**
- * devm_kasprintf - Allocate resource managed space
- *             and copy an existing formatted string into that
+ * devm_kasprintf - Allocate resource managed space and format a string
+ *                 into that.
  * @dev: Device to allocate memory for
  * @gfp: the GFP mask used in the devm_kmalloc() call when
  *       allocating memory
- * @fmt: the string to duplicate
+ * @fmt: The printf()-style format string
+ * @...: Arguments for the format string
  * RETURNS:
  * Pointer to allocated string on success, NULL on failure.
  */
index 82bb58c..28f1363 100644 (file)
@@ -611,8 +611,8 @@ extern int devres_release_group(struct device *dev, void *id);
 extern void *devm_kmalloc(struct device *dev, size_t size, gfp_t gfp);
 extern char *devm_kvasprintf(struct device *dev, gfp_t gfp, const char *fmt,
                             va_list ap);
-extern char *devm_kasprintf(struct device *dev, gfp_t gfp,
-                           const char *fmt, ...);
+extern __printf(3, 4)
+char *devm_kasprintf(struct device *dev, gfp_t gfp, const char *fmt, ...);
 static inline void *devm_kzalloc(struct device *dev, size_t size, gfp_t gfp)
 {
        return devm_kmalloc(dev, size, gfp | __GFP_ZERO);