lkml.org 
[lkml]   [2016]   [Sep]   [7]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
    /
    SubjectRe: [PATCH v4 1/5] gpio: pca953x: code shrink
    From
    Date
    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.

    >

    \
     
     \ /
      Last update: 2016-09-17 09:58    [W:3.867 / U:0.496 seconds]
    ©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site