summaryrefslogtreecommitdiff
path: root/drivers/net/can/mcp251x.c
AgeCommit message (Collapse)Author
2014-04-22can: mcp251x: fix locking in BERR counter functionalityMarcel Ziswiler
Symptoms: The interface stops receiving CAN frames when reception of CAN frame and call to the introduced get_berr_counter function coincide. Reproduction: Ip requests, among others, the berr field for the can interfaces. NOTE that it does so even if called as 'ip link show lo', as interface-based filtering is only done after the system calls to receive interface information. Run candump on a MCP-based can interface that has a lot of traffic (via 'cangen -g1' on another can node). On the system with the MCP chip, run while /bin/true; do ip link > /dev/null ; done; Reception of CAN-frames (as shown by candump) will cease within seconds. This issue got introduced by commit 1b59090a47101b4bf379d2c35986ad3f0bcb2aa1 as access to the SPI registers of the MCP251x were not locked. Issue report and patch courtesy David R. Piegdon of Indurad GmbH.
2013-01-08can: mcp251x: add BERR counter functionalityMitja Spes
Add BERR counter functionality to MCP251x driver. Signed-off-by: Mitja Spes <mitja@lxnav.com>
2011-04-06can: mcp251x: Allow pass IRQ flags through platform data.Enric Balletbo i Serra
When an interrupt occurs, the INT pin is driven low by the MCP251x controller (falling edge) but in some cases the INT pin can be connected to the MPU through a transistor or level translator which inverts this signal. In this case interrupt should be configured in rising edge. This patch adds support to pass the IRQ flags via mcp251x_platform_data. Signed-off-by: Enric Balletbo i Serra <eballetbo@iseebcn.com> Acked-by: Wolfgang Grandegger <wg@grandegger.com> Acked-by: Marc Kleine-Budde <mkl@pengutronix.de> Signed-off-by: David S. Miller <davem@davemloft.net>
2011-02-16workqueue, freezer: unify spelling of 'freeze' + 'able' to 'freezable'Tejun Heo
There are two spellings in use for 'freeze' + 'able' - 'freezable' and 'freezeable'. The former is the more prominent one. The latter is mostly used by workqueue and in a few other odd places. Unify the spelling to 'freezable'. Signed-off-by: Tejun Heo <tj@kernel.org> Reported-by: Alan Stern <stern@rowland.harvard.edu> Acked-by: "Rafael J. Wysocki" <rjw@sisk.pl> Acked-by: Greg Kroah-Hartman <gregkh@suse.de> Acked-by: Dmitry Torokhov <dtor@mail.ru> Cc: David Woodhouse <dwmw2@infradead.org> Cc: Alex Dubov <oakad@yahoo.com> Cc: "David S. Miller" <davem@davemloft.net> Cc: Steven Whitehouse <swhiteho@redhat.com>
2010-10-26can: mcp251x: fix reception of standard RTR framesMarc Kleine-Budde
This patch sets the missing CAN_RTR_FLAG if a standard RTR frame is received. (For extended frames the CAN_RTR_FLAG was already set correctly.) Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de> Signed-off-by: David S. Miller <davem@davemloft.net>
2010-10-21can: mcp251x: fix generation of error framesMarc Kleine-Budde
The function "mcp251x_error_skb" is used to generate error frames. They are identified by the "CAN_ERR_FLAG" in can_id. The function overwrites the can_id so that the frames show up as normal frames instead of error frames. This patch fixes the problem by or'ing the can_id instead of overwriting it. Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de> Tested-by: Jargalan Nermunkh <jargalan.nermunkh@criticallink.com> Signed-off-by: David S. Miller <davem@davemloft.net>
2010-10-21can: mcp251x: fix endless loop in interrupt handler if CANINTF_MERRF is setMarc Kleine-Budde
Commit d3cd15657516141adce387810be8cb377baf020e introduced a bug, the interrupt handler would loop endlessly if the CANINTF_MERRF bit is set, because it's not cleared. This patch fixes the problem by masking out the CANINTF_MERRF and all other non interesting bits. Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de> Signed-off-by: David S. Miller <davem@davemloft.net>
2010-10-18can: mcp251x: optimize 2515, rx int gets cleared automaticallyMarc Kleine-Budde
Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de> Acked-by: Wolfgang Grandegger <wg@grandegger.com>
2010-10-18can: mcp251x: define helper functions mcp251x_is_2510, mcp251x_is_2515Marc Kleine-Budde
Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de> Acked-by: Wolfgang Grandegger <wg@grandegger.com>
2010-10-18can: mcp251x: Don't use pdata->model for chip selection anymoreMarc Kleine-Budde
Since commit e446630c960946b5c1762e4eadb618becef599e7, i.e. v2.6.35-rc1, the mcp251x chip model can be selected via the modalias member in the struct spi_board_info. The driver stores the actual model in the struct mcp251x_platform_data. From the driver point of view the platform_data should be read only. Since all in-tree users of the mcp251x have already been converted to the modalias method, this patch moves the "model" member from the struct mcp251x_platform_data to the driver's private data structure. Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de> Cc: Christian Pellegrin <chripell@fsfe.org> Cc: Marc Zyngier <maz@misterjones.org>
2010-10-18can: mcp251x: write intf only when neededMarc Kleine-Budde
This patch introduces a variable "clear_intf" that hold the bits that should be cleared. Only read-modify-write register if "clear_intf" is set. Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de> Acked-by: Wolfgang Grandegger <wg@grandegger.com>
2010-10-18can: mcp251x: read-modify-write eflag only when neededSascha Hauer
Use read-modify-write instead of a simple write to change the register contents, to close existing the race window between the original manual read and write. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de> Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de> Acked-by: Wolfgang Grandegger <wg@grandegger.com>
2010-10-18can: mcp251x: allow to read two registers in one spi transferSascha Hauer
This patch bases on work done earlier by David Jander. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de> Acked-by: David Jander <david@protonic.nl> Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de> Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de> Acked-by: Wolfgang Grandegger <wg@grandegger.com>
2010-10-18can: mcp251x: increase rx_errors on overflow, not only rx_over_errorsSascha Hauer
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de> Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de> Acked-by: Wolfgang Grandegger <wg@grandegger.com>
2010-10-18can: mcp251x: fix NOHZ local_softirq_pending 08 warningMarc Kleine-Budde
This patch replaces netif_rx() with netif_rx_ni() which has to be used from the threaded interrupt i.e. process context context. Thanks to Christian Pellegrin for pointing at the right fix: 481a8199142c050b72bff8a1956a49fd0a75bbe0 by Oliver Hartkopp. Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de> Acked-by: Wolfgang Grandegger <wg@grandegger.com>
2010-05-10net: trans_start cleanupsEric Dumazet
Now that core network takes care of trans_start updates, dont do it in drivers themselves, if possible. Drivers can avoid one cache miss (on dev->trans_start) in their start_xmit() handler. Exceptions are NETIF_F_LLTX drivers Signed-off-by: Eric Dumazet <eric.dumazet@gmail.com> Signed-off-by: David S. Miller <davem@davemloft.net>
2010-04-13Fix some #includes in CAN drivers (rebased for net-next-2.6)Hans J. Koch
In the current implementation, CAN drivers need to #include <linux/can.h> _before_ they #include <linux/can/dev.h>, which is both ugly and unnecessary. Fix this by including <linux/can.h> in <linux/can/dev.h> and remove the #include <linux/can.h> lines from drivers. Signed-off-by: Hans J. Koch <hjk@linutronix.de> Signed-off-by: David S. Miller <davem@davemloft.net>
2010-04-11Merge branch 'master' of ↵David S. Miller
master.kernel.org:/pub/scm/linux/kernel/git/davem/net-2.6 Conflicts: drivers/net/stmmac/stmmac_main.c drivers/net/wireless/wl12xx/wl1271_cmd.c drivers/net/wireless/wl12xx/wl1271_main.c drivers/net/wireless/wl12xx/wl1271_spi.c net/core/ethtool.c net/mac80211/scan.c
2010-03-30Add hotplug support to mcp251x driverMarc Zyngier
Chip model can now be selected directly by matching the modalias name (instead of filling the .model field in platform_data), and allows the module to be auto-loaded. Previous behaviour is of course still supported. Convert the two in-tree users to this feature (icontrol & zeus). Tested on an Zeus platform (mcp2515). Signed-off-by: Marc Zyngier <maz@misterjones.org> Acked-by: Christian Pellegrin <chripell@fsfe.org> Cc: Edwin Peer <epeer@tmtservices.co.za> Acked-by: Wolfgang Grandegger <wg@grandegger.com> Signed-off-by: David S. Miller <davem@davemloft.net>
2010-03-30include cleanup: Update gfp.h and slab.h includes to prepare for breaking ↵Tejun Heo
implicit slab.h inclusion from percpu.h percpu.h is included by sched.h and module.h and thus ends up being included when building most .c files. percpu.h includes slab.h which in turn includes gfp.h making everything defined by the two files universally available and complicating inclusion dependencies. percpu.h -> slab.h dependency is about to be removed. Prepare for this change by updating users of gfp and slab facilities include those headers directly instead of assuming availability. As this conversion needs to touch large number of source files, the following script is used as the basis of conversion. http://userweb.kernel.org/~tj/misc/slabh-sweep.py The script does the followings. * Scan files for gfp and slab usages and update includes such that only the necessary includes are there. ie. if only gfp is used, gfp.h, if slab is used, slab.h. * When the script inserts a new include, it looks at the include blocks and try to put the new include such that its order conforms to its surrounding. It's put in the include block which contains core kernel includes, in the same order that the rest are ordered - alphabetical, Christmas tree, rev-Xmas-tree or at the end if there doesn't seem to be any matching order. * If the script can't find a place to put a new include (mostly because the file doesn't have fitting include block), it prints out an error message indicating which .h file needs to be added to the file. The conversion was done in the following steps. 1. The initial automatic conversion of all .c files updated slightly over 4000 files, deleting around 700 includes and adding ~480 gfp.h and ~3000 slab.h inclusions. The script emitted errors for ~400 files. 2. Each error was manually checked. Some didn't need the inclusion, some needed manual addition while adding it to implementation .h or embedding .c file was more appropriate for others. This step added inclusions to around 150 files. 3. The script was run again and the output was compared to the edits from #2 to make sure no file was left behind. 4. Several build tests were done and a couple of problems were fixed. e.g. lib/decompress_*.c used malloc/free() wrappers around slab APIs requiring slab.h to be added manually. 5. The script was run on all .h files but without automatically editing them as sprinkling gfp.h and slab.h inclusions around .h files could easily lead to inclusion dependency hell. Most gfp.h inclusion directives were ignored as stuff from gfp.h was usually wildly available and often used in preprocessor macros. Each slab.h inclusion directive was examined and added manually as necessary. 6. percpu.h was updated not to include slab.h. 7. Build test were done on the following configurations and failures were fixed. CONFIG_GCOV_KERNEL was turned off for all tests (as my distributed build env didn't work with gcov compiles) and a few more options had to be turned off depending on archs to make things build (like ipr on powerpc/64 which failed due to missing writeq). * x86 and x86_64 UP and SMP allmodconfig and a custom test config. * powerpc and powerpc64 SMP allmodconfig * sparc and sparc64 SMP allmodconfig * ia64 SMP allmodconfig * s390 SMP allmodconfig * alpha SMP allmodconfig * um on x86_64 SMP allmodconfig 8. percpu.h modifications were reverted so that it could be applied as a separate patch and serve as bisection point. Given the fact that I had only a couple of failures from tests on step 6, I'm fairly confident about the coverage of this conversion patch. If there is a breakage, it's likely to be something in one of the arch headers which should be easily discoverable easily on most builds of the specific arch. Signed-off-by: Tejun Heo <tj@kernel.org> Guess-its-ok-by: Christoph Lameter <cl@linux-foundation.org> Cc: Ingo Molnar <mingo@redhat.com> Cc: Lee Schermerhorn <Lee.Schermerhorn@hp.com>
2010-02-03can: mcp251x: Move to threaded interrupts instead of workqueues.Christian Pellegrin
This patch addresses concerns about efficiency of handling incoming packets. Handling of interrupts is done in a threaded interrupt handler which has a smaller latency than workqueues. This change needed a rework of the locking scheme that was much simplified. Some other (more or less longstanding) bugs are fixed: utilization of just half of the RX buffers, useless wait for interrupt on open, more reliable reset sequence. The MERR interrupt is not used anymore: it overloads the CPU in error-passive state without any additional information. One shot mode is disabled because it's not clear if it can be handled efficiently on this CAN controller. Signed-off-by: Christian Pellegrin <chripell@fsfe.org> Acked-by: Wolfgang Grandegger <wg@grandegger.com> Signed-off-by: David S. Miller <davem@davemloft.net>
2010-01-15can: Proper ctrlmode handling for CAN devicesChristian Pellegrin
This patch adds error checking of ctrlmode values for CAN devices. As an example all availabe bits are implemented in the mcp251x driver. Signed-off-by: Christian Pellegrin <chripell@fsfe.org> Acked-by: Wolfgang Grandegger <wg@grandegger.com> Signed-off-by: David S. Miller <davem@davemloft.net>
2010-01-12can: Unify droping of invalid tx skbs and netdev statsOliver Hartkopp
To prevent the CAN drivers to operate on invalid socketbuffers the skbs are now checked and silently dropped at the xmit-function consistently. Also the netdev stats are consistently using the CAN data length code (dlc) for [rx|tx]_bytes now. Signed-off-by: Oliver Hartkopp <oliver@hartkopp.net> Acked-by: Wolfgang Grandegger <wg@grandegger.com> Signed-off-by: David S. Miller <davem@davemloft.net>
2010-01-03drivers/net/can: Correct NULL testJulia Lawall
Test the just-allocated value for NULL rather than some other value. The semantic patch that makes this change is as follows: (http://coccinelle.lip6.fr/) // <smpl> @@ expression x,y; statement S; @@ x = \(kmalloc\|kcalloc\|kzalloc\)(...); ( if ((x) == NULL) S | if ( - y + x == NULL) S ) // </smpl> Signed-off-by: Julia Lawall <julia@diku.dk> Acked-by: Oliver Hartkopp <oliver@hartkopp.net> Signed-off-by: David S. Miller <davem@davemloft.net>
2009-12-13can: Fix data length code handling in rx pathOliver Hartkopp
A valid CAN dataframe can have a data length code (DLC) of 0 .. 8 data bytes. When reading the CAN controllers register the 4-bit value may contain values from 0 .. 15 which may exceed the reserved space in the socket buffer! The ISO 11898-1 Chapter 8.4.2.3 (DLC field) says that register values > 8 should be reduced to 8 without any error reporting or frame drop. This patch introduces a new helper macro to cast a given 4-bit data length code (dlc) to __u8 and ensure the DLC value to be max. 8 bytes. The different handlings in the rx path of the CAN netdevice drivers are fixed. Signed-off-by: Oliver Hartkopp <oliver@hartkopp.net> Signed-off-by: Wolfgang Grandegger <wg@grandegger.com> Signed-off-by: David S. Miller <davem@davemloft.net>
2009-11-18can: fix setting mcp251x bit timing on openChristian Pellegrin
Signed-off-by: Christian Pellegrin <chripell@fsfe.org> Signed-off-by: Wolfgang Grandegger <wg@grandegger.com> Signed-off-by: David S. Miller <davem@davemloft.net>
2009-11-08can: Driver for the Microchip MCP251x SPI CAN controllersChristian Pellegrin
Signed-off-by: Christian Pellegrin <chripell@fsfe.org> Signed-off-by: Wolfgang Grandegger <wg@grandegger.com> Signed-off-by: David S. Miller <davem@davemloft.net>