Skip to content

Commit

Permalink
pinctrl: baytrail: Keep pointer to struct device instead of its conta…
Browse files Browse the repository at this point in the history
…iner

There is no need to keep pointer to struct platform_device, which is container
of struct device, because the latter is what have been used everywhere outside
of ->probe() path. In any case we may derive pointer to the container when
needed.

Acked-by: Hans de Goede <[email protected]>
Acked-by: Mika Westerberg <[email protected]>
Reviewed-by: Linus Walleij <[email protected]>
Signed-off-by: Andy Shevchenko <[email protected]>
  • Loading branch information
andy-shev committed Dec 13, 2019
1 parent 66c812d commit 990ec24
Showing 1 changed file with 29 additions and 29 deletions.
58 changes: 29 additions & 29 deletions drivers/pinctrl/intel/pinctrl-baytrail.c
Original file line number Diff line number Diff line change
Expand Up @@ -106,9 +106,9 @@ struct byt_gpio_pin_context {
}

struct byt_gpio {
struct device *dev;
struct gpio_chip chip;
struct irq_chip irqchip;
struct platform_device *pdev;
struct pinctrl_dev *pctl_dev;
struct pinctrl_desc pctl_desc;
const struct intel_pinctrl_soc_data *soc_data;
Expand Down Expand Up @@ -668,7 +668,7 @@ static void byt_set_group_simple_mux(struct byt_gpio *vg,

padcfg0 = byt_gpio_reg(vg, group.pins[i], BYT_CONF0_REG);
if (!padcfg0) {
dev_warn(&vg->pdev->dev,
dev_warn(vg->dev,
"Group %s, pin %i not muxed (no padcfg0)\n",
group.name, i);
continue;
Expand Down Expand Up @@ -698,7 +698,7 @@ static void byt_set_group_mixed_mux(struct byt_gpio *vg,

padcfg0 = byt_gpio_reg(vg, group.pins[i], BYT_CONF0_REG);
if (!padcfg0) {
dev_warn(&vg->pdev->dev,
dev_warn(vg->dev,
"Group %s, pin %i not muxed (no padcfg0)\n",
group.name, i);
continue;
Expand Down Expand Up @@ -785,13 +785,12 @@ static int byt_gpio_request_enable(struct pinctrl_dev *pctl_dev,
value |= gpio_mux;
writel(value, reg);

dev_warn(&vg->pdev->dev, FW_BUG
"pin %u forcibly re-configured as GPIO\n", offset);
dev_warn(vg->dev, FW_BUG "pin %u forcibly re-configured as GPIO\n", offset);
}

raw_spin_unlock_irqrestore(&byt_lock, flags);

pm_runtime_get(&vg->pdev->dev);
pm_runtime_get(vg->dev);

return 0;
}
Expand All @@ -803,7 +802,7 @@ static void byt_gpio_disable_free(struct pinctrl_dev *pctl_dev,
struct byt_gpio *vg = pinctrl_dev_get_drvdata(pctl_dev);

byt_gpio_clear_triggering(vg, offset);
pm_runtime_put(&vg->pdev->dev);
pm_runtime_put(vg->dev);
}

static int byt_gpio_set_direction(struct pinctrl_dev *pctl_dev,
Expand Down Expand Up @@ -1013,7 +1012,7 @@ static int byt_pin_config_set(struct pinctrl_dev *pctl_dev,
if (val & BYT_INPUT_EN) {
val &= ~BYT_INPUT_EN;
writel(val, val_reg);
dev_warn(&vg->pdev->dev,
dev_warn(vg->dev,
"pin %u forcibly set to input mode\n",
offset);
}
Expand All @@ -1035,7 +1034,7 @@ static int byt_pin_config_set(struct pinctrl_dev *pctl_dev,
if (val & BYT_INPUT_EN) {
val &= ~BYT_INPUT_EN;
writel(val, val_reg);
dev_warn(&vg->pdev->dev,
dev_warn(vg->dev,
"pin %u forcibly set to input mode\n",
offset);
}
Expand Down Expand Up @@ -1412,7 +1411,7 @@ static void byt_gpio_irq_handler(struct irq_desc *desc)
reg = byt_gpio_reg(vg, base, BYT_INT_STAT_REG);

if (!reg) {
dev_warn(&vg->pdev->dev,
dev_warn(vg->dev,
"Pin %i: could not retrieve interrupt status register\n",
base);
continue;
Expand All @@ -1434,7 +1433,6 @@ static void byt_init_irq_valid_mask(struct gpio_chip *chip,
unsigned int ngpios)
{
struct byt_gpio *vg = gpiochip_get_data(chip);
struct device *dev = &vg->pdev->dev;
void __iomem *reg;
u32 value;
int i;
Expand All @@ -1449,7 +1447,7 @@ static void byt_init_irq_valid_mask(struct gpio_chip *chip,

reg = byt_gpio_reg(vg, pin, BYT_CONF0_REG);
if (!reg) {
dev_warn(&vg->pdev->dev,
dev_warn(vg->dev,
"Pin %i: could not retrieve conf0 register\n",
i);
continue;
Expand All @@ -1458,10 +1456,10 @@ static void byt_init_irq_valid_mask(struct gpio_chip *chip,
value = readl(reg);
if (value & BYT_DIRECT_IRQ_EN) {
clear_bit(i, valid_mask);
dev_dbg(dev, "excluding GPIO %d from IRQ domain\n", i);
dev_dbg(vg->dev, "excluding GPIO %d from IRQ domain\n", i);
} else if ((value & BYT_PIN_MUX) == byt_get_gpio_mux(vg, i)) {
byt_gpio_clear_triggering(vg, i);
dev_dbg(dev, "disabling GPIO %d\n", i);
dev_dbg(vg->dev, "disabling GPIO %d\n", i);
}
}
}
Expand All @@ -1477,7 +1475,7 @@ static int byt_gpio_irq_init_hw(struct gpio_chip *chip)
reg = byt_gpio_reg(vg, base, BYT_INT_STAT_REG);

if (!reg) {
dev_warn(&vg->pdev->dev,
dev_warn(vg->dev,
"Pin %i: could not retrieve irq status reg\n",
base);
continue;
Expand All @@ -1488,7 +1486,7 @@ static int byt_gpio_irq_init_hw(struct gpio_chip *chip)
might be misconfigured in bios */
value = readl(reg);
if (value)
dev_err(&vg->pdev->dev,
dev_err(vg->dev,
"GPIO interrupt error, pins misconfigured. INT_STAT%u: 0x%08x\n",
base / 32, value);
}
Expand All @@ -1499,7 +1497,7 @@ static int byt_gpio_irq_init_hw(struct gpio_chip *chip)
static int byt_gpio_add_pin_ranges(struct gpio_chip *chip)
{
struct byt_gpio *vg = gpiochip_get_data(chip);
struct device *dev = &vg->pdev->dev;
struct device *dev = vg->dev;
int ret;

ret = gpiochip_add_pin_range(chip, dev_name(dev), 0, 0, vg->soc_data->npins);
Expand All @@ -1511,29 +1509,30 @@ static int byt_gpio_add_pin_ranges(struct gpio_chip *chip)

static int byt_gpio_probe(struct byt_gpio *vg)
{
struct platform_device *pdev = to_platform_device(vg->dev);
struct gpio_chip *gc;
struct resource *irq_rc;
int ret;

/* Set up gpio chip */
vg->chip = byt_gpio_chip;
gc = &vg->chip;
gc->label = dev_name(&vg->pdev->dev);
gc->label = dev_name(vg->dev);
gc->base = -1;
gc->can_sleep = false;
gc->add_pin_ranges = byt_gpio_add_pin_ranges;
gc->parent = &vg->pdev->dev;
gc->parent = vg->dev;
gc->ngpio = vg->soc_data->npins;

#ifdef CONFIG_PM_SLEEP
vg->saved_context = devm_kcalloc(&vg->pdev->dev, gc->ngpio,
vg->saved_context = devm_kcalloc(vg->dev, gc->ngpio,
sizeof(*vg->saved_context), GFP_KERNEL);
if (!vg->saved_context)
return -ENOMEM;
#endif

/* set up interrupts */
irq_rc = platform_get_resource(vg->pdev, IORESOURCE_IRQ, 0);
irq_rc = platform_get_resource(pdev, IORESOURCE_IRQ, 0);
if (irq_rc && irq_rc->start) {
struct gpio_irq_chip *girq;

Expand All @@ -1550,7 +1549,7 @@ static int byt_gpio_probe(struct byt_gpio *vg)
girq->init_valid_mask = byt_init_irq_valid_mask;
girq->parent_handler = byt_gpio_irq_handler;
girq->num_parents = 1;
girq->parents = devm_kcalloc(&vg->pdev->dev, girq->num_parents,
girq->parents = devm_kcalloc(vg->dev, girq->num_parents,
sizeof(*girq->parents), GFP_KERNEL);
if (!girq->parents)
return -ENOMEM;
Expand All @@ -1559,9 +1558,9 @@ static int byt_gpio_probe(struct byt_gpio *vg)
girq->handler = handle_bad_irq;
}

ret = devm_gpiochip_add_data(&vg->pdev->dev, gc, vg);
ret = devm_gpiochip_add_data(vg->dev, gc, vg);
if (ret) {
dev_err(&vg->pdev->dev, "failed adding byt-gpio chip\n");
dev_err(vg->dev, "failed adding byt-gpio chip\n");
return ret;
}

Expand All @@ -1571,10 +1570,11 @@ static int byt_gpio_probe(struct byt_gpio *vg)
static int byt_set_soc_data(struct byt_gpio *vg,
const struct intel_pinctrl_soc_data *soc_data)
{
struct platform_device *pdev = to_platform_device(vg->dev);
int i;

vg->soc_data = soc_data;
vg->communities_copy = devm_kcalloc(&vg->pdev->dev,
vg->communities_copy = devm_kcalloc(vg->dev,
soc_data->ncommunities,
sizeof(*vg->communities_copy),
GFP_KERNEL);
Expand All @@ -1586,7 +1586,7 @@ static int byt_set_soc_data(struct byt_gpio *vg,

*comm = vg->soc_data->communities[i];

comm->pad_regs = devm_platform_ioremap_resource(vg->pdev, 0);
comm->pad_regs = devm_platform_ioremap_resource(pdev, 0);
if (IS_ERR(comm->pad_regs))
return PTR_ERR(comm->pad_regs);
}
Expand Down Expand Up @@ -1628,7 +1628,7 @@ static int byt_pinctrl_probe(struct platform_device *pdev)
if (!vg)
return -ENOMEM;

vg->pdev = pdev;
vg->dev = &pdev->dev;
ret = byt_set_soc_data(vg, soc_data);
if (ret) {
dev_err(&pdev->dev, "failed to set soc data\n");
Expand Down Expand Up @@ -1672,7 +1672,7 @@ static int byt_gpio_suspend(struct device *dev)

reg = byt_gpio_reg(vg, pin, BYT_CONF0_REG);
if (!reg) {
dev_warn(&vg->pdev->dev,
dev_warn(vg->dev,
"Pin %i: could not retrieve conf0 register\n",
i);
continue;
Expand Down Expand Up @@ -1704,7 +1704,7 @@ static int byt_gpio_resume(struct device *dev)

reg = byt_gpio_reg(vg, pin, BYT_CONF0_REG);
if (!reg) {
dev_warn(&vg->pdev->dev,
dev_warn(vg->dev,
"Pin %i: could not retrieve conf0 register\n",
i);
continue;
Expand Down

0 comments on commit 990ec24

Please sign in to comment.