linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Brian Norris <computersforpeace@gmail.com>
To: w.danford@electronics-software.com
Cc: linux-kernel@vger.kernel.org
Subject: Re: source file /drivers/base/platform.c
Date: Wed, 22 Oct 2014 16:56:14 -0700	[thread overview]
Message-ID: <20141022235614.GF1193@ld-irv-0074> (raw)
In-Reply-To: <20141022160955.802aba6dbaeed9f5026600c863362da9.2d1b0160c3.wbe@email22.secureserver.net>

On Wed, Oct 22, 2014 at 04:09:55PM -0700, w.danford@electronics-software.com 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

      reply	other threads:[~2014-10-22 23:56 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-10-22 23:09 source file /drivers/base/platform.c w.danford
2014-10-22 23:56 ` Brian Norris [this message]

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=20141022235614.GF1193@ld-irv-0074 \
    --to=computersforpeace@gmail.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=w.danford@electronics-software.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).