summaryrefslogtreecommitdiffstats
path: root/drivers/spi/spi.c
Commit message (Collapse)AuthorAgeFilesLines
*-. Merge remote-tracking branches 'spi/fix/au1550', 'spi/fix/davinci', ↵Mark Brown2014-08-301-0/+1
|\ \ | | | | | | | | | 'spi/fix/doc', 'spi/fix/dw', 'spi/fix/omap-mcspi', 'spi/fix/pxa2xx', 'spi/fix/rockchip' and 'spi/fix/rspi' into spi-linus
| * | spi: Add missing kerneldoc bitsThierry Reding2014-08-131-0/+1
| |/ | | | | | | | | | | | | | | These are all arguments or fields that got added without updating the kerneldoc comments. Signed-off-by: Thierry Reding <treding@nvidia.com> Signed-off-by: Mark Brown <broonie@linaro.org>
* | Merge tag 'spi-v3.17' of ↵Linus Torvalds2014-08-051-6/+6
|\ \ | |/ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | git://git.kernel.org/pub/scm/linux/kernel/git/broonie/spi Pull spi updates from Mark Brown: "A quiet release, more bug fixes than anything else. A few things do stand out though: - updates to several drivers to move towards the standard GPIO chip select handling in the core. - DMA support for the SH MSIOF driver. - support for Rockchip SPI controllers (their first mainline submission)" * tag 'spi-v3.17' of git://git.kernel.org/pub/scm/linux/kernel/git/broonie/spi: (64 commits) spi: davinci: use spi_device.cs_gpio to store gpio cs per spi device spi: davinci: add support to configure gpio cs through dt spi/pl022: Explicitly truncate large bitmask spi/atmel: Fix pointer to int conversion warnings on 64 bit builds spi: davinci: fix to support more than 2 chip selects spi: topcliff-pch: don't hardcode PCI slot to get DMA device spi: orion: fix incorrect handling of cell-index DT property spi: orion: Fix error return code in orion_spi_probe() spi/rockchip: fix error return code in rockchip_spi_probe() spi/rockchip: remove redundant dev_err call in rockchip_spi_probe() spi/rockchip: remove duplicated include from spi-rockchip.c ARM: dts: fix the chip select gpios definition in the SPI nodes spi: s3c64xx: Update binding documentation spi: s3c64xx: use the generic SPI "cs-gpios" property spi: s3c64xx: Revert "spi: s3c64xx: Added provision for dedicated cs pin" spi: atmel: Use dmaengine_prep_slave_sg() API spi: topcliff-pch: Update error messages for dmaengine_prep_slave_sg() API spi: sh-msiof: Use correct device for DMA mapping with IOMMU spi: sh-msiof: Handle dmaengine_prep_slave_single() failures gracefully spi: rspi: Handle dmaengine_prep_slave_sg() failures gracefully ...
| * Merge remote-tracking branch 'spi/topic/core' into spi-nextMark Brown2014-08-041-2/+0
| |\
| | * spi: Remove unused variableMark Brown2014-06-211-1/+0
| | | | | | | | | | | | | | | Reported-by: kbuild test robot Signed-off-by: Mark Brown <broonie@linaro.org>
| | * spi: Remove redundant OOM message in spi.cSachin Kamat2014-06-211-1/+0
| | | | | | | | | | | | | | | | | | | | | | | | Let memory subsystem handle the error logging. Signed-off-by: Sachin Kamat <sachin.kamat@samsung.com> Reviewed-by: Naveen Krishna Chatradhi <ch.naveen@samsung.com> Signed-off-by: Mark Brown <broonie@linaro.org>
| * | spi: core: Pass correct device to dma_map_sg()Geert Uytterhoeven2014-07-111-4/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | According to Documentation/dmaengine.txt, scatterlists must be mapped using the DMA struct device. However, "dma_chan.dev->device" is the sysfs class device's device. Use "dma_chan.device->dev" instead, which is the real DMA device's device. Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be> Signed-off-by: Mark Brown <broonie@linaro.org>
| * | spi: core: Fix check for dma_map_sg() failuresGeert Uytterhoeven2014-07-111-0/+2
| |/ | | | | | | | | | | | | | | | | According to Documentation/DMA-API.txt, dma_map_sg() returns 0 on failure. As spi_map_buf() returns an error code, convert zero into -ENOMEM. Keep the existing check for negative numbers just in case. Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be> Signed-off-by: Mark Brown <broonie@linaro.org>
* | clk: Support for clock parents and rates assigned from device treeSylwester Nawrocki2014-07-251-0/+5
|/ | | | | | | | | | | | | This patch adds helper functions to configure clock parents and rates as specified through 'assigned-clock-parents', 'assigned-clock-rates' DT properties for a clock provider or clock consumer device. The helpers are now being called by the bus code for the platform, I2C and SPI busses, before the driver probing and also in the clock core after registration of a clock provider. Signed-off-by: Sylwester Nawrocki <s.nawrocki@samsung.com> Acked-by: Kyungmin Park <kyungmin.park@samsung.com> Signed-off-by: Mike Turquette <mturquette@linaro.org>
* Merge remote-tracking branch 'spi/topic/dt' into spi-nextMark Brown2014-06-021-0/+2
|\
| * spi: add "spi-lsb-first" to devicetreeZhao Qiang2014-04-141-0/+2
| | | | | | | | | | | | | | | | add optional property devicetree for SPI slave nodes into devicetree so that LSB mode can be enabled by devicetree. Signed-off-by: Zhao Qiang <B45475@freescale.com> Signed-off-by: Mark Brown <broonie@linaro.org>
* | Merge remote-tracking branch 'spi/topic/core' into spi-nextMark Brown2014-06-021-11/+9
|\ \
| * | spi: core: Ignore unsupported spi-[tr]x-bus-width property valuesGeert Uytterhoeven2014-05-261-10/+8
| | | | | | | | | | | | | | | | | | | | | | | | | | | Rejecting unsupported values of spi-tx-bus-width and spi-rx-bus-width may break compatibility with future DTs. Just ignore them, falling back to Single SPI Transfers. Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be> Signed-off-by: Mark Brown <broonie@linaro.org>
| * | spi: core: Increase timeout valueHarini Katakam2014-04-141-1/+1
| |/ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The existing timeout value in wait_for_completion_timeout is calculated from the transfer length and speed with tolerance of 10msec. This is too low because this is used for error conditions such as hardware hang etc. The xfer->speed_hz considered may not be the actual speed set because the best clock divisor is chosen from a limited set such that the actual speed <= requested speed. This will lead to timeout being less than actual transfer time. Considering acceptable latencies, this timeout can be set to a value double the expected transfer plus 100 msecs. This patch adds the same in the core. Signed-off-by: Harini Katakam <harinik@xilinx.com> Signed-off-by: Mark Brown <broonie@linaro.org>
* | spi: core: Don't destroy master queue if we fail to create itMark Brown2014-05-031-2/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | If we fail to create the master queue for some reason we should not attempt to clean it up since attempting to stop a kthread that was not created will hang and it's just generally bad practice. Unfortunately at present we call spi_destroy_queue() even in cases where the creation fails. Fix this by fixing the error handling in spi_master_initialize_queue() so that we only flag the master as queued or destroy the queue if creation succeeded. The change to the flag is done since the general master cleanup uses this to destroy the queue. Reported-by: Ricardo Ribalda Delgado <ricardo.ribalda@gmail.com> Signed-off-by: Mark Brown <broonie@linaro.org> Acked-by: Geert Uytterhoeven <geert@linux-m68k.org>
* | spi: core: Protect DMA code by #ifdef CONFIG_HAS_DMAGeert Uytterhoeven2014-05-021-44/+65
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | If NO_DMA=y: drivers/built-in.o: In function `spi_map_buf': spi.c:(.text+0x21bc60): undefined reference to `dma_map_sg' drivers/built-in.o: In function `spi_unmap_buf.isra.33': spi.c:(.text+0x21c32e): undefined reference to `dma_unmap_sg' make[3]: *** [vmlinux] Error 1 Protect the DMA code by #ifdef CONFIG_HAS_DMA to fix this: - Extract __spi_map_msg() from spi_map_msg(), - Provide dummy definitions of __spi_map_msg() and spi_unmap_msg() if !CONFIG_HAS_DMA. Signed-off-by: Geert Uytterhoeven <geert@linux-m68k.org> Signed-off-by: Mark Brown <broonie@linaro.org>
* | spi: core: Ignore unsupported Dual/Quad Transfer Mode bitsGeert Uytterhoeven2014-04-181-1/+10
|/ | | | | | | | | | | | | | | | | | The availability of SPI Dual or Quad Transfer Mode as indicated by the "spi-tx-bus-width" and "spi-rx-bus-width" properties in the device tree is a hardware property of the SPI master, SPI slave, and board wiring. Hence the SPI core should not reject an SPI slave because an SPI master driver doesn't (yet) support Dual or Quad Transfer Mode. Change the lack of Dual or Quad Transfer Mode support in the SPI master driver from an error condition to a warning condition, and ignore the unsupported mode bits, falling back to Single Transfer Mode, to avoid breakages when running old kernels with new device trees. Fixes: f477b7fb13df (spi: DUAL and QUAD support) Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be> Signed-off-by: Mark Brown <broonie@linaro.org> Cc: stable@vger.kernel.org
*-. Merge remote-tracking branches 'spi/topic/sunxi', 'spi/topic/tegra114', ↵Mark Brown2014-03-301-1/+11
|\ \ | | | | | | | | | 'spi/topic/ti-qspi', 'spi/topic/ti-ssp', 'spi/topic/topcliff-pch', 'spi/topic/txx9', 'spi/topic/xcomm' and 'spi/topic/xfer' into spi-next
| | * spi: Add a timeout when waiting for transfersMark Brown2014-02-031-1/+11
| |/ | | | | | | | | | | | | Don't wait indefinitely for transfers to complete but time out after 10ms more than we expect the transfer to take on the wire. Signed-off-by: Mark Brown <broonie@linaro.org>
| |
| \
*-. \ Merge remote-tracking branches 'spi/topic/bus-num', 'spi/topic/cleanup', ↵Mark Brown2014-03-301-0/+3
|\ \ \ | | |/ | |/| | | | 'spi/topic/clps711x', 'spi/topic/coldfire', 'spi/topic/completion' and 'spi/topic/davinci' into spi-next
| | * spi: core: Set max_speed_hz of spi_device default to max_speed_hz of controllerAxel Lin2014-02-101-0/+3
| |/ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | In __spi_validate(), xfer->speed_hz is set to be spi->max_speed_hz if it is not set for this transfer. However, if spi->max_speed_hz is also not set, xfer->speed_hz is 0. Some drivers (e.g. au1550, tegra114, tegra20-sflash, tegra20-slink, etc.) then use below code to avoid setting xfer->speed_hz to 0. /* Set speed to the spi max fequency if spi device has not set */ spi->max_speed_hz = spi->max_speed_hz ? : tspi->spi_max_frequency; Let's handle it in spi core. If spi->max_speed_hz is not set, make it default to spi->master->max_speed_hz. So In __spi_validate() if both xfer->speed_hz and spi->max_speed_hz are not set, xfer->speed_hz will be set to spi->master->max_speed_hz. Signed-off-by: Axel Lin <axel.lin@ingics.com> Signed-off-by: Mark Brown <broonie@linaro.org>
* | Merge remote-tracking branch 'spi/topic/dma' into spi-nextMark Brown2014-03-301-0/+180
|\ \
| * | spi: Make max_tx and max_rx the same typeMark Brown2014-02-121-1/+1
| | | | | | | | | | | | | | | | | | Prevents spurious compiler warnings. Signed-off-by: Mark Brown <broonie@linaro.org>
| * | spi: Make core DMA mapping functions generate scatterlistsMark Brown2014-02-041-25/+76
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | We cannot unconditionally use dma_map_single() to map data for use with SPI since transfers may exceed a page and virtual addresses may not be provided with physically contiguous pages. Further, addresses allocated using vmalloc() need to be mapped differently to other addresses. Currently only the MXS driver handles all this, a few drivers do handle the possibility that buffers may not be physically contiguous which is the main potential problem but many don't even do that. Factoring this out into the core will make it easier for drivers to do a good job so if the driver is using the core DMA code then generate a scatterlist instead of mapping to a single address so do that. This code is mainly based on a combination of the existing code in the MXS and PXA2xx drivers. In future we should be able to extend it to allow the core to concatenate adjacent transfers if they are compatible, improving performance. Currently for simplicity clients are not allowed to use the scatterlist when they do DMA mapping, in the future the existing single address mappings will be replaced with use of the scatterlist most likely as part of pre-verifying transfers. This change makes it mandatory to use scatterlists when using the core DMA mapping so update the s3c64xx driver to do this when used with dmaengine. Doing so makes the code more ugly but it is expected that the old s3c-dma code can be removed very soon. Signed-off-by: Mark Brown <broonie@linaro.org>
| * | spi: Provide core support for full duplex devicesMark Brown2014-02-041-0/+47
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | It is fairly common for SPI devices to require that one or both transfer directions is always active. Currently drivers open code this in various ways with varying degrees of efficiency. Start factoring this out by providing flags SPI_MASTER_MUST_TX and SPI_MASTER_MUST_RX. These will cause the core to provide buffers for the requested direction if none are specified in the underlying transfer. Currently this is fairly inefficient since we actually allocate a data buffer which may get large, support for mapping transfers using a scatterlist will allow us to avoid this for DMA based transfers. Signed-off-by: Mark Brown <broonie@linaro.org>
| * | spi: Provide core support for DMA mapping transfersMark Brown2014-02-031-0/+82
| |/ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The process of DMA mapping buffers for SPI transfers does not vary between devices so in order to save duplication of code in drivers this can be factored out into the core, allowing it to be integrated with the work that is being done on factoring out the common elements from the data path including more sharing of dmaengine code. In order to use this masters need to provide a can_dma() operation and while the hardware is prepared they should ensure that DMA channels are provided in tx_dma and rx_dma. The core will then ensure that the buffers are mapped for DMA prior to calling transfer_one_message(). Currently the cleanup on error is not complete, this needs to be improved. Signed-off-by: Mark Brown <broonie@linaro.org>
* | Merge remote-tracking branch 'spi/topic/core' into spi-nextMark Brown2014-03-301-18/+28
|\ \
| * | spi: Do not require a completionMark Brown2014-03-251-2/+0
| | | | | | | | | | | | | | | | | | | | | | | | | | | There is no real reason why we require transfers to have a completion and the only user of the completion now checks to see if one has been provided before using it so stop enforcing this. This makes it more convenient for drivers to chain multiple asynchronous transfers together. Signed-off-by: Mark Brown <broonie@linaro.org>
| * | spi: core: Use master->max_speed_hz as transfer speed when xfer->speed_hz > ↵Axel Lin2014-03-171-8/+6
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | master->max_speed_hz When xfer->speed_hz is greater than master->max_speed_hz, it's generally safe to use master->max_speed_hz as transfer speed. Thus use master->max_speed_hz as transfer speed rather than return error when xfer->speed_hz > master->max_speed_hz. Signed-off-by: Axel Lin <axel.lin@ingics.com> Tested-by: Guenter Roeck <linux@roeck-us.net> Reviewed-by: Guenter Roeck <linux@roeck-us.net> Signed-off-by: Mark Brown <broonie@linaro.org>
| * | spi: core: make zero length transfer valid againAtsushi Nemoto2014-03-041-3/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Zero length transfer becomes invalid since "spi: core: Validate length of the transfers in message" commit, but it should be valid to support an odd device, for example, which requires long delay between chipselect and the first transfer, etc. Signed-off-by: Atsushi Nemoto <anemo@mba.ocn.ne.jp> Tested-by: Thierry Reding <treding@nvidia.com> Signed-off-by: Mark Brown <broonie@linaro.org>
| * | spi: core: Replace msleep with usleep_range to get more accurate sleep timeAxel Lin2014-02-231-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | Fixes below checkpatch warning: WARNING: msleep < 20ms can sleep for up to 20ms; see Documentation/timers/timers-howto.txt + msleep(10); Signed-off-by: Axel Lin <axel.lin@ingics.com> Signed-off-by: Mark Brown <broonie@linaro.org>
| * | spi: core: Validate length of the transfers in messageIvan T. Ivanov2014-02-221-0/+17
| | | | | | | | | | | | | | | | | | | | | | | | SPI transfer length should be multiple of SPI word size, where SPI word size should be power-of-two multiple Signed-off-by: Ivan T. Ivanov <iivanov@mm-sol.com> Signed-off-by: Mark Brown <broonie@linaro.org>
| * | spi: Clean up probe and remove functionsJean Delvare2014-02-141-7/+5
| |/ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | While backporting 33cf00e5 ("spi: attach/detach SPI device to the ACPI power domain"), I noticed that the code changes were suboptimal: * Why use &spi->dev when we have dev at hand? * After fixing the above, spi is used only once, so we don't really need a local variable for it. This results in the following clean-up. Signed-off-by: Jean Delvare <jdelvare@suse.de> Acked-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com> Signed-off-by: Mark Brown <broonie@linaro.org>
* | Merge remote-tracking branch 'spi/fix/core' into spi-linusMark Brown2014-03-301-3/+3
|\ \
| * | spi: Fix handling of cs_change in core implementationMark Brown2014-03-301-3/+3
| |/ | | | | | | | | | | | | | | | | | | | | The core implementation of cs_change didn't follow the documentation which says that cs_change in the middle of the transfer means to briefly deassert chip select, instead it followed buggy drivers which change the polarity of chip select. Use a delay of 10us between deassert and reassert simply from pulling numbers out of a hat. Reported-by: Gerhard Sittig <gsi@denx.de> Signed-off-by: Mark Brown <broonie@linaro.org>
* | Merge remote-tracking branch 'spi/fix/core' into spi-linusMark Brown2014-02-111-3/+1
|\ \ | |/ |/|
| * spi: Fix crash with double message finalisation on error handlingGeert Uytterhoeven2014-01-281-3/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This reverts commit e120cc0dcf2880a4c5c0a6cb27b655600a1cfa1d. It causes a NULL pointer dereference with drivers using the generic spi_transfer_one_message(), which always calls spi_finalize_current_message(), which zeroes master->cur_msg. Drivers implementing transfer_one_message() theirselves must always call spi_finalize_current_message(), even if the transfer failed: * @transfer_one_message: the subsystem calls the driver to transfer a single * message while queuing transfers that arrive in the meantime. When the * driver is finished with this message, it must call * spi_finalize_current_message() so the subsystem can issue the next * transfer Signed-off-by: Geert Uytterhoeven <geert+renesas@linux-m68k.org> Signed-off-by: Mark Brown <broonie@linaro.org>
* | Merge tag 'spi-v3.14-2' of ↵Linus Torvalds2014-01-251-28/+46
|\ \ | |/ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | git://git.kernel.org/pub/scm/linux/kernel/git/broonie/spi Pull spi updates from Mark Brown: "A respun version of the merges for the pull request previously sent with a few additional fixes. The last two merges were fixed up by hand since the branches have moved on and currently have the prior merge in them. Quite a busy release for the SPI subsystem, mostly in cleanups big and small scattered through the stack rather than anything else: - New driver for the Broadcom BC63xx HSSPI controller - Fix duplicate device registration for ACPI - Conversion of s3c64xx to DMAEngine (this pulls in platform and DMA changes upon which the transiton depends) - Some small optimisations to reduce the amount of time we hold locks in the datapath, eliminate some redundant checks and the size of a spi_transfer - Lots of fixes, cleanups and general enhancements to drivers, especially the rspi and Atmel drivers" * tag 'spi-v3.14-2' of git://git.kernel.org/pub/scm/linux/kernel/git/broonie/spi: (112 commits) spi: core: Fix transfer failure when master->transfer_one returns positive value spi: Correct set_cs() documentation spi: Clarify transfer_one() w.r.t. spi_finalize_current_transfer() spi: Spelling s/finised/finished/ spi: sc18is602: Convert to use bits_per_word_mask spi: Remove duplicate code to set default bits_per_word setting spi/pxa2xx: fix compilation warning when !CONFIG_PM_SLEEP spi: clps711x: Add MODULE_ALIAS to support module auto-loading spi: rspi: Add missing clk_disable() calls in error and cleanup paths spi: rspi: Spelling s/transmition/transmission/ spi: rspi: Add support for specifying CPHA/CPOL spi/pxa2xx: initialize DMA channels to -1 to prevent inadvertent match spi: rspi: Add more QSPI register documentation spi: rspi: Add more RSPI register documentation spi: rspi: Remove dependency on DMAE for SHMOBILE spi/s3c64xx: Correct indentation spi: sh: Use spi_sh_clear_bit() instead of open-coded spi: bitbang: Grammar s/make to make/to make/ spi: sh-hspi: Spelling s/recive/receive/ spi: core: Improve tx/rx_nbits check comments ...
| * Merge remote-tracking branch 'spi/topic/core' into spi-linusMark Brown2014-01-231-20/+26
| |\
| | * spi: core: Improve tx/rx_nbits check commentsGeert Uytterhoeven2014-01-131-3/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | - Rephrase the comments about tx/rx_nbits validity checks, - Remove the stale comment about SPI_3WIRE (the code it refers to was removed in commit 368ca4e0c75612c0a4d6bbcef7efb944604340c2 ("spi: Eliminate 3WIRE spi_transfer check")). Signed-off-by: Geert Uytterhoeven <geert+renesas@linux-m68k.org> Signed-off-by: Mark Brown <broonie@linaro.org>
| | * spi: core: Use list_first_entry to extract head of queueAxel Lin2014-01-091-1/+1
| | | | | | | | | | | | | | | | | | | | | For slightly better readability. Signed-off-by: Axel Lin <axel.lin@ingics.com> Signed-off-by: Mark Brown <broonie@linaro.org>
| | * spi: core: Use list_first_entry_or_null() instead of open-codedAxel Lin2014-01-021-5/+2
| | | | | | | | | | | | | | | | | | | | | Use list_first_entry_or_null() to save a few lines. Signed-off-by: Axel Lin <axel.lin@ingics.com> Signed-off-by: Mark Brown <broonie@linaro.org>
| | * spi: Eliminate 3WIRE spi_transfer checkTrent Piepho2013-12-301-6/+0
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Checking for SPI_3WIRE isn't needed. spi_setup() already prevents 3WIRE mode from being combined with DUAL or QUAD mode support. So there is no need to differentiate between a single bit device with SPI_3WIRE set and one with without. It doesn't change the allowed bit widths. Signed-off-by: Trent Piepho <tpiepho@gmail.com> Signed-off-by: Mark Brown <broonie@linaro.org>
| | * spi: Factor validation and initialisation of messages outside lockMark Brown2013-11-241-5/+21
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Currently we do a bunch of per-message validation and initialisation in __spi_async() which is called with the bus lock held. Since none of this validation depends on the current bus status there's no need to hold the lock to do it so split it out into a separate __spi_validate() function which is called prior to taking the bus lock. This could be slightly neater but keep things simple for now to show the code motion clearly. Based on observations from Martin Sperl. Signed-off-by: Mark Brown <broonie@linaro.org>
| * | Merge remote-tracking branch 'spi/fix/core' into spi-linusMark Brown2014-01-231-8/+20
| |\ \
| | * | spi: core: Fix transfer failure when master->transfer_one returns positive valueAxel Lin2014-01-211-1/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | master->transfer_one returns positive value is not a error. So set ret to 0 when master->transfer_one returns positive value. Otherwise, I hit "spi_master spi0: failed to transfer one message from queue" error when my transfer_one callback returns 1. Signed-off-by: Axel Lin <axel.lin@ingics.com> Signed-off-by: Mark Brown <broonie@linaro.org>
| | * | spi: Spelling s/finised/finished/Geert Uytterhoeven2014-01-211-1/+1
| | | | | | | | | | | | | | | | | | | | Signed-off-by: Geert Uytterhoeven <geert+renesas@linux-m68k.org> Signed-off-by: Mark Brown <broonie@linaro.org>
| | * | spi: Check conflicting CS based on spi->chip_select instead of device nameMika Westerberg2014-01-091-5/+13
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Commit e13ac47bec20 (spi: Use stable dev_name for ACPI enumerated SPI slaves) changed the SPI device naming to be based on ACPI device name instead of carrying bus number and chip select for devices enumerated from ACPI namespace. In case of a buggy BIOS that lists multiple SPI devices sharing the same chip select (even though they should use different) the current code fails to detect that and allows the devices to be added to the bus. Fix this by walking through the bus and comparing spi->chip_select instead of device name. This should work regardless what the device name will be in future. Signed-off-by: Mika Westerberg <mika.westerberg@linux.intel.com> Acked-by: Jarkko Nikula <jarkko.nikula@linux.intel.com> Signed-off-by: Mark Brown <broonie@linaro.org>
| | * | spidev: fix hang when transfer_one_message failsDaniel Santos2014-01-061-1/+3
| | |/ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This corrects a problem in spi_pump_messages() that leads to an spi message hanging forever when a call to transfer_one_message() fails. This failure occurs in my MCP2210 driver when the cs_change bit is set on the last transfer in a message, an operation which the hardware does not support. Rationale Since the transfer_one_message() returns an int, we must presume that it may fail. If transfer_one_message() should never fail, it should return void. Thus, calls to transfer_one_message() should properly manage a failure. Fixes: ffbbdd21329f3 (spi: create a message queueing infrastructure) Signed-off-by: Daniel Santos <daniel.santos@pobox.com> Signed-off-by: Mark Brown <broonie@linaro.org> Cc: stable@vger.kernel.org
* | | ACPI: fix module autoloading for ACPI enumerated devicesZhang Rui2014-01-161-0/+10
|/ / | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | ACPI enumerated devices has ACPI style _HID and _CID strings, all of these strings can be used for both driver loading and matching. Currently, in Platform, I2C and SPI bus, the ACPI style driver matching is supported by invoking acpi_driver_match_device() in bus .match() callback. But, the module autoloading is still broken. For example, there is any ACPI device with _HID "INTABCD" that is enumerated to platform bus, and we have a driver that can probe it. The driver exports its module_alias as "acpi:INTABCD" use the following code static const struct acpi_device_id xxx_acpi_match[] = { { "INTABCD", 0 }, { } }; MODULE_DEVICE_TABLE(acpi, xxx_acpi_match); But, unfortunately, the device' modalias is shown as "platform:INTABCD:00", please refer to modalias_show() and platform_uevent() in drivers/base/platform.c. This results in that the driver will not be loaded automatically when the device node is created, because their modalias do not match. This also applies to I2C and SPI bus. With this patch, the device' modalias will be shown as "acpi:INTABCD" as well. Signed-off-by: Zhang Rui <rui.zhang@intel.com> Acked-by: Mark Brown <broonie@linaro.org> Acked-by: Wolfram Sang <wsa@the-dreams.de> Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
OpenPOWER on IntegriCloud