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: <CAHp75VcHU+Rh2ROjMcK+Yuyu1Ty9C0Dcx2SjrnrM4BV9NuMZig@mail.gmail.com>
Date:   Tue, 2 Aug 2022 10:47:04 +0200
From:   Andy Shevchenko <andy.shevchenko@...il.com>
To:     Colin Foster <colin.foster@...advantage.com>
Cc:     linux-arm Mailing List <linux-arm-kernel@...ts.infradead.org>,
        "open list:GPIO SUBSYSTEM" <linux-gpio@...r.kernel.org>,
        netdev <netdev@...r.kernel.org>,
        Linux Kernel Mailing List <linux-kernel@...r.kernel.org>,
        devicetree <devicetree@...r.kernel.org>,
        Terry Bowman <terry.bowman@....com>,
        Vladimir Oltean <vladimir.oltean@....com>,
        Wolfram Sang <wsa@...nel.org>,
        Microchip Linux Driver Support <UNGLinuxDriver@...rochip.com>,
        Steen Hegelund <Steen.Hegelund@...rochip.com>,
        Lars Povlsen <lars.povlsen@...rochip.com>,
        Linus Walleij <linus.walleij@...aro.org>,
        Paolo Abeni <pabeni@...hat.com>,
        Jakub Kicinski <kuba@...nel.org>,
        Eric Dumazet <edumazet@...gle.com>,
        "David S. Miller" <davem@...emloft.net>,
        Russell King <linux@...linux.org.uk>,
        Heiner Kallweit <hkallweit1@...il.com>,
        Andrew Lunn <andrew@...n.ch>,
        Krzysztof Kozlowski <krzysztof.kozlowski+dt@...aro.org>,
        Rob Herring <robh+dt@...nel.org>,
        Lee Jones <lee.jones@...aro.org>, katie.morris@...advantage.com
Subject: Re: [PATCH v14 mfd 9/9] mfd: ocelot: add support for the vsc7512 chip
 via spi

On Tue, Aug 2, 2022 at 4:17 AM Colin Foster
<colin.foster@...advantage.com> wrote:

...

> > I'm wondering if you can use in both cases
> > spi_message_init_with_transfers().
>
> > > +static int ocelot_spi_regmap_bus_read(void *context, const void *reg, size_t reg_size,
> > > +                                     void *val, size_t val_size)
> > > +{
> > > +       struct spi_transfer tx, padding, rx;
>
> struct spi_transfer xfers[3] = {0};
> struct spi_transfer *xfer_tok = xfers;

unsigned int index;

> > > +       struct device *dev = context;
> > > +       struct ocelot_ddata *ddata;
> > > +       struct spi_device *spi;
> > > +       struct spi_message msg;
> > > +
> > > +       ddata = dev_get_drvdata(dev);
> > > +       spi = to_spi_device(dev);
> > > +
> > > +       spi_message_init(&msg);
> > > +
> > > +       memset(&tx, 0, sizeof(tx));
> > > +
> > > +       tx.tx_buf = reg;
> > > +       tx.len = reg_size;

index = 0;

> xfer_tok->tx_buf = reg;
> xfer_tok->len = reg_size;

tok[index] = ...;
index++;

> xfer_tok++;
>
> > > +       spi_message_add_tail(&tx, &msg);
> > > +
> > > +       if (ddata->spi_padding_bytes) {
> > > +               memset(&padding, 0, sizeof(padding));
> > > +
> > > +               padding.len = ddata->spi_padding_bytes;
> > > +               padding.tx_buf = ddata->dummy_buf;
> > > +               padding.dummy_data = 1;
>
> xfer_tok->len
> xfer_tok->tx_buf
> xfer_tok->dummy_data

tok[index] = ...

> xfer_tok++;

index++;

> > > +               spi_message_add_tail(&padding, &msg);
> > > +       }
> > > +
> > > +       memset(&rx, 0, sizeof(rx));
> > > +       rx.rx_buf = val;
> > > +       rx.len = val_size;
>
> xfer_tok->rx_buf
> xfer_tok->len

tok[index] = ...

> xfer_tok++;

index++;

> > > +       spi_message_add_tail(&rx, &msg);
>
> spi_message_init_with_transfers(&msg, xfers, xfer_tok - xfers);

..., index);

> > I'm wondering if you can use in both cases
> > spi_message_init_with_transfers().
>
> I could see that implementation getting the response of "what the heck
> were you thinking" or "that looks alright" and I honestly have no idea
> which pool it will fall into.

See above. I.o.w. use index based assignments.

> > > +       return spi_sync(spi, &msg);
> > > +}

-- 
With Best Regards,
Andy Shevchenko

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