lkml.org 
[lkml]   [2022]   [Aug]   [1]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [PATCH v14 mfd 9/9] mfd: ocelot: add support for the vsc7512 chip via spi
Hi Andy,

Apologies for the late response. Everything seemed straightforward, but
as I was implementing your suggestions one thing came out.

I just want to make sure my implementation isn't horribly off before the
next patch set.

Specifically this question (copied from below):
> 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;

> > + 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;

xfer_tok->tx_buf = reg;
xfer_tok->len = reg_size;
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
xfer_tok++;

> > +
> > + 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
xfer_tok++;

> > +
> > + spi_message_add_tail(&rx, &msg);

spi_message_init_with_transfers(&msg, xfers, xfer_tok - xfers);

>
> 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.

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

\
 
 \ /
  Last update: 2022-08-02 04:18    [W:0.211 / U:0.068 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site