Skip to content

Commit

Permalink
Merge branch 'for-davem' of git://gitorious.org/linux-can/linux-can-next
Browse files Browse the repository at this point in the history
Marc Kleine-Budde says:

====================
this is a pull-request for net-next/master. There is are 9 patches by
Fabio Baltieri and Kurt Van Dijck which add LED infrastructure and
support for CAN devices. Bernd Krumboeck adds a driver for the USB CAN
adapter from 8 devices. Oliver Hartkopp improves the CAN gateway
functionality. There are 4 patches by me, which clean up the CAN's
Kconfig.
====================

Signed-off-by: David S. Miller <davem@davemloft.net>
  • Loading branch information
David S. Miller committed Jan 28, 2013
2 parents 0e36cbb + e6afa00 commit 6155002
Show file tree
Hide file tree
Showing 27 changed files with 1,488 additions and 60 deletions.
37 changes: 23 additions & 14 deletions drivers/net/can/Kconfig
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
menu "CAN Device Drivers"
depends on CAN

config CAN_VCAN
tristate "Virtual Local CAN Interface (vcan)"
depends on CAN
---help---
Similar to the network loopback devices, vcan offers a
virtual local CAN interface.
Expand All @@ -13,7 +11,6 @@ config CAN_VCAN

config CAN_SLCAN
tristate "Serial / USB serial CAN Adaptors (slcan)"
depends on CAN
---help---
CAN driver for several 'low cost' CAN interfaces that are attached
via serial lines or via USB-to-serial adapters using the LAWICEL
Expand All @@ -33,16 +30,16 @@ config CAN_SLCAN

config CAN_DEV
tristate "Platform CAN drivers with Netlink support"
depends on CAN
default y
---help---
Enables the common framework for platform CAN drivers with Netlink
support. This is the standard library for CAN drivers.
If unsure, say Y.

if CAN_DEV

config CAN_CALC_BITTIMING
bool "CAN bit-timing calculation"
depends on CAN_DEV
default y
---help---
If enabled, CAN bit-timing parameters will be calculated for the
Expand All @@ -54,28 +51,39 @@ config CAN_CALC_BITTIMING
arguments "tq", "prop_seg", "phase_seg1", "phase_seg2" and "sjw".
If unsure, say Y.

config CAN_LEDS
bool "Enable LED triggers for Netlink based drivers"
depends on LEDS_CLASS
select LEDS_TRIGGERS
---help---
This option adds two LED triggers for packet receive and transmit
events on each supported CAN device.

Say Y here if you are working on a system with led-class supported
LEDs and you want to use them as canbus activity indicators.

config CAN_AT91
tristate "Atmel AT91 onchip CAN controller"
depends on CAN_DEV && (ARCH_AT91SAM9263 || ARCH_AT91SAM9X5)
depends on ARCH_AT91SAM9263 || ARCH_AT91SAM9X5
---help---
This is a driver for the SoC CAN controller in Atmel's AT91SAM9263
and AT91SAM9X5 processors.

config CAN_TI_HECC
depends on CAN_DEV && ARCH_OMAP3
depends on ARCH_OMAP3
tristate "TI High End CAN Controller"
---help---
Driver for TI HECC (High End CAN Controller) module found on many
TI devices. The device specifications are available from www.ti.com

config CAN_MCP251X
tristate "Microchip MCP251x SPI CAN controllers"
depends on CAN_DEV && SPI && HAS_DMA
depends on SPI && HAS_DMA
---help---
Driver for the Microchip MCP251x SPI CAN controllers.

config CAN_BFIN
depends on CAN_DEV && (BF534 || BF536 || BF537 || BF538 || BF539 || BF54x)
depends on BF534 || BF536 || BF537 || BF538 || BF539 || BF54x
tristate "Analog Devices Blackfin on-chip CAN"
---help---
Driver for the Analog Devices Blackfin on-chip CAN controllers
Expand All @@ -85,7 +93,7 @@ config CAN_BFIN

config CAN_JANZ_ICAN3
tristate "Janz VMOD-ICAN3 Intelligent CAN controller"
depends on CAN_DEV && MFD_JANZ_CMODIO
depends on MFD_JANZ_CMODIO
---help---
Driver for Janz VMOD-ICAN3 Intelligent CAN controller module, which
connects to a MODULbus carrier board.
Expand All @@ -98,21 +106,21 @@ config HAVE_CAN_FLEXCAN

config CAN_FLEXCAN
tristate "Support for Freescale FLEXCAN based chips"
depends on CAN_DEV && HAVE_CAN_FLEXCAN
depends on HAVE_CAN_FLEXCAN
---help---
Say Y here if you want to support for Freescale FlexCAN.

config PCH_CAN
tristate "Intel EG20T PCH CAN controller"
depends on CAN_DEV && PCI
depends on PCI
---help---
This driver is for PCH CAN of Topcliff (Intel EG20T PCH) which
is an IOH for x86 embedded processor (Intel Atom E6xx series).
This driver can access CAN bus.

