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]

 



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



[Index of Archives]     [Device Tree Compilter]     [Device Tree Spec]     [Linux Driver Backports]     [Video for Linux]     [Linux USB Devel]     [Linux PCI Devel]     [Linux Audio Users]     [Linux Kernel]     [Linux SCSI]     [XFree86]     [Yosemite Backpacking]


  Powered by Linux