Re: [PATCH] staging: axis-fifo: Fix line over 80 characters error
On Thu, 2018-10-25 at 09:05 +0300, Dan Carpenter wrote: > On Wed, Oct 24, 2018 at 05:05:53PM +0200, Aleksa Zdravkovic wrote: > > This patch fixes the checkpatch.pl warning: [] > > diff --git a/drivers/staging/axis-fifo/axis-fifo.c > > b/drivers/staging/axis-fifo/axis-fifo.c [] > > @@ -482,10 +482,10 @@ static ssize_t axis_fifo_write(struct file *f, const > > char __user *buf, > > spin_lock_irq(&fifo->write_queue_lock); > > ret = wait_event_interruptible_lock_irq_timeout > > (fifo->write_queue, > > -ioread32(fifo->base_addr + XLLF_TDFV_OFFSET) > > + ioread32(fifo->base_addr + XLLF_TDFV_OFFSET) > > >= words_to_write, > > -fifo->write_queue_lock, > > -(write_timeout >= 0) ? msecs_to_jiffies(write_timeout) > > : > > + fifo->write_queue_lock, > > + (write_timeout >= 0) ? msecs_to_jiffies(write_timeout) : > > MAX_SCHEDULE_TIMEOUT); > > The original was fine. Just leave it. > > Checkpatch.pl is only useful if it improves the readability for humans. True, but I think the original is just OK. Any suggestion on how to make the thing better? wait_event_interruptible_lock_irq_timeout is a fairly long identifier with multiple long arguments. It's as if it should be written here as ret = wait_event_interruptible_lock_irq_timeout(fifo->write_queue, ioread32(fifo->base_addr + XLLF_TDFV_OFFSET) >= words_to_write, fifo->write_queue_lock, write_timeout >= 0 ? msecs_to_jiffies(write_timeout) : MAX_SCHEDULE_TIMEOUT); where the longest is way over 80 chars, (140?) but I simply don't care because it's just that much more readable for me. ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
Re: [alsa-devel] [PATCH v2] staging: bcm2835-audio: interpolate audio delay
On Thu, 25 Oct 2018 00:02:34 +0200, Kirill Marinushkin wrote: > > >> When you play sound - the pointer increments. > > > > Unfortunately, when you play sound, the pointer does not actually > > increment, for up to about 10 milliseconds. I know of no way to actually > > access the true “live” position of the frame that is being played at any > > instant; hence the desire to estimate it. > > > > Your vision of situation in the opposite from my vision. What you see as a > symptom - I see as a root cause. As I see, you should fix the > pointer-not-incrementing. Why do you think that it's okay that the pointer is > not updating during sound play? Why do you insist that there is a delay? I > don't > understand why we are so stuck here. Well, in the API POV, it's nothing wrong to keep hwptr sticking while updating only delay value. It implies that the hardware chip doesn't provide the hwptr update. Though, usually the delay value is provided also from the hardware, e.g. reading the link position or such. It's a typical case like USB-audio, where the hwptr gets updated and the delay indicates the actual position *behind* hwptr. That works because hwptr shows the position in the ring buffer at which you can access the data. And it doesn't mean that hwptr is the actually playing position, but it can be ahead of the current position, when many samples are queued on FIFO. The delay is provided to correct the position back to the actual point. But, this also doesn't mean that the delay shouldn't be used for the purpose like this patchset, either. OTOH, providing a finer hwptr value would be likely more apps-friendly; there must be many programs that don't evaluate the delay value properly. So, I suppose that hwptr update might be a better option if the code won't become too complex. Let's see. One another thing I'd like to point out is that the value given in the patch is nothing but an estimated position, optimistically calculated via the system timer. Mike and I had already discussion in another thread, and another possible option would be to provide the proper timestamp-vs-hwptr pair, instead of updating the timestamp always at the status read. Maybe it's worth to have a module option to suppress this optimistic hwptr update behavior, in case something went wrong with clocks? thanks, Takashi ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
[PATCH] staging: iio: ad7780: update voltage on read
The ad7780 driver previously did not read the correct device output. This patch fixes two issues. - The driver read an outdated value set at initialization. It now updates its voltage on read. - Variable val subtracted an uninitialized value on IIO_CHAN_INFO_OFFSET. This was fixed by assiging the correct value instead. Signed-off-by: Renato Lui Geh --- drivers/staging/iio/adc/ad7780.c | 6 +- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/drivers/staging/iio/adc/ad7780.c b/drivers/staging/iio/adc/ad7780.c index b67412db0318..06700fe554a2 100644 --- a/drivers/staging/iio/adc/ad7780.c +++ b/drivers/staging/iio/adc/ad7780.c @@ -87,16 +87,20 @@ static int ad7780_read_raw(struct iio_dev *indio_dev, long m) { struct ad7780_state *st = iio_priv(indio_dev); + int voltage_uv = 0; switch (m) { case IIO_CHAN_INFO_RAW: return ad_sigma_delta_single_conversion(indio_dev, chan, val); case IIO_CHAN_INFO_SCALE: + voltage_uv = regulator_get_voltage(st->reg); + if (voltage_uv) + st->int_vref_mv = voltage_uv/1000; *val = st->int_vref_mv * st->gain; *val2 = chan->scan_type.realbits - 1; return IIO_VAL_FRACTIONAL_LOG2; case IIO_CHAN_INFO_OFFSET: - *val -= (1 << (chan->scan_type.realbits - 1)); + *val = -(1 << (chan->scan_type.realbits - 1)); return IIO_VAL_INT; } -- 2.19.1 ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
Re: [PATCH] staging: iio: ad7780: update voltage on read
On 10/25/2018 03:32 PM, Renato Lui Geh wrote: > The ad7780 driver previously did not read the correct device output. > This patch fixes two issues. > > - The driver read an outdated value set at initialization. It now > updates its voltage on read. > - Variable val subtracted an uninitialized value on > IIO_CHAN_INFO_OFFSET. This was fixed by assiging the correct value > instead. > > Signed-off-by: Renato Lui Geh Hi, Thanks for the patch, this looks good. But please create one patch per issue and do not put unrelated changes into the same patch. Also your mail client seems to have replaced tabs in the patch with spaces, this means the patch will not apply cleanly. Check the Documentation/email-clients.txt file for some hints how to configure your mail client so it will not break patches. - Lars > --- > drivers/staging/iio/adc/ad7780.c | 6 +- > 1 file changed, 5 insertions(+), 1 deletion(-) > > diff --git a/drivers/staging/iio/adc/ad7780.c > b/drivers/staging/iio/adc/ad7780.c > index b67412db0318..06700fe554a2 100644 > --- a/drivers/staging/iio/adc/ad7780.c > +++ b/drivers/staging/iio/adc/ad7780.c > @@ -87,16 +87,20 @@ static int ad7780_read_raw(struct iio_dev *indio_dev, > long m) > { > struct ad7780_state *st = iio_priv(indio_dev); > + int voltage_uv = 0; > > switch (m) { > case IIO_CHAN_INFO_RAW: > return ad_sigma_delta_single_conversion(indio_dev, chan, val); > case IIO_CHAN_INFO_SCALE: > + voltage_uv = regulator_get_voltage(st->reg); > + if (voltage_uv) > + st->int_vref_mv = voltage_uv/1000; > *val = st->int_vref_mv * st->gain; > *val2 = chan->scan_type.realbits - 1; > return IIO_VAL_FRACTIONAL_LOG2; > case IIO_CHAN_INFO_OFFSET: > - *val -= (1 << (chan->scan_type.realbits - 1)); > + *val = -(1 << (chan->scan_type.realbits - 1)); > return IIO_VAL_INT; > } > ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
[bug report] staging: vc04_services: add vchiq_pagelist_info structure
Hello Michael Zoran, The patch 4807f2c0e684: "staging: vc04_services: add vchiq_pagelist_info structure" from Nov 7, 2016, leads to the following static checker warning: drivers/staging/vc04_services/interface/vchiq_arm/vchiq_2835_arm.c:440 create_pagelist() warn: overflowed symbol reused: 'count' drivers/staging/vc04_services/interface/vchiq_arm/vchiq_2835_arm.c 398 static struct vchiq_pagelist_info * 399 create_pagelist(char __user *buf, size_t count, unsigned short type) This comes from the user from the ioctl. It starts as an int but gets cast to unsigned long. 400 { 401 PAGELIST_T *pagelist; 402 struct vchiq_pagelist_info *pagelistinfo; 403 struct page **pages; 404 u32 *addrs; 405 unsigned int num_pages, offset, i, k; 406 int actual_pages; 407 size_t pagelist_size; 408 struct scatterlist *scatterlist, *sg; 409 int dma_buffers; 410 dma_addr_t dma_addr; 411 412 offset = ((unsigned int)(unsigned long)buf & (PAGE_SIZE - 1)); 413 num_pages = DIV_ROUND_UP(count + offset, PAGE_SIZE); ^ Which means that this can definitely overflow. I can happen in two ways. First the "count + offset" can overflow. Then the DIV_ROUND_UP starts by adding PAGE_SIZE to the result and that addition can overflow. The problem with handling integer overflow issues from a static analysis perspective is that many integer overflows are not harmful. Often we maybe we get a smaller num_pages from what we had intended but it doesn't cause a problem because we never reference "count" again. This warning message is supposed to solve that problem by warning by only complaining when we re-use count. 414 415 pagelist_size = sizeof(PAGELIST_T) + 416 (num_pages * sizeof(u32)) + 417 (num_pages * sizeof(pages[0]) + 418 (num_pages * sizeof(struct scatterlist))) + 419 sizeof(struct vchiq_pagelist_info); 420 421 /* Allocate enough storage to hold the page pointers and the page 422 * list 423 */ 424 pagelist = dma_zalloc_coherent(g_dev, 425 pagelist_size, 426 &dma_addr, 427 GFP_KERNEL); 428 429 vchiq_log_trace(vchiq_arm_log_level, "%s - %pK", __func__, pagelist); 430 431 if (!pagelist) 432 return NULL; 433 434 addrs = pagelist->addrs; 435 pages = (struct page **)(addrs + num_pages); 436 scatterlist = (struct scatterlist *)(pages + num_pages); 437 pagelistinfo= (struct vchiq_pagelist_info *) 438(scatterlist + num_pages); 439 440 pagelist->length = count; ^ So it complains here. But then when I look at it more, it's not clear to me if it matters that "pagelist->length" is out of sync with "num_pages"... Anyway, that's why I'm forwarding this static checker output to you instead of trying to fix it myself. 441 pagelist->type = type; 442 pagelist->offset = offset; regards, dan carpenter ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
Re: [bug report] staging: vc04_services: add vchiq_pagelist_info structure
> On Oct 25, 2018, at 8:44 AM, Dan Carpenter wrote: > > Hello Michael Zoran, > > The patch 4807f2c0e684: "staging: vc04_services: add > vchiq_pagelist_info structure" from Nov 7, 2016, leads to the > following static checker warning: > > drivers/staging/vc04_services/interface/vchiq_arm/vchiq_2835_arm.c:440 > create_pagelist() > warn: overflowed symbol reused: 'count' > > drivers/staging/vc04_services/interface/vchiq_arm/vchiq_2835_arm.c > 398 static struct vchiq_pagelist_info * > 399 create_pagelist(char __user *buf, size_t count, unsigned short type) > > This comes from the user from the ioctl. It starts as an int but gets > cast to unsigned long. > > 400 { > 401 PAGELIST_T *pagelist; > 402 struct vchiq_pagelist_info *pagelistinfo; > 403 struct page **pages; > 404 u32 *addrs; > 405 unsigned int num_pages, offset, i, k; > 406 int actual_pages; > 407 size_t pagelist_size; > 408 struct scatterlist *scatterlist, *sg; > 409 int dma_buffers; > 410 dma_addr_t dma_addr; > 411 > 412 offset = ((unsigned int)(unsigned long)buf & (PAGE_SIZE - 1)); > 413 num_pages = DIV_ROUND_UP(count + offset, PAGE_SIZE); > ^ > Which means that this can definitely overflow. I can happen in two > ways. First the "count + offset" can overflow. Then the DIV_ROUND_UP > starts by adding PAGE_SIZE to the result and that addition can overflow. > > The problem with handling integer overflow issues from a static analysis > perspective is that many integer overflows are not harmful. Often we > maybe we get a smaller num_pages from what we had intended but it doesn't > cause a problem because we never reference "count" again. This warning > message is supposed to solve that problem by warning by only complaining > when we re-use count. > > 414 > 415 pagelist_size = sizeof(PAGELIST_T) + > 416 (num_pages * sizeof(u32)) + > 417 (num_pages * sizeof(pages[0]) + > 418 (num_pages * sizeof(struct scatterlist))) + > 419 sizeof(struct vchiq_pagelist_info); > 420 > 421 /* Allocate enough storage to hold the page pointers and the > page > 422 * list > 423 */ > 424 pagelist = dma_zalloc_coherent(g_dev, > 425 pagelist_size, > 426 &dma_addr, > 427 GFP_KERNEL); > 428 > 429 vchiq_log_trace(vchiq_arm_log_level, "%s - %pK", __func__, > pagelist); > 430 > 431 if (!pagelist) > 432 return NULL; > 433 > 434 addrs = pagelist->addrs; > 435 pages = (struct page **)(addrs + num_pages); > 436 scatterlist = (struct scatterlist *)(pages + num_pages); > 437 pagelistinfo= (struct vchiq_pagelist_info *) > 438(scatterlist + num_pages); > 439 > 440 pagelist->length = count; >^ > So it complains here. But then when I look at it more, it's not clear > to me if it matters that "pagelist->length" is out of sync with > "num_pages"... > > Anyway, that's why I'm forwarding this static checker output to you > instead of trying to fix it myself. > > 441 pagelist->type = type; > 442 pagelist->offset = offset; > > regards, > dan carpenter Hi Dan, I no longer have any PI/RPI boards anymore. I gave my boards away to someone who was in desperate need of really a cheap computer. So It’s not clear to me how I can help much or be able to locally test changes anymore. I’ve also been spending my time on other things these days. I was mostly interested in getting arm64 to work on the PI 3, which I essentially accomplished. Although I isn’t clear 64 bit has much use on the PI 3, it was a great learning experience anyway. I learned a lot about linux kernel development and the processes involved in submitting patches. As a final note, this driver has many of these issues. I know that fixing static errors like this is important, but due to the nature of the driver itself I’m am not sure changes like this have much gain. ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
Re: [PATCH] staging: iio: ad7780: update voltage on read
Hi, Thanks for the quick review. :) But please create one patch per issue and do not put unrelated changes into the same patch. Should I resend this patch as a patchset containing the two changes? Also your mail client seems to have replaced tabs in the patch with spaces, this means the patch will not apply cleanly. Check the Documentation/email-clients.txt file for some hints how to configure your mail client so it will not break patches. From my end my original email patch appears to have tabs instead of spaces. I redownloaded my email and vim shows that the indentation has the ^I tab characters. But when downloading your reply it was converted to spaces. Am I missing something? Thanks again, Renato ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
Re: [PATCH] staging: axis-fifo: Fix line over 80 characters error
On Wed, Oct 24, 2018 at 11:18:17PM -0700, Joe Perches wrote: > On Thu, 2018-10-25 at 09:05 +0300, Dan Carpenter wrote: > > On Wed, Oct 24, 2018 at 05:05:53PM +0200, Aleksa Zdravkovic wrote: > > > This patch fixes the checkpatch.pl warning: > [] > > > diff --git a/drivers/staging/axis-fifo/axis-fifo.c > > > b/drivers/staging/axis-fifo/axis-fifo.c > [] > > > @@ -482,10 +482,10 @@ static ssize_t axis_fifo_write(struct file *f, > > > const char __user *buf, > > > spin_lock_irq(&fifo->write_queue_lock); > > > ret = wait_event_interruptible_lock_irq_timeout > > > (fifo->write_queue, > > > - ioread32(fifo->base_addr + XLLF_TDFV_OFFSET) > > > + ioread32(fifo->base_addr + XLLF_TDFV_OFFSET) > > > >= words_to_write, > > > - fifo->write_queue_lock, > > > - (write_timeout >= 0) ? msecs_to_jiffies(write_timeout) > > > : > > > + fifo->write_queue_lock, > > > + (write_timeout >= 0) ? msecs_to_jiffies(write_timeout) : > > > MAX_SCHEDULE_TIMEOUT); > > > > The original was fine. Just leave it. > > > > Checkpatch.pl is only useful if it improves the readability for humans. > > True, but I think the original is just OK. > > Any suggestion on how to make the thing better? > > wait_event_interruptible_lock_irq_timeout is a fairly long > identifier with multiple long arguments. > > It's as if it should be written here as > > ret = > wait_event_interruptible_lock_irq_timeout(fifo->write_queue, > > ioread32(fifo->base_addr + XLLF_TDFV_OFFSET) >= words_to_write, > > fifo->write_queue_lock, > write_timeout > >= 0 ? msecs_to_jiffies(write_timeout) : MAX_SCHEDULE_TIMEOUT); > > where the longest is way over 80 chars, (140?) but I simply don't care > because it's just that much more readable for me. > > Thank you Dan and Joe for your feedback. I don't have any suggestion how to improve this code otherwise. I will try to find a way to improve it. Maybe we can define some macros but I don't think it would help much. ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
Re: [PATCH] staging: iio: ad7780: update voltage on read
On Thu, Oct 25, 2018 at 11:26:36AM -0300, Renato Lui Geh wrote: > Hi, > > Thanks for the quick review. :) > > > But please create one patch per issue and do not put unrelated changes into > > the same patch. > > Should I resend this patch as a patchset containing the two changes? Yes! "One patch per change policy" > > Also your mail client seems to have replaced tabs in the patch with spaces, > > this means the patch will not apply cleanly. Check the > > Documentation/email-clients.txt file for some hints how to configure your > > mail client so it will not break patches. > > From my end my original email patch appears to have tabs instead of > spaces. I redownloaded my email and vim shows that the indentation has > the ^I tab characters. But when downloading your reply it was converted > to spaces. Am I missing something? Your patch applies fine. I think the problem is on Lars end due to Thunderbird. In the meantime, you can verify the patch using: $ git am Also, you can try to use `git send-email` to send patches. -- Himanshu Jha Undergraduate Student Department of Electronics & Communication Guru Tegh Bahadur Institute of Technology ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
[PATCH RFC 06/11] staging: vchiq_arm: Register a platform device for audio
Following Eric's commit 37b7b3087a2f ("staging/vc04_services: Register a platform device for the camera driver.") this register the audio driver as a platform device, too. Signed-off-by: Stefan Wahren --- drivers/staging/vc04_services/interface/vchiq_arm/vchiq_arm.c | 4 1 file changed, 4 insertions(+) diff --git a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_arm.c b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_arm.c index 778a252..fc6388b 100644 --- a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_arm.c +++ b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_arm.c @@ -170,6 +170,7 @@ static struct class *vchiq_class; static struct device *vchiq_dev; static DEFINE_SPINLOCK(msg_queue_spinlock); static struct platform_device *bcm2835_camera; +static struct platform_device *bcm2835_audio; static struct vchiq_drvdata bcm2835_drvdata = { .cache_line_size = 32, @@ -3670,6 +3671,7 @@ static int vchiq_probe(struct platform_device *pdev) MAJOR(vchiq_devid), MINOR(vchiq_devid)); bcm2835_camera = vchiq_register_child(pdev, "bcm2835-camera"); + bcm2835_audio = vchiq_register_child(pdev, "bcm2835_audio"); return 0; @@ -3686,6 +3688,8 @@ static int vchiq_probe(struct platform_device *pdev) static int vchiq_remove(struct platform_device *pdev) { + if (!IS_ERR(bcm2835_audio)) + platform_device_unregister(bcm2835_audio); if (!IS_ERR(bcm2835_camera)) platform_device_unregister(bcm2835_camera); vchiq_debugfs_deinit(); -- 2.7.4 ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
[PATCH RFC 07/11] staging: bcm2835-audio: Enable compile test
Enable the compilation test for bcm2835-audio to gain more build coverage. Signed-off-by: Stefan Wahren --- drivers/staging/vc04_services/bcm2835-audio/Kconfig | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/staging/vc04_services/bcm2835-audio/Kconfig b/drivers/staging/vc04_services/bcm2835-audio/Kconfig index 9f53653..62c1c8b 100644 --- a/drivers/staging/vc04_services/bcm2835-audio/Kconfig +++ b/drivers/staging/vc04_services/bcm2835-audio/Kconfig @@ -1,6 +1,6 @@ config SND_BCM2835 tristate "BCM2835 Audio" -depends on ARCH_BCM2835 && SND +depends on (ARCH_BCM2835 || COMPILE_TEST) && SND select SND_PCM select BCM2835_VCHIQ help -- 2.7.4 ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
[PATCH RFC 00/11] staging: vc04_services: Improve driver load/unload
This patch series improves the load/unload of bcm2835 camera and audio drivers. It has been tested with Raspberry Pi 3 B and a camera module V1. This series based on current linux-next and Phil Elwell's series ("Improve VCHIQ cache line size handling"). After Nicolas' series ("staging: vc04_services: Some dead code removal") has been applied, i will rebase my series. Stefan Wahren (11): staging: bcm2835-camera: Abort probe if there is no camera staging: bcm2835-camera: fix module autoloading staging: bcm2835-camera: Move module info to the end staging: vchiq_arm: Fix platform device unregistration staging: vchiq_arm: Fix camera device registration staging: vchiq_arm: Register a platform device for audio staging: bcm2835-audio: Enable compile test staging: bcm2835-audio: use module_platform_driver() macro staging: bcm2835-audio: Drop DT dependency staging: bcm2835-camera: Provide more specific probe error messages staging: bcm2835-camera: Add hint about possible faulty config .../staging/vc04_services/bcm2835-audio/Kconfig| 2 +- .../staging/vc04_services/bcm2835-audio/bcm2835.c | 61 ++--- .../vc04_services/bcm2835-camera/bcm2835-camera.c | 78 +++--- .../vc04_services/bcm2835-camera/mmal-vchiq.c | 5 +- .../vc04_services/interface/vchiq_arm/vchiq_arm.c | 27 ++-- 5 files changed, 102 insertions(+), 71 deletions(-) -- 2.7.4 ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
[PATCH RFC 08/11] staging: bcm2835-audio: use module_platform_driver() macro
There is not much value behind this boilerplate, so use module_platform_driver() instead. Signed-off-by: Stefan Wahren --- .../staging/vc04_services/bcm2835-audio/bcm2835.c| 20 +--- 1 file changed, 1 insertion(+), 19 deletions(-) diff --git a/drivers/staging/vc04_services/bcm2835-audio/bcm2835.c b/drivers/staging/vc04_services/bcm2835-audio/bcm2835.c index 87d56ab..87a27fd 100644 --- a/drivers/staging/vc04_services/bcm2835-audio/bcm2835.c +++ b/drivers/staging/vc04_services/bcm2835-audio/bcm2835.c @@ -356,25 +356,7 @@ static struct platform_driver bcm2835_alsa0_driver = { .of_match_table = snd_bcm2835_of_match_table, }, }; - -static int bcm2835_alsa_device_init(void) -{ - int retval; - - retval = platform_driver_register(&bcm2835_alsa0_driver); - if (retval) - pr_err("Error registering bcm2835_audio driver %d .\n", retval); - - return retval; -} - -static void bcm2835_alsa_device_exit(void) -{ - platform_driver_unregister(&bcm2835_alsa0_driver); -} - -late_initcall(bcm2835_alsa_device_init); -module_exit(bcm2835_alsa_device_exit); +module_platform_driver(bcm2835_alsa0_driver); MODULE_AUTHOR("Dom Cobley"); MODULE_DESCRIPTION("Alsa driver for BCM2835 chip"); -- 2.7.4 ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
[PATCH RFC 03/11] staging: bcm2835-camera: Move module info to the end
In order to have this more consistent between the vc04 services move the module information to the end of the file. Signed-off-by: Stefan Wahren --- .../staging/vc04_services/bcm2835-camera/bcm2835-camera.c| 12 ++-- 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/drivers/staging/vc04_services/bcm2835-camera/bcm2835-camera.c b/drivers/staging/vc04_services/bcm2835-camera/bcm2835-camera.c index 7d3222c..cd773eb 100644 --- a/drivers/staging/vc04_services/bcm2835-camera/bcm2835-camera.c +++ b/drivers/staging/vc04_services/bcm2835-camera/bcm2835-camera.c @@ -43,12 +43,6 @@ #define MAX_BCM2835_CAMERAS 2 -MODULE_DESCRIPTION("Broadcom 2835 MMAL video capture"); -MODULE_AUTHOR("Vincent Sanders"); -MODULE_LICENSE("GPL"); -MODULE_VERSION(BM2835_MMAL_VERSION); -MODULE_ALIAS("platform:bcm2835-camera"); - int bcm2835_v4l2_debug; module_param_named(debug, bcm2835_v4l2_debug, int, 0644); MODULE_PARM_DESC(bcm2835_v4l2_debug, "Debug level 0-2"); @@ -1976,3 +1970,9 @@ static struct platform_driver bcm2835_camera_driver = { }; module_platform_driver(bcm2835_camera_driver) + +MODULE_DESCRIPTION("Broadcom 2835 MMAL video capture"); +MODULE_AUTHOR("Vincent Sanders"); +MODULE_LICENSE("GPL"); +MODULE_VERSION(BM2835_MMAL_VERSION); +MODULE_ALIAS("platform:bcm2835-camera"); -- 2.7.4 ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
[PATCH RFC 05/11] staging: vchiq_arm: Fix camera device registration
Since the camera driver isn't probed via DT, we need to properly setup DMA. Fixes: 37b7b3087a2f ("staging/vc04_services: Register a platform device for the camera driver.") Signed-off-by: Stefan Wahren --- .../vc04_services/interface/vchiq_arm/vchiq_arm.c| 20 +--- 1 file changed, 17 insertions(+), 3 deletions(-) diff --git a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_arm.c b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_arm.c index d7d7c2f0..778a252 100644 --- a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_arm.c +++ b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_arm.c @@ -49,6 +49,7 @@ #include #include #include +#include #include #include "vchiq_core.h" @@ -3588,6 +3589,21 @@ static const struct of_device_id vchiq_of_match[] = { }; MODULE_DEVICE_TABLE(of, vchiq_of_match); +static struct platform_device * +vchiq_register_child(struct platform_device *pdev, const char *name) +{ + struct platform_device_info pdevinfo; + + memset(&pdevinfo, 0, sizeof(pdevinfo)); + + pdevinfo.parent = &pdev->dev; + pdevinfo.name = name; + pdevinfo.id = PLATFORM_DEVID_NONE; + pdevinfo.dma_mask = DMA_BIT_MASK(32); + + return platform_device_register_full(&pdevinfo); +} + static int vchiq_probe(struct platform_device *pdev) { struct device_node *fw_node; @@ -3653,9 +3669,7 @@ static int vchiq_probe(struct platform_device *pdev) VCHIQ_VERSION, VCHIQ_VERSION_MIN, MAJOR(vchiq_devid), MINOR(vchiq_devid)); - bcm2835_camera = platform_device_register_data(&pdev->dev, - "bcm2835-camera", -1, - NULL, 0); + bcm2835_camera = vchiq_register_child(pdev, "bcm2835-camera"); return 0; -- 2.7.4 ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
[PATCH RFX 09/11] staging: bcm2835-audio: Drop DT dependency
Just like the bcm2835-video make this a platform driver which is probed by vchiq. In order to change the number of channels use a module parameter instead, but use the maximum as default. Signed-off-by: Stefan Wahren --- .../staging/vc04_services/bcm2835-audio/bcm2835.c | 41 ++ 1 file changed, 19 insertions(+), 22 deletions(-) diff --git a/drivers/staging/vc04_services/bcm2835-audio/bcm2835.c b/drivers/staging/vc04_services/bcm2835-audio/bcm2835.c index 87a27fd..5c5b600 100644 --- a/drivers/staging/vc04_services/bcm2835-audio/bcm2835.c +++ b/drivers/staging/vc04_services/bcm2835-audio/bcm2835.c @@ -4,15 +4,17 @@ #include #include +#include +#include #include #include -#include #include "bcm2835.h" static bool enable_hdmi; static bool enable_headphones; static bool enable_compat_alsa = true; +static int num_channels = MAX_SUBSTREAMS; module_param(enable_hdmi, bool, 0444); MODULE_PARM_DESC(enable_hdmi, "Enables HDMI virtual audio device"); @@ -21,6 +23,8 @@ MODULE_PARM_DESC(enable_headphones, "Enables Headphones virtual audio device"); module_param(enable_compat_alsa, bool, 0444); MODULE_PARM_DESC(enable_compat_alsa, "Enables ALSA compatibility virtual audio device"); +module_param(num_channels, int, 0644); +MODULE_PARM_DESC(num_channels, "Number of audio channels (default: 8)"); static void bcm2835_devm_free_vchi_ctx(struct device *dev, void *res) { @@ -293,31 +297,30 @@ static int snd_add_child_devices(struct device *device, u32 numchans) return 0; } -static int snd_bcm2835_alsa_probe_dt(struct platform_device *pdev) +static int snd_bcm2835_alsa_probe(struct platform_device *pdev) { struct device *dev = &pdev->dev; - u32 numchans; int err; - err = of_property_read_u32(dev->of_node, "brcm,pwm-channels", - &numchans); - if (err) { - dev_err(dev, "Failed to get DT property 'brcm,pwm-channels'"); - return err; + if (num_channels <= 0 || num_channels > MAX_SUBSTREAMS) { + num_channels = MAX_SUBSTREAMS; + dev_warn(dev, "Illegal num_channels value, will use %u\n", +num_channels); } - if (numchans == 0 || numchans > MAX_SUBSTREAMS) { - numchans = MAX_SUBSTREAMS; - dev_warn(dev, -"Illegal 'brcm,pwm-channels' value, will use %u\n", -numchans); + dev->coherent_dma_mask = DMA_BIT_MASK(32); + dev->dma_mask = &dev->coherent_dma_mask; + err = of_dma_configure(dev, NULL, true); + if (err) { + dev_err(dev, "Unable to setup DMA: %d\n", err); + return err; } err = bcm2835_devm_add_vchi_ctx(dev); if (err) return err; - err = snd_add_child_devices(dev, numchans); + err = snd_add_child_devices(dev, num_channels); if (err) return err; @@ -339,21 +342,14 @@ static int snd_bcm2835_alsa_resume(struct platform_device *pdev) #endif -static const struct of_device_id snd_bcm2835_of_match_table[] = { - { .compatible = "brcm,bcm2835-audio",}, - {}, -}; -MODULE_DEVICE_TABLE(of, snd_bcm2835_of_match_table); - static struct platform_driver bcm2835_alsa0_driver = { - .probe = snd_bcm2835_alsa_probe_dt, + .probe = snd_bcm2835_alsa_probe, #ifdef CONFIG_PM .suspend = snd_bcm2835_alsa_suspend, .resume = snd_bcm2835_alsa_resume, #endif .driver = { .name = "bcm2835_audio", - .of_match_table = snd_bcm2835_of_match_table, }, }; module_platform_driver(bcm2835_alsa0_driver); @@ -361,3 +357,4 @@ module_platform_driver(bcm2835_alsa0_driver); MODULE_AUTHOR("Dom Cobley"); MODULE_DESCRIPTION("Alsa driver for BCM2835 chip"); MODULE_LICENSE("GPL"); +MODULE_ALIAS("platform:bcm2835_audio"); -- 2.7.4 ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
[PATCH RFC 04/11] staging: vchiq_arm: Fix platform device unregistration
In error case platform_device_register_data would return an ERR_PTR instead of NULL. So we better check this before unregistration. Fixes: 37b7b3087a2f ("staging/vc04_services: Register a platform device for the camera driver.") Signed-off-by: Stefan Wahren --- drivers/staging/vc04_services/interface/vchiq_arm/vchiq_arm.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_arm.c b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_arm.c index ea78937..d7d7c2f0 100644 --- a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_arm.c +++ b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_arm.c @@ -3672,7 +3672,8 @@ static int vchiq_probe(struct platform_device *pdev) static int vchiq_remove(struct platform_device *pdev) { - platform_device_unregister(bcm2835_camera); + if (!IS_ERR(bcm2835_camera)) + platform_device_unregister(bcm2835_camera); vchiq_debugfs_deinit(); device_destroy(vchiq_class, vchiq_devid); class_destroy(vchiq_class); -- 2.7.4 ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
[PATCH RFC 11/11] staging: bcm2835-camera: Add hint about possible faulty config
As per default the GPU memory config of the Raspberry Pi isn't sufficient for the camera usage. Even worse the bcm2835 camera driver doesn't provide a helpful error message in this case. So let's add a hint to point the user to the likely cause. Signed-off-by: Stefan Wahren --- drivers/staging/vc04_services/bcm2835-camera/mmal-vchiq.c | 5 - 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/drivers/staging/vc04_services/bcm2835-camera/mmal-vchiq.c b/drivers/staging/vc04_services/bcm2835-camera/mmal-vchiq.c index cc2d993..bffd75d 100644 --- a/drivers/staging/vc04_services/bcm2835-camera/mmal-vchiq.c +++ b/drivers/staging/vc04_services/bcm2835-camera/mmal-vchiq.c @@ -1623,8 +1623,11 @@ int vchiq_mmal_component_init(struct vchiq_mmal_instance *instance, component = &instance->component[instance->component_idx]; ret = create_component(instance, component, name); - if (ret < 0) + if (ret < 0) { + pr_err("%s: failed to create component %d (Not enough GPU mem?)\n", + __func__, ret); goto unlock; + } /* ports info needs gathering */ component->control.type = MMAL_PORT_TYPE_CONTROL; -- 2.7.4 ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
[PATCH RFC 02/11] staging: bcm2835-camera: fix module autoloading
In order to make the module bcm2835-camera load automatically, we need to add a module alias. Fixes: 4bebb0312ea9 ("staging/bcm2835-camera: Set ourselves up as a platform driver.") Signed-off-by: Stefan Wahren --- drivers/staging/vc04_services/bcm2835-camera/bcm2835-camera.c | 1 + 1 file changed, 1 insertion(+) diff --git a/drivers/staging/vc04_services/bcm2835-camera/bcm2835-camera.c b/drivers/staging/vc04_services/bcm2835-camera/bcm2835-camera.c index d6fbef7..7d3222c 100644 --- a/drivers/staging/vc04_services/bcm2835-camera/bcm2835-camera.c +++ b/drivers/staging/vc04_services/bcm2835-camera/bcm2835-camera.c @@ -47,6 +47,7 @@ MODULE_DESCRIPTION("Broadcom 2835 MMAL video capture"); MODULE_AUTHOR("Vincent Sanders"); MODULE_LICENSE("GPL"); MODULE_VERSION(BM2835_MMAL_VERSION); +MODULE_ALIAS("platform:bcm2835-camera"); int bcm2835_v4l2_debug; module_param_named(debug, bcm2835_v4l2_debug, int, 0644); -- 2.7.4 ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
[PATCH RFC 01/11] staging: bcm2835-camera: Abort probe if there is no camera
Abort the probing of the camera driver in case there isn't a camera actually connected to the Raspberry Pi. This solution also avoids a NULL ptr dereference of mmal instance on driver unload. Fixes: 7b3ad5abf027 ("staging: Import the BCM2835 MMAL-based V4L2 camera driver.") Signed-off-by: Stefan Wahren --- drivers/staging/vc04_services/bcm2835-camera/bcm2835-camera.c | 9 + 1 file changed, 9 insertions(+) diff --git a/drivers/staging/vc04_services/bcm2835-camera/bcm2835-camera.c b/drivers/staging/vc04_services/bcm2835-camera/bcm2835-camera.c index c04bdf0..d6fbef7 100644 --- a/drivers/staging/vc04_services/bcm2835-camera/bcm2835-camera.c +++ b/drivers/staging/vc04_services/bcm2835-camera/bcm2835-camera.c @@ -1841,6 +1841,12 @@ static int bcm2835_mmal_probe(struct platform_device *pdev) num_cameras = get_num_cameras(instance, resolutions, MAX_BCM2835_CAMERAS); + + if (num_cameras < 1) { + ret = -ENODEV; + goto cleanup_mmal; + } + if (num_cameras > MAX_BCM2835_CAMERAS) num_cameras = MAX_BCM2835_CAMERAS; @@ -1940,6 +1946,9 @@ static int bcm2835_mmal_probe(struct platform_device *pdev) pr_info("%s: error %d while loading driver\n", BM2835_MMAL_MODULE_NAME, ret); +cleanup_mmal: + vchiq_mmal_finalise(instance); + return ret; } -- 2.7.4 ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
[PATCH RFC 10/11] staging: bcm2835-camera: Provide more specific probe error messages
Currently there is only a catch-all info message which print the relevant error code without any context. So add more specific error messages in order to narrow down possible issues. Signed-off-by: Stefan Wahren --- .../vc04_services/bcm2835-camera/bcm2835-camera.c | 58 +++--- 1 file changed, 39 insertions(+), 19 deletions(-) diff --git a/drivers/staging/vc04_services/bcm2835-camera/bcm2835-camera.c b/drivers/staging/vc04_services/bcm2835-camera/bcm2835-camera.c index cd773eb..84ca22d 100644 --- a/drivers/staging/vc04_services/bcm2835-camera/bcm2835-camera.c +++ b/drivers/staging/vc04_services/bcm2835-camera/bcm2835-camera.c @@ -1539,8 +1539,11 @@ static int mmal_init(struct bm2835_mmal_dev *dev) struct vchiq_mmal_component *camera; ret = vchiq_mmal_init(&dev->instance); - if (ret < 0) + if (ret < 0) { + v4l2_err(&dev->v4l2_dev, "%s: vchiq mmal init failed %d\n", +__func__, ret); return ret; + } /* get the camera component ready */ ret = vchiq_mmal_component_init(dev->instance, "ril.camera", @@ -1549,7 +1552,9 @@ static int mmal_init(struct bm2835_mmal_dev *dev) goto unreg_mmal; camera = dev->component[MMAL_COMPONENT_CAMERA]; - if (camera->outputs < MMAL_CAMERA_PORT_COUNT) { + if (camera->outputs < MMAL_CAMERA_PORT_COUNT) { + v4l2_err(&dev->v4l2_dev, "%s: too few camera outputs %d needed %d\n", +__func__, camera->outputs, MMAL_CAMERA_PORT_COUNT); ret = -EINVAL; goto unreg_camera; } @@ -1557,8 +1562,11 @@ static int mmal_init(struct bm2835_mmal_dev *dev) ret = set_camera_parameters(dev->instance, camera, dev); - if (ret < 0) + if (ret < 0) { + v4l2_err(&dev->v4l2_dev, "%s: unable to set camera parameters: %d\n", +__func__, ret); goto unreg_camera; + } /* There was an error in the firmware that meant the camera component * produced BGR instead of RGB. @@ -1647,8 +1655,8 @@ static int mmal_init(struct bm2835_mmal_dev *dev) if (dev->component[MMAL_COMPONENT_PREVIEW]->inputs < 1) { ret = -EINVAL; - pr_debug("too few input ports %d needed %d\n", -dev->component[MMAL_COMPONENT_PREVIEW]->inputs, 1); + v4l2_err(&dev->v4l2_dev, "%s: too few input ports %d needed %d\n", +__func__, dev->component[MMAL_COMPONENT_PREVIEW]->inputs, 1); goto unreg_preview; } @@ -1661,8 +1669,8 @@ static int mmal_init(struct bm2835_mmal_dev *dev) if (dev->component[MMAL_COMPONENT_IMAGE_ENCODE]->inputs < 1) { ret = -EINVAL; - v4l2_err(&dev->v4l2_dev, "too few input ports %d needed %d\n", -dev->component[MMAL_COMPONENT_IMAGE_ENCODE]->inputs, + v4l2_err(&dev->v4l2_dev, "%s: too few input ports %d needed %d\n", +__func__, dev->component[MMAL_COMPONENT_IMAGE_ENCODE]->inputs, 1); goto unreg_image_encoder; } @@ -1676,8 +1684,8 @@ static int mmal_init(struct bm2835_mmal_dev *dev) if (dev->component[MMAL_COMPONENT_VIDEO_ENCODE]->inputs < 1) { ret = -EINVAL; - v4l2_err(&dev->v4l2_dev, "too few input ports %d needed %d\n", -dev->component[MMAL_COMPONENT_VIDEO_ENCODE]->inputs, + v4l2_err(&dev->v4l2_dev, "%s: too few input ports %d needed %d\n", +__func__, dev->component[MMAL_COMPONENT_VIDEO_ENCODE]->inputs, 1); goto unreg_vid_encoder; } @@ -1706,8 +1714,11 @@ static int mmal_init(struct bm2835_mmal_dev *dev) sizeof(enable)); } ret = bm2835_mmal_set_all_camera_controls(dev); - if (ret < 0) + if (ret < 0) { + v4l2_err(&dev->v4l2_dev, "%s: failed to set all camera controls: %d\n", +__func__, ret); goto unreg_vid_encoder; + } return 0; @@ -1873,21 +1884,29 @@ static int bcm2835_mmal_probe(struct platform_device *pdev) snprintf(dev->v4l2_dev.name, sizeof(dev->v4l2_dev.name), "%s", BM2835_MMAL_MODULE_NAME); ret = v4l2_device_register(NULL, &dev->v4l2_dev); - if (ret) + if (ret) { + dev_err(&pdev->dev, "%s: could not register V4L2 device: %d\n", + __func__, ret); goto free_dev; + } /* setup v4l controls */ ret = bm2835_mmal_init_controls(dev, &dev->ctrl_handler); -
Re: [PATCH] staging: iio: ad7780: update voltage on read
On 10/25/2018 04:55 PM, Himanshu Jha wrote: > On Thu, Oct 25, 2018 at 11:26:36AM -0300, Renato Lui Geh wrote: >> Hi, >> >> Thanks for the quick review. :) >> >>> But please create one patch per issue and do not put unrelated changes into >>> the same patch. >> >> Should I resend this patch as a patchset containing the two changes? > > Yes! "One patch per change policy" > >>> Also your mail client seems to have replaced tabs in the patch with spaces, >>> this means the patch will not apply cleanly. Check the >>> Documentation/email-clients.txt file for some hints how to configure your >>> mail client so it will not break patches. >> >> From my end my original email patch appears to have tabs instead of >> spaces. I redownloaded my email and vim shows that the indentation has >> the ^I tab characters. But when downloading your reply it was converted >> to spaces. Am I missing something? > > Your patch applies fine. > > I think the problem is on Lars end due to Thunderbird. Yeah, looks like I need to read email-clients.txt... I think it is mis-rendered on my side due to the "Content-Type: ... format=flowed" in the header. ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
Re: [alsa-devel] [PATCH v2] staging: bcm2835-audio: interpolate audio delay
Hello Takashi, Mike, @Takashi On 10/25/18 09:37, Takashi Iwai wrote: > Well, in the API POV, it's nothing wrong to keep hwptr sticking while > updating only delay value. It implies that the hardware chip doesn't > provide the hwptr update. Thank you for the clarification. Modifying `runtime->delay` from the `pointer` function looked wrong for me. Now I understand the motivation and the use-case. I will be more careful when analyzing the code which doesn't fit my expectations. @Mike I was wrong. You can ignore my comments. Please don't take them personal: it's all about having high-quality code in kernel. Best Regards, Kirill ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
Re: [PATCH v4] staging: iio: ad2s1210: Switch to the gpio descriptor interface
On Thu, Oct 25, 2018 at 08:43:56AM +0200, Slawomir Stepien wrote: > On paź 24, 2018 20:20, Nishad Kamdar wrote: > > Use the gpiod interface instead of the deprecated old non-descriptor > > interface. > > > > Signed-off-by: Nishad Kamdar > > --- > > Changes in v4: > > - Add spaces after { and before } in gpios[] > >initialization. > > - Check the correct pointer for error. > > - Align the dev_err msg to existing format in the code. > > Changes in v3: > > - Use a pointer to pointer for gpio_desc in > >struct ad2s1210_gpio as it will be used to > >modify a pointer. > > - Use dot notation to initialize the structure. > > - Use a pointer variable to avoid writing gpios[i]. > > Changes in v2: > > - Use the spi_device struct embedded in st instead > >of passing it as an argument to ad2s1210_setup_gpios(). > > - Use an array of structs to reduce redundant code in > >in ad2s1210_setup_gpios(). > > - Remove ad2s1210_free_gpios() as devm API is being used. > > --- > > drivers/staging/iio/resolver/ad2s1210.c | 92 ++--- > > drivers/staging/iio/resolver/ad2s1210.h | 3 - > > 2 files changed, 50 insertions(+), 45 deletions(-) > > Looks good to me. > > Reviewed-by: Slawomir Stepien > > -- > Slawomir Stepien Hi, Thanks for the review. I was thinking of adding the device tree support to this file as well. Can you please tell me if I can submit the new patch in a patchset with this patch as the first and the one adding device tree support as the second? Thanks and regards, Nishad ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
[PATCH 0/2] staging: vboxvideo: Remove chekpatch issues
This series cleans the following checkpatch.pl issues: CHECK: Prefer kernel type 'u32' over 'uint32_t' CHECK: Avoid using bool structure members because of possible alignment issues Shayenne da Luz Moura (2): staging: vboxvideo: Change uint32_t to u32 staging: vboxvideo: Use unsigned int instead bool drivers/staging/vboxvideo/vbox_drv.h| 14 +++--- drivers/staging/vboxvideo/vbox_mode.c | 2 +- drivers/staging/vboxvideo/vboxvideo_guest.h | 2 +- 3 files changed, 9 insertions(+), 9 deletions(-) -- 2.19.1 ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
[PATCH 0/4] staging: wilc1000: validate input to set_wiphy_param and return proper errors
Validate input parameters to set_wiphy_param before scheduling handle_cfg_param() to validate them. This way proper errors can be returned to caller. Also cleaned up unused code in handle_cfg_param. Adham Abozaeid (4): staging: wilc1000: remove unused flags in handle_cfg_param() stagign: wilc1000: validate cfg parameters before scheduling the work staging: wilc1000: Don't keep a copy of wiphy parameters in the driver staging: wilc1000: Remove unused mutex cfg_values_lock drivers/staging/wilc1000/host_interface.c | 291 +- drivers/staging/wilc1000/host_interface.h | 32 -- .../staging/wilc1000/wilc_wfi_cfgoperations.c | 50 ++- drivers/staging/wilc1000/wilc_wlan_if.h | 9 - 4 files changed, 58 insertions(+), 324 deletions(-) mode change 100644 => 100755 drivers/staging/wilc1000/host_interface.c mode change 100644 => 100755 drivers/staging/wilc1000/host_interface.h mode change 100644 => 100755 drivers/staging/wilc1000/wilc_wfi_cfgoperations.c mode change 100644 => 100755 drivers/staging/wilc1000/wilc_wlan_if.h -- 2.17.1 ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
[PATCH 2/4] stagign: wilc1000: validate cfg parameters before scheduling the work
Validate cfg parameters after being called by cfg80211 in set_wiphy_params before scheduling the work executed in handle_cfg_param Signed-off-by: Adham Abozaeid --- drivers/staging/wilc1000/host_interface.c | 61 ++- .../staging/wilc1000/wilc_wfi_cfgoperations.c | 50 --- 2 files changed, 62 insertions(+), 49 deletions(-) mode change 100644 => 100755 drivers/staging/wilc1000/wilc_wfi_cfgoperations.c diff --git a/drivers/staging/wilc1000/host_interface.c b/drivers/staging/wilc1000/host_interface.c index 1a1ac5e936a7..0bb3b4f6d04e 100755 --- a/drivers/staging/wilc1000/host_interface.c +++ b/drivers/staging/wilc1000/host_interface.c @@ -377,61 +377,41 @@ static void handle_cfg_param(struct work_struct *work) if (param->flag & RETRY_SHORT) { u16 retry_limit = param->short_retry_limit; - if (retry_limit > 0 && retry_limit < 256) { - wid_list[i].id = WID_SHORT_RETRY_LIMIT; - wid_list[i].val = (s8 *)¶m->short_retry_limit; - wid_list[i].type = WID_SHORT; - wid_list[i].size = sizeof(u16); - hif_drv->cfg_values.short_retry_limit = retry_limit; - } else { - netdev_err(vif->ndev, "Range(1~256) over\n"); - goto unlock; - } + wid_list[i].id = WID_SHORT_RETRY_LIMIT; + wid_list[i].val = (s8 *)¶m->short_retry_limit; + wid_list[i].type = WID_SHORT; + wid_list[i].size = sizeof(u16); + hif_drv->cfg_values.short_retry_limit = retry_limit; i++; } if (param->flag & RETRY_LONG) { u16 limit = param->long_retry_limit; - if (limit > 0 && limit < 256) { - wid_list[i].id = WID_LONG_RETRY_LIMIT; - wid_list[i].val = (s8 *)¶m->long_retry_limit; - wid_list[i].type = WID_SHORT; - wid_list[i].size = sizeof(u16); - hif_drv->cfg_values.long_retry_limit = limit; - } else { - netdev_err(vif->ndev, "Range(1~256) over\n"); - goto unlock; - } + wid_list[i].id = WID_LONG_RETRY_LIMIT; + wid_list[i].val = (s8 *)¶m->long_retry_limit; + wid_list[i].type = WID_SHORT; + wid_list[i].size = sizeof(u16); + hif_drv->cfg_values.long_retry_limit = limit; i++; } if (param->flag & FRAG_THRESHOLD) { u16 frag_th = param->frag_threshold; - if (frag_th > 255 && frag_th < 7937) { - wid_list[i].id = WID_FRAG_THRESHOLD; - wid_list[i].val = (s8 *)¶m->frag_threshold; - wid_list[i].type = WID_SHORT; - wid_list[i].size = sizeof(u16); - hif_drv->cfg_values.frag_threshold = frag_th; - } else { - netdev_err(vif->ndev, "Threshold Range fail\n"); - goto unlock; - } + wid_list[i].id = WID_FRAG_THRESHOLD; + wid_list[i].val = (s8 *)¶m->frag_threshold; + wid_list[i].type = WID_SHORT; + wid_list[i].size = sizeof(u16); + hif_drv->cfg_values.frag_threshold = frag_th; i++; } if (param->flag & RTS_THRESHOLD) { u16 rts_th = param->rts_threshold; - if (rts_th > 255) { - wid_list[i].id = WID_RTS_THRESHOLD; - wid_list[i].val = (s8 *)¶m->rts_threshold; - wid_list[i].type = WID_SHORT; - wid_list[i].size = sizeof(u16); - hif_drv->cfg_values.rts_threshold = rts_th; - } else { - netdev_err(vif->ndev, "Threshold Range fail\n"); - goto unlock; - } + wid_list[i].id = WID_RTS_THRESHOLD; + wid_list[i].val = (s8 *)¶m->rts_threshold; + wid_list[i].type = WID_SHORT; + wid_list[i].size = sizeof(u16); + hif_drv->cfg_values.rts_threshold = rts_th; i++; } @@ -441,7 +421,6 @@ static void handle_cfg_param(struct work_struct *work) if (ret) netdev_err(vif->ndev, "Error in setting CFG params\n"); -unlock: mutex_unlock(&hif_drv->cfg_values_lock); kfree(msg); } diff --git a/drivers/staging/wilc1000/wilc_wfi_cfgoperations.c b/drivers/staging/wilc1000/wilc_wfi_cfgoperations.c old mode 100644 new mode 100755 index 4fd5a64b..26bb78a49d81 --- a/drivers/staging/wilc1000/wilc_wfi_cfgoperations.c +++ b/drivers/staging/wilc1000/wilc_wfi_cfgoperations.c @@ -1149,21 +1149,55 @@ static int set_wiphy
[PATCH 3/4] staging: wilc1000: Don't keep a copy of wiphy parameters in the driver
host_if_drv.cfg_values is a write only member, and can be removed Signed-off-by: Adham Abozaeid --- drivers/staging/wilc1000/host_interface.c | 13 - drivers/staging/wilc1000/host_interface.h | 1 - 2 files changed, 14 deletions(-) diff --git a/drivers/staging/wilc1000/host_interface.c b/drivers/staging/wilc1000/host_interface.c index 0bb3b4f6d04e..cdc495287949 100755 --- a/drivers/staging/wilc1000/host_interface.c +++ b/drivers/staging/wilc1000/host_interface.c @@ -375,43 +375,31 @@ static void handle_cfg_param(struct work_struct *work) mutex_lock(&hif_drv->cfg_values_lock); if (param->flag & RETRY_SHORT) { - u16 retry_limit = param->short_retry_limit; - wid_list[i].id = WID_SHORT_RETRY_LIMIT; wid_list[i].val = (s8 *)¶m->short_retry_limit; wid_list[i].type = WID_SHORT; wid_list[i].size = sizeof(u16); - hif_drv->cfg_values.short_retry_limit = retry_limit; i++; } if (param->flag & RETRY_LONG) { - u16 limit = param->long_retry_limit; - wid_list[i].id = WID_LONG_RETRY_LIMIT; wid_list[i].val = (s8 *)¶m->long_retry_limit; wid_list[i].type = WID_SHORT; wid_list[i].size = sizeof(u16); - hif_drv->cfg_values.long_retry_limit = limit; i++; } if (param->flag & FRAG_THRESHOLD) { - u16 frag_th = param->frag_threshold; - wid_list[i].id = WID_FRAG_THRESHOLD; wid_list[i].val = (s8 *)¶m->frag_threshold; wid_list[i].type = WID_SHORT; wid_list[i].size = sizeof(u16); - hif_drv->cfg_values.frag_threshold = frag_th; i++; } if (param->flag & RTS_THRESHOLD) { - u16 rts_th = param->rts_threshold; - wid_list[i].id = WID_RTS_THRESHOLD; wid_list[i].val = (s8 *)¶m->rts_threshold; wid_list[i].type = WID_SHORT; wid_list[i].size = sizeof(u16); - hif_drv->cfg_values.rts_threshold = rts_th; i++; } @@ -3139,7 +3127,6 @@ int wilc_init(struct net_device *dev, struct host_if_drv **hif_drv_handler) mutex_lock(&hif_drv->cfg_values_lock); hif_drv->hif_state = HOST_IF_IDLE; - hif_drv->cfg_values.scan_source = DEFAULT_SCAN; hif_drv->p2p_timeout = 0; diff --git a/drivers/staging/wilc1000/host_interface.h b/drivers/staging/wilc1000/host_interface.h index 5f894fe7c896..60cb1a1fee1a 100755 --- a/drivers/staging/wilc1000/host_interface.h +++ b/drivers/staging/wilc1000/host_interface.h @@ -238,7 +238,6 @@ struct host_if_drv { enum host_if_state hif_state; u8 assoc_bssid[ETH_ALEN]; - struct cfg_param_attr cfg_values; /*lock to protect concurrent setting of cfg params*/ struct mutex cfg_values_lock; -- 2.17.1 ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
[PATCH 1/4] staging: wilc1000: remove unused flags in handle_cfg_param()
handle_cfg_param() receives a bit map that describes what to be changed. Some of these bits flags aren't referred to from elsewhere and can be removed. Signed-off-by: Adham Abozaeid --- drivers/staging/wilc1000/host_interface.c | 216 -- drivers/staging/wilc1000/host_interface.h | 29 --- drivers/staging/wilc1000/wilc_wlan_if.h | 9 - 3 files changed, 254 deletions(-) mode change 100644 => 100755 drivers/staging/wilc1000/host_interface.c mode change 100644 => 100755 drivers/staging/wilc1000/host_interface.h mode change 100644 => 100755 drivers/staging/wilc1000/wilc_wlan_if.h diff --git a/drivers/staging/wilc1000/host_interface.c b/drivers/staging/wilc1000/host_interface.c old mode 100644 new mode 100755 index 01db8999335e..1a1ac5e936a7 --- a/drivers/staging/wilc1000/host_interface.c +++ b/drivers/staging/wilc1000/host_interface.c @@ -374,64 +374,6 @@ static void handle_cfg_param(struct work_struct *work) mutex_lock(&hif_drv->cfg_values_lock); - if (param->flag & BSS_TYPE) { - u8 bss_type = param->bss_type; - - if (bss_type < 6) { - wid_list[i].id = WID_BSS_TYPE; - wid_list[i].val = (s8 *)¶m->bss_type; - wid_list[i].type = WID_CHAR; - wid_list[i].size = sizeof(char); - hif_drv->cfg_values.bss_type = bss_type; - } else { - netdev_err(vif->ndev, "check value 6 over\n"); - goto unlock; - } - i++; - } - if (param->flag & AUTH_TYPE) { - u8 auth_type = param->auth_type; - - if (auth_type == 1 || auth_type == 2 || auth_type == 5) { - wid_list[i].id = WID_AUTH_TYPE; - wid_list[i].val = (s8 *)¶m->auth_type; - wid_list[i].type = WID_CHAR; - wid_list[i].size = sizeof(char); - hif_drv->cfg_values.auth_type = auth_type; - } else { - netdev_err(vif->ndev, "Impossible value\n"); - goto unlock; - } - i++; - } - if (param->flag & AUTHEN_TIMEOUT) { - if (param->auth_timeout > 0) { - wid_list[i].id = WID_AUTH_TIMEOUT; - wid_list[i].val = (s8 *)¶m->auth_timeout; - wid_list[i].type = WID_SHORT; - wid_list[i].size = sizeof(u16); - hif_drv->cfg_values.auth_timeout = param->auth_timeout; - } else { - netdev_err(vif->ndev, "Range(1 ~ 65535) over\n"); - goto unlock; - } - i++; - } - if (param->flag & POWER_MANAGEMENT) { - u8 pm_mode = param->power_mgmt_mode; - - if (pm_mode < 5) { - wid_list[i].id = WID_POWER_MANAGEMENT; - wid_list[i].val = (s8 *)¶m->power_mgmt_mode; - wid_list[i].type = WID_CHAR; - wid_list[i].size = sizeof(char); - hif_drv->cfg_values.power_mgmt_mode = pm_mode; - } else { - netdev_err(vif->ndev, "Invalid power mode\n"); - goto unlock; - } - i++; - } if (param->flag & RETRY_SHORT) { u16 retry_limit = param->short_retry_limit; @@ -492,160 +434,6 @@ static void handle_cfg_param(struct work_struct *work) } i++; } - if (param->flag & PREAMBLE) { - u16 preamble_type = param->preamble_type; - - if (param->preamble_type < 3) { - wid_list[i].id = WID_PREAMBLE; - wid_list[i].val = (s8 *)¶m->preamble_type; - wid_list[i].type = WID_CHAR; - wid_list[i].size = sizeof(char); - hif_drv->cfg_values.preamble_type = preamble_type; - } else { - netdev_err(vif->ndev, "Preamble Range(0~2) over\n"); - goto unlock; - } - i++; - } - if (param->flag & SHORT_SLOT_ALLOWED) { - u8 slot_allowed = param->short_slot_allowed; - - if (slot_allowed < 2) { - wid_list[i].id = WID_SHORT_SLOT_ALLOWED; - wid_list[i].val = (s8 *)¶m->short_slot_allowed; - wid_list[i].type = WID_CHAR; - wid_list[i].size = sizeof(char); - hif_drv->cfg_values.short_slot_allowed = slot_allowed; - } else { - netdev_err(vif->ndev, "Short slot(2) over\n"); - goto unlock; - } - i++; - } - i
[PATCH 4/4] staging: wilc1000: Remove unused mutex cfg_values_lock
After removing cfg_values member, cfg_values_lock that was used to protect it can also be removed. Signed-off-by: Adham Abozaeid --- drivers/staging/wilc1000/host_interface.c | 9 - drivers/staging/wilc1000/host_interface.h | 2 -- 2 files changed, 11 deletions(-) diff --git a/drivers/staging/wilc1000/host_interface.c b/drivers/staging/wilc1000/host_interface.c index cdc495287949..165330b494f5 100755 --- a/drivers/staging/wilc1000/host_interface.c +++ b/drivers/staging/wilc1000/host_interface.c @@ -369,11 +369,8 @@ static void handle_cfg_param(struct work_struct *work) struct cfg_param_attr *param = &msg->body.cfg_info; int ret; struct wid wid_list[32]; - struct host_if_drv *hif_drv = vif->hif_drv; int i = 0; - mutex_lock(&hif_drv->cfg_values_lock); - if (param->flag & RETRY_SHORT) { wid_list[i].id = WID_SHORT_RETRY_LIMIT; wid_list[i].val = (s8 *)¶m->short_retry_limit; @@ -409,7 +406,6 @@ static void handle_cfg_param(struct work_struct *work) if (ret) netdev_err(vif->ndev, "Error in setting CFG params\n"); - mutex_unlock(&hif_drv->cfg_values_lock); kfree(msg); } @@ -3123,15 +3119,10 @@ int wilc_init(struct net_device *dev, struct host_if_drv **hif_drv_handler) timer_setup(&hif_drv->connect_timer, timer_connect_cb, 0); timer_setup(&hif_drv->remain_on_ch_timer, listen_timer_cb, 0); - mutex_init(&hif_drv->cfg_values_lock); - mutex_lock(&hif_drv->cfg_values_lock); - hif_drv->hif_state = HOST_IF_IDLE; hif_drv->p2p_timeout = 0; - mutex_unlock(&hif_drv->cfg_values_lock); - wilc->clients_count++; return 0; diff --git a/drivers/staging/wilc1000/host_interface.h b/drivers/staging/wilc1000/host_interface.h index 60cb1a1fee1a..c78e0682a248 100755 --- a/drivers/staging/wilc1000/host_interface.h +++ b/drivers/staging/wilc1000/host_interface.h @@ -238,8 +238,6 @@ struct host_if_drv { enum host_if_state hif_state; u8 assoc_bssid[ETH_ALEN]; - /*lock to protect concurrent setting of cfg params*/ - struct mutex cfg_values_lock; struct timer_list scan_timer; struct wilc_vif *scan_timer_vif; -- 2.17.1 ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
[PATCH v2 0/2] staging: iio: ad7780: correct driver read
The purpose of this series is to correct two issues in the driver's raw read function. Changelog: * v2 - separated original patch into two patches (https://marc.info/?l=linux-iio&m=154047435605492) Renato Lui Geh (2): staging: iio: ad7780: update voltage on read staging: iio: ad7780: fix offset read value drivers/staging/iio/adc/ad7780.c | 6 +- 1 file changed, 5 insertions(+), 1 deletion(-) -- 2.19.1 ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
[PATCH v2 1/2] staging: iio: ad7780: update voltage on read
The ad7780 driver previously did not read the correct device output, as it read an outdated value set at initialization. It now updates its voltage on read. Signed-off-by: Renato Lui Geh --- drivers/staging/iio/adc/ad7780.c | 4 1 file changed, 4 insertions(+) diff --git a/drivers/staging/iio/adc/ad7780.c b/drivers/staging/iio/adc/ad7780.c index b67412db0318..27972563bb6a 100644 --- a/drivers/staging/iio/adc/ad7780.c +++ b/drivers/staging/iio/adc/ad7780.c @@ -87,11 +87,15 @@ static int ad7780_read_raw(struct iio_dev *indio_dev, long m) { struct ad7780_state *st = iio_priv(indio_dev); + int voltage_uv = 0; switch (m) { case IIO_CHAN_INFO_RAW: return ad_sigma_delta_single_conversion(indio_dev, chan, val); case IIO_CHAN_INFO_SCALE: + voltage_uv = regulator_get_voltage(st->reg); + if (voltage_uv) + st->int_vref_mv = voltage_uv/1000; *val = st->int_vref_mv * st->gain; *val2 = chan->scan_type.realbits - 1; return IIO_VAL_FRACTIONAL_LOG2; -- 2.19.1 ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
[PATCH v2 2/2] staging: iio: ad7780: fix offset read value
Variable val subtracted an uninitialized value on IIO_CHAN_INFO_OFFSET. This was fixed by assigning the correct value instead. Signed-off-by: Renato Lui Geh --- drivers/staging/iio/adc/ad7780.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/staging/iio/adc/ad7780.c b/drivers/staging/iio/adc/ad7780.c index 27972563bb6a..06700fe554a2 100644 --- a/drivers/staging/iio/adc/ad7780.c +++ b/drivers/staging/iio/adc/ad7780.c @@ -100,7 +100,7 @@ static int ad7780_read_raw(struct iio_dev *indio_dev, *val2 = chan->scan_type.realbits - 1; return IIO_VAL_FRACTIONAL_LOG2; case IIO_CHAN_INFO_OFFSET: - *val -= (1 << (chan->scan_type.realbits - 1)); + *val = -(1 << (chan->scan_type.realbits - 1)); return IIO_VAL_INT; } -- 2.19.1 ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
[PATCH 0/6] staging:iio:ad2s90: Add scale info and improve error handling
This patch set adds scale info to ad2s90's single channel, improve error handling in it's functions and fix a possible race condition issue. The goal with this patch set is to address the points discussed in the mailing list in an effort to move ad2s90.c out of staging. Matheus Tavares (5): staging:iio:ad2s90: Make read_raw return spi_read's error code staging:iio:ad2s90: Make probe handle spi_setup failure staging:iio:ad2s90: Remove always overwritten assignment staging:iio:ad2s90: Move device registration to the end of probe staging:iio:ad2s90: Check channel type at read_raw Victor Colombo (1): staging:iio:ad2s90: Add IIO_CHAN_INFO_SCALE to channel spec and read_raw drivers/staging/iio/resolver/ad2s90.c | 55 ++- 1 file changed, 37 insertions(+), 18 deletions(-) -- 2.18.0 ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
[PATCH 1/6] staging:iio:ad2s90: Make read_raw return spi_read's error code
Previously, when spi_read returned an error code inside ad2s90_read_raw, the code was ignored and IIO_VAL_INT was returned. This patch makes the function return the error code returned by spi_read when it fails. Signed-off-by: Matheus Tavares --- drivers/staging/iio/resolver/ad2s90.c | 9 ++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/drivers/staging/iio/resolver/ad2s90.c b/drivers/staging/iio/resolver/ad2s90.c index 59586947a936..11fac9f90148 100644 --- a/drivers/staging/iio/resolver/ad2s90.c +++ b/drivers/staging/iio/resolver/ad2s90.c @@ -35,12 +35,15 @@ static int ad2s90_read_raw(struct iio_dev *indio_dev, struct ad2s90_state *st = iio_priv(indio_dev); mutex_lock(&st->lock); + ret = spi_read(st->sdev, st->rx, 2); - if (ret) - goto error_ret; + if (ret < 0) { + mutex_unlock(&st->lock); + return ret; + } + *val = (((u16)(st->rx[0])) << 4) | ((st->rx[1] & 0xF0) >> 4); -error_ret: mutex_unlock(&st->lock); return IIO_VAL_INT; -- 2.18.0 ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
[PATCH 2/6] staging:iio:ad2s90: Make probe handle spi_setup failure
Previously, ad2s90_probe ignored the return code from spi_setup, not handling its possible failure. This patch makes ad2s90_probe check if the code is an error code and, if so, do the following: - Call dev_err with an appropriate error message. - Return the spi_setup's error code, aborting the execution of the rest of the function. Signed-off-by: Matheus Tavares --- drivers/staging/iio/resolver/ad2s90.c | 7 ++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/drivers/staging/iio/resolver/ad2s90.c b/drivers/staging/iio/resolver/ad2s90.c index 11fac9f90148..d6a42e3f1bd8 100644 --- a/drivers/staging/iio/resolver/ad2s90.c +++ b/drivers/staging/iio/resolver/ad2s90.c @@ -88,7 +88,12 @@ static int ad2s90_probe(struct spi_device *spi) /* need 600ns between CS and the first falling edge of SCLK */ spi->max_speed_hz = 83; spi->mode = SPI_MODE_3; - spi_setup(spi); + ret = spi_setup(spi); + + if (ret < 0) { + dev_err(&spi->dev, "spi_setup failed!\n"); + return ret; + } return 0; } -- 2.18.0 ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
[PATCH 3/6] staging:iio:ad2s90: Remove always overwritten assignment
This patch removes an initial assignment to the variable ret at probe, that was always overwritten. Signed-off-by: Matheus Tavares --- drivers/staging/iio/resolver/ad2s90.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/staging/iio/resolver/ad2s90.c b/drivers/staging/iio/resolver/ad2s90.c index d6a42e3f1bd8..c20d37dc065a 100644 --- a/drivers/staging/iio/resolver/ad2s90.c +++ b/drivers/staging/iio/resolver/ad2s90.c @@ -64,7 +64,7 @@ static int ad2s90_probe(struct spi_device *spi) { struct iio_dev *indio_dev; struct ad2s90_state *st; - int ret = 0; + int ret; indio_dev = devm_iio_device_alloc(&spi->dev, sizeof(*st)); if (!indio_dev) -- 2.18.0 ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
[PATCH 6/6] staging:iio:ad2s90: Check channel type at read_raw
This patch adds a channel type check at the beginning of the ad2s90_read_raw function. Since ad2s90 has only one channel, it just checks if the given channel is the expected one and if not, return -EINVAL. Signed-off-by: Matheus Tavares --- drivers/staging/iio/resolver/ad2s90.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/drivers/staging/iio/resolver/ad2s90.c b/drivers/staging/iio/resolver/ad2s90.c index 52b656875ed1..24002042a5c5 100644 --- a/drivers/staging/iio/resolver/ad2s90.c +++ b/drivers/staging/iio/resolver/ad2s90.c @@ -34,6 +34,9 @@ static int ad2s90_read_raw(struct iio_dev *indio_dev, int ret; struct ad2s90_state *st = iio_priv(indio_dev); + if (chan->type != IIO_ANGL) + return -EINVAL; + switch (m) { case IIO_CHAN_INFO_SCALE: /* 2 * Pi / (2^12 - 1) ~= 0.001534355 */ -- 2.18.0 ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
[PATCH 5/6] staging:iio:ad2s90: Add IIO_CHAN_INFO_SCALE to channel spec and read_raw
From: Victor Colombo This patch adds the IIO_CHAN_INFO_SCALE mask to ad2s90_chan and implements the relative read behavior at ad2s90_read_raw. Signed-off-by: Victor Colombo --- drivers/staging/iio/resolver/ad2s90.c | 32 ++- 1 file changed, 22 insertions(+), 10 deletions(-) diff --git a/drivers/staging/iio/resolver/ad2s90.c b/drivers/staging/iio/resolver/ad2s90.c index b4a6a89c11b0..52b656875ed1 100644 --- a/drivers/staging/iio/resolver/ad2s90.c +++ b/drivers/staging/iio/resolver/ad2s90.c @@ -34,19 +34,31 @@ static int ad2s90_read_raw(struct iio_dev *indio_dev, int ret; struct ad2s90_state *st = iio_priv(indio_dev); - mutex_lock(&st->lock); + switch (m) { + case IIO_CHAN_INFO_SCALE: + /* 2 * Pi / (2^12 - 1) ~= 0.001534355 */ + *val = 0; + *val2 = 1534355; + return IIO_VAL_INT_PLUS_NANO; + case IIO_CHAN_INFO_RAW: + mutex_lock(&st->lock); + + ret = spi_read(st->sdev, st->rx, 2); + if (ret < 0) { + mutex_unlock(&st->lock); + return ret; + } + + *val = (((u16)(st->rx[0])) << 4) | ((st->rx[1] & 0xF0) >> 4); - ret = spi_read(st->sdev, st->rx, 2); - if (ret < 0) { mutex_unlock(&st->lock); - return ret; - } - *val = (((u16)(st->rx[0])) << 4) | ((st->rx[1] & 0xF0) >> 4); - - mutex_unlock(&st->lock); + return IIO_VAL_INT; + default: + break; + } - return IIO_VAL_INT; + return -EINVAL; } static const struct iio_info ad2s90_info = { @@ -57,7 +69,7 @@ static const struct iio_chan_spec ad2s90_chan = { .type = IIO_ANGL, .indexed = 1, .channel = 0, - .info_mask_separate = BIT(IIO_CHAN_INFO_RAW), + .info_mask_separate = BIT(IIO_CHAN_INFO_RAW) | BIT(IIO_CHAN_INFO_SCALE), }; static int ad2s90_probe(struct spi_device *spi) -- 2.18.0 ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
[PATCH 4/6] staging:iio:ad2s90: Move device registration to the end of probe
Previously, devm_iio_device_register was being called before the spi_setup call and the spi_device's max_speed_hz and mode assignments. This could lead to a race condition since the driver was still being set up after it was already made ready to use. To fix it, this patch moves the device registration to the end of ad2s90_probe. Signed-off-by: Matheus Tavares --- drivers/staging/iio/resolver/ad2s90.c | 6 +- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/drivers/staging/iio/resolver/ad2s90.c b/drivers/staging/iio/resolver/ad2s90.c index c20d37dc065a..b4a6a89c11b0 100644 --- a/drivers/staging/iio/resolver/ad2s90.c +++ b/drivers/staging/iio/resolver/ad2s90.c @@ -81,10 +81,6 @@ static int ad2s90_probe(struct spi_device *spi) indio_dev->num_channels = 1; indio_dev->name = spi_get_device_id(spi)->name; - ret = devm_iio_device_register(indio_dev->dev.parent, indio_dev); - if (ret) - return ret; - /* need 600ns between CS and the first falling edge of SCLK */ spi->max_speed_hz = 83; spi->mode = SPI_MODE_3; @@ -95,7 +91,7 @@ static int ad2s90_probe(struct spi_device *spi) return ret; } - return 0; + return devm_iio_device_register(indio_dev->dev.parent, indio_dev); } static const struct spi_device_id ad2s90_id[] = { -- 2.18.0 ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel