History log of /drivers/net/can/at91_can.c
Revision Date Author Comments
e77980e50bc2850599d4d9c0192b67a9ffd6daac 17-Sep-2014 David Dueck <davidcdueck@googlemail.com> can: at91_can: add missing prepare and unprepare of the clock

In order to make the driver work with the common clock framework, this patch
converts the clk_enable()/clk_disable() to
clk_prepare_enable()/clk_disable_unprepare(). While there, add the missing
error handling.

Signed-off-by: David Dueck <davidcdueck@googlemail.com>
Signed-off-by: Anthony Harivel <anthony.harivel@emtrion.de>
Acked-by: Boris Brezillon <boris.brezillon@free-electrons.com>
Cc: linux-stable <stable@vger.kernel.org>
Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
c971fa2ae42e73e9ccc2f5e93f268c8742da4c5d 07-Mar-2014 Oliver Hartkopp <socketcan@hartkopp.net> can: Unify MTU settings for CAN interfaces

CAN interfaces only support MTU values of 16 (CAN 2.0) and 72 (CAN FD).
Setting the MTU to other values is pointless but it does not really hurt.
With the introduction of the CAN FD support in drivers/net/can a new
function to switch the MTU for CAN FD has been introduced.

This patch makes use of this can_change_mtu() function to check for correct
MTU settings also in legacy CAN (2.0) devices.

Signed-off-by: Oliver Hartkopp <socketcan@hartkopp.net>
Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
17a50ee4bd47bdba94546e0526fc9ce93dc77d5e 11-Feb-2014 Yoann DI RUZZA <ydiruzza@gmail.com> can: at91_can: add listen only mode

This patch adds listen only mode support to the at91_can driver.

Signed-off-by: Yoann DI-RUZZA <ydiruzza@gmail.com>
Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
a81ab36bf52d0ca3a32251a923be1dbced726141 08-Jan-2014 Paul Gortmaker <paul.gortmaker@windriver.com> drivers/net: delete non-required instances of include <linux/init.h>

None of these files are actually using any __init type directives
and hence don't need to include <linux/init.h>. Most are just a
left over from __devinit and __cpuinit removal, or simply due to
code getting copied from one driver to the next.

This covers everything under drivers/net except for wireless, which
has been submitted separately.

Signed-off-by: Paul Gortmaker <paul.gortmaker@windriver.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
5abbeea553c8260ed4e2ac4aae962aff800b6c6d 09-Oct-2013 Marc Kleine-Budde <mkl@pengutronix.de> can: at91-can: fix device to driver data mapping for platform devices

In commit:

3078cde7 can: at91_can: add dt support

device tree support was added to the at91_can driver. In this commit the
mapping of device to driver data was mixed up. This results in the sam9x5
parameters being used for the sam9263 and the workaround for the broken mailbox
0 on the sam9263 not being activated.

This patch fixes the broken platform_device_id table.

Cc: linux-stable <stable@vger.kernel.org>
Cc: Ludovic Desroches <ludovic.desroches@atmel.com>
Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
6cbdb91821afecc05dfd591f26c8e247b8e6ac56 10-Sep-2013 Jingoo Han <jg1.han@samsung.com> can: at91_can: use dev_get_platdata()

Use the wrapper function for retrieving the platform data instead of
accessing dev->platform_data directly. This is a cosmetic change
to make the code simpler and enhance the readability.

Signed-off-by: Jingoo Han <jg1.han@samsung.com>
Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
40f7e0dd05f1902c05ae4e4e8cba4a24c3f47c3a 21-Aug-2013 Libo Chen <libo.chen@huawei.com> can: at91_can: use platform_set_drvdata()

Use the wrapper functions for getting and setting the driver data using
platform_device instead of using dev_set_drvdata() with &pdev->dev,
so we can directly pass a struct platform_device.

Signed-off-by: Libo Chen <libo.chen@huawei.com>
Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
1f3e4b0cc4deb9d740261273fbbf5ea95c8434d0 12-Jun-2013 Sachin Kamat <sachin.kamat@linaro.org> can: at91_can: Use of_match_ptr()

