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

staging: hikey9xx: hi6421-spmi-pmic: rename some vars

- When referring to regmap, rename map to regmap
- inside hi6421-spmi-pmic, call private data struct as
  ddata.

No functional changes.
Signed-off-by: default avatarMauro Carvalho Chehab <mchehab+huawei@kernel.org>
Link: https://lore.kernel.org/r/d23592b11ac606e3b9a3ff95a754cb75921e60aa.1611949675.git.mchehab+huawei@kernel.orgSigned-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent 2ba53d04
...@@ -43,17 +43,17 @@ static const struct mfd_cell hi6421v600_devs[] = { ...@@ -43,17 +43,17 @@ static const struct mfd_cell hi6421v600_devs[] = {
static irqreturn_t hi6421_spmi_irq_handler(int irq, void *priv) static irqreturn_t hi6421_spmi_irq_handler(int irq, void *priv)
{ {
struct hi6421_spmi_pmic *pmic = (struct hi6421_spmi_pmic *)priv; struct hi6421_spmi_pmic *ddata = (struct hi6421_spmi_pmic *)priv;
unsigned long pending; unsigned long pending;
unsigned int data; unsigned int data;
int i, offset; int i, offset;
for (i = 0; i < HISI_IRQ_ARRAY; i++) { for (i = 0; i < HISI_IRQ_ARRAY; i++) {
regmap_read(pmic->map, offset, &data); regmap_read(ddata->regmap, offset, &data);
data &= HISI_MASK_FIELD; data &= HISI_MASK_FIELD;
if (data != 0) if (data != 0)
pr_debug("data[%d]=0x%d\n\r", i, data); pr_debug("data[%d]=0x%d\n\r", i, data);
regmap_write(pmic->map, i + SOC_PMIC_IRQ0_ADDR, data); regmap_write(ddata->regmap, i + SOC_PMIC_IRQ0_ADDR, data);
/* for_each_set_bit() macro requires unsigned long */ /* for_each_set_bit() macro requires unsigned long */
pending = data; pending = data;
...@@ -61,14 +61,14 @@ static irqreturn_t hi6421_spmi_irq_handler(int irq, void *priv) ...@@ -61,14 +61,14 @@ static irqreturn_t hi6421_spmi_irq_handler(int irq, void *priv)
/* solve powerkey order */ /* solve powerkey order */
if ((i == HISI_IRQ_KEY_NUM) && if ((i == HISI_IRQ_KEY_NUM) &&
((pending & HISI_IRQ_KEY_VALUE) == HISI_IRQ_KEY_VALUE)) { ((pending & HISI_IRQ_KEY_VALUE) == HISI_IRQ_KEY_VALUE)) {
generic_handle_irq(pmic->irqs[HISI_IRQ_KEY_DOWN]); generic_handle_irq(ddata->irqs[HISI_IRQ_KEY_DOWN]);
generic_handle_irq(pmic->irqs[HISI_IRQ_KEY_UP]); generic_handle_irq(ddata->irqs[HISI_IRQ_KEY_UP]);
pending &= (~HISI_IRQ_KEY_VALUE); pending &= (~HISI_IRQ_KEY_VALUE);
} }
if (pending) { if (pending) {
for_each_set_bit(offset, &pending, HISI_BITS) for_each_set_bit(offset, &pending, HISI_BITS)
generic_handle_irq(pmic->irqs[offset + i * HISI_BITS]); generic_handle_irq(ddata->irqs[offset + i * HISI_BITS]);
} }
} }
...@@ -77,7 +77,7 @@ static irqreturn_t hi6421_spmi_irq_handler(int irq, void *priv) ...@@ -77,7 +77,7 @@ static irqreturn_t hi6421_spmi_irq_handler(int irq, void *priv)
static void hi6421_spmi_irq_mask(struct irq_data *d) static void hi6421_spmi_irq_mask(struct irq_data *d)
{ {
struct hi6421_spmi_pmic *pmic = irq_data_get_irq_chip_data(d); struct hi6421_spmi_pmic *ddata = irq_data_get_irq_chip_data(d);
unsigned long flags; unsigned long flags;
unsigned int data; unsigned int data;
u32 offset; u32 offset;
...@@ -85,28 +85,28 @@ static void hi6421_spmi_irq_mask(struct irq_data *d) ...@@ -85,28 +85,28 @@ static void hi6421_spmi_irq_mask(struct irq_data *d)
offset = (irqd_to_hwirq(d) >> 3); offset = (irqd_to_hwirq(d) >> 3);
offset += SOC_PMIC_IRQ_MASK_0_ADDR; offset += SOC_PMIC_IRQ_MASK_0_ADDR;
spin_lock_irqsave(&pmic->lock, flags); spin_lock_irqsave(&ddata->lock, flags);
regmap_read(pmic->map, offset, &data); regmap_read(ddata->regmap, offset, &data);
data |= (1 << (irqd_to_hwirq(d) & 0x07)); data |= (1 << (irqd_to_hwirq(d) & 0x07));
regmap_write(pmic->map, offset, data); regmap_write(ddata->regmap, offset, data);
spin_unlock_irqrestore(&pmic->lock, flags); spin_unlock_irqrestore(&ddata->lock, flags);
} }
static void hi6421_spmi_irq_unmask(struct irq_data *d) static void hi6421_spmi_irq_unmask(struct irq_data *d)
{ {
struct hi6421_spmi_pmic *pmic = irq_data_get_irq_chip_data(d); struct hi6421_spmi_pmic *ddata = irq_data_get_irq_chip_data(d);
u32 data, offset; u32 data, offset;
unsigned long flags; unsigned long flags;
offset = (irqd_to_hwirq(d) >> 3); offset = (irqd_to_hwirq(d) >> 3);
offset += SOC_PMIC_IRQ_MASK_0_ADDR; offset += SOC_PMIC_IRQ_MASK_0_ADDR;
spin_lock_irqsave(&pmic->lock, flags); spin_lock_irqsave(&ddata->lock, flags);
regmap_read(pmic->map, offset, &data); regmap_read(ddata->regmap, offset, &data);
data &= ~(1 << (irqd_to_hwirq(d) & 0x07)); data &= ~(1 << (irqd_to_hwirq(d) & 0x07));
regmap_write(pmic->map, offset, data); regmap_write(ddata->regmap, offset, data);
spin_unlock_irqrestore(&pmic->lock, flags); spin_unlock_irqrestore(&ddata->lock, flags);
} }
static struct irq_chip hi6421_spmi_pmu_irqchip = { static struct irq_chip hi6421_spmi_pmu_irqchip = {
...@@ -120,11 +120,11 @@ static struct irq_chip hi6421_spmi_pmu_irqchip = { ...@@ -120,11 +120,11 @@ static struct irq_chip hi6421_spmi_pmu_irqchip = {
static int hi6421_spmi_irq_map(struct irq_domain *d, unsigned int virq, static int hi6421_spmi_irq_map(struct irq_domain *d, unsigned int virq,
irq_hw_number_t hw) irq_hw_number_t hw)
{ {
struct hi6421_spmi_pmic *pmic = d->host_data; struct hi6421_spmi_pmic *ddata = d->host_data;
irq_set_chip_and_handler_name(virq, &hi6421_spmi_pmu_irqchip, irq_set_chip_and_handler_name(virq, &hi6421_spmi_pmu_irqchip,
handle_simple_irq, "hisi"); handle_simple_irq, "hisi");
irq_set_chip_data(virq, pmic); irq_set_chip_data(virq, ddata);
irq_set_irq_type(virq, IRQ_TYPE_NONE); irq_set_irq_type(virq, IRQ_TYPE_NONE);
return 0; return 0;
...@@ -135,21 +135,21 @@ static const struct irq_domain_ops hi6421_spmi_domain_ops = { ...@@ -135,21 +135,21 @@ static const struct irq_domain_ops hi6421_spmi_domain_ops = {
.xlate = irq_domain_xlate_twocell, .xlate = irq_domain_xlate_twocell,
}; };
static void hi6421_spmi_pmic_irq_prc(struct hi6421_spmi_pmic *pmic) static void hi6421_spmi_pmic_irq_prc(struct hi6421_spmi_pmic *ddata)
{ {
int i; int i;
unsigned int pending; unsigned int pending;
for (i = 0 ; i < HISI_IRQ_ARRAY; i++) for (i = 0 ; i < HISI_IRQ_ARRAY; i++)
regmap_write(pmic->map, SOC_PMIC_IRQ_MASK_0_ADDR + i, regmap_write(ddata->regmap, SOC_PMIC_IRQ_MASK_0_ADDR + i,
HISI_MASK_STATE); HISI_MASK_STATE);
for (i = 0 ; i < HISI_IRQ_ARRAY; i++) { for (i = 0 ; i < HISI_IRQ_ARRAY; i++) {
regmap_read(pmic->map, SOC_PMIC_IRQ0_ADDR + i, &pending); regmap_read(ddata->regmap, SOC_PMIC_IRQ0_ADDR + i, &pending);
pr_debug("PMU IRQ address value:irq[0x%x] = 0x%x\n", pr_debug("PMU IRQ address value:irq[0x%x] = 0x%x\n",
SOC_PMIC_IRQ0_ADDR + i, pending); SOC_PMIC_IRQ0_ADDR + i, pending);
regmap_write(pmic->map, SOC_PMIC_IRQ0_ADDR + i, regmap_write(ddata->regmap, SOC_PMIC_IRQ0_ADDR + i,
HISI_MASK_STATE); HISI_MASK_STATE);
} }
} }
...@@ -165,79 +165,79 @@ static int hi6421_spmi_pmic_probe(struct spmi_device *pdev) ...@@ -165,79 +165,79 @@ static int hi6421_spmi_pmic_probe(struct spmi_device *pdev)
{ {
struct device *dev = &pdev->dev; struct device *dev = &pdev->dev;
struct device_node *np = dev->of_node; struct device_node *np = dev->of_node;
struct hi6421_spmi_pmic *pmic; struct hi6421_spmi_pmic *ddata;
struct regmap *map; struct regmap *map;
unsigned int virq; unsigned int virq;
int ret, i; int ret, i;
pmic = devm_kzalloc(dev, sizeof(*pmic), GFP_KERNEL); ddata = devm_kzalloc(dev, sizeof(*ddata), GFP_KERNEL);
if (!pmic) if (!ddata)
return -ENOMEM; return -ENOMEM;
map = devm_regmap_init_spmi_ext(pdev, &spmi_regmap_config); map = devm_regmap_init_spmi_ext(pdev, &spmi_regmap_config);
if (IS_ERR(map)) if (IS_ERR(map))
return PTR_ERR(map); return PTR_ERR(map);
spin_lock_init(&pmic->lock); spin_lock_init(&ddata->lock);
pmic->dev = dev; ddata->dev = dev;
pmic->map = map; ddata->regmap = map;
pmic->gpio = of_get_gpio(np, 0); ddata->gpio = of_get_gpio(np, 0);
if (pmic->gpio < 0) if (ddata->gpio < 0)
return pmic->gpio; return ddata->gpio;
if (!gpio_is_valid(pmic->gpio)) if (!gpio_is_valid(ddata->gpio))
return -EINVAL; return -EINVAL;
ret = devm_gpio_request_one(dev, pmic->gpio, GPIOF_IN, "pmic"); ret = devm_gpio_request_one(dev, ddata->gpio, GPIOF_IN, "pmic");
if (ret < 0) { if (ret < 0) {
dev_err(dev, "failed to request gpio%d\n", pmic->gpio); dev_err(dev, "failed to request gpio%d\n", ddata->gpio);
return ret; return ret;
} }
pmic->irq = gpio_to_irq(pmic->gpio); ddata->irq = gpio_to_irq(ddata->gpio);
hi6421_spmi_pmic_irq_prc(pmic); hi6421_spmi_pmic_irq_prc(ddata);
pmic->irqs = devm_kzalloc(dev, HISI_IRQ_NUM * sizeof(int), GFP_KERNEL); ddata->irqs = devm_kzalloc(dev, HISI_IRQ_NUM * sizeof(int), GFP_KERNEL);
if (!pmic->irqs) { if (!ddata->irqs) {
ret = -ENOMEM; ret = -ENOMEM;
goto irq_malloc; goto irq_malloc;
} }
pmic->domain = irq_domain_add_simple(np, HISI_IRQ_NUM, 0, ddata->domain = irq_domain_add_simple(np, HISI_IRQ_NUM, 0,
&hi6421_spmi_domain_ops, pmic); &hi6421_spmi_domain_ops, ddata);
if (!pmic->domain) { if (!ddata->domain) {
dev_err(dev, "failed irq domain add simple!\n"); dev_err(dev, "failed irq domain add simple!\n");
ret = -ENODEV; ret = -ENODEV;
goto irq_malloc; goto irq_malloc;
} }
for (i = 0; i < HISI_IRQ_NUM; i++) { for (i = 0; i < HISI_IRQ_NUM; i++) {
virq = irq_create_mapping(pmic->domain, i); virq = irq_create_mapping(ddata->domain, i);
if (!virq) { if (!virq) {
dev_err(dev, "Failed mapping hwirq\n"); dev_err(dev, "Failed mapping hwirq\n");
ret = -ENOSPC; ret = -ENOSPC;
goto irq_malloc; goto irq_malloc;
} }
pmic->irqs[i] = virq; ddata->irqs[i] = virq;
dev_dbg(dev, "%s: pmic->irqs[%d] = %d\n", dev_dbg(dev, "%s: ddata->irqs[%d] = %d\n",
__func__, i, pmic->irqs[i]); __func__, i, ddata->irqs[i]);
} }
ret = request_threaded_irq(pmic->irq, hi6421_spmi_irq_handler, NULL, ret = request_threaded_irq(ddata->irq, hi6421_spmi_irq_handler, NULL,
IRQF_TRIGGER_LOW | IRQF_SHARED | IRQF_NO_SUSPEND, IRQF_TRIGGER_LOW | IRQF_SHARED | IRQF_NO_SUSPEND,
"pmic", pmic); "pmic", ddata);
if (ret < 0) { if (ret < 0) {
dev_err(dev, "could not claim pmic IRQ: error %d\n", ret); dev_err(dev, "could not claim pmic IRQ: error %d\n", ret);
goto irq_malloc; goto irq_malloc;
} }
dev_set_drvdata(&pdev->dev, pmic); dev_set_drvdata(&pdev->dev, ddata);
/* /*
* The logic below will rely that the pmic is already stored at * The logic below will rely that the ddata is already stored at
* drvdata. * drvdata.
*/ */
dev_dbg(&pdev->dev, "SPMI-PMIC: adding children for %pOF\n", dev_dbg(&pdev->dev, "SPMI-PMIC: adding children for %pOF\n",
...@@ -251,16 +251,16 @@ static int hi6421_spmi_pmic_probe(struct spmi_device *pdev) ...@@ -251,16 +251,16 @@ static int hi6421_spmi_pmic_probe(struct spmi_device *pdev)
dev_err(dev, "Failed to add child devices: %d\n", ret); dev_err(dev, "Failed to add child devices: %d\n", ret);
irq_malloc: irq_malloc:
free_irq(pmic->irq, pmic); free_irq(ddata->irq, ddata);
return ret; return ret;
} }
static void hi6421_spmi_pmic_remove(struct spmi_device *pdev) static void hi6421_spmi_pmic_remove(struct spmi_device *pdev)
{ {
struct hi6421_spmi_pmic *pmic = dev_get_drvdata(&pdev->dev); struct hi6421_spmi_pmic *ddata = dev_get_drvdata(&pdev->dev);
free_irq(pmic->irq, pmic); free_irq(ddata->irq, ddata);
} }
static const struct of_device_id pmic_spmi_id_table[] = { static const struct of_device_id pmic_spmi_id_table[] = {
......
...@@ -104,7 +104,7 @@ static int hi6421_spmi_regulator_enable(struct regulator_dev *rdev) ...@@ -104,7 +104,7 @@ static int hi6421_spmi_regulator_enable(struct regulator_dev *rdev)
/* cannot enable more than one regulator at one time */ /* cannot enable more than one regulator at one time */
mutex_lock(&sreg->enable_mutex); mutex_lock(&sreg->enable_mutex);
ret = regmap_update_bits(pmic->map, rdev->desc->enable_reg, ret = regmap_update_bits(pmic->regmap, rdev->desc->enable_reg,
rdev->desc->enable_mask, rdev->desc->enable_mask,
rdev->desc->enable_mask); rdev->desc->enable_mask);
...@@ -121,7 +121,7 @@ static int hi6421_spmi_regulator_disable(struct regulator_dev *rdev) ...@@ -121,7 +121,7 @@ static int hi6421_spmi_regulator_disable(struct regulator_dev *rdev)
struct hi6421_spmi_reg_info *sreg = rdev_get_drvdata(rdev); struct hi6421_spmi_reg_info *sreg = rdev_get_drvdata(rdev);
struct hi6421_spmi_pmic *pmic = sreg->pmic; struct hi6421_spmi_pmic *pmic = sreg->pmic;
return regmap_update_bits(pmic->map, rdev->desc->enable_reg, return regmap_update_bits(pmic->regmap, rdev->desc->enable_reg,
rdev->desc->enable_mask, 0); rdev->desc->enable_mask, 0);
} }
...@@ -131,7 +131,7 @@ static unsigned int hi6421_spmi_regulator_get_mode(struct regulator_dev *rdev) ...@@ -131,7 +131,7 @@ static unsigned int hi6421_spmi_regulator_get_mode(struct regulator_dev *rdev)
struct hi6421_spmi_pmic *pmic = sreg->pmic; struct hi6421_spmi_pmic *pmic = sreg->pmic;
u32 reg_val; u32 reg_val;
regmap_read(pmic->map, rdev->desc->enable_reg, &reg_val); regmap_read(pmic->regmap, rdev->desc->enable_reg, &reg_val);
if (reg_val & sreg->eco_mode_mask) if (reg_val & sreg->eco_mode_mask)
return REGULATOR_MODE_IDLE; return REGULATOR_MODE_IDLE;
...@@ -157,7 +157,7 @@ static int hi6421_spmi_regulator_set_mode(struct regulator_dev *rdev, ...@@ -157,7 +157,7 @@ static int hi6421_spmi_regulator_set_mode(struct regulator_dev *rdev,
return -EINVAL; return -EINVAL;
} }
return regmap_update_bits(pmic->map, rdev->desc->enable_reg, return regmap_update_bits(pmic->regmap, rdev->desc->enable_reg,
sreg->eco_mode_mask, val); sreg->eco_mode_mask, val);
} }
...@@ -266,7 +266,7 @@ static int hi6421_spmi_regulator_probe(struct platform_device *pdev) ...@@ -266,7 +266,7 @@ static int hi6421_spmi_regulator_probe(struct platform_device *pdev)
config.dev = pdev->dev.parent; config.dev = pdev->dev.parent;
config.driver_data = sreg; config.driver_data = sreg;
config.regmap = pmic->map; config.regmap = pmic->regmap;
rdev = devm_regulator_register(dev, &info->desc, &config); rdev = devm_regulator_register(dev, &info->desc, &config);
if (IS_ERR(rdev)) { if (IS_ERR(rdev)) {
......
...@@ -26,7 +26,7 @@ struct hi6421_spmi_pmic { ...@@ -26,7 +26,7 @@ struct hi6421_spmi_pmic {
int irq; int irq;
int gpio; int gpio;
unsigned int *irqs; unsigned int *irqs;
struct regmap *map; struct regmap *regmap;
}; };
enum hi6421_spmi_pmic_irq_list { enum hi6421_spmi_pmic_irq_list {
......
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