Re: [PATCH 3/6] drivers: base: Share implementations for dev_get_resource*()

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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@xxxxxxxxx>
> ---
>  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@xxxxxxxxxxxxxxxxxxx
http://lists.infradead.org/mailman/listinfo/barebox



[Index of Archives]     [Linux Embedded]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [XFree86]

  Powered by Linux