lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <25e057c00901150229g35d8e9bdn6a19585cbc9d15bd@mail.gmail.com>
Date:	Thu, 15 Jan 2009 11:29:53 +0100
From:	"roel kluin" <roel.kluin@...il.com>
To:	"Magnus Damm" <magnus.damm@...il.com>
Cc:	linux-kernel@...r.kernel.org, akpm@...ux-foundation.org,
	lethal@...ux-sh.org, johnstul@...ibm.com, gregkh@...e.de,
	mingo@...hat.com, tglx@...utronix.de
Subject: Re: [RESEND][PATCH] early platform drivers V2

> +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
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