config CAN_GRCAN
tristate "Aeroflex Gaisler GRCAN and GRHCAN CAN devices"
depends on CAN_DEV && OF
depends on OF
---help---
Say Y here if you want to use Aeroflex Gaisler GRCAN or GRHCAN.
Note that the driver supports little endian, even though little
Expand All @@ -131,9 +139,10 @@ source "drivers/net/can/usb/Kconfig"

source "drivers/net/can/softing/Kconfig"

endif

config CAN_DEBUG_DEVICES
bool "CAN devices debugging messages"
depends on CAN
---help---
Say Y here if you want the CAN device drivers to produce a bunch of
debug messages to the system log. Select this if you are having
Expand Down
2 changes: 2 additions & 0 deletions drivers/net/can/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ obj-$(CONFIG_CAN_SLCAN) += slcan.o
obj-$(CONFIG_CAN_DEV) += can-dev.o
can-dev-y := dev.o

can-dev-$(CONFIG_CAN_LEDS) += led.o

obj-y += usb/
obj-y += softing/

Expand Down
10 changes: 10 additions & 0 deletions drivers/net/can/at91_can.c
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@

#include <linux/can/dev.h>
#include <linux/can/error.h>
#include <linux/can/led.h>

#define AT91_MB_MASK(i) ((1 << (i)) - 1)

Expand Down Expand Up @@ -641,6 +642,8 @@ static void at91_read_msg(struct net_device *dev, unsigned int mb)

stats->rx_packets++;
stats->rx_bytes += cf->can_dlc;

can_led_event(dev, CAN_LED_EVENT_RX);
}

/**
Expand Down Expand Up @@ -875,6 +878,7 @@ static void at91_irq_tx(struct net_device *dev, u32 reg_sr)
/* _NOTE_: subtract AT91_MB_TX_FIRST offset from mb! */
can_get_echo_skb(dev, mb - get_mb_tx_first(priv));
dev->stats.tx_packets++;
can_led_event(dev, CAN_LED_EVENT_TX);
}
}

Expand Down Expand Up @@ -1128,6 +1132,8 @@ static int at91_open(struct net_device *dev)
goto out_close;
}

can_led_event(dev, CAN_LED_EVENT_OPEN);

/* start chip and queuing */
at91_chip_start(dev);
napi_enable(&priv->napi);
Expand Down Expand Up @@ -1159,6 +1165,8 @@ static int at91_close(struct net_device *dev)

close_candev(dev);

can_led_event(dev, CAN_LED_EVENT_STOP);

return 0;
}

Expand Down Expand Up @@ -1321,6 +1329,8 @@ static int at91_can_probe(struct platform_device *pdev)
goto exit_free;
}

devm_can_led_init(dev);

dev_info(&pdev->dev, "device registered (reg_base=%p, irq=%d)\n",
priv->reg_base, dev->irq);

Expand Down
2 changes: 1 addition & 1 deletion drivers/net/can/c_can/Kconfig
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
menuconfig CAN_C_CAN
tristate "Bosch C_CAN/D_CAN devices"
depends on CAN_DEV && HAS_IOMEM
depends on HAS_IOMEM

if CAN_C_CAN

Expand Down
10 changes: 10 additions & 0 deletions drivers/net/can/c_can/c_can.c
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@
#include <linux/can.h>
#include <linux/can/dev.h>
#include <linux/can/error.h>
#include <linux/can/led.h>

#include "c_can.h"

Expand Down Expand Up @@ -477,6 +478,8 @@ static int c_can_read_msg_object(struct net_device *dev, int iface, int ctrl)
stats->rx_packets++;
stats->rx_bytes += frame->can_dlc;

can_led_event(dev, CAN_LED_EVENT_RX);

return 0;
}

Expand Down Expand Up @@ -751,6 +754,7 @@ static void c_can_do_tx(struct net_device *dev)
C_CAN_IFACE(MSGCTRL_REG, 0))
& IF_MCONT_DLC_MASK;
stats->tx_packets++;
can_led_event(dev, CAN_LED_EVENT_TX);
c_can_inval_msg_object(dev, 0, msg_obj_no);
} else {
break;
Expand Down Expand Up @@ -1115,6 +1119,8 @@ static int c_can_open(struct net_device *dev)

napi_enable(&priv->napi);

can_led_event(dev, CAN_LED_EVENT_OPEN);

/* start the c_can controller */
c_can_start(dev);

Expand Down Expand Up @@ -1143,6 +1149,8 @@ static int c_can_close(struct net_device *dev)
c_can_reset_ram(priv, false);
c_can_pm_runtime_put_sync(priv);

can_led_event(dev, CAN_LED_EVENT_STOP);

return 0;
}

