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: <1473260973.29864.13.camel@perches.com>
Date:   Wed, 07 Sep 2016 08:09:33 -0700
From:   Joe Perches <joe@...ches.com>
To:     Bartosz Golaszewski <bgolaszewski@...libre.com>,
        Linus Walleij <linus.walleij@...aro.org>,
        Alexandre Courbot <gnurou@...il.com>,
        Andy Shevchenko <andriy.shevchenko@...ux.intel.com>,
        Vignesh R <vigneshr@...com>, Yong Li <yong.b.li@...el.com>,
        Geert Uytterhoeven <geert+renesas@...der.be>
Cc:     linux-gpio <linux-gpio@...r.kernel.org>,
        LKML <linux-kernel@...r.kernel.org>
Subject: Re: [PATCH v4 1/5] gpio: pca953x: code shrink

On Wed, 2016-09-07 at 16:49 +0200, Bartosz Golaszewski wrote:
> There are multiple places in the driver code where a
> switch (chip->chip_type) is used to determine the proper register
> offset.
> 
> Unduplicate the code by adding a simple structure holding the possible
> offsets that differ between the pca953x and pca957x chip families and
> use it to avoid the checks.
[]
> diff --git a/drivers/gpio/gpio-pca953x.c b/drivers/gpio/gpio-pca953x.c
[]
> @@ -94,6 +94,24 @@ MODULE_DEVICE_TABLE(acpi, pca953x_acpi_ids);
>  
>  #define NBANK(chip) DIV_ROUND_UP(chip->gpio_chip.ngpio, BANK_SZ)
>  
> +struct pca953x_offset {
> > +	int direction;
> > +	int output;
> > +	int input;
> +};

The struct name seems suboptimal.
Maybe pca95xx_reg_io_config or some such.

> +static const struct pca953x_offset pca953x_offsets = {
> > +	.direction = PCA953X_DIRECTION,
> > +	.output = PCA953X_OUTPUT,
> > +	.input = PCA953X_INPUT,
> +};
> +
> +static const struct pca953x_offset pca957x_offsets = {
> > +	.direction = PCA957X_CFG,
> > +	.output = PCA957X_OUT,
> > +	.input = PCA957X_IN,
> +};

The more naming consistency for #defines would be nice too
at some point.

> 

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