Ignore:
Timestamp:
Sep 18, 2022, 7:39:50 AM (3 years ago)
Author:
Paul Smedley
Message:

Initial commit of 5.17.15

File:
1 edited

Legend:

Unmodified
Added
Removed
  • GPL/branches/uniaud32-exp/lib32/devres.c

    r720 r737  
    472472}
    473473EXPORT_SYMBOL(devm_ioremap);
     474
     475/**
     476 * devm_kvasprintf - Allocate resource managed space and format a string
     477 *                   into that.
     478 * @dev: Device to allocate memory for
     479 * @gfp: the GFP mask used in the devm_kmalloc() call when
     480 *       allocating memory
     481 * @fmt: The printf()-style format string
     482 * @ap: Arguments for the format string
     483 * RETURNS:
     484 * Pointer to allocated string on success, NULL on failure.
     485 */
     486char *devm_kvasprintf(struct device *dev, gfp_t gfp, const char *fmt,
     487                      va_list ap)
     488{
     489        unsigned int len;
     490        char *p;
     491        va_list aq;
     492
     493        va_copy(aq, ap);
     494        len = vsnprintf(NULL, 0, fmt, aq);
     495        va_end(aq);
     496
     497        p = devm_kmalloc(dev, len+1, gfp);
     498        if (!p)
     499                return NULL;
     500
     501        vsnprintf(p, len+1, fmt, ap);
     502
     503        return p;
     504}
     505EXPORT_SYMBOL(devm_kvasprintf);
     506/**
     507 * devm_kasprintf - Allocate resource managed space and format a string
     508 *                  into that.
     509 * @dev: Device to allocate memory for
     510 * @gfp: the GFP mask used in the devm_kmalloc() call when
     511 *       allocating memory
     512 * @fmt: The printf()-style format string
     513 * @...: Arguments for the format string
     514 * RETURNS:
     515 * Pointer to allocated string on success, NULL on failure.
     516 */
     517char *devm_kasprintf(struct device *dev, gfp_t gfp, const char *fmt, ...)
     518{
     519        va_list ap;
     520        char *p;
     521
     522        va_start(ap, fmt);
     523        p = devm_kvasprintf(dev, gfp, fmt, ap);
     524        va_end(ap);
     525
     526        return p;
     527}
     528EXPORT_SYMBOL_GPL(devm_kasprintf);
Note: See TracChangeset for help on using the changeset viewer.