mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: "roel kluin" <roel.kluin@gmail.com>
To: "Magnus Damm" <magnus.damm@gmail.com>
Cc: linux-kernel@vger.kernel.org, akpm@linux-foundation.org,
	lethal@linux-sh.org, johnstul@us.ibm.com, gregkh@suse.de,
	mingo@redhat.com, tglx@linutronix.de
Subject: Re: [RESEND][PATCH] early platform drivers V2
Date: Thu, 15 Jan 2009 11:29:53 +0100	[thread overview]
Message-ID: <25e057c00901150229g35d8e9bdn6a19585cbc9d15bd@mail.gmail.com> (raw)
In-Reply-To: <20090114105436.18974.45429.sendpatchset@rx1.opensource.se>

> +static int __init early_platform_match(struct early_platform_driver *epdrv,
> +                                      struct platform_device **pdevs,
> +                                      int nr_pdevs, int id,
> +                                      struct platform_device **match)
> +{
> +       struct platform_device *pdev;
> +       int k, n, match_id;
> +
> +       if (id == -2)
> +               match_id = epdrv->requested_id;
> +       else
> +               match_id = id;
> +
> +       n = 0;
> +       *match = NULL;
> +       for (k = 0; k < nr_pdevs; k++) {
> +               pdev = pdevs[k];
> +               if (platform_match(&pdev->dev, &epdrv->pdrv->driver)) {

> +                       if (id != -2) /* skip previously checked device */
> +                               if (match_id == epdrv->requested_id)
> +                                       goto skip;
> +
> +                       if (pdev->id == match_id)
> +                               *match = pdev;
> +
> +skip:
> +                       if (pdev->id > match_id)
> +                               n++;

you can replace the 10 lines above by:

/* skip previously checked device */
if ((id == -2 || match_id != epdrv->requested_id) && pdev->id == match_id)
        *match = pdev;
else if (pdev->id > match_id)
        n++;

> +               }
> +       }
> +
> +       return n;
> +}

> +/**
> + * early_platform_driver_probe
> + * @class_str: string to identify early platform driver class
> + * @pdevs: platform devices to match against
> + * @nr_pdevs: number of platform devices to match against
> + * @nr_probe: number of platform devices to successfully probe before exiting
> + */
> +int __init early_platform_driver_probe(char *class_str,
> +                                      struct platform_device **pdevs,
> +                                      int nr_pdevs, int nr_probe)
> +{
> +       struct early_platform_driver *epdrv;
> +       struct platform_device *match;
> +       int k, n, i;
> +
> +       /* The "class_str" parameter may or may not be present on the kernel
> +        * command line. If it is present then there may be more than one
> +        * matching parameter.
> +        *
> +        * Since we register our early platform drivers using early_param()
> +        * we need to make sure that they also get registered in the case
> +        * when the parameter is missing from the kernel command line.
> +        *
> +        * We use parse_early_options() to make sure the early_param() gets
> +        * called at least once. The early_param() may be called more than
> +        * once since the name of the preferred device may be specified on
> +        * the kernel command line. early_platform_driver_register() handles
> +        * this case for us.
> +        */
> +       parse_early_options(class_str);
> +
> +       n = 0;
> +       list_for_each_entry(epdrv, &early_platform_driver_list, list) {
> +               /* only use drivers matching our class_str */
> +               if (strcmp(class_str, epdrv->class_str))
> +                       continue;
> +
> +               /* start with exact device match, continue with any device */
> +               k = 1;
> +               for (i = -2; k && n < nr_probe; i++) {
> +                       k = early_platform_match(epdrv, pdevs, nr_pdevs,
> +                                                i, &match);
> +                       if (!match)
> +                               continue;
> +
> +                       if (epdrv->pdrv->probe(match)) {

shouldn't this be

if (!epdrv->pdrv->probe(match)) {

> +                               pr_warning("%s: unable to probe %s early.\n",
> +                                          class_str, match->name);
> +                               continue;
> +                       }
> +                       n++;
> +               }
> +       }
> +
> +       if (!n)
> +               pr_warning("%s: no early platform devices found.\n", class_str);
> +
> +       return n;
> +}

I think k, n and i could get more descriptive names

  parent reply	other threads:[~2009-01-15 10:30 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-01-14 10:54 Magnus Damm
2009-01-14 22:36 ` Andrew Morton
2009-01-15 10:11   ` Magnus Damm
2009-01-14 22:47 ` Andrew Morton
2009-01-15 10:29 ` roel kluin [this message]
2009-01-15 10:38   ` Magnus Damm

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=25e057c00901150229g35d8e9bdn6a19585cbc9d15bd@mail.gmail.com \
    --to=roel.kluin@gmail.com \
    --cc=akpm@linux-foundation.org \
    --cc=gregkh@suse.de \
    --cc=johnstul@us.ibm.com \
    --cc=lethal@linux-sh.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=magnus.damm@gmail.com \
    --cc=mingo@redhat.com \
    --cc=tglx@linutronix.de \
    /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

all inboxes | Powered by JetHome®