Re: source file /drivers/base/platform.c

From: Brian Norris
Date: Wed Oct 22 2014 - 19:56:23 EST


On Wed, Oct 22, 2014 at 04:09:55PM -0700, w.danford@xxxxxxxxxxxxxxxxxxxxxxxx wrote:
> /**
> * platform_get_resource - get a resource for a device
> * @dev: platform device
> * @type: resource type
> * @num: resource index
> */
> struct resource *platform_get_resource(struct platform_device *dev,
> unsigned int type, unsigned int num)
[...]
> As a result I now suggest a more specific definition is desirable.
> The definition of the 'num' is the offset index for the specific
> resource 'type' to be searched for ignoring all others not of this
> 'type'. ... still convoluted. By example, first resource of 'type'
> is num=0, second resource of 'type' is num=1 even though say they
> may be [1] and [3] in the complete resource array of resource structs.
>
> Note my example has type IORESOURCE_MEM as members [0] and [2] in the
> arrya. So to look for [2] it is the second, num = 1, of type
> IORESOURCE_MEM.
>
> In conclusion this is a documentation issue!

You spent a lot of words to get to this point! Yes, the problem is with
the assumptions you were making, not with the implementation of
platform_get_resource().

AIUI, your latest interpretation is correct. The indexing of resources
is on a per-resource-type basis. So you're requesting the Nth resource
of type M when type=M and num=N.

Feel free to send a proper patch to improve the comments above
platform_get_resource(), if you think that will help the next person to
come across this API.

Brian
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/