of_match_ptr() eliminates having an #ifdef returning NULL for the case
when OF is disabled.

Signed-off-by: Sachin Kamat <sachin.kamat@linaro.org>
Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
0672f0ab57dc71958542ac41e5a7ccb6a382a8f3 31-May-2013 Jingoo Han <jg1.han@samsung.com> net: can: replace strict_strtoul() with kstrtoul()

The usage of strict_strtoul() is not preferred, because
strict_strtoul() is obsolete. Thus, kstrtoul() should be
used.

Signed-off-by: Jingoo Han <jg1.han@samsung.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
3e1dd6da1a7af98a795fafa9437679767c605a7b 07-May-2013 Jingoo Han <jg1.han@samsung.com> net: can: at91_can: remove unnecessary platform_set_drvdata()

The driver core clears the driver data to NULL after device_release
or on probe failure, since commit 0998d0631001288a5974afc0b2a5f568bcdecb4d
(device-core: Ensure drvdata = NULL when no driver is bound).
Thus, it is not needed to manually clear the device driver data to NULL.

Signed-off-by: Jingoo Han <jg1.han@samsung.com>
Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
3078cde792340280b761a0f46f99799a78f4395d 11-Mar-2013 Ludovic Desroches <ludovic.desroches@atmel.com> can: at91_can: add dt support

Add device tree support.

Signed-off-by: Ludovic Desroches <ludovic.desroches@atmel.com>
Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
4723f2b8a12b6170e1835082d8c73fa932306846 18-Dec-2012 Fabio Baltieri <fabio.baltieri@gmail.com> can: at91_can: add LED trigger support

Add support for canbus activity led indicators on at91_can devices by
calling appropriate can_led functions.

These are only enabled when CONFIG_CAN_LEDS is Y, becomes no-op
otherwise.

Cc: Wolfgang Grandegger <wg@grandegger.com>
Cc: Marc Kleine-Budde <mkl@pengutronix.de>
Signed-off-by: Fabio Baltieri <fabio.baltieri@gmail.com>
Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
3c8ac0f2ad53a96ac58efe7c98fac2986d081dfc 03-Dec-2012 Bill Pemberton <wfp5p@virginia.edu> can: remove __dev* attributes

CONFIG_HOTPLUG is going away as an option. As result the __dev*
markings will be going away.

Remove use of __devinit, __devexit_p, __devinitdata, __devinitconst,
and __devexit.

Signed-off-by: Bill Pemberton <wfp5p@virginia.edu>
Cc: Wolfgang Grandegger <wg@grandegger.com>
Cc: Marc Kleine-Budde <mkl@pengutronix.de>
Cc: linux-can@vger.kernel.org
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
09ca71cae2df6c8426ed3347f4de591812d92e2d 12-Oct-2012 Marc Kleine-Budde <mkl@pengutronix.de> can: at91_can: add MODULE_DEVICE_TABLE

This patch adds a MODULE_DEVICE_TABLE for the platform bindings, so that the
module can be loaded automatically by udev.

Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
bcd2360c1ff9fff69eb45bedc5fba7240c6da875 29-Oct-2012 Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com> arm: at91: move platfarm_data to include/linux/platform_data/atmel.h

Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com>
Cc: Nicolas Ferre <nicolas.ferre@atmel.com>
194b9a4cb91713ddb60c9f98f7212f6d8cb8e05f 16-Jul-2012 Marc Kleine-Budde <mkl@pengutronix.de> can: mark bittiming_const pointer in struct can_priv as const

