mail archive of the barebox mailing list
 help / color / mirror / Atom feed
From: Sascha Hauer <s.hauer@pengutronix.de>
To: Andrey Smirnov <andrew.smirnov@gmail.com>
Cc: barebox@lists.infradead.org
Subject: Re: [PATCH 3/6] drivers: base: Share implementations for dev_get_resource*()
Date: Mon, 29 Oct 2018 09:52:14 +0100	[thread overview]
Message-ID: <20181029085214.mnn25qlp6a72zsq4@pengutronix.de> (raw)
In-Reply-To: <20181027013230.24387-4-andrew.smirnov@gmail.com>

On Fri, Oct 26, 2018 at 06:32:27PM -0700, Andrey Smirnov wrote:
> Both dev_get_resource() and dev_get_resource_by_name() implement the
> same algorithm and differ only in matching criteria. Move that
> algoritm into a separate generic function and implement those two
> functions using it.
> 
> Signed-off-by: Andrey Smirnov <andrew.smirnov@gmail.com>
> ---
>  drivers/base/driver.c | 39 +++++++++++++++++++++++----------------
>  1 file changed, 23 insertions(+), 16 deletions(-)
> 
> diff --git a/drivers/base/driver.c b/drivers/base/driver.c
> index 22ca96d7e..4c1b6110a 100644
> --- a/drivers/base/driver.c
> +++ b/drivers/base/driver.c
> @@ -325,14 +325,27 @@ int register_driver(struct driver_d *drv)
>  }
>  EXPORT_SYMBOL(register_driver);
>  
> -struct resource *dev_get_resource(struct device_d *dev, unsigned long type,
> -				  int num)
> +static struct resource *
> +dev_get_resource_by_name_or_id(struct device_d *dev, unsigned long type,
> +			       const char *name, int num)

The behaviour of this function is a bit ambiguous: type must always match,
name must match if given, num must match if name is not given but is otherwise
ignored. Given that dev_get_resource() and dev_get_resource_by_name()
both implement a simpler behaviour and both are straight forward to read
I don't think this is an improvement.

Sascha

-- 
Pengutronix e.K.                           |                             |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |

_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

  reply	other threads:[~2018-10-29  8:52 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-10-27  1:32 [PATCH 0/6] Refactor driver resource allocation code Andrey Smirnov
2018-10-27  1:32 ` [PATCH 1/6] drivers: base: Simplify generic_memmap_ro() Andrey Smirnov
2018-10-27  7:47   ` Sam Ravnborg
2018-10-27  1:32 ` [PATCH 2/6] drivers: base: Drop dev_get_mem_region_by_name() Andrey Smirnov
2018-10-27  1:32 ` [PATCH 3/6] drivers: base: Share implementations for dev_get_resource*() Andrey Smirnov
2018-10-29  8:52   ` Sascha Hauer [this message]
2018-10-27  1:32 ` [PATCH 4/6] drivers: base: Simplify dev_request_mem_region_err_null() Andrey Smirnov
2018-10-27  1:32 ` [PATCH 5/6] drivers: base: Share code for dev_request_mem_region*() Andrey Smirnov
2018-10-27  8:20   ` Sam Ravnborg
2018-10-29  8:58     ` Sascha Hauer
2018-10-27  8:26   ` Sam Ravnborg
2018-10-27  8:46     ` Sam Ravnborg
2018-10-27  1:32 ` [PATCH 6/6] drivers: base: Share code for getting and then requesting a region Andrey Smirnov
2018-10-29  9:00 ` [PATCH 0/6] Refactor driver resource allocation code Sascha Hauer

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=20181029085214.mnn25qlp6a72zsq4@pengutronix.de \
    --to=s.hauer@pengutronix.de \
    --cc=andrew.smirnov@gmail.com \
    --cc=barebox@lists.infradead.org \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox