Re: [PATCH 03/11] regulator: introduce regulator logging functions.

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

 



On 23-09-20, Sascha Hauer wrote:
> dev_* functions only print the struct device * as context, but often
> a single struct device * implements multiple regulators. Add rdev_*
> logging functions which allow to to print one specific regulator as
> context.
> 
> Signed-off-by: Sascha Hauer <s.hauer@xxxxxxxxxxxxxx>

Reviewed-by: Marco Felsch <m.felsch@xxxxxxxxxxxxxx>

> ---
>  drivers/regulator/core.c | 12 ++++++++++--
>  include/regulator.h      | 13 +++++++++++++
>  2 files changed, 23 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/regulator/core.c b/drivers/regulator/core.c
> index 41a3378ac8..8ef5a2372c 100644
> --- a/drivers/regulator/core.c
> +++ b/drivers/regulator/core.c
> @@ -19,6 +19,14 @@ struct regulator {
>  	struct device *dev;
>  };
>  
> +const char *rdev_get_name(struct regulator_dev *rdev)
> +{
> +	if (rdev->name)
> +		return rdev->name;
> +
> +	return "";
> +}
> +
>  static int regulator_map_voltage(struct regulator_dev *rdev, int min_uV,
>  				 int max_uV)
>  {
> @@ -125,7 +133,7 @@ static int regulator_resolve_supply(struct regulator_dev *rdev)
>  	if (!supply_name)
>  		return 0;
>  
> -	dev_dbg(rdev->dev, "resolving %s\n", supply_name);
> +	rdev_dbg(rdev, "resolving %s\n", supply_name);
>  
>  	supply = regulator_get(rdev->dev, supply_name);
>  	if (IS_ERR(supply)) {
> @@ -141,7 +149,7 @@ static int regulator_resolve_supply(struct regulator_dev *rdev)
>  		 * we couldn't. If you want to get rid of this warning, consider
>  		 * migrating your platform to have deep probe support.
>  		 */
> -		dev_warn(rdev->dev, "Failed to get '%s' regulator (ignored).\n",
> +		rdev_warn(rdev, "Failed to get '%s' regulator (ignored).\n",
>  			 supply_name);
>  		return 0;
>  	}
> diff --git a/include/regulator.h b/include/regulator.h
> index 5eb236e602..d02ea8ffd0 100644
> --- a/include/regulator.h
> +++ b/include/regulator.h
> @@ -159,6 +159,19 @@ int dev_regulator_register(struct regulator_dev *rd, const char * name,
>  
>  void regulators_print(void);
>  
> +const char *rdev_get_name(struct regulator_dev *rdev);
> +
> +#define rdev_crit(rdev, fmt, ...)                                       \
> +        pr_crit("%s: " fmt, rdev_get_name(rdev), ##__VA_ARGS__)
> +#define rdev_err(rdev, fmt, ...)                                        \
> +        pr_err("%s: " fmt, rdev_get_name(rdev), ##__VA_ARGS__)
> +#define rdev_warn(rdev, fmt, ...)                                       \
> +        pr_warn("%s: " fmt, rdev_get_name(rdev), ##__VA_ARGS__)
> +#define rdev_info(rdev, fmt, ...)                                       \
> +        pr_info("%s: " fmt, rdev_get_name(rdev), ##__VA_ARGS__)
> +#define rdev_dbg(rdev, fmt, ...)                                        \
> +        pr_debug("%s: " fmt, rdev_get_name(rdev), ##__VA_ARGS__)
> +
>  #ifdef CONFIG_REGULATOR
>  
>  struct regulator *regulator_get(struct device *, const char *);
> -- 
> 2.39.2
> 
> 
> 




[Index of Archives]     [Linux Embedded]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [XFree86]

  Powered by Linux