14 Nov, 2020
1 commit
-
Clang warns:
drivers/spi/spi-bcm2835aux.c:532:50: warning: variable 'err' is
uninitialized when used here [-Wuninitialized]
dev_err(&pdev->dev, "could not get clk: %d\n", err);
^~~
./include/linux/dev_printk.h:112:32: note: expanded from macro 'dev_err'
_dev_err(dev, dev_fmt(fmt), ##__VA_ARGS__)
^~~~~~~~~~~
drivers/spi/spi-bcm2835aux.c:495:9: note: initialize the variable 'err'
to silence this warning
int err;
^
= 0
1 warning generated.Restore the assignment so that the error value can be used in the
dev_err statement and there is no uninitialized memory being leaked.Fixes: e13ee6cc4781 ("spi: bcm2835aux: Fix use-after-free on unbind")
Link: https://github.com/ClangBuiltLinux/linux/issues/1199
Signed-off-by: Nathan Chancellor
Link: https://lore.kernel.org/r/20201113180701.455541-1-natechancellor@gmail.com
Signed-off-by: Mark Brown
12 Nov, 2020
1 commit
-
bcm2835aux_spi_remove() accesses the driver's private data after calling
spi_unregister_master() even though that function releases the last
reference on the spi_master and thereby frees the private data.Fix by switching over to the new devm_spi_alloc_master() helper which
keeps the private data accessible until the driver has unbound.Fixes: b9dd3f6d4172 ("spi: bcm2835aux: Fix controller unregister order")
Signed-off-by: Lukas Wunner
Cc: # v4.4+: 123456789abc: spi: Introduce device-managed SPI controller allocation
Cc: # v4.4+: b9dd3f6d4172: spi: bcm2835aux: Fix controller unregister order
Cc: # v4.4+
Link: https://lore.kernel.org/r/b290b06357d0c0bdee9cecc539b840a90630f101.1605121038.git.lukas@wunner.de
Signed-off-by: Mark Brown
24 Aug, 2020
1 commit
-
Replace the existing /* fall through */ comments and its variants with
the new pseudo-keyword macro fallthrough[1]. Also, remove unnecessary
fall-through markings when it is the case.[1] https://www.kernel.org/doc/html/v5.7/process/deprecated.html?highlight=fallthrough#implicit-switch-case-fall-through
Signed-off-by: Gustavo A. R. Silva
17 Jul, 2020
1 commit
-
Setting spi_transfer->effective_speed_hz in transfer_one so that
it can get used in cs_change_delay configured with delay as a muliple
of SPI clock cycles.Signed-off-by: Martin Sperl
Signed-off-by: Marc Kleine-Budde
Link: https://lore.kernel.org/r/20200709074120.110069-3-mkl@pengutronix.de
Signed-off-by: Mark Brown
20 May, 2020
1 commit
-
The BCM2835aux SPI driver uses devm_spi_register_master() on bind.
As a consequence, on unbind, __device_release_driver() first invokes
bcm2835aux_spi_remove() before unregistering the SPI controller via
devres_release_all().This order is incorrect: bcm2835aux_spi_remove() turns off the SPI
controller, including its interrupts and clock. The SPI controller
is thus no longer usable.When the SPI controller is subsequently unregistered, it unbinds all
its slave devices. If their drivers need to access the SPI bus,
e.g. to quiesce their interrupts, unbinding will fail.As a rule, devm_spi_register_master() must not be used if the
->remove() hook performs teardown steps which shall be performed
after unbinding of slaves.Fix by using the non-devm variant spi_register_master(). Note that the
struct spi_master as well as the driver-private data are not freed until
after bcm2835aux_spi_remove() has finished, so accessing them is safe.Fixes: 1ea29b39f4c8 ("spi: bcm2835aux: add bcm2835 auxiliary spi device driver")
Signed-off-by: Lukas Wunner
Cc: stable@vger.kernel.org # v4.4+
Cc: Martin Sperl
Link: https://lore.kernel.org/r/32f27f4d8242e4d75f9a53f7e8f1f77483b08669.1589557526.git.lukas@wunner.de
Signed-off-by: Mark Brown
05 Sep, 2019
1 commit
-
Use devm_platform_ioremap_resource() to simplify the code a bit.
This is detected by coccinelle.Reported-by: Hulk Robot
Signed-off-by: YueHaibing
Link: https://lore.kernel.org/r/20190904135918.25352-6-yuehaibing@huawei.com
Signed-off-by: Mark Brown
02 Aug, 2019
1 commit
-
We don't need dev_err() messages when platform_get_irq() fails now that
platform_get_irq() prints an error message itself when something goes
wrong. Let's remove these prints with a simple semantic patch.//
@@
expression ret;
struct platform_device *E;
@@ret =
(
platform_get_irq(E, ...)
|
platform_get_irq_byname(E, ...)
);if ( \( ret < 0 \| ret
While we're here, remove braces on if statements that only have one
statement (manually).Cc: Mark Brown
Cc: linux-spi@vger.kernel.org
Cc: Greg Kroah-Hartman
Signed-off-by: Stephen Boyd
Link: https://lore.kernel.org/r/20190730181557.90391-42-swboyd@chromium.org
Signed-off-by: Mark Brown
11 Jun, 2019
1 commit
-
Linux 5.2-rc4
31 May, 2019
1 commit
-
Based on 3 normalized pattern(s):
this program is free software you can redistribute it and or modify
it under the terms of the gnu general public license as published by
the free software foundation either version 2 of the license or at
your option any later version this program is distributed in the
hope that it will be useful but without any warranty without even
the implied warranty of merchantability or fitness for a particular
purpose see the gnu general public license for more detailsthis program is free software you can redistribute it and or modify
it under the terms of the gnu general public license as published by
the free software foundation either version 2 of the license or at
your option any later version [author] [kishon] [vijay] [abraham]
[i] [kishon]@[ti] [com] this program is distributed in the hope that
it will be useful but without any warranty without even the implied
warranty of merchantability or fitness for a particular purpose see
the gnu general public license for more detailsthis program is free software you can redistribute it and or modify
it under the terms of the gnu general public license as published by
the free software foundation either version 2 of the license or at
your option any later version [author] [graeme] [gregory]
[gg]@[slimlogic] [co] [uk] [author] [kishon] [vijay] [abraham] [i]
[kishon]@[ti] [com] [based] [on] [twl6030]_[usb] [c] [author] [hema]
[hk] [hemahk]@[ti] [com] this program is distributed in the hope
that it will be useful but without any warranty without even the
implied warranty of merchantability or fitness for a particular
purpose see the gnu general public license for more detailsextracted by the scancode license scanner the SPDX license identifier
GPL-2.0-or-later
has been chosen to replace the boilerplate/reference in 1105 file(s).
Signed-off-by: Thomas Gleixner
Reviewed-by: Allison Randal
Reviewed-by: Richard Fontana
Reviewed-by: Kate Stewart
Cc: linux-spdx@vger.kernel.org
Link: https://lkml.kernel.org/r/20190527070033.202006027@linutronix.de
Signed-off-by: Greg Kroah-Hartman
13 May, 2019
1 commit
-
Printing an error on memory allocation failure is unnecessary,
as the memory allocation core code already takes care of that.Signed-off-by: Hoan Nguyen An
Reviewed-by: Geert Uytterhoeven
Reviewed-by: Martin Sperl
Signed-off-by: Mark Brown
08 Apr, 2019
1 commit
-
When building CONFIG_DEBUG_FS is not set
gcc warn this:drivers/spi/spi-bcm2835aux.c: In function bcm2835aux_spi_probe:
drivers/spi/spi-bcm2835aux.c:591:2: error: too many arguments to function bcm2835aux_debugfs_create
bcm2835aux_debugfs_create(bs, dev_name(&pdev->dev));
^~~~~~~~~~~~~~~~~~~~~~~~~
drivers/spi/spi-bcm2835aux.c:145:13: note: declared here
static void bcm2835aux_debugfs_create(struct bcm2835aux_spi *bs)Reported-by: Hulk Robot
Fixes: 8048d151eb4d ("spi: bcm2835aux: add driver stats to debugfs")
Signed-off-by: YueHaibing
Reviewed-by: Mukesh Ojha
Signed-off-by: Mark Brown
04 Apr, 2019
1 commit
-
Fixes: 5fd917afc4bf ("spi: bcm2835aux: make the polling duration limits configurable")
Signed-off-by: kbuild test robot
Signed-off-by: Mark Brown
03 Apr, 2019
9 commits
-
To estimate efficiency add statistics on transfer types
(polling and interrupt) used to debugfs.Signed-off-by: Martin Sperl
Signed-off-by: Mark Brown -
Under some circumstances the default 30 us polling limit is not optimal
and may lead to long delays because we are waiting on an interrupt.
with this patch we have the possibility to influence this policy.So make this limit (in us) configurable via a module parameters
(but also modifyable via /sys/modules/...)Signed-off-by: Martin Sperl
Acked-by: Stefan Wahren
Signed-off-by: Mark Brown -
Setup gpio-cs to the correct levels during setup and also make the
gpio definitely an output GPIO.This is transparently fixing some badly configured DTs in the process
where cs-gpio is set but the gpios are still configured with native cs.It also makes 100% sure that the initial CS levels are as expected -
especially on systems with devices on a bus with mixed CS_HIGH/CS_LOW
settings.Fixes: 1ea29b39f4c812ec ("spi: bcm2835aux: add bcm2835 auxiliary spi device...")
Signed-off-by: Martin Sperl
Acked-by: Stefan Wahren
Signed-off-by: Mark Brown -
From personal bad experience (even as the author of the original driver)
it shows that native-cs is "somewhat" supported by the spi bus driver
when using a buggy device tree.So make sure that the driver is warning in dmesg about this fact
that we are running in a not supported mode that may have surprizing
limitations.Fixes: 1ea29b39f4c812ec ("spi: bcm2835aux: add bcm2835 auxiliary spi device...")
Signed-off-by: Martin Sperl
Acked-by: Stefan Wahren
Signed-off-by: Mark Brown -
The original driver by default defines num_chipselects as -1.
This actually allicates an array of 65535 entries in
of_spi_register_master.There is a side-effect for buggy device trees that (contrary to
dt-binding documentation) have no cs-gpio defined.This mode was never supported by the driver due to limitations
of native cs and additional code complexity and is explicitly
not stated to be implemented.To keep backwards compatibility with such buggy DTs we limit
the number of chip_selects to 1, as for all practical purposes
it is only ever realistic to use a single chip select in
native cs mode without negative side-effects.Fixes: 1ea29b39f4c812ec ("spi: bcm2835aux: add bcm2835 auxiliary spi device...")
Signed-off-by: Martin Sperl
Acked-by: Stefan Wahren
Signed-off-by: Mark Brown -
Remove dead code that never can get reached, as we limit count to
a max of 3.Suggested-by: Hubert Denkmair
Signed-off-by: Martin Sperl
Acked-by: Stefan Wahren
Signed-off-by: Mark Brown -
On long running tests with a mcp2517fd can controller it showed that
on rare occations the data read shows corruptions for longer spi transfers.Example of a 22 byte transfer:
expected (as captured on logic analyzer):
FF FF 78 00 00 00 08 06 00 00 91 20 77 56 84 85 86 87 88 89 8a 8bread by the driver:
FF FF 78 00 00 00 08 06 00 00 91 20 77 56 84 88 89 8a 00 00 8b 9bTo fix this use BCM2835_AUX_SPI_STAT_RX_LVL to determine when we may
read data from the fifo reliably without any corruption.Surprisingly the only values ever empirically read in
BCM2835_AUX_SPI_STAT_RX_LVL are 0x00, 0x10, 0x20 and 0x30.
So whenever the mask is not 0 we can read from the fifo in a safe manner.The patch has now been tested intensively and we are no longer
able to reproduce the "RX" issue any longer.Fixes: 1ea29b39f4c812ec ("spi: bcm2835aux: add bcm2835 auxiliary spi device...")
Reported-by: Hubert Denkmair
Signed-off-by: Martin Sperl
Acked-by: Stefan Wahren
Signed-off-by: Mark Brown -
This read of the fifo is a potential candidate for a race condition
as the spi transfer is not necessarily finished and so can lead to
an early read of the fifo that still misses data.So it has been removed.
Fixes: 1ea29b39f4c812ec ("spi: bcm2835aux: add bcm2835 auxiliary spi device...")
Suggested-by: Hubert Denkmair
Signed-off-by: Martin Sperl
Acked-by: Stefan Wahren
Signed-off-by: Mark Brown -
Sharing more code between polling and interrupt-driven mode.
Signed-off-by: Martin Sperl
Acked-by: Stefan Wahren
Signed-off-by: Mark Brown
23 Jan, 2019
1 commit
-
Fix a static code checker warning:
drivers/spi/spi-bcm2835aux.c:460
bcm2835aux_spi_probe() warn: passing zero to 'PTR_ERR'In case of error, the function devm_clk_get() returns ERR_PTR()
and not returns NULL.Signed-off-by: YueHaibing
Signed-off-by: Mark Brown
15 Nov, 2018
1 commit
-
The license text is specifying GPL v2 or later but the MODULE_LICENSE
is set to GPL v2 which means GNU Public License v2 only. So choose the
license text as the correct one.Signed-off-by: Stefan Wahren
Acked-by: Florian Kauer
Acked-by: Martin Sperl
Signed-off-by: Mark Brown
04 May, 2018
1 commit
-
The BCM2835 AUX SPI has a shared interrupt line (with AUX UART).
Downstream fixes this with an AUX irqchip to demux the IRQ sources and a
DT change which breaks compatibility with older kernels. The AUX irqchip
was already rejected for upstream[1] and the DT change would break
working systems if the DTB is updated to a newer one. The latter issue
was brought to my attention by Alex Graf.The root cause however is a bug in the shared handler. Shared handlers
must check that interrupts are actually enabled before servicing the
interrupt. Add a check that the TXEMPTY or IDLE interrupts are enabled.[1] https://patchwork.kernel.org/patch/9781221/
Cc: Alexander Graf
Cc: Marc Zyngier
Cc: Mark Brown
Cc: Eric Anholt
Cc: Stefan Wahren
Cc: Florian Fainelli
Cc: Ray Jui
Cc: Scott Branden
Cc: bcm-kernel-feedback-list@broadcom.com
Cc: linux-spi@vger.kernel.org
Cc: linux-rpi-kernel@lists.infradead.org
Cc: linux-arm-kernel@lists.infradead.org
Signed-off-by: Rob Herring
Reviewed-by: Eric Anholt
Signed-off-by: Mark Brown
15 Feb, 2018
1 commit
-
We want to check for xfers that are over 30 microseconds. Rather than
find how many µs a xfer will take, instead find how many bytes can be
transferred in 30 µs. The latter must be less than 32 bits (since our
clock speed is limited to 32 bits), while the former involves 64 bit
quantities and more arithmetic operations.Signed-off-by: Trent Piepho
Signed-off-by: Mark Brown
11 Mar, 2016
1 commit
-
…pic/bcm2835' and 'spi/topic/bcm2835aux' into spi-next
16 Feb, 2016
2 commits
-
The auxiliary spi supports only CPHA=0 modes as the first bit is
always output to the pin before the first clock cycle. In CPHA=1
modes the first clock edge outputs the second bit hence the slave
can never read the first bit.Also the CPHA registers switch between clocking data in/out on
rising/falling edge hence depend on the CPOL setting.Signed-off-by: Stephan Olbrich
Reviewed-by: Eric Anholt
Signed-off-by: Mark Brown -
When using reverse polarity for clock (spi-cpol) on a device
the clock line gets altered after chip-select has been asserted
resulting in an additional clock beat, which confuses hardware.This happens due to the fact, the the hardware was initialized
and reset at the begin and end of each transfer which results
in default state for all lines except chip-select which is
handled by the spi-subsystem as gpio-cs is used.To avoid this situation this patch moves the setup of polarity
(spi-cpol and spi-cpha) outside of the chip-select into
prepare_message, which is run prior to asserting chip-select.Signed-off-by: Stephan Olbrich
Reviewed-by: Martin Sperl
Tested-by: Martin Sperl
Reviewed-by: Eric Anholt
Signed-off-by: Mark Brown
11 Feb, 2016
1 commit
-
The tx empty irq can be disabled when all data was copied.
This prevents unnecessary interrupts while the last bytes are sent.Signed-off-by: Stephan Olbrich
Reviewed-by: Eric Anholt
Signed-off-by: Mark Brown
10 Feb, 2016
1 commit
-
The bitmasks for txempty and idle interrupts were interchanged.
Signed-off-by: Stephan Olbrich
Reviewed-by: Eric Anholt
Signed-off-by: Mark Brown
16 Oct, 2015
2 commits
-
Change the initialization order of the HW so that the interrupt
is only requested after the HW is initializedAlso the use of irq_of_parse_and_map is replaced by platform_get_irq.
Signed-off-by: Martin Sperl
Signed-off-by: Mark Brown -
There are strange issues with the auxiliary spi device that result
in "lost" data in the RX path if the fifo is filled by too much
(even though the status register is checked if new data can get filled
in).This has been observed primarily for the interrupt case.
Polling works fine, probably because the RX fifo is pulled immediately
when in the tight polling loop.For that reason we have to limit the pending bytes to less than 15
when filling the fifo in interrupt mode.There also was an issue returning the "wrong" last 1/2 bytes
of a transfer when the transfer is not a multiple of 3 bytes.
(this impacted polling and interrupt modes)Also fixed an overflow in the estimation of the transfer time used
to decide if we run in interrupt or polling mode (found with the
spi-bcm2835.c driver originally).Reported-by: Georgii Staroselskii
Signed-off-by: Martin Sperl
Signed-off-by: Mark Brown
07 Oct, 2015
1 commit
-
The bcm2835 has 2 auxiliary spi bus masters spi1 and spi2.
This implements the driver to enable these devices.
The driver does not implement native chip-selects but uses
the aribtrary GPIO-chip-selects provided by the spi-chipselect.Note that this driver relies on the fact that
the clock is implemented by the clk-bcm2835-aux driver,
which enables/disables the HW block when requesting/releasing
the clock.Signed-off-by: Martin Sperl
Acked-by: Eric Anholt
Signed-off-by: Mark Brown