This patch marks the bittiming_const pointer as in the struct can_pric as
"const". This allows us to mark the struct can_bittiming_const in the CAN
drivers as "const", too.

Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
871d33725545ca2e402b4526f38f89d041ba930f 27-Nov-2011 Axel Lin <axel.lin@gmail.com> net/can: convert drivers/net/can/* to use module_platform_driver()

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>
f861c2b80c45954e1ea04ead24cafcb1806dd536 17-Oct-2011 Marc Kleine-Budde <mkl@pengutronix.de> can: remove references to berlios mailinglist

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>
6388b39614208d63661607f45157e3326548eb62 17-Apr-2011 Marc Kleine-Budde <mkl@pengutronix.de> can: at91_can: add support for the AT91SAM9X5 SOCs

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>
07a648e668aa7f7c94d41d8d2e4ad53b609e391d 01-Jun-2011 Marc Kleine-Budde <mkl@pengutronix.de> can: at91_can: register mb0 sysfs entry only on at91sam9263

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>
d3d47264a364aa3adcbb485471dbf9f693fb4216 03-May-2011 Marc Kleine-Budde <mkl@pengutronix.de> can: at91_can: add id_table and convert prime mailbox constats to functions

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>
79008997e232ad1d871bb6fedfb7fbd77ea95af8 03-May-2011 Marc Kleine-Budde <mkl@pengutronix.de> can: at91_can: convert derived mailbox constants into functions

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>
b049994d0f3a19c1706627117a7269ce5bd335ab 03-May-2011 Marc Kleine-Budde <mkl@pengutronix.de> can: at91_can: rename AT91_MB_RX_MASK to AT91_IRQ_MB_RX

... 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>
267cbe047cb4f6a3a6337029fc60862be1cf437d 30-Apr-2011 Marc Kleine-Budde <mkl@pengutronix.de> can: at91_can: directly define AT91_MB_RX_LAST

...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>
9c2e0a6d2f7b7c76e0cbc42a8da99fd732f0fdfa 03-May-2011 Marc Kleine-Budde <mkl@pengutronix.de> can: at91_can: let get_tx_* functions return unsigned int

Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
e14ee40bece891b5edccdd514112999ec423a448 21-Oct-2010 Marc Kleine-Budde <mkl@pengutronix.de> can: at91_can: don't copy data to rx'ed RTR frames

Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
Acked-by: Wolfgang Grandegger <wg@grandegger.com>
5613fff2dc315e5f44623031cb62a29942548427 16-Apr-2011 Marc Kleine-Budde <mkl@pengutronix.de> can: at91_can: fix comment about priv->tx_next

Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
44d856665789288859b7aa47ca25933c1c6ab57d 30-Jan-2011 Marc Kleine-Budde <mkl@pengutronix.de> can: at91_can: don't align struct definitions

Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
25985edcedea6396277003854657b5f3cb31a628 31-Mar-2011 Lucas De Marchi <lucas.demarchi@profusion.mobi> Fix common misspellings

Fixes generated by 'codespell' and manually reviewed.

Signed-off-by: Lucas De Marchi <lucas.demarchi@profusion.mobi>
fef52b0171dfd7dd9b85c9cc201bd433b42a8ded 04-Feb-2011 Vasiliy Kulikov <segoon@openwall.com> net: can: at91_can: world-writable sysfs files

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>
3a5655a5b545e9647c3437473ee3d815fe1b9050 10-Jan-2011 Marc Kleine-Budde <mkl@pengutronix.de> can: at91_can: make can_id of mailbox 0 configurable

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>
9e0a2d1ca3de6e284e99ad5cae1ae33ecb74c479 09-Jan-2011 Marc Kleine-Budde <mkl@pengutronix.de> can: at91_can: don't use mailbox 0

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>
0909c1ec6f016b3f580fa2f4630659a5874a8ef8 06-Jan-2011 Marc Kleine-Budde <mkl@pengutronix.de> can: at91_can: clean up usage of AT91_MB_RX_FIRST and AT91_MB_RX_NUM

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>
3e9ebd3cf48d9181e0931c6fd8f1a7dc4d6cb27c 29-Oct-2010 Hans J. Koch <hjk@hansjkoch.de> netdev: can: Change mail address of Hans 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>
00389b0820c44cceec3f6981cb4d217982ec73b2 21-Oct-2010 Marc Kleine-Budde <mkl@pengutronix.de> can: at91_can: add KBUILD_MODNAME to bittiming constant

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>
882055c8387e85cb380ab152b96ff69b570d8989 21-Oct-2010 Marc Kleine-Budde <mkl@pengutronix.de> can: at91_can: convert dev_<level> printing to netdev_<level>

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>
7672fe7373c7b871220093e568610ac95e96de35 21-Oct-2010 Marc Kleine-Budde <mkl@pengutronix.de> can: at91_can: convert readl, writel their __raw pendants

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>
b156fd0483c8f18b3cc544d9c400fe454458e16a 21-Oct-2010 Marc Kleine-Budde <mkl@pengutronix.de> can: at91_can: set bittiming in chip_start

Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
Signed-off-by: David S. Miller <davem@davemloft.net>
33a6f298c28a65fa643bc70222ebffe75077f197 21-Oct-2010 Marc Kleine-Budde <mkl@pengutronix.de> can: at91_can: implement and use at91_get_berr_counter

Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
Signed-off-by: David S. Miller <davem@davemloft.net>
a9d992ecb36f8ed00130eaf41a406fda03433d23 21-Oct-2010 Marc Kleine-Budde <mkl@pengutronix.de> can: at91_can: fix section mismatch warning

...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>
b61f674051e58b394454602d492d5e3e3471facc 21-Oct-2010 Marc Kleine-Budde <mkl@pengutronix.de> can: at91_can: fix compiler warning in at91_irq_err_state

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>
759a6c768dcdbbb4d3f1fb965b674c15773e09ca 21-Oct-2010 Marc Kleine-Budde <mkl@pengutronix.de> can: at91_can: fix use after free of priv

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>
8a0e0a49b0a917c8c8dce6f7121ec73a5c8e3932 21-Oct-2010 Marc Kleine-Budde <mkl@pengutronix.de> can: at91_can: fix reception of extended frames

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>
dbe91325c2d6ad34c1ce4f2aeae4bbd11b7a3fff 21-Oct-2010 Marc Kleine-Budde <mkl@pengutronix.de> can: at91_can: use correct bit to enable CAN_CTRLMODE_3_SAMPLES

Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
Signed-off-by: David S. Miller <davem@davemloft.net>
1ae5dc342ac78d7a42965fd1f323815f6f5ef2c1 10-May-2010 Eric Dumazet <eric.dumazet@gmail.com> net: trans_start cleanups

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>
127aa0e14b3e1f8476c4781facdfac11d5546872 11-Apr-2010 Eric Dumazet <eric.dumazet@gmail.com> drivers: net: last_rx elimination

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>
829e0015431537176e38812f88fffe1d3250083e 13-Apr-2010 Hans J. Koch <hjk@linutronix.de> Fix some #includes in CAN drivers (rebased for net-next-2.6)

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>
ad72c347e56bf3a0231b9d686e17764157d2961c 14-Jan-2010 Christian Pellegrin <chripell@fsfe.org> can: Proper ctrlmode handling for CAN devices

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>
3ccd4c6167d3b39d52631767ebbf8b5677c5855d 12-Jan-2010 Oliver Hartkopp <oliver@hartkopp.net> can: Unify droping of invalid tx skbs and netdev stats

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>
4773a47d8a564633cd80b94df397e91e946893e2 19-Dec-2009 Uwe Kleine-König <u.kleine-koenig@pengutronix.de> can/at91: don't check platform_get_irq's return value against zero

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>
c7cd606f60e7679c7f9eee7010f02a6f000209c1 12-Dec-2009 Oliver Hartkopp <oliver@hartkopp.net> can: Fix data length code handling in rx path

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>
7b6856a0296a8f187bb88ba31fa83a08abba7966 20-Oct-2009 Wolfgang Grandegger <wg@grandegger.com> can: provide library functions for skb allocation

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>
a6e4bc5304033e434fabccabb230b8e9ff55d76f 09-Oct-2009 Wolfgang Grandegger <wg@grandegger.com> can: make the number of echo skb's configurable

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>
99c4a6344f6574c97019ac16e8d54bfe5ad21f2d 25-Sep-2009 David S. Miller <davem@davemloft.net> at91_can: Forgotten git 'add' of at91_can.c

Signed-off-by: David S. Miller <davem@davemloft.net>