staging: regulator: hi6421v600-regulator: add a driver-specific debug macro

Using dev_dbg() is not too nice, as, instead of printing the
name of the regulator, it prints "regulator.<number>", making
harder to associate what is happening with each ldo line.

So, add a debug-specific macro, which will print the rdev's
name, just like the regulator core.

Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
Link: https://lore.kernel.org/r/1690b8531b23910aa915bd2725410b926022c481.1597647359.git.mchehab+huawei@kernel.org
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
This commit is contained in:
Mauro Carvalho Chehab 2020-08-17 09:10:54 +02:00 committed by Greg Kroah-Hartman
parent 67a345c784
commit 875a65a05d
1 changed files with 32 additions and 29 deletions

View File

@ -39,6 +39,9 @@
#include <linux/uaccess.h>
#include <linux/spmi.h>
#define rdev_dbg(rdev, fmt, arg...) \
pr_debug("%s: %s: " fmt, rdev->desc->name, __func__, ##arg)
struct hi6421v600_regulator {
struct regulator_desc rdesc;
struct hi6421_spmi_pmic *pmic;
@ -60,10 +63,10 @@ static int hi6421_spmi_regulator_is_enabled(struct regulator_dev *rdev)
reg_val = hi6421_spmi_pmic_read(pmic, rdev->desc->enable_reg);
dev_dbg(&rdev->dev,
"%s: enable_reg=0x%x, val= 0x%x, enable_state=%d\n",
__func__, rdev->desc->enable_reg,
reg_val, (reg_val & rdev->desc->enable_mask));
rdev_dbg(rdev,
"enable_reg=0x%x, val= 0x%x, enable_state=%d\n",
rdev->desc->enable_reg,
reg_val, (reg_val & rdev->desc->enable_mask));
return ((reg_val & rdev->desc->enable_mask) != 0);
}
@ -73,21 +76,20 @@ static int hi6421_spmi_regulator_enable(struct regulator_dev *rdev)
struct hi6421v600_regulator *sreg = rdev_get_drvdata(rdev);
struct hi6421_spmi_pmic *pmic = sreg->pmic;
dev_dbg(&rdev->dev, "%s: off_on_delay=%d us\n",
__func__, rdev->desc->off_on_delay);
/* cannot enable more than one regulator at one time */
mutex_lock(&enable_mutex);
usleep_range(HISI_REGS_ENA_PROTECT_TIME,
HISI_REGS_ENA_PROTECT_TIME + 1000);
/* set enable register */
rdev_dbg(rdev,
"off_on_delay=%d us, enable_reg=0x%x, enable_mask=0x%x\n",
rdev->desc->off_on_delay, rdev->desc->enable_reg,
rdev->desc->enable_mask);
hi6421_spmi_pmic_rmw(pmic, rdev->desc->enable_reg,
rdev->desc->enable_mask,
rdev->desc->enable_mask);
dev_dbg(&rdev->dev, "%s: enable_reg=0x%x, enable_mask=0x%x\n",
__func__, rdev->desc->enable_reg,
rdev->desc->enable_mask);
mutex_unlock(&enable_mutex);
@ -100,6 +102,9 @@ static int hi6421_spmi_regulator_disable(struct regulator_dev *rdev)
struct hi6421_spmi_pmic *pmic = sreg->pmic;
/* set enable register to 0 */
rdev_dbg(rdev, "enable_reg=0x%x, enable_mask=0x%x\n",
rdev->desc->enable_reg, rdev->desc->enable_mask);
hi6421_spmi_pmic_rmw(pmic, rdev->desc->enable_reg,
rdev->desc->enable_mask, 0);
@ -117,9 +122,9 @@ static int hi6421_spmi_regulator_get_voltage_sel(struct regulator_dev *rdev)
selector = (reg_val & rdev->desc->vsel_mask) >> (ffs(rdev->desc->vsel_mask) - 1);
dev_dbg(&rdev->dev,
"%s: vsel_reg=0x%x, value=0x%x, entry=0x%x, voltage=%d mV\n",
__func__, rdev->desc->vsel_reg, reg_val, selector,
rdev_dbg(rdev,
"vsel_reg=0x%x, value=0x%x, entry=0x%x, voltage=%d mV\n",
rdev->desc->vsel_reg, reg_val, selector,
rdev->desc->ops->list_voltage(rdev, selector) / 1000);
return selector;
@ -139,15 +144,14 @@ static int hi6421_spmi_regulator_set_voltage_sel(struct regulator_dev *rdev,
reg_val = selector << (ffs(rdev->desc->vsel_mask) - 1);
/* set voltage selector */
hi6421_spmi_pmic_rmw(pmic, rdev->desc->vsel_reg,
rdev->desc->vsel_mask, reg_val);
dev_dbg(&rdev->dev,
"%s: vsel_reg=0x%x, mask=0x%x, value=0x%x, voltage=%d mV\n",
__func__,
rdev_dbg(rdev,
"vsel_reg=0x%x, mask=0x%x, value=0x%x, voltage=%d mV\n",
rdev->desc->vsel_reg, rdev->desc->vsel_mask, reg_val,
rdev->desc->ops->list_voltage(rdev, selector) / 1000);
hi6421_spmi_pmic_rmw(pmic, rdev->desc->vsel_reg,
rdev->desc->vsel_mask, reg_val);
return 0;
}
@ -165,9 +169,9 @@ static unsigned int hi6421_spmi_regulator_get_mode(struct regulator_dev *rdev)
else
mode = REGULATOR_MODE_NORMAL;
dev_dbg(&rdev->dev,
"%s: enable_reg=0x%x, eco_mode_mask=0x%x, reg_val=0x%x, %s mode\n",
__func__, rdev->desc->enable_reg, sreg->eco_mode_mask, reg_val,
rdev_dbg(rdev,
"enable_reg=0x%x, eco_mode_mask=0x%x, reg_val=0x%x, %s mode\n",
rdev->desc->enable_reg, sreg->eco_mode_mask, reg_val,
mode == REGULATOR_MODE_IDLE ? "idle" : "normal");
return mode;
@ -192,13 +196,12 @@ static int hi6421_spmi_regulator_set_mode(struct regulator_dev *rdev,
}
/* set mode */
rdev_dbg(rdev, "enable_reg=0x%x, eco_mode_mask=0x%x, value=0x%x\n",
rdev->desc->enable_reg, sreg->eco_mode_mask, val);
hi6421_spmi_pmic_rmw(pmic, rdev->desc->enable_reg,
sreg->eco_mode_mask, val);
dev_dbg(&rdev->dev,
"%s: enable_reg=0x%x, eco_mode_mask=0x%x, value=0x%x\n",
__func__, rdev->desc->enable_reg, sreg->eco_mode_mask, val);
return 0;
}
@ -209,10 +212,10 @@ static unsigned int hi6421_spmi_regulator_get_optimum_mode(struct regulator_dev
struct hi6421v600_regulator *sreg = rdev_get_drvdata(rdev);
if (load_uA || ((unsigned int)load_uA > sreg->eco_uA)) {
dev_dbg(&rdev->dev, "%s: normal mode", __func__);
rdev_dbg(rdev, "normal mode");
return REGULATOR_MODE_NORMAL;
} else {
dev_dbg(&rdev->dev, "%s: idle mode", __func__);
rdev_dbg(rdev, "idle mode");
return REGULATOR_MODE_IDLE;
}
}
@ -373,7 +376,7 @@ static int hi6421_spmi_regulator_probe_ldo(struct platform_device *pdev,
goto probe_end;
}
dev_dbg(dev, "valid_modes_mask: 0x%x, valid_ops_mask: 0x%x\n",
rdev_dbg(rdev, "valid_modes_mask: 0x%x, valid_ops_mask: 0x%x\n",
constraint->valid_modes_mask, constraint->valid_ops_mask);
dev_set_drvdata(dev, rdev);