Commit b660bf65 authored by Mauro Carvalho Chehab's avatar Mauro Carvalho Chehab Committed by Greg Kroah-Hartman

staging: regulator: hi6421v600-regulator: coding style fixups

There are several issues on those drivers related to their
coding style. Solve most of them.
Signed-off-by: default avatarMauro Carvalho Chehab <mchehab+huawei@kernel.org>
Link: https://lore.kernel.org/r/9ea7fdc004c7c44ae513b6c8f6c4a4493dd1ac61.1597647359.git.mchehab+huawei@kernel.orgSigned-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent 12ca3b20
// SPDX-License-Identifier: GPL-2.0
/* /*
* Device driver for regulators in Hisi IC * Device driver for regulators in Hisi IC
* *
...@@ -52,7 +53,7 @@ struct hisi_regulator { ...@@ -52,7 +53,7 @@ struct hisi_regulator {
u32 off_on_delay; u32 off_on_delay;
u32 eco_uA; u32 eco_uA;
struct regulator_desc rdesc; struct regulator_desc rdesc;
int (*dt_parse)(struct hisi_regulator *, struct spmi_device *); int (*dt_parse)(struct hisi_regulator *reg, struct spmi_device *spmi);
}; };
static DEFINE_MUTEX(enable_mutex); static DEFINE_MUTEX(enable_mutex);
...@@ -77,7 +78,8 @@ static int hisi_regulator_is_enabled(struct regulator_dev *dev) ...@@ -77,7 +78,8 @@ static int hisi_regulator_is_enabled(struct regulator_dev *dev)
struct hisi_pmic *pmic = rdev_to_pmic(dev); struct hisi_pmic *pmic = rdev_to_pmic(dev);
reg_val = hisi_pmic_read(pmic, sreg->register_info.ctrl_reg); reg_val = hisi_pmic_read(pmic, sreg->register_info.ctrl_reg);
pr_debug("<[%s]: ctrl_reg=0x%x,enable_state=%d>\n", __func__, sreg->register_info.ctrl_reg,\ pr_debug("<[%s]: ctrl_reg=0x%x,enable_state=%d>\n",
__func__, sreg->register_info.ctrl_reg,
(reg_val & sreg->register_info.enable_mask)); (reg_val & sreg->register_info.enable_mask));
return ((reg_val & sreg->register_info.enable_mask) != 0); return ((reg_val & sreg->register_info.enable_mask) != 0);
...@@ -98,13 +100,12 @@ static int hisi_regulator_enable(struct regulator_dev *dev) ...@@ -98,13 +100,12 @@ static int hisi_regulator_enable(struct regulator_dev *dev)
usleep_range(HISI_REGS_ENA_PROTECT_TIME, usleep_range(HISI_REGS_ENA_PROTECT_TIME,
HISI_REGS_ENA_PROTECT_TIME + 1000); HISI_REGS_ENA_PROTECT_TIME + 1000);
/* set enable register */ /* set enable register */
hisi_pmic_rmw(pmic, sreg->register_info.ctrl_reg, hisi_pmic_rmw(pmic, sreg->register_info.ctrl_reg,
sreg->register_info.enable_mask, sreg->register_info.enable_mask,
sreg->register_info.enable_mask); sreg->register_info.enable_mask);
pr_debug("<[%s]: ctrl_reg=0x%x,enable_mask=0x%x>\n", __func__, sreg->register_info.ctrl_reg,\ pr_debug("<[%s]: ctrl_reg=0x%x,enable_mask=0x%x>\n",
__func__, sreg->register_info.ctrl_reg,
sreg->register_info.enable_mask); sreg->register_info.enable_mask);
mutex_unlock(&enable_mutex); mutex_unlock(&enable_mutex);
...@@ -132,7 +133,8 @@ static int hisi_regulator_get_voltage(struct regulator_dev *dev) ...@@ -132,7 +133,8 @@ static int hisi_regulator_get_voltage(struct regulator_dev *dev)
/* get voltage selector */ /* get voltage selector */
reg_val = hisi_pmic_read(pmic, sreg->register_info.vset_reg); reg_val = hisi_pmic_read(pmic, sreg->register_info.vset_reg);
pr_debug("<[%s]: vset_reg=0x%x>\n", __func__, sreg->register_info.vset_reg); pr_debug("<[%s]: vset_reg=0x%x>\n",
__func__, sreg->register_info.vset_reg);
selector = (reg_val & sreg->register_info.vset_mask) >> selector = (reg_val & sreg->register_info.vset_mask) >>
(ffs(sreg->register_info.vset_mask) - 1); (ffs(sreg->register_info.vset_mask) - 1);
...@@ -141,7 +143,7 @@ static int hisi_regulator_get_voltage(struct regulator_dev *dev) ...@@ -141,7 +143,7 @@ static int hisi_regulator_get_voltage(struct regulator_dev *dev)
} }
static int hisi_regulator_set_voltage(struct regulator_dev *dev, static int hisi_regulator_set_voltage(struct regulator_dev *dev,
int min_uV, int max_uV, unsigned *selector) int min_uV, int max_uV, unsigned int *selector)
{ {
struct hisi_regulator *sreg = rdev_get_drvdata(dev); struct hisi_regulator *sreg = rdev_get_drvdata(dev);
struct hisi_pmic *pmic = rdev_to_pmic(dev); struct hisi_pmic *pmic = rdev_to_pmic(dev);
...@@ -165,11 +167,11 @@ static int hisi_regulator_set_voltage(struct regulator_dev *dev, ...@@ -165,11 +167,11 @@ static int hisi_regulator_set_voltage(struct regulator_dev *dev,
sreg->register_info.vset_mask, sreg->register_info.vset_mask,
vsel << (ffs(sreg->register_info.vset_mask) - 1)); vsel << (ffs(sreg->register_info.vset_mask) - 1));
pr_debug("<[%s]: vset_reg=0x%x, vset_mask=0x%x, value=0x%x>\n", __func__,\ pr_debug("<[%s]: vset_reg=0x%x, vset_mask=0x%x, value=0x%x>\n",
sreg->register_info.vset_reg,\ __func__,
sreg->register_info.vset_mask,\ sreg->register_info.vset_reg,
vsel << (ffs(sreg->register_info.vset_mask) - 1)\ sreg->register_info.vset_mask,
); vsel << (ffs(sreg->register_info.vset_mask) - 1));
return ret; return ret;
} }
...@@ -181,10 +183,10 @@ static unsigned int hisi_regulator_get_mode(struct regulator_dev *dev) ...@@ -181,10 +183,10 @@ static unsigned int hisi_regulator_get_mode(struct regulator_dev *dev)
u32 reg_val; u32 reg_val;
reg_val = hisi_pmic_read(pmic, sreg->register_info.ctrl_reg); reg_val = hisi_pmic_read(pmic, sreg->register_info.ctrl_reg);
pr_debug("<[%s]: reg_val=%d, ctrl_reg=0x%x, eco_mode_mask=0x%x>\n", __func__, reg_val,\ pr_debug("<[%s]: reg_val=%d, ctrl_reg=0x%x, eco_mode_mask=0x%x>\n",
sreg->register_info.ctrl_reg,\ __func__, reg_val,
sreg->register_info.eco_mode_mask\ sreg->register_info.ctrl_reg,
); sreg->register_info.eco_mode_mask);
if (reg_val & sreg->register_info.eco_mode_mask) if (reg_val & sreg->register_info.eco_mode_mask)
return REGULATOR_MODE_IDLE; return REGULATOR_MODE_IDLE;
...@@ -215,21 +217,21 @@ static int hisi_regulator_set_mode(struct regulator_dev *dev, ...@@ -215,21 +217,21 @@ static int hisi_regulator_set_mode(struct regulator_dev *dev,
sreg->register_info.eco_mode_mask, sreg->register_info.eco_mode_mask,
eco_mode << (ffs(sreg->register_info.eco_mode_mask) - 1)); eco_mode << (ffs(sreg->register_info.eco_mode_mask) - 1));
pr_debug("<[%s]: ctrl_reg=0x%x, eco_mode_mask=0x%x, value=0x%x>\n", __func__,\ pr_debug("<[%s]: ctrl_reg=0x%x, eco_mode_mask=0x%x, value=0x%x>\n",
sreg->register_info.ctrl_reg,\ __func__,
sreg->register_info.eco_mode_mask,\ sreg->register_info.ctrl_reg,
eco_mode << (ffs(sreg->register_info.eco_mode_mask) - 1)\ sreg->register_info.eco_mode_mask,
); eco_mode << (ffs(sreg->register_info.eco_mode_mask) - 1));
return 0; return 0;
} }
static unsigned int hisi_regulator_get_optimum_mode(struct regulator_dev *dev,
unsigned int hisi_regulator_get_optimum_mode(struct regulator_dev *dev, int input_uV, int output_uV,
int input_uV, int output_uV, int load_uA) int load_uA)
{ {
struct hisi_regulator *sreg = rdev_get_drvdata(dev); struct hisi_regulator *sreg = rdev_get_drvdata(dev);
if ((load_uA == 0) || ((unsigned int)load_uA > sreg->eco_uA)) if (load_uA || ((unsigned int)load_uA > sreg->eco_uA))
return REGULATOR_MODE_NORMAL; return REGULATOR_MODE_NORMAL;
else else
return REGULATOR_MODE_IDLE; return REGULATOR_MODE_IDLE;
...@@ -362,7 +364,7 @@ static const struct hisi_regulator hisi_regulator_ldo = { ...@@ -362,7 +364,7 @@ static const struct hisi_regulator hisi_regulator_ldo = {
.dt_parse = hisi_dt_parse_ldo, .dt_parse = hisi_dt_parse_ldo,
}; };
static struct of_device_id of_hisi_regulator_match_tbl[] = { static const struct of_device_id of_hisi_regulator_match_tbl[] = {
{ {
.compatible = "hisilicon-hisi-ldo", .compatible = "hisilicon-hisi-ldo",
.data = &hisi_regulator_ldo, .data = &hisi_regulator_ldo,
...@@ -388,14 +390,14 @@ static int hisi_regulator_probe(struct spmi_device *pdev) ...@@ -388,14 +390,14 @@ static int hisi_regulator_probe(struct spmi_device *pdev)
int ret = 0; int ret = 0;
/* to check which type of regulator this is */ /* to check which type of regulator this is */
match = of_match_device(of_hisi_regulator_match_tbl, &pdev->dev); match = of_match_device(of_hisi_regulator_match_tbl, &pdev->dev);
if (NULL == match) { if (!match) {
pr_err("get hisi regulator fail!\n\r"); pr_err("get hisi regulator fail!\n\r");
return -EINVAL; return -EINVAL;
} }
template = match->data; template = match->data;
initdata = of_get_regulator_init_data(dev, np, NULL); initdata = of_get_regulator_init_data(dev, np, NULL);
if (NULL == initdata) { if (!initdata) {
pr_err("get regulator init data error !\n"); pr_err("get regulator init data error !\n");
return -EINVAL; return -EINVAL;
} }
...@@ -404,7 +406,7 @@ static int hisi_regulator_probe(struct spmi_device *pdev) ...@@ -404,7 +406,7 @@ static int hisi_regulator_probe(struct spmi_device *pdev)
constraint = &initdata->constraints; constraint = &initdata->constraints;
ret = of_property_read_u32_array(np, "hisilicon,valid-modes-mask", ret = of_property_read_u32_array(np, "hisilicon,valid-modes-mask",
&(constraint->valid_modes_mask), 1); &constraint->valid_modes_mask, 1);
if (ret) { if (ret) {
pr_err("no hisilicon,valid-modes-mask property set\n"); pr_err("no hisilicon,valid-modes-mask property set\n");
ret = -ENODEV; ret = -ENODEV;
...@@ -420,18 +422,16 @@ static int hisi_regulator_probe(struct spmi_device *pdev) ...@@ -420,18 +422,16 @@ static int hisi_regulator_probe(struct spmi_device *pdev)
constraint->valid_ops_mask |= temp_modes; constraint->valid_ops_mask |= temp_modes;
sreg = kmemdup(template, sizeof(*sreg), GFP_KERNEL); sreg = kmemdup(template, sizeof(*sreg), GFP_KERNEL);
if (!sreg) { if (!sreg)
pr_err("template kememdup is fail. \n");
return -ENOMEM; return -ENOMEM;
}
sreg->name = initdata->constraints.name; sreg->name = initdata->constraints.name;
rdesc = &sreg->rdesc; rdesc = &sreg->rdesc;
rdesc->name = sreg->name; rdesc->name = sreg->name;
rdesc->min_uV = initdata->constraints.min_uV; rdesc->min_uV = initdata->constraints.min_uV;
supplyname = of_get_property(np, "hisilicon,supply_name", NULL); supplyname = of_get_property(np, "hisilicon,supply_name", NULL);
if (supplyname != NULL) { if (supplyname)
initdata->supply_regulator = supplyname; initdata->supply_regulator = supplyname;
}
/* to parse device tree data for regulator specific */ /* to parse device tree data for regulator specific */
ret = sreg->dt_parse(sreg, pdev); ret = sreg->dt_parse(sreg, pdev);
...@@ -454,7 +454,8 @@ static int hisi_regulator_probe(struct spmi_device *pdev) ...@@ -454,7 +454,8 @@ static int hisi_regulator_probe(struct spmi_device *pdev)
goto hisi_probe_end; goto hisi_probe_end;
} }
pr_debug("[%s]:valid_modes_mask[0x%x], valid_ops_mask[0x%x]\n", rdesc->name,\ pr_debug("[%s]:valid_modes_mask[0x%x], valid_ops_mask[0x%x]\n",
rdesc->name,
constraint->valid_modes_mask, constraint->valid_ops_mask); constraint->valid_modes_mask, constraint->valid_ops_mask);
dev_set_drvdata(dev, rdev); dev_set_drvdata(dev, rdev);
...@@ -477,11 +478,12 @@ static void hisi_regulator_remove(struct spmi_device *pdev) ...@@ -477,11 +478,12 @@ static void hisi_regulator_remove(struct spmi_device *pdev)
kfree(sreg); kfree(sreg);
} }
static int hisi_regulator_suspend(struct device *dev, pm_message_t state) static int hisi_regulator_suspend(struct device *dev, pm_message_t state)
{ {
struct hisi_regulator *hisi_regulator = dev_get_drvdata(dev); struct hisi_regulator *hisi_regulator = dev_get_drvdata(dev);
if (NULL == hisi_regulator) { if (!hisi_regulator) {
pr_err("%s:regulator is NULL\n", __func__); pr_err("%s:regulator is NULL\n", __func__);
return -ENOMEM; return -ENOMEM;
} }
...@@ -490,13 +492,13 @@ static int hisi_regulator_suspend(struct device *dev, pm_message_t state) ...@@ -490,13 +492,13 @@ static int hisi_regulator_suspend(struct device *dev, pm_message_t state)
pr_info("%s:-\n", __func__); pr_info("%s:-\n", __func__);
return 0; return 0;
}/*lint !e715 */ }
static int hisi_regulator_resume(struct device *dev) static int hisi_regulator_resume(struct device *dev)
{ {
struct hisi_regulator *hisi_regulator = dev_get_drvdata(dev); struct hisi_regulator *hisi_regulator = dev_get_drvdata(dev);
if (NULL == hisi_regulator) { if (!hisi_regulator) {
pr_err("%s:regulator is NULL\n", __func__); pr_err("%s:regulator is NULL\n", __func__);
return -ENOMEM; return -ENOMEM;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment