All of lore.kernel.org
 help / color / mirror / Atom feed
From: Christian Lamparter <chunkeey@googlemail.com>
To: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
Cc: davem@davemloft.net, jarod@redhat.com, ivan@de.ibm.com,
	ebiggers@google.com, tklauser@distanz.ch, tremyfr@gmail.com,
	robh@kernel.org, netdev@vger.kernel.org,
	linux-kernel@vger.kernel.org, kernel-janitors@vger.kernel.org
Subject: Re: [PATCH] net: ibm: emac: Fix some error handling path in 'emac_probe()'
Date: Sat, 19 Aug 2017 13:22:56 +0000	[thread overview]
Message-ID: <2515086.XcP7alDqkk@debian64> (raw)
In-Reply-To: <20170818230757.10934-1-christophe.jaillet@wanadoo.fr>

On Saturday, August 19, 2017 1:07:57 AM CEST Christophe JAILLET wrote:
> If 'irq_of_parse_and_map()' or 'of_address_to_resource()' fail, 'err' is
> known to be 0 at this point.
> So return -ENODEV instead in the first case and propagate the error
> returned by 'of_address_to_resource()' in the 2nd case.
> 
> While at it, turn a 'err != 0' test into an equivalent 'err' to be more
> consistent.
> 
> Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
> ---
>  drivers/net/ethernet/ibm/emac/core.c | 6 ++++--
>  1 file changed, 4 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/net/ethernet/ibm/emac/core.c b/drivers/net/ethernet/ibm/emac/core.c
> index 95135d20458f..1af56a97fb47 100644
> --- a/drivers/net/ethernet/ibm/emac/core.c
> +++ b/drivers/net/ethernet/ibm/emac/core.c
> [...]
>  	/* Map EMAC regs */
> -	if (of_address_to_resource(np, 0, &dev->rsrc_regs)) {
> +	err = of_address_to_resource(np, 0, &dev->rsrc_regs);
> +	if (err) {
>  		printk(KERN_ERR "%pOF: Can't get registers address\n", np);
>  		goto err_irq_unmap;
>  	}
>  // TODO : request_mem_region
>  dev->emacp = ioremap(dev->rsrc_regs.start,
>                       resource_size(&dev->rsrc_regs));
>  ...

If you want to go for 101%: you could get rid of this block
altogether by doing: 
	dev->emacp = of_iomap(np, 0);

Note1:
This will also make the rsrc_regs variable in the emac_instance
struct redundant. So simply remove it from the core.h.

Note2: if you want to go for 110%, you could replace this with
platform_get_resource() and devm_ioremap_resource() (if you
are interested, take a look at devm_ioremap_resource's kdoc
it has an example).

Thanks,
Christian

WARNING: multiple messages have this Message-ID (diff)
From: Christian Lamparter <chunkeey@googlemail.com>
To: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
Cc: davem@davemloft.net, jarod@redhat.com, ivan@de.ibm.com,
	ebiggers@google.com, tklauser@distanz.ch, tremyfr@gmail.com,
	robh@kernel.org, netdev@vger.kernel.org,
	linux-kernel@vger.kernel.org, kernel-janitors@vger.kernel.org
Subject: Re: [PATCH] net: ibm: emac: Fix some error handling path in 'emac_probe()'
Date: Sat, 19 Aug 2017 15:22:56 +0200	[thread overview]
Message-ID: <2515086.XcP7alDqkk@debian64> (raw)
In-Reply-To: <20170818230757.10934-1-christophe.jaillet@wanadoo.fr>

On Saturday, August 19, 2017 1:07:57 AM CEST Christophe JAILLET wrote:
> If 'irq_of_parse_and_map()' or 'of_address_to_resource()' fail, 'err' is
> known to be 0 at this point.
> So return -ENODEV instead in the first case and propagate the error
> returned by 'of_address_to_resource()' in the 2nd case.
> 
> While at it, turn a 'err != 0' test into an equivalent 'err' to be more
> consistent.
> 
> Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
> ---
>  drivers/net/ethernet/ibm/emac/core.c | 6 ++++--
>  1 file changed, 4 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/net/ethernet/ibm/emac/core.c b/drivers/net/ethernet/ibm/emac/core.c
> index 95135d20458f..1af56a97fb47 100644
> --- a/drivers/net/ethernet/ibm/emac/core.c
> +++ b/drivers/net/ethernet/ibm/emac/core.c
> [...]
>  	/* Map EMAC regs */
> -	if (of_address_to_resource(np, 0, &dev->rsrc_regs)) {
> +	err = of_address_to_resource(np, 0, &dev->rsrc_regs);
> +	if (err) {
>  		printk(KERN_ERR "%pOF: Can't get registers address\n", np);
>  		goto err_irq_unmap;
>  	}
>  // TODO : request_mem_region
>  dev->emacp = ioremap(dev->rsrc_regs.start,
>                       resource_size(&dev->rsrc_regs));
>  ...

If you want to go for 101%: you could get rid of this block
altogether by doing: 
	dev->emacp = of_iomap(np, 0);

Note1:
This will also make the rsrc_regs variable in the emac_instance
struct redundant. So simply remove it from the core.h.

Note2: if you want to go for 110%, you could replace this with
platform_get_resource() and devm_ioremap_resource() (if you
are interested, take a look at devm_ioremap_resource's kdoc
it has an example).

Thanks,
Christian

  reply	other threads:[~2017-08-19 13:22 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-08-18 23:07 [PATCH] net: ibm: emac: Fix some error handling path in 'emac_probe()' Christophe JAILLET
2017-08-18 23:07 ` Christophe JAILLET
2017-08-19 13:22 ` Christian Lamparter [this message]
2017-08-19 13:22   ` Christian Lamparter
2017-08-20  4:41   ` Christophe JAILLET
2017-08-20  4:41     ` Christophe JAILLET

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=2515086.XcP7alDqkk@debian64 \
    --to=chunkeey@googlemail.com \
    --cc=christophe.jaillet@wanadoo.fr \
    --cc=davem@davemloft.net \
    --cc=ebiggers@google.com \
    --cc=ivan@de.ibm.com \
    --cc=jarod@redhat.com \
    --cc=kernel-janitors@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=robh@kernel.org \
    --cc=tklauser@distanz.ch \
    --cc=tremyfr@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.