Re: [PATCH 4/7] irqchip/irq-mbigen.c: Use devm_platform_ioremap_resource()

From: Marc Zyngier
Date: Mon Apr 29 2019 - 04:16:46 EST


On 04/04/2019 08:20, Mukesh Ojha wrote:
> devm_platform_ioremap_resource() internally have platform_get_resource()
> and devm_ioremap_resource() in it. So instead of calling them separately
> use devm_platform_ioremap_resource() directly.
>
> Signed-off-by: Mukesh Ojha <mojha@xxxxxxxxxxxxxx>
> ---
> drivers/irqchip/irq-ls-scfg-msi.c | 4 +---
> drivers/irqchip/irq-mbigen.c | 9 +--------
> 2 files changed, 2 insertions(+), 11 deletions(-)

You're changing two drivers, and yet only mention one. Bad.

>
> diff --git a/drivers/irqchip/irq-ls-scfg-msi.c b/drivers/irqchip/irq-ls-scfg-msi.c
> index c671b32..aec5a2f 100644
> --- a/drivers/irqchip/irq-ls-scfg-msi.c
> +++ b/drivers/irqchip/irq-ls-scfg-msi.c
> @@ -336,7 +336,6 @@ static int ls_scfg_msi_probe(struct platform_device *pdev)
> {
> const struct of_device_id *match;
> struct ls_scfg_msi *msi_data;
> - struct resource *res;
> int i, ret;
>
> match = of_match_device(ls_scfg_msi_id, &pdev->dev);
> @@ -349,8 +348,7 @@ static int ls_scfg_msi_probe(struct platform_device *pdev)
>
> msi_data->cfg = (struct ls_scfg_msi_cfg *) match->data;
>
> - res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
> - msi_data->regs = devm_ioremap_resource(&pdev->dev, res);
> + msi_data->regs = devm_platform_ioremap_resource(pdev, 0);
> if (IS_ERR(msi_data->regs)) {
> dev_err(&pdev->dev, "failed to initialize 'regs'\n");
> return PTR_ERR(msi_data->regs);
> diff --git a/drivers/irqchip/irq-mbigen.c b/drivers/irqchip/irq-mbigen.c
> index 98b6e1d..c9aedfb 100644
> --- a/drivers/irqchip/irq-mbigen.c
> +++ b/drivers/irqchip/irq-mbigen.c
> @@ -327,7 +327,6 @@ static inline int mbigen_acpi_create_domain(struct platform_device *pdev,
> static int mbigen_device_probe(struct platform_device *pdev)
> {
> struct mbigen_device *mgn_chip;
> - struct resource *res;
> int err;
>
> mgn_chip = devm_kzalloc(&pdev->dev, sizeof(*mgn_chip), GFP_KERNEL);
> @@ -335,13 +334,7 @@ static int mbigen_device_probe(struct platform_device *pdev)
> return -ENOMEM;
>
> mgn_chip->pdev = pdev;
> -
> - res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
> - if (!res)
> - return -EINVAL;
> -
> - mgn_chip->base = devm_ioremap(&pdev->dev, res->start,
> - resource_size(res));
> + mgn_chip->base = devm_platform_ioremap_resource(pdev, 0);
> if (!mgn_chip->base) {

Now you are introducing a bug, as devm_ioremap and
devm_platform_ioremap_resource do not return the same thing.

> dev_err(&pdev->dev, "failed to ioremap %pR\n", res);
> return -ENOMEM;
>

Thanks,

M.
--
Jazz is not dead. It just smells funny...