summaryrefslogtreecommitdiff
path: root/drivers/net/can/at91_can.c
AgeCommit message (Collapse)Author
2011-11-29net/can: convert drivers/net/can/* to use module_platform_driver()Axel Lin
This patch converts the drivers in drivers/net/can/* to use the module_platform_driver() macro which makes the code smaller and a bit simpler. Cc: Wolfgang Grandegger <wg@grandegger.com> Cc: "David S. Miller" <davem@davemloft.net> Cc: Bhupesh Sharma <bhupesh.sharma@st.com> Cc: Jiri Kosina <jkosina@suse.cz> Cc: Grant Likely <grant.likely@secretlab.ca> Cc: Anatolij Gustschin <agust@denx.de> Cc: Paul Bolle <pebolle@tiscali.nl> Cc: Kurt Van Dijck <kurt.van.dijck@eia.be> Cc: Alexey Dobriyan <adobriyan@gmail.com> Signed-off-by: Axel Lin <axel.lin@gmail.com> Acked-by: Marc Kleine-Budde <mkl@pengutronix.de> Signed-off-by: David S. Miller <davem@davemloft.net>
2011-10-17can: remove references to berlios mailinglistMarc Kleine-Budde
The BerliOS project, which currently hosts our mailinglist, will close with the end of the year. Now take the chance and remove all occurrences of the mailinglist address from the source files. Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de> Signed-off-by: David S. Miller <davem@davemloft.net>
2011-06-06can: at91_can: add support for the AT91SAM9X5 SOCsMarc Kleine-Budde
The AT91SAM9X5 SOCs have a similar CAN core, but they only have 8 compared to 16 mailboxes on the AT91SAM9263 SOC. Another difference is that the bits defining the state of the CAN core are cleared on read, thus the driver has to derive the state by looking at the error counters. Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
2011-06-06can: at91_can: register mb0 sysfs entry only on at91sam9263Marc Kleine-Budde
This patch prepares the driver for the at91sam9X5 processors, which don't have the mb0 bug. (See commit 3a5655a5b545e9647c3437473ee3d815fe1b9050 for more details.) Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
2011-06-06can: at91_can: add id_table and convert prime mailbox constats to functionsMarc Kleine-Budde
This is the second of two patches converting the at91_can driver from a compile time mailbox setup to a dynamic one. This patch first adds a id_table to the platform driver. Depending on the driver_data the constants for the mailbox setup is selected. Then all remaining prime mailbox constants are converted to functions, using the run time selected mailbox constants. Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
2011-06-06can: at91_can: convert derived mailbox constants into functionsMarc Kleine-Budde
This is the first of two patches converting the at91_can driver from a compile time mailbox setup to a dynamic one. This patch converts all derived mailbox constants to functions. Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
2011-06-06can: at91_can: rename AT91_MB_RX_MASK to AT91_IRQ_MB_RXMarc Kleine-Budde
... and use it for AT91_NEXT_MB_MASK, AT91_IRQ_MB_RX and AT91_IRQ_MB_RX, too. Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
2011-06-06can: at91_can: directly define AT91_MB_RX_LASTMarc Kleine-Budde
...instead of deriving it from AT91_MB_RX_FIRST and AT91_MB_RX_NUM. This removes a level of computation, when switching the driver from compile time constants to runtime values. Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
2011-06-06can: at91_can: let get_tx_* functions return unsigned intMarc Kleine-Budde
Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
2011-06-06can: at91_can: don't copy data to rx'ed RTR framesMarc Kleine-Budde
Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de> Acked-by: Wolfgang Grandegger <wg@grandegger.com>
2011-06-06can: at91_can: fix comment about priv->tx_nextMarc Kleine-Budde
Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
2011-06-06can: at91_can: don't align struct definitionsMarc Kleine-Budde
Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
2011-03-31Fix common misspellingsLucas De Marchi
Fixes generated by 'codespell' and manually reviewed. Signed-off-by: Lucas De Marchi <lucas.demarchi@profusion.mobi>
2011-02-04net: can: at91_can: world-writable sysfs filesVasiliy Kulikov
Don't allow everybody to write to mb0_id file. Signed-off-by: Vasiliy Kulikov <segoon@openwall.com> Acked-by: Kurt Van Dijck <kurt.van.dijck@eia.be> Signed-off-by: David S. Miller <davem@davemloft.net>
2011-01-24can: at91_can: make can_id of mailbox 0 configurableMarc Kleine-Budde
Due to a chip bug (errata 50.2.6.3 & 50.3.5.3 in "AT91SAM9263 Preliminary 6249H-ATARM-27-Jul-09") the contents of mailbox 0 may be send under certain conditions (even if disabled or in rx mode). The workaround in the errata suggests not to use the mailbox and load it with an unused identifier. This patch implements the second part of the workaround. A sysfs entry "mb0_id" is introduced. While the interface is down it can be used to configure the can_id of mailbox 0. The default value id 0x7ff. In order to use an extended can_id add the CAN_EFF_FLAG (0x80000000U) to the can_id. Example: - standard id 0x7ff: echo 0x7ff > /sys/class/net/can0/mb0_id - extended id 0x1fffffff: echo 0x9fffffff > /sys/class/net/can0/mb0_id Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de> Acked-by: Wolfgang Grandegger <wg@grandegger.com> Acked-by: Kurt Van Dijck <kurt.van.dijck@eia.be> For the Documentation-part: Acked-by: Wolfram Sang <w.sang@pengutronix.de>
2011-01-24can: at91_can: don't use mailbox 0Marc Kleine-Budde
Due to a chip bug (errata 50.2.6.3 & 50.3.5.3 in "AT91SAM9263 Preliminary 6249H-ATARM-27-Jul-09") the contents of mailbox 0 may be send under certain conditions (even if disabled or in rx mode). The workaround in the errata suggests not to use the mailbox and load it with a unused identifier. This patch implements the first part of the workaround, it updates AT91_MB_RX_NUM and AT91_MB_RX_FIRST (and the inline documentation) so that mailbox 0 stays unused. Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de> Acked-by: Wolfgang Grandegger <wg@grandegger.com> Acked-by: Kurt Van Dijck <kurt.van.dijck@eia.be>
2011-01-24can: at91_can: clean up usage of AT91_MB_RX_FIRST and AT91_MB_RX_NUMMarc Kleine-Budde
This patch cleans up the usage of two macros which specify the mailbox usage. AT91_MB_RX_FIRST and AT91_MB_RX_NUM define the first and the number of RX mailboxes. The current driver uses these variables in an unclean way; assuming that AT91_MB_RX_FIRST is 0; This patch cleans up the usage of these macros, no longer assuming AT91_MB_RX_FIRST == 0. Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de> Acked-by: Wolfgang Grandegger <wg@grandegger.com>
2010-10-30netdev: can: Change mail address of Hans J. KochHans J. Koch
My old mail address doesn't exist anymore. This changes all occurrences to my new address. Signed-off-by: Hans J. Koch <hjk@hansjkoch.de> Signed-off-by: David S. Miller <davem@davemloft.net>
2010-10-24can: at91_can: add KBUILD_MODNAME to bittiming constantMarc Kleine-Budde
While there replace all usage of self defined DRV_NAME by KBUILD_MODNAME. Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de> Signed-off-by: David S. Miller <davem@davemloft.net>
2010-10-24can: at91_can: convert dev_<level> printing to netdev_<level>Marc Kleine-Budde
While there, remove "printk()" on driver loading. Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de> Signed-off-by: David S. Miller <davem@davemloft.net>
2010-10-24can: at91_can: convert readl, writel their __raw pendantsMarc Kleine-Budde
Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de> Cc: Russell King <rmk@arm.linux.org.uk> Signed-off-by: David S. Miller <davem@davemloft.net>
2010-10-24can: at91_can: set bittiming in chip_startMarc Kleine-Budde
Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de> Signed-off-by: David S. Miller <davem@davemloft.net>
2010-10-24can: at91_can: implement and use at91_get_berr_counterMarc Kleine-Budde
Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de> Signed-off-by: David S. Miller <davem@davemloft.net>
2010-10-24can: at91_can: fix section mismatch warningMarc Kleine-Budde
...by adding the correct annotation "__devinit" to the driver's probe function. Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de> Acked-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de> Signed-off-by: David S. Miller <davem@davemloft.net>
2010-10-24can: at91_can: fix compiler warning in at91_irq_err_stateMarc Kleine-Budde
This patch fixes the following compiler warning: drivers/net/can/at91_can.c: In function 'at91_irq_err_state': drivers/net/can/at91_can.c:779: warning: 'reg_ier' may be used uninitialized in this function drivers/net/can/at91_can.c:779: warning: 'reg_idr' may be used uninitialized in this function Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de> Signed-off-by: David S. Miller <davem@davemloft.net>
2010-10-24can: at91_can: fix use after free of privMarc Kleine-Budde
The priv is part of the memory allocated by alloc_candev(). This patch moved the free it after last usage of priv. While there convert all free_netdev() to free_candev() (which is currently just a wrapper around free_netdev()) to be symetrically with the allocation via alloc_candev(). Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de> Signed-off-by: David S. Miller <davem@davemloft.net>
2010-10-24can: at91_can: fix reception of extended framesMarc Kleine-Budde
The AT91_MID_MIDE bit must be set in order to receive extended frames. The reception of an extended frame sets this bit, while reception of standard frames resets it. This results in some lost extended frames in an extended ID only environment. But leads to unpredictable lost extended ID frames in a mixed environment. The problem is fixed by setting the AT91_MID_MIDE after reception of a CAN frame. Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de> Signed-off-by: David S. Miller <davem@davemloft.net>
2010-10-24can: at91_can: use correct bit to enable CAN_CTRLMODE_3_SAMPLESMarc Kleine-Budde
Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de> Signed-off-by: David S. Miller <davem@davemloft.net>
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-13drivers: net: last_rx eliminationEric Dumazet
Network drivers do not have to update last_rx, unless they need it for their private use. 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-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>
2009-12-18can/at91: don't check platform_get_irq's return value against zeroUwe Kleine-König
platform_get_irq returns -ENXIO on failure, so !irq was probably always true. Better use (int)irq <= 0. Note that a return value of zero is still handled as error even though this could mean irq0. This is a followup to 305b3228f9ff4d59f49e6d34a7034d44ee8ce2f0 that changed the return value of platform_get_irq from 0 to -ENXIO on error. Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de> Signed-off-by: Wolfgang Grandegger <wg@grandegger.com> 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-10-20can: provide library functions for skb allocationWolfgang Grandegger
This patch makes the private functions alloc_can_skb() and alloc_can_err_skb() of the at91_can driver public and adapts all drivers to use these. While making the patch I realized, that the skb's are *not* setup consistently. It's now done as shown below: skb->protocol = htons(ETH_P_CAN); skb->pkt_type = PACKET_BROADCAST; skb->ip_summed = CHECKSUM_UNNECESSARY; *cf = (struct can_frame *)skb_put(skb, sizeof(struct can_frame)); memset(*cf, 0, sizeof(struct can_frame)); The frame is zeroed out to avoid uninitialized data to be passed to user space. Some drivers or library code did not set "pkt_type" or "ip_summed". Also, "__constant_htons()" should not be used for runtime invocations, as pointed out by David Miller. Signed-off-by: Wolfgang Grandegger <wg@grandegger.com> Signed-off-by: David S. Miller <davem@davemloft.net>
2009-10-13can: make the number of echo skb's configurableWolfgang Grandegger
This patch allows the CAN controller driver to define the number of echo skb's used for the local loopback (echo), as suggested by Kurt Van Dijck, with the function: struct net_device *alloc_candev(int sizeof_priv, unsigned int echo_skb_max); The CAN drivers have been adapted accordingly. For the ems_usb driver, as suggested by Sebastian Haas, the number of echo skb's has been increased to 10, which improves the transmission performance a lot. Signed-off-by: Wolfgang Grandegger <wg@grandegger.com> Signed-off-by: Kurt Van Dijck <kurt.van.dijck@eia.be> Signed-off-by: David S. Miller <davem@davemloft.net>
2009-09-25at91_can: Forgotten git 'add' of at91_can.cDavid S. Miller
Signed-off-by: David S. Miller <davem@davemloft.net>