Expand Down Expand Up @@ -1268,6 +1276,8 @@ int register_c_can_dev(struct net_device *dev)
err = register_candev(dev);
if (err)
c_can_pm_runtime_disable(priv);
else
devm_can_led_init(dev);

return err;
}
Expand Down
2 changes: 1 addition & 1 deletion drivers/net/can/cc770/Kconfig
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
menuconfig CAN_CC770
tristate "Bosch CC770 and Intel AN82527 devices"
depends on CAN_DEV && HAS_IOMEM
depends on HAS_IOMEM

if CAN_CC770

Expand Down
26 changes: 25 additions & 1 deletion drivers/net/can/dev.c
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,9 @@
#include <linux/if_arp.h>
#include <linux/can.h>
#include <linux/can/dev.h>
#include <linux/can/skb.h>
#include <linux/can/netlink.h>
#include <linux/can/led.h>
#include <net/rtnetlink.h>

#define MOD_DESC "CAN device driver interface"
Expand Down Expand Up @@ -501,13 +503,18 @@ struct sk_buff *alloc_can_skb(struct net_device *dev, struct can_frame **cf)
{
struct sk_buff *skb;

skb = netdev_alloc_skb(dev, sizeof(struct can_frame));
skb = netdev_alloc_skb(dev, sizeof(struct can_skb_priv) +
sizeof(struct can_frame));
if (unlikely(!skb))
return NULL;

skb->protocol = htons(ETH_P_CAN);
skb->pkt_type = PACKET_BROADCAST;
skb->ip_summed = CHECKSUM_UNNECESSARY;

skb_reserve(skb, sizeof(struct can_skb_priv));
((struct can_skb_priv *)(skb->head))->ifindex = dev->ifindex;

*cf = (struct can_frame *)skb_put(skb, sizeof(struct can_frame));
memset(*cf, 0, sizeof(struct can_frame));

Expand Down Expand Up @@ -794,10 +801,25 @@ void unregister_candev(struct net_device *dev)
}
EXPORT_SYMBOL_GPL(unregister_candev);

/*
* Test if a network device is a candev based device
* and return the can_priv* if so.
*/
struct can_priv *safe_candev_priv(struct net_device *dev)
{
if ((dev->type != ARPHRD_CAN) || (dev->rtnl_link_ops != &can_link_ops))
return NULL;

return netdev_priv(dev);
}
EXPORT_SYMBOL_GPL(safe_candev_priv);

static __init int can_dev_init(void)
{
int err;

can_led_notifier_init();

err = rtnl_link_register(&can_link_ops);
if (!err)
printk(KERN_INFO MOD_DESC "\n");
Expand All @@ -809,6 +831,8 @@ module_init(can_dev_init);
static __exit void can_dev_exit(void)
{
rtnl_link_unregister(&can_link_ops);

can_led_notifier_exit();
}
module_exit(can_dev_exit);

Expand Down
11 changes: 11 additions & 0 deletions drivers/net/can/flexcan.c
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
#include <linux/can.h>
#include <linux/can/dev.h>
#include <linux/can/error.h>
#include <linux/can/led.h>
#include <linux/can/platform/flexcan.h>
#include <linux/clk.h>
#include <linux/delay.h>
Expand Down Expand Up @@ -564,6 +565,8 @@ static int flexcan_read_frame(struct net_device *dev)
stats->rx_packets++;
stats->rx_bytes += cf->can_dlc;

can_led_event(dev, CAN_LED_EVENT_RX);

return 1;
}

Expand Down Expand Up @@ -652,6 +655,7 @@ static irqreturn_t flexcan_irq(int irq, void *dev_id)
if (reg_iflag1 & (1 << FLEXCAN_TX_BUF_ID)) {
stats->tx_bytes += can_get_echo_skb(dev, 0);
stats->tx_packets++;
can_led_event(dev, CAN_LED_EVENT_TX);
flexcan_write((1 << FLEXCAN_TX_BUF_ID), &regs->iflag1);
netif_wake_queue(dev);
}
Expand Down Expand Up @@ -865,6 +869,9 @@ static int flexcan_open(struct net_device *dev)
err = flexcan_chip_start(dev);
if (err)
goto out_close;

can_led_event(dev, CAN_LED_EVENT_OPEN);

napi_enable(&priv->napi);
netif_start_queue(dev);

Expand Down Expand Up @@ -893,6 +900,8 @@ static int flexcan_close(struct net_device *dev)

close_candev(dev);

can_led_event(dev, CAN_LED_EVENT_STOP);

return 0;
}

Expand Down Expand Up @@ -1092,6 +1101,8 @@ static int flexcan_probe(struct platform_device *pdev)
goto failed_register;
}

devm_can_led_init(dev);

dev_info(&pdev->dev, "device registered (reg_base=%p, irq=%d)\n",
priv->base, dev->irq);

Expand Down
Loading

0 comments on commit 6155002

Please sign in to comment.