Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1447769

Re: [RFC 7/7] [media] rc: add support for IR LEDs driven through SPI

From Sean Young <sean@mess.org>
Newsgroups linux.kernel
Subject Re: [RFC 7/7] [media] rc: add support for IR LEDs driven through SPI
Date 2016-07-21 12:30 +0200
Message-ID <rXjoR-6b9-3@gated-at.bofh.it> (permalink)
References <rWFB7-5U4-7@gated-at.bofh.it> <rWFB7-5U4-5@gated-at.bofh.it> <rXaEV-yP-15@gated-at.bofh.it> <rWMsV-1T0-1@gated-at.bofh.it> <rXaEV-yP-13@gated-at.bofh.it>
Organization linux.* mail to news gateway

Show all headers | View raw


Hi Andi,

On Thu, Jul 21, 2016 at 10:09:26AM +0900, Andi Shyti wrote:
> > > +	ret = regulator_enable(idata->regulator);
> > > +	if (ret)
> > > +		return ret;
> > > +
> > > +	mutex_lock(&idata->mutex);
> > > +	idata->xfer.len = n;
> > > +	idata->xfer.tx_buf = buffer;
> > > +	mutex_unlock(&idata->mutex);
> > 
> > I'm not convinced the locking works here. You want to guard against 
> > someone modifying xfer while you are sending (so in spi_sync_transfer), 
> > which this locking is not doing. You could declare a 
> > local "struct spi_transfer xfer" and avoid the mutex altogether.
> 
> I cannot declare xfer locally because the spi framework needs
> a statically allocated xfer, so that either I dynamically
> allocate it in the function or I declare it global in idata.

It can be stack allocated for sync transfers. You might want to lock
the spi bus.

> With the mutex I would like to prevent different tasks to change
> the value at the same time, it's an easy case, it shouldn't make
> much difference.

That's cargo-cult locking. It does not achieve anything.


Sean

Back to linux.kernel | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

[RFC 7/7] [media] rc: add support for IR LEDs driven through SPI Andi Shyti <andi.shyti@samsung.com> - 2016-07-19 18:00 +0200
  Re: [RFC 7/7] [media] rc: add support for IR LEDs driven through SPI Sean Young <sean@mess.org> - 2016-07-20 01:20 +0200
    Re: [RFC 7/7] [media] rc: add support for IR LEDs driven through SPI Andi Shyti <andi.shyti@samsung.com> - 2016-07-21 03:10 +0200
      Re: [RFC 7/7] [media] rc: add support for IR LEDs driven through SPI Sean Young <sean@mess.org> - 2016-07-21 12:30 +0200
        Re: [RFC 7/7] [media] rc: add support for IR LEDs driven through SPI Andi Shyti <andi@etezian.org> - 2016-07-21 17:00 +0200

csiph-web