Re: [PATCH v14 mfd 9/9] mfd: ocelot: add support for the vsc7512 chip via spi

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Tue, Aug 2, 2022 at 4:17 AM Colin Foster
<colin.foster@xxxxxxxxxxxxxxxx> 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



[Index of Archives]     [Linux SPI]     [Linux Kernel]     [Linux ARM (vger)]     [Linux ARM MSM]     [Linux Omap]     [Linux Arm]     [Linux Tegra]     [Fedora ARM]     [Linux for Samsung SOC]     [eCos]     [Linux Fastboot]     [Gcc Help]     [Git]     [DCCP]     [IETF Announce]     [Security]     [Linux MIPS]     [Yosemite Campsites]

  Powered by Linux