: can-next 2020-09-16
Subsystems (8)
Marc Kleine-Budde
maintainerHello,
during pengutronix annually techweek, I had time to look dig through the linux-can mailinglist and pick up some patches. This will be the next pull request to net-next.
There will be a separate series for flexcan (soonish) and m_can (later).
regards,
Marc
Marc Kleine-Budde
maintainerPATCH 1/37 can: grcan: fix spelling mistake "buss" -> "bus"
From: Colin Ian King <[email protected]>
There is a spelling mistake in a netdev_err error message. Fix it.
--- drivers/net/can/grcan.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/can/grcan.c +1 -1
@@ -726,7 +726,7 @@ static void grcan_err(struct net_device *dev, u32 sources, u32 status) txrx ="on rx " ; stats->rx_errors++; } -netdev_err (dev,"Fatal AHB buss error %s- halting device\n" , +netdev_err (dev,"Fatal AHB bus error %s- halting device\n" , txrx);spin_lock_irqsave (&priv->lock, flags);
Signature · 1 line
2.28.0
Marc Kleine-Budde
maintainerPATCH 2/37 can: flexcan: fix spelling mistake "reserverd" -> "reserved"
In reply to Marc Kleine-BuddeFrom: Alexandre Belloni <[email protected]>
Fix a mistake in a register layout description.
--- drivers/net/can/flexcan.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/can/flexcan.c +1 -1
@@ -230,7 +230,7 @@ struct flexcan_regs {/* FIFO-mode: * MB * 0x080...0x08f 0 RX message buffer -* 0x090...0x0df 1-5 reserverd +* 0x090...0x0df 1-5 reserved * 0x0e0...0x0ff 6-7 8 entry ID table * (mx25, mx28, mx35, mx53) * 0x0e0...0x2df 6-7..37 8..128 entry ID table
Signature · 1 line
2.28.0
Marc Kleine-Budde
maintainerPATCH 3/37 can: include: fix spelling mistakes
In reply to Marc Kleine-BuddeThis patch fixes spelling erros found by "codespell" in the include/linux/can subtree.
--- include/linux/can/core.h | 2 +- include/linux/can/dev.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-)
include/linux/can/core.h +1 -1
@@ -2,7 +2,7 @@/* * linux/can/core.h * -* Protoypes and definitions for CAN protocol modules using the PF_CAN core +* Prototypes and definitions for CAN protocol modules using the PF_CAN core * * Authors: Oliver Hartkopp <[email protected]> * Urs Thuermann <[email protected]>
include/linux/can/dev.h +1 -1
@@ -108,7 +108,7 @@ static inline bool can_skb_headroom_valid(struct net_device *dev, skb->ip_summed =CHECKSUM_UNNECESSARY ; -/* preform proper loopback on capable devices */ +/* perform proper loopback on capable devices */ if (dev->flags &IFF_ECHO ) skb->pkt_type =PACKET_LOOPBACK ;else
Signature · 1 line
2.28.0
Marc Kleine-Budde
maintainerPATCH 4/37 can: net: fix spelling mistakes
In reply to Marc Kleine-BuddeThis patch fixes spelling erros found by "codespell" in the net/can subtree.
--- net/can/af_can.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
net/can/af_can.c +2 -2
@@ -358,7 +358,7 @@ static unsigned int effhash(canid_t can_id)* * Return: * Pointer to optimal filterlist for the given can_id/mask pair. -* Constistency checked mask. +* Consistency checked mask. * Reduced can_id to have a preprocessed filter compare value. */ static struct hlist_head *can_rcv_list_find(canid_t *can_id, canid_t *mask,
@@ -411,7 +411,7 @@ static struct hlist_head *can_rcv_list_find(canid_t *can_id, canid_t *mask,/** * can_rx_register - subscribe CAN frames from a specific interface * @net: the applicable net namespace -* @dev: pointer to netdevice (NULL => subcribe from 'all' CAN devices list) +* @dev: pointer to netdevice (NULL => subscribe from 'all' CAN devices list) * @can_id: CAN identifier (see description) * @mask: CAN mask (see description) * @func: callback function on filter match
Signature · 1 line
2.28.0
Marc Kleine-Budde
maintainerPATCH 5/37 can: drivers: fix spelling mistakes
In reply to Marc Kleine-BuddeThis patch fixes spelling erros found by "codespell" in the drivers/net/can subtree.
--- drivers/net/can/at91_can.c | 8 ++++---- drivers/net/can/cc770/cc770.c | 2 +- drivers/net/can/cc770/cc770.h | 2 +- drivers/net/can/grcan.c | 2 +- drivers/net/can/m_can/Kconfig | 2 +- drivers/net/can/pch_can.c | 4 ++-- drivers/net/can/sja1000/peak_pci.c | 2 +- drivers/net/can/sja1000/peak_pcmcia.c | 2 +- drivers/net/can/softing/Kconfig | 4 ++-- drivers/net/can/softing/softing_fw.c | 8 ++++---- drivers/net/can/softing/softing_main.c | 8 ++++---- drivers/net/can/softing/softing_platform.h | 2 +- drivers/net/can/ti_hecc.c | 2 +- drivers/net/can/usb/Kconfig | 2 +- drivers/net/can/usb/gs_usb.c | 4 ++-- drivers/net/can/usb/mcba_usb.c | 2 +- drivers/net/can/usb/peak_usb/pcan_usb_fd.c | 4 ++-- drivers/net/can/usb/peak_usb/pcan_usb_pro.c | 2 +- drivers/net/can/usb/ucan.c | 4 ++-- drivers/net/can/usb/usb_8dev.c | 4 ++-- drivers/net/can/xilinx_can.c | 2 +- 21 files changed, 36 insertions(+), 36 deletions(-)
drivers/net/can/at91_can.c +4 -4
@@ -643,7 +643,7 @@ static void at91_read_msg(struct net_device *dev, unsigned int mb)* * The first message goes into mb nr. 1 and issues an interrupt. All * rx ints are disabled in the interrupt handler and a napi poll is -* scheduled. We read the mailbox, but do _not_ reenable the mb (to +* scheduled. We read the mailbox, but do _not_ re-enable the mb (to * receive another message). * * lower mbxs upper
@@ -661,13 +661,13 @@ static void at91_read_msg(struct net_device *dev, unsigned int mb)* * The variable priv->rx_next points to the next mailbox to read a * message from. As long we're in the lower mailboxes we just read the -* mailbox but not reenable it. +* mailbox but not re-enable it. * -* With completion of the last of the lower mailboxes, we reenable the +* With completion of the last of the lower mailboxes, we re-enable the * whole first group, but continue to look for filled mailboxes in the * upper mailboxes. Imagine the second group like overflow mailboxes, * which takes CAN messages if the lower goup is full. While in the -* upper group we reenable the mailbox right after reading it. Giving +* upper group we re-enable the mailbox right after reading it. Giving * the chip more room to store messages. * * After finishing we look again in the lower group if we've still
drivers/net/can/cc770/cc770.c +1 -1
@@ -538,7 +538,7 @@ static int cc770_err(struct net_device *dev, u8 status) priv->can.can_stats.error_warning++; } }else { -/* Back to error avtive */ +/* Back to error active */ cf->can_id |=CAN_ERR_PROT ; cf->data[2 ] =CAN_ERR_PROT_ACTIVE ; priv->can.state =CAN_STATE_ERROR_ACTIVE ;
drivers/net/can/cc770/cc770.h +1 -1
@@ -184,7 +184,7 @@ struct cc770_priv {u8 control_normal_mode;/* Control register for normal mode */ u8 cpu_interface;/* CPU interface register */ u8 clkout;/* Clock out register */ -u8 bus_config;/* Bus conffiguration register */ +u8 bus_config;/* Bus configuration register */ struct sk_buff *tx_skb; };
drivers/net/can/grcan.c +1 -1
@@ -1243,7 +1243,7 @@ static int grcan_poll(struct napi_struct *napi, int budget)int rx_budget = budget /2 ;int tx_budget = budget - rx_budget; -/* Half of the budget for receiveing messages */ +/* Half of the budget for receiving messages */ rx_work_done =grcan_receive (dev, rx_budget);/* Half of the budget for transmitting messages as that can trigger echo
drivers/net/can/m_can/Kconfig +1 -1
@@ -20,5 +20,5 @@ config CAN_M_CAN_TCAN4X5X tristate "TCAN4X5X M_CAN device" help Say Y here if you want support for Texas Instruments TCAN4x5x - M_CAN controller. This device is a peripherial device that uses the + M_CAN controller. This device is a peripheral device that uses the SPI bus for communication.
drivers/net/can/pch_can.c +2 -2
@@ -461,7 +461,7 @@ static void pch_can_int_clr(struct pch_can_priv *priv, u32 mask) PCH_ID2_DIR | (0x7ff << 2));iowrite32 (0x0 , &priv->regs->ifregs[1 ].id1); -/* Claring NewDat, TxRqst & IntPnd */ +/* Clearing NewDat, TxRqst & IntPnd */ pch_can_bit_clear (&priv->regs->ifregs[1 ].mcont,PCH_IF_MCONT_NEWDAT |PCH_IF_MCONT_INTPND |PCH_IF_MCONT_TXRQXT );
@@ -834,7 +834,7 @@ static int pch_can_open(struct net_device *ndev)struct pch_can_priv *priv =netdev_priv (ndev);int retval; -/* Regstering the interrupt. */ +/* Registering the interrupt. */ retval =request_irq (priv->dev->irq, pch_can_interrupt,IRQF_SHARED , ndev->name, ndev);if (retval) {
drivers/net/can/sja1000/peak_pci.c +1 -1
@@ -97,7 +97,7 @@ MODULE_DEVICE_TABLE(pci, peak_pci_tbl);/* GPIOICR byte access offsets */ #define PITA_GPOUT 0x18/* GPx output value */ #define PITA_GPIN 0x19/* GPx input value */ -#define PITA_GPOEN 0x1A/* configure GPx as ouput pin */ +#define PITA_GPOEN 0x1A/* configure GPx as output pin */ /* I2C GP bits */ #define PITA_GPIN_SCL 0x01/* Serial Clock Line */
drivers/net/can/sja1000/peak_pcmcia.c +1 -1
@@ -671,7 +671,7 @@ static int pcan_probe(struct pcmcia_device *pdev) card->fw_major =pcan_read_reg (card,PCC_FW_MAJOR ); card->fw_minor =pcan_read_reg (card,PCC_FW_MINOR ); -/* display board name and firware version */ +/* display board name and firmware version */ dev_info (&pdev->dev,"PEAK-System pcmcia card %s fw %d.%d\n" , pdev->prod_id[1 ] ? pdev->prod_id[1 ] :"PCAN-PC Card" , card->fw_major, card->fw_minor);
drivers/net/can/softing/Kconfig +2 -2
@@ -5,14 +5,14 @@ config CAN_SOFTING help Support for CAN cards from Softing Gmbh & some cards from Vector Gmbh. - Softing Gmbh CAN cards come with 1 or 2 physical busses. + Softing Gmbh CAN cards come with 1 or 2 physical buses. Those cards typically use Dual Port RAM to communicate with the host CPU. The interface is then identical for PCI and PCMCIA cards. This driver operates on a platform device, which has been created by softing_cs or softing_pci driver. Warning: The API of the card does not allow fine control per bus, but - controls the 2 busses on the card together. + controls the 2 buses on the card together. As such, some actions (start/stop/busoff recovery) on 1 bus must bring down the other bus too temporarily.
drivers/net/can/softing/softing_fw.c +4 -4
@@ -273,7 +273,7 @@ int softing_load_app_fw(const char *file, struct softing *card) goto failed; } -/* regualar data */ +/* regular data */ for (sum =0 , j =0 ; j < len; ++j) sum += dat[j];/* work in 16bit (target) */
@@ -474,14 +474,14 @@ int softing_startstop(struct net_device *dev, int up)if (ret) goto failed;if (!bus_bitmask_start) -/* no busses to be brought up */ +/* no buses to be brought up */ goto card_done;if ((bus_bitmask_start &1 ) && (bus_bitmask_start &2 ) && (softing_error_reporting (card->net[0 ]) !=softing_error_reporting (card->net[1 ]))) {dev_alert (&card->pdev->dev, -"err_reporting flag differs for busses\n" ); +"err_reporting flag differs for buses\n" ); goto invalid; } error_reporting =0 ;
@@ -635,7 +635,7 @@ int softing_startstop(struct net_device *dev, int up) priv->can.state =CAN_STATE_ERROR_ACTIVE ;open_candev (netdev);if (dev != netdev) { -/* notify other busses on the restart */ +/* notify other buses on the restart */ softing_netdev_rx (netdev, &msg,0 ); ++priv->can.can_stats.restarts; }
drivers/net/can/softing/softing_main.c +4 -4
@@ -170,8 +170,8 @@ static int softing_handle_1(struct softing *card) msg.can_dlc =CAN_ERR_DLC ; msg.data[1 ] =CAN_ERR_CRTL_RX_OVERFLOW ;/* -* service to all busses, we don't know which it was applicable -* but only service busses that are online +* service to all buses, we don't know which it was applicable +* but only service buses that are online */ for (j =0 ; j <ARRAY_SIZE (card->net); ++j) { netdev = card->net[j];
@@ -339,7 +339,7 @@ static irqreturn_t softing_irq_thread(int irq, void *dev_id)continue ; priv =netdev_priv (netdev);if (!canif_is_active (netdev)) -/* it makes no sense to wake dead busses */ +/* it makes no sense to wake dead buses */ continue ;if (priv->tx.pending >=TX_ECHO_SKB_MAX )continue ;
@@ -374,7 +374,7 @@ static irqreturn_t softing_irq_v1(int irq, void *dev_id) }/* -* netdev/candev inter-operability +* netdev/candev interoperability */ static int softing_netdev_open (struct net_device *ndev) {
drivers/net/can/softing/softing_platform.h +1 -1
@@ -19,7 +19,7 @@ struct softing_platform_data {* 16bit, shared interrupt */ int generation; -int nbus;/* # busses on device */ +int nbus;/* # buses on device */ unsigned int freq;/* operating frequency in Hz */ unsigned int max_brp;unsigned int max_sjw;
drivers/net/can/ti_hecc.c +1 -1
@@ -454,7 +454,7 @@ static int ti_hecc_get_berr_counter(const struct net_device *ndev,/* ti_hecc_xmit: HECC Transmit * * The transmit mailboxes start from 0 to HECC_MAX_TX_MBOX. In HECC the -* priority of the mailbox for tranmission is dependent upon priority setting +* priority of the mailbox for transmission is dependent upon priority setting * field in mailbox registers. The mailbox with highest value in priority field * is transmitted first. Only when two mailboxes have the same value in * priority field the highest numbered mailbox is transmitted first.
drivers/net/can/usb/Kconfig +1 -1
@@ -90,7 +90,7 @@ config CAN_PEAK_USB tristate "PEAK PCAN-USB/USB Pro interfaces for CAN 2.0b/CAN-FD" help This driver supports the PEAK-System Technik USB adapters that enable - access to the CAN bus, with repect to the CAN 2.0b and/or CAN-FD + access to the CAN bus, with respect to the CAN 2.0b and/or CAN-FD standards, that is: PCAN-USB single CAN 2.0b channel USB adapter
drivers/net/can/usb/gs_usb.c +2 -2
@@ -828,7 +828,7 @@ static struct gs_can *gs_make_candev(unsigned int channel, netdev->flags |=IFF_ECHO ;/* we support full roundtrip echo */ -/* dev settup */ +/* dev setup */ strcpy (dev->bt_const.name,"gs_usb" ); dev->bt_const.tseg1_min = bt_const->tseg1_min; dev->bt_const.tseg1_max = bt_const->tseg1_max;
@@ -852,7 +852,7 @@ static struct gs_can *gs_make_candev(unsigned int channel, dev->tx_context[rc].echo_id =GS_MAX_TX_URBS ; } -/* can settup */ +/* can setup */ dev->can.state =CAN_STATE_STOPPED ; dev->can.clock.freq = bt_const->fclk_can; dev->can.bittiming_const = &dev->bt_const;
drivers/net/can/usb/mcba_usb.c +1 -1
@@ -28,7 +28,7 @@#define MCBA_CTX_FREE MCBA_MAX_TX_URBS/* RX buffer must be bigger than msg size since at the -* beggining USB messages are stacked. +* beginning USB messages are stacked. */ #define MCBA_USB_RX_BUFF_SIZE 64#define MCBA_USB_TX_BUFF_SIZE (sizeof(struct mcba_usb_msg))
drivers/net/can/usb/peak_usb/pcan_usb_fd.c +2 -2
@@ -35,7 +35,7 @@ MODULE_SUPPORTED_DEVICE("PEAK-System PCAN-USB Pro FD adapter");#define PCAN_UFD_RX_BUFFER_SIZE 2048#define PCAN_UFD_TX_BUFFER_SIZE 512 -/* read some versions info from the hw devcie */ +/* read some versions info from the hw device */ struct __packed pcan_ufd_fw_info {__le16 size_of;/* sizeof this */ __le16 type;/* type of this structure */
@@ -796,7 +796,7 @@ static int pcan_usb_fd_start(struct peak_usb_device *dev)return err; } -/* socket callback used to copy berr counters values receieved through USB */ +/* socket callback used to copy berr counters values received through USB */ static int pcan_usb_fd_get_berr_counter (const struct net_device *netdev,struct can_berr_counter *bec) {
drivers/net/can/usb/peak_usb/pcan_usb_pro.c +1 -1
@@ -973,7 +973,7 @@ int pcan_usb_pro_probe(struct usb_interface *intf)struct usb_endpoint_descriptor *ep = &if_desc->endpoint[i].desc;/* -* below is the list of valid ep addreses. Any other ep address +* below is the list of valid ep addresses. Any other ep address * is considered as not-CAN interface address => no dev created */ switch (ep->bEndpointAddress) {
drivers/net/can/usb/ucan.c +2 -2
@@ -1445,7 +1445,7 @@ static int ucan_probe(struct usb_interface *intf,/* request the device information and store it in ctl_msg_buffer * -* note: ucan_ctrl_command_* wrappers connot be used yet +* note: ucan_ctrl_command_* wrappers cannot be used yet * because `up` is initialised in Stage 3 */ ret = usb_control_msg(udev,
@@ -1494,7 +1494,7 @@ static int ucan_probe(struct usb_interface *intf, up =netdev_priv (netdev); -/* initialze data */ +/* initialize data */ up->udev = udev; up->intf = intf; up->netdev = netdev;
drivers/net/can/usb/usb_8dev.c +2 -2
@@ -88,7 +88,7 @@ enum usb_8dev_cmd {/* status */ #define USB_8DEV_STATUSMSG_OK 0x00/* Normal condition. */ -#define USB_8DEV_STATUSMSG_OVERRUN 0x01/* Overrun occured when sending */ +#define USB_8DEV_STATUSMSG_OVERRUN 0x01/* Overrun occurred when sending */ #define USB_8DEV_STATUSMSG_BUSLIGHT 0x02/* Error counter has reached 96 */ #define USB_8DEV_STATUSMSG_BUSHEAVY 0x03/* Error count. has reached 128 */ #define USB_8DEV_STATUSMSG_BUSOFF 0x04/* Device is in BUSOFF */
@@ -165,7 +165,7 @@ struct __packed usb_8dev_rx_msg {/* command frame */ struct __packed usb_8dev_cmd_msg {u8 begin; -u8 channel;/* unkown - always 0 */ +u8 channel;/* unknown - always 0 */ u8 command;/* command to execute */ u8 opt1;/* optional parameter / return value */ u8 opt2;/* optional parameter 2 */
drivers/net/can/xilinx_can.c +1 -1
@@ -1308,7 +1308,7 @@ static void xcan_tx_interrupt(struct net_device *ndev, u32 isr)/** * xcan_interrupt - CAN Isr * @irq: irq number -* @dev_id: device id poniter +* @dev_id: device id pointer * * This is the xilinx CAN Isr. It checks for the type of interrupt * and invokes the corresponding ISR.
Signature · 1 line
2.28.0
Marc Kleine-Budde
maintainerPATCH 6/37 can: raw: fix indention
In reply to Marc Kleine-BuddeThis patch fixes the indention to follow kernel coding style.
--- net/can/raw.c | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-)
net/can/raw.c +12 -12
@@ -154,16 +154,16 @@ static void raw_rcv(struct sk_buff *oskb, void *data)if (!skb)return ; -/* Put the datagram to the queue so that raw_recvmsg() can -* get it from there. We need to pass the interface index to -* raw_recvmsg(). We pass a whole struct sockaddr_can in skb->cb -* containing the interface index. +/* Put the datagram to the queue so that raw_recvmsg() can get +* it from there. We need to pass the interface index to +* raw_recvmsg(). We pass a whole struct sockaddr_can in +* skb->cb containing the interface index. */ sock_skb_cb_check_size (sizeof (struct sockaddr_can )); addr = (struct sockaddr_can *)skb->cb;memset (addr,0 ,sizeof (*addr)); - addr->can_family =AF_CAN ; + addr->can_family =AF_CAN ; addr->can_ifindex = skb->dev->ifindex;/* add CAN specific message flags for raw_recvmsg() */
@@ -290,8 +290,8 @@ static int raw_notifier(struct notifier_block *nb,kfree (ro->filter); ro->ifindex =0 ; - ro->bound =0 ; - ro->count =0 ; + ro->bound =0 ; + ro->count =0 ;release_sock (sk); sk->sk_err =ENODEV ;
@@ -374,8 +374,8 @@ static int raw_release(struct socket *sock)kfree (ro->filter); ro->ifindex =0 ; - ro->bound =0 ; - ro->count =0 ; + ro->bound =0 ; + ro->count =0 ;free_percpu (ro->uniq);sock_orphan (sk);
@@ -773,7 +773,7 @@ static int raw_sendmsg(struct socket *sock, struct msghdr *msg, size_t size)skb_setup_tx_timestamp (skb, sk->sk_tsflags); skb->dev = dev; - skb->sk = sk; + skb->sk = sk; skb->priority = sk->sk_priority; err =can_send (skb, ro->loopback);
@@ -801,8 +801,8 @@ static int raw_recvmsg(struct socket *sock, struct msghdr *msg, size_t size,int err =0 ;int noblock; - noblock = flags &MSG_DONTWAIT ; - flags &= ~MSG_DONTWAIT ; + noblock = flags &MSG_DONTWAIT ; + flags &= ~MSG_DONTWAIT ; skb =skb_recv_datagram (sk, flags, noblock, &err);if (!skb)
Signature · 1 line
2.28.0
Marc Kleine-Budde
maintainerPATCH 7/37 can: slcan: update dead link
In reply to Marc Kleine-BuddeFrom: Diego Elio Pettenò <[email protected]>
BerliOS has not been operating for more than five years. linux-can moved to GitHub.
--- drivers/net/can/Kconfig | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/net/can/Kconfig +2 -2
@@ -41,8 +41,8 @@ config CAN_SLCAN www.canusb.com / www.can232.com / www.mictronics.de / www.canhack.de Userspace tools to attach the SLCAN line discipline (slcan_attach, - slcand) can be found in the can-utils at the SocketCAN SVN, see - http://developer.berlios.de/projects/socketcan for details. + slcand) can be found in the can-utils at the linux-can project, see + https://github.com/linux-can/can-utils for details. The slcan driver supports up to 10 CAN netdevices by default which can be changed by the 'maxdev=xx' module option. This driver can
Signature · 1 line
2.28.0
Marc Kleine-Budde
maintainerPATCH 8/37 can: softing: update dead link
In reply to Marc Kleine-BuddeFrom: Diego Elio Pettenò <[email protected]>
BerliOS has not been operating for more than five years. linux-can moved to GitHub.
--- drivers/net/can/softing/Kconfig | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/can/softing/Kconfig +1 -1
@@ -24,7 +24,7 @@ config CAN_SOFTING_CS Support for PCMCIA cards from Softing Gmbh & some cards from Vector Gmbh. You need firmware for these, which you can get at - http://developer.berlios.de/projects/socketcan/ + https://github.com/linux-can/can-firmware This version of the driver is written against firmware version 4.6 (softing-fw-4.6-binaries.tar.gz) In order to use the card as CAN device, you need the Softing generic
Signature · 1 line
2.28.0
Marc Kleine-Budde
maintainerPATCH 9/37 can: remove "WITH Linux-syscall-note" from SPDX tag of C files
In reply to Marc Kleine-BuddeFrom: Masahiro Yamada <[email protected]>
The "WITH Linux-syscall-note" exception is intended for UAPI headers.
See LICENSES/exceptions/Linux-syscall-note
--- net/can/bcm.c | 2 +- net/can/gw.c | 2 +- net/can/proc.c | 2 +- net/can/raw.c | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-)
net/can/bcm.c +1 -1
@@ -1,4 +1,4 @@ -// SPDX-License-Identifier: ((GPL-2.0 WITH Linux-syscall-note) OR BSD-3-Clause) +// SPDX-License-Identifier: (GPL-2.0 OR BSD-3-Clause) /* * bcm.c - Broadcast Manager to filter/send (cyclic) CAN content *
net/can/gw.c +1 -1
@@ -1,4 +1,4 @@ -// SPDX-License-Identifier: ((GPL-2.0 WITH Linux-syscall-note) OR BSD-3-Clause) +// SPDX-License-Identifier: (GPL-2.0 OR BSD-3-Clause) /* gw.c - CAN frame Gateway/Router/Bridge with netlink interface * * Copyright (c) 2019 Volkswagen Group Electronic Research
net/can/proc.c +1 -1
@@ -1,4 +1,4 @@ -// SPDX-License-Identifier: ((GPL-2.0 WITH Linux-syscall-note) OR BSD-3-Clause) +// SPDX-License-Identifier: (GPL-2.0 OR BSD-3-Clause) /* * proc.c - procfs support for Protocol family CAN core module *
net/can/raw.c +1 -1
@@ -1,4 +1,4 @@ -// SPDX-License-Identifier: ((GPL-2.0 WITH Linux-syscall-note) OR BSD-3-Clause) +// SPDX-License-Identifier: (GPL-2.0 OR BSD-3-Clause) /* raw.c - Raw sockets for protocol family CAN * * Copyright (c) 2002-2007 Volkswagen Group Electronic Research
Signature · 1 line
2.28.0
Marc Kleine-Budde
maintainerPATCH 10/37 can: dev: can_put_echo_skb(): print number of echo_skb that is occupied
In reply to Marc Kleine-BuddeThis patch prints the number of the occupied echo_skb, to ease implementing and debugging of new drivers.
--- drivers/net/can/dev.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/can/dev.c +1 -1
@@ -463,7 +463,7 @@ void can_put_echo_skb(struct sk_buff *skb, struct net_device *dev, priv->echo_skb[idx] = skb; }else {/* locking problem with netif_stop_queue() ?? */ -netdev_err (dev,"%s: BUG! echo_skb is occupied!\n" , __func__); +netdev_err (dev,"%s: BUG! echo_skb %d is occupied!\n" , __func__, idx);kfree_skb (skb); } }
Signature · 1 line
2.28.0
Marc Kleine-Budde
maintainerPATCH 11/37 can: dev: can_put_echo_skb(): propagate error in case of errors
In reply to Marc Kleine-BuddeThe function can_put_echo_skb() can fail for several reasons. It may fail due to OOM, but when it fails it's usually due to locking problems in the driver.
In order to help developing and debugging of new drivers propagate error value in case of errors.
--- drivers/net/can/dev.c | 11 +++++++---- include/linux/can/dev.h | 4 ++-- 2 files changed, 9 insertions(+), 6 deletions(-)
drivers/net/can/dev.c +7 -4
@@ -434,8 +434,8 @@ static void can_flush_echo_skb(struct net_device *dev)* of the device driver. The driver must protect access to * priv->echo_skb, if necessary. */ -void can_put_echo_skb (struct sk_buff *skb,struct net_device *dev, -unsigned int idx) +int can_put_echo_skb (struct sk_buff *skb,struct net_device *dev, +unsigned int idx) {struct can_priv *priv =netdev_priv (dev);
@@ -446,13 +446,13 @@ void can_put_echo_skb(struct sk_buff *skb, struct net_device *dev, (skb->protocol != htons(ETH_P_CAN) && skb->protocol != htons(ETH_P_CANFD))) {kfree_skb (skb); -return ; +return 0 ; }if (!priv->echo_skb[idx]) { skb =can_create_echo_skb (skb);if (!skb) -return ; +return -ENOMEM ;/* make settings for echo to reduce code in irq context */ skb->pkt_type =PACKET_BROADCAST ;
@@ -465,7 +465,10 @@ void can_put_echo_skb(struct sk_buff *skb, struct net_device *dev,/* locking problem with netif_stop_queue() ?? */ netdev_err (dev,"%s: BUG! echo_skb %d is occupied!\n" , __func__, idx);kfree_skb (skb); +return -EBUSY ; } + +return 0 ; }EXPORT_SYMBOL_GPL (can_put_echo_skb);
include/linux/can/dev.h +2 -2
@@ -201,8 +201,8 @@ void can_bus_off(struct net_device *dev);void can_change_state (struct net_device *dev,struct can_frame *cf,enum can_state tx_state,enum can_state rx_state); -void can_put_echo_skb (struct sk_buff *skb,struct net_device *dev, -unsigned int idx); +int can_put_echo_skb (struct sk_buff *skb,struct net_device *dev, +unsigned int idx);struct sk_buff *__can_get_echo_skb (struct net_device *dev,unsigned int idx,u8 *len_ptr);unsigned int can_get_echo_skb (struct net_device *dev,unsigned int idx);
Signature · 1 line
2.28.0
Marc Kleine-Budde
maintainerPATCH 12/37 can: dev: can_change_state(): print human readable state change messages
In reply to Marc Kleine-BuddeIn order to ease debugging let can_change_state() print the human readable state change messages. Also print the old and new state.
--- drivers/net/can/dev.c | 26 +++++++++++++++++++++++++- 1 file changed, 25 insertions(+), 1 deletion(-)
drivers/net/can/dev.c +25 -1
@@ -371,6 +371,28 @@ static int can_rx_state_to_frame(struct net_device *dev, enum can_state state) } } +static const char *can_get_state_str (const enum can_state state) +{ +switch (state) { +case CAN_STATE_ERROR_ACTIVE : +return "Error Active" ; +case CAN_STATE_ERROR_WARNING : +return "Error Warning" ; +case CAN_STATE_ERROR_PASSIVE : +return "Error Passive" ; +case CAN_STATE_BUS_OFF : +return "Bus Off" ; +case CAN_STATE_STOPPED : +return "Stopped" ; +case CAN_STATE_SLEEPING : +return "Sleeping" ; +default : +return "<unknown>" ; + } + +return "<unknown>" ; +} +void can_change_state (struct net_device *dev,struct can_frame *cf,enum can_state tx_state,enum can_state rx_state) {
@@ -382,7 +404,9 @@ void can_change_state(struct net_device *dev, struct can_frame *cf,return ; } -netdev_dbg (dev,"New error state: %d\n" , new_state); +netdev_dbg (dev,"Controller changed from %s State (%d) into %s State (%d).\n" , +can_get_state_str (priv->state), priv->state, +can_get_state_str (new_state), new_state);can_update_state_error_stats (dev, new_state); priv->state = new_state;
Signature · 1 line
2.28.0
Marc Kleine-Budde
maintainerPATCH 13/37 can: dev: can_bus_off(): print scheduling of restart if activated
In reply to Marc Kleine-BuddeIf a CAN device goes into bus-off and has automatic restart enabled, inform user that a automatic restart is scheduled after the configured delay.
--- drivers/net/can/dev.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-)
drivers/net/can/dev.c +5 -1
@@ -639,7 +639,11 @@ void can_bus_off(struct net_device *dev) {struct can_priv *priv =netdev_priv (dev); -netdev_info (dev,"bus-off\n" ); +if (priv->restart_ms) +netdev_info (dev,"bus-off, scheduling restart in %d ms\n" , + priv->restart_ms); +else +netdev_info (dev,"bus-off\n" );netif_carrier_off (dev);
Signature · 1 line
2.28.0
Marc Kleine-Budde
maintainerPATCH 14/37 can: c_can: Remove unused inline function
In reply to Marc Kleine-BuddeFrom: YueHaibing <[email protected]>
commit 524369e2391f ("can: c_can: remove obsolete STRICT_FRAME_ORDERING Kconfig option") left behind this, remove it.
--- drivers/net/can/c_can/c_can.c | 9 --------- 1 file changed, 9 deletions(-)
drivers/net/can/c_can/c_can.c +0 -9
@@ -356,15 +356,6 @@ static void c_can_setup_tx_object(struct net_device *dev, int iface, } } -static inline void c_can_activate_all_lower_rx_msg_obj (struct net_device *dev, -int iface) -{ -int i; - -for (i =C_CAN_MSG_OBJ_RX_FIRST ; i <=C_CAN_MSG_RX_LOW_LAST ; i++) -c_can_object_get (dev, iface, i,IF_COMM_CLR_NEWDAT ); -} -static int c_can_handle_lost_msg_obj (struct net_device *dev,int iface,int objno,u32 ctrl) {
Signature · 1 line
2.28.0
Marc Kleine-Budde
maintainerPATCH 15/37 can: mcba_usb: remove redundant initialization of variable err
In reply to Marc Kleine-BuddeFrom: Colin Ian King <[email protected]>
The variable err is being initialized with a value that is never read and it is being updated later with a new value. The initialization is redundant and can be removed.
Addresses-Coverity: ("Unused value")
--- drivers/net/can/usb/mcba_usb.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/can/usb/mcba_usb.c +1 -1
@@ -793,7 +793,7 @@ static int mcba_usb_probe(struct usb_interface *intf, {struct net_device *netdev;struct mcba_priv *priv; -int err = -ENOMEM ; +int err;struct usb_device *usbdev =interface_to_usbdev (intf); netdev =alloc_candev (sizeof (struct mcba_priv ),MCBA_MAX_TX_URBS );
Signature · 1 line
2.28.0
Marc Kleine-Budde
maintainerPATCH 16/37 can: mscan: mark expected switch fall-through
In reply to Marc Kleine-BuddeAs -Wimplicit-fallthrough is now enabled the mscan driver shows this warning, which is fixed by this patch:
drivers/net/can/mscan/mscan.c: In function ‘mscan_start_xmit’:drivers/net/can/mscan/mscan.c:211:3: warning: this statement may fall through [-Wimplicit-fallthrough=]
211 | netif_stop_queue(dev);
| ^~~~~~~~~~~~~~~~~~~~~
drivers/net/can/mscan/mscan.c:212:2: note: here
212 | case 2:
| ^~~~--- drivers/net/can/mscan/mscan.c | 1 + 1 file changed, 1 insertion(+)
drivers/net/can/mscan/mscan.c +1 -0
@@ -209,6 +209,7 @@ static netdev_tx_t mscan_start_xmit(struct sk_buff *skb, struct net_device *dev)* since buffer with lower id have higher priority (hell..) */ netif_stop_queue (dev); + fallthrough;case 2 :if (buf_id < priv->prev_buf_id) { priv->cur_pri++;
Signature · 1 line
2.28.0
Marc Kleine-Budde
maintainerPATCH 17/37 can: ti_hecc: convert to devm_platform_ioremap_resource_byname()
In reply to Marc Kleine-BuddeFrom: Dejin Zheng <[email protected]>
Use the function devm_platform_ioremap_resource_byname() to simplify source code which calls the functions platform_get_resource_byname() and devm_ioremap_resource(). Remove also a few error messages which became unnecessary with this software refactoring.
--- drivers/net/can/ti_hecc.c | 27 +++++---------------------- 1 file changed, 5 insertions(+), 22 deletions(-)
drivers/net/can/ti_hecc.c +5 -22
@@ -857,7 +857,7 @@ static int ti_hecc_probe(struct platform_device *pdev)struct net_device *ndev = (struct net_device *)0 ;struct ti_hecc_priv *priv;struct device_node *np = pdev->dev.of_node; -struct resource *res, *irq; +struct resource *irq;struct regulator *reg_xceiver;int err = -ENODEV ;
@@ -878,39 +878,22 @@ static int ti_hecc_probe(struct platform_device *pdev) priv =netdev_priv (ndev);/* handle hecc memory */ - res =platform_get_resource_byname (pdev,IORESOURCE_MEM ,"hecc" ); -if (!res) { -dev_err (&pdev->dev,"can't get IORESOURCE_MEM hecc\n" ); -return -EINVAL ; - } - - priv->base =devm_ioremap_resource (&pdev->dev, res); + priv->base =devm_platform_ioremap_resource_byname (pdev,"hecc" );if (IS_ERR (priv->base)) {dev_err (&pdev->dev,"hecc ioremap failed\n" );return PTR_ERR (priv->base); }/* handle hecc-ram memory */ - res =platform_get_resource_byname (pdev,IORESOURCE_MEM ,"hecc-ram" ); -if (!res) { -dev_err (&pdev->dev,"can't get IORESOURCE_MEM hecc-ram\n" ); -return -EINVAL ; - } - - priv->hecc_ram =devm_ioremap_resource (&pdev->dev, res); + priv->hecc_ram =devm_platform_ioremap_resource_byname (pdev, +"hecc-ram" );if (IS_ERR (priv->hecc_ram)) {dev_err (&pdev->dev,"hecc-ram ioremap failed\n" );return PTR_ERR (priv->hecc_ram); }/* handle mbx memory */ - res =platform_get_resource_byname (pdev,IORESOURCE_MEM ,"mbx" ); -if (!res) { -dev_err (&pdev->dev,"can't get IORESOURCE_MEM mbx\n" ); -return -EINVAL ; - } - - priv->mbx =devm_ioremap_resource (&pdev->dev, res); + priv->mbx =devm_platform_ioremap_resource_byname (pdev,"mbx" );if (IS_ERR (priv->mbx)) {dev_err (&pdev->dev,"mbx ioremap failed\n" );return PTR_ERR (priv->mbx);
Signature · 1 line
2.28.0
Marc Kleine-Budde
maintainerPATCH 18/37 can: peak_usb: convert to use le32_add_cpu()
In reply to Marc Kleine-BuddeFrom: Liu Shixin <[email protected]>
Convert cpu_to_le32(le32_to_cpu(E1) + E2) to use le32_add_cpu().
--- drivers/net/can/usb/peak_usb/pcan_usb_pro.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/can/usb/peak_usb/pcan_usb_pro.c +1 -1
@@ -186,7 +186,7 @@ static int pcan_msg_add_rec(struct pcan_usb_pro_msg *pm, int id, ...) len = pc - pm->rec_ptr;if (len >0 ) { - *pm->u.rec_cnt =cpu_to_le32 (le32_to_cpu (*pm->u.rec_cnt) +1 ); +le32_add_cpu (pm->u.rec_cnt,1 ); *pm->rec_ptr = id; pm->rec_ptr = pc;
Signature · 1 line
2.28.0
Marc Kleine-Budde
maintainerPATCH 19/37 can: peak_canfd: Remove unused macros
In reply to Marc Kleine-BuddeFrom: Wang Hai <[email protected]>
CANFD_CLK_SEL_DIV_MASK and CANFD_OPTIONS_SET are never used after they were introduced. Remove them.
--- drivers/net/can/peak_canfd/peak_pciefd_main.c | 2 -- 1 file changed, 2 deletions(-)
drivers/net/can/peak_canfd/peak_pciefd_main.c +0 -2
@@ -116,8 +116,6 @@ MODULE_LICENSE("GPL v2");#define CANFD_CTL_IRQ_CL_DEF 16/* Rx msg max nb per IRQ in Rx DMA */ #define CANFD_CTL_IRQ_TL_DEF 10/* Time before IRQ if < CL (x100 µs) */ -#define CANFD_OPTIONS_SET (CANFD_OPTION_ERROR | CANFD_OPTION_BUSLOAD) -/* Tx anticipation window (link logical address should be aligned on 2K * boundary) */
Signature · 1 line
2.28.0
Marc Kleine-Budde
maintainerPATCH 20/37 can: pch_can: use generic power management
In reply to Marc Kleine-BuddeFrom: Vaibhav Gupta <[email protected]>
Drivers using legacy power management .suspen()/.resume() callbacks have to manage PCI states and device's PM states themselves. They also need to take care of standard configuration registers.
Switch to generic power management framework using a single "struct dev_pm_ops" variable to take the unnecessary load from the driver. This also avoids the need for the driver to directly call most of the PCI helper functions and device power state control functions, as through the generic framework PCI Core takes care of the necessary operations, and drivers are required to do only device-specific jobs.
--- drivers/net/can/pch_can.c | 63 +++++++++++++-------------------------- 1 file changed, 21 insertions(+), 42 deletions(-)
drivers/net/can/pch_can.c +21 -42
@@ -957,8 +957,7 @@ static void pch_can_remove(struct pci_dev *pdev)free_candev (priv->ndev); } -#ifdef CONFIG_PM -static void pch_can_set_int_custom (struct pch_can_priv *priv) +static void __maybe_unused pch_can_set_int_custom (struct pch_can_priv *priv) {/* Clearing the IE, SIE and EIE bits of Can control register. */ pch_can_bit_clear (&priv->regs->cont,PCH_CTRL_IE_SIE_EIE );
@@ -969,14 +968,14 @@ static void pch_can_set_int_custom(struct pch_can_priv *priv) }/* This function retrieves interrupt enabled for the CAN device. */ -static u32 pch_can_get_int_enables (struct pch_can_priv *priv) +static u32 __maybe_unused pch_can_get_int_enables (struct pch_can_priv *priv) {/* Obtaining the status of IE, SIE and EIE interrupt bits. */ return (ioread32 (&priv->regs->cont) &PCH_CTRL_IE_SIE_EIE ) >>1 ; } -static u32 pch_can_get_rxtx_ir (struct pch_can_priv *priv,u32 buff_num, -enum pch_ifreg dir) +static u32 __maybe_unused pch_can_get_rxtx_ir (struct pch_can_priv *priv, +u32 buff_num,enum pch_ifreg dir) {u32 ie, enable;
@@ -997,8 +996,8 @@ static u32 pch_can_get_rxtx_ir(struct pch_can_priv *priv, u32 buff_num,return enable; } -static void pch_can_set_rx_buffer_link (struct pch_can_priv *priv, -u32 buffer_num,int set) +static void __maybe_unused pch_can_set_rx_buffer_link (struct pch_can_priv *priv, +u32 buffer_num,int set) {iowrite32 (PCH_CMASK_RX_TX_GET , &priv->regs->ifregs[0 ].cmask);pch_can_rw_msg_obj (&priv->regs->ifregs[0 ].creq, buffer_num);
@@ -1013,7 +1012,8 @@ static void pch_can_set_rx_buffer_link(struct pch_can_priv *priv,pch_can_rw_msg_obj (&priv->regs->ifregs[0 ].creq, buffer_num); } -static u32 pch_can_get_rx_buffer_link (struct pch_can_priv *priv,u32 buffer_num) +static u32 __maybe_unused pch_can_get_rx_buffer_link (struct pch_can_priv *priv, +u32 buffer_num) {u32 link;
@@ -1027,20 +1027,19 @@ static u32 pch_can_get_rx_buffer_link(struct pch_can_priv *priv, u32 buffer_num)return link; } -static int pch_can_get_buffer_status (struct pch_can_priv *priv) +static int __maybe_unused pch_can_get_buffer_status (struct pch_can_priv *priv) {return (ioread32 (&priv->regs->treq1) &0xffff ) | (ioread32 (&priv->regs->treq2) <<16 ); } -static int pch_can_suspend (struct pci_dev *pdev,pm_message_t state) +static int __maybe_unused pch_can_suspend (struct device *dev_d) {int i; -int retval;u32 buf_stat;/* Variable for reading the transmit buffer status. */ int counter =PCH_COUNTER_LIMIT ; -struct net_device *dev =pci_get_drvdata (pdev); +struct net_device *dev =dev_get_drvdata (dev_d);struct pch_can_priv *priv =netdev_priv (dev);/* Stop the CAN controller */
@@ -1058,7 +1057,7 @@ static int pch_can_suspend(struct pci_dev *pdev, pm_message_t state)udelay (1 ); }if (!counter) -dev_err (&pdev->dev,"%s -> Transmission time out.\n" , __func__); +dev_err (dev_d,"%s -> Transmission time out.\n" , __func__);/* Save interrupt configuration and then disable them */ priv->int_enables =pch_can_get_int_enables (priv);
@@ -1081,35 +1080,16 @@ static int pch_can_suspend(struct pci_dev *pdev, pm_message_t state)/* Disable all Receive buffers */ pch_can_set_rx_all (priv,0 ); - retval =pci_save_state (pdev); -if (retval) { -dev_err (&pdev->dev,"pci_save_state failed.\n" ); - }else { -pci_enable_wake (pdev, PCI_D3hot,0 ); -pci_disable_device (pdev); -pci_set_power_state (pdev,pci_choose_state (pdev, state)); - } -return retval; +return 0 ; } -static int pch_can_resume (struct pci_dev *pdev) +static int __maybe_unused pch_can_resume (struct device *dev_d) {int i; -int retval; -struct net_device *dev =pci_get_drvdata (pdev); +struct net_device *dev =dev_get_drvdata (dev_d);struct pch_can_priv *priv =netdev_priv (dev); -pci_set_power_state (pdev,PCI_D0 ); -pci_restore_state (pdev); - retval =pci_enable_device (pdev); -if (retval) { -dev_err (&pdev->dev,"pci_enable_device failed.\n" ); -return retval; - } - -pci_enable_wake (pdev, PCI_D3hot,0 ); - priv->can.state =CAN_STATE_ERROR_ACTIVE ;/* Disabling all interrupts. */
@@ -1146,12 +1126,8 @@ static int pch_can_resume(struct pci_dev *pdev)/* Restore Run Mode */ pch_can_set_run_mode (priv,PCH_CAN_RUN ); - return retval; +return 0 ; } -#else -#define pch_can_suspend NULL -#define pch_can_resume NULL -#endif static int pch_can_get_berr_counter (const struct net_device *dev,struct can_berr_counter *bec)
@@ -1252,13 +1228,16 @@ static int pch_can_probe(struct pci_dev *pdev,return rc; } +static SIMPLE_DEV_PM_OPS(pch_can_pm_ops, + pch_can_suspend, + pch_can_resume); +static struct pci_driver pch_can_pci_driver = { .name ="pch_can" , .id_table = pch_pci_tbl, .probe = pch_can_probe, .remove = pch_can_remove, - .suspend = pch_can_suspend, - .resume = pch_can_resume, + .driver.pm = &pch_can_pm_ops, };module_pci_driver (pch_can_pci_driver);
Signature · 1 line
2.28.0
Marc Kleine-Budde
maintainerPATCH 21/37 can: pcan_usb: Document the commands sent to the device
In reply to Marc Kleine-BuddeFrom: Stephane Grosjean <[email protected]>
This patch documents the functions and numbers of the commands sent by the driver to the PCAN-USB CAN device from PEAK-System GmbH.
--- drivers/net/can/usb/peak_usb/pcan_usb.c | 33 +++++++++++++++++++------ 1 file changed, 26 insertions(+), 7 deletions(-)
drivers/net/can/usb/peak_usb/pcan_usb.c +26 -7
@@ -34,6 +34,22 @@ MODULE_SUPPORTED_DEVICE("PEAK-System PCAN-USB adapter");#define PCAN_USB_CMD_LEN (PCAN_USB_CMD_ARGS + \ PCAN_USB_CMD_ARGS_LEN) +/* PCAN-USB commands */ +#define PCAN_USB_CMD_BITRATE 1 +#define PCAN_USB_CMD_SET_BUS 3 +#define PCAN_USB_CMD_DEVID 4 +#define PCAN_USB_CMD_SN 6 +#define PCAN_USB_CMD_REGISTER 9 +#define PCAN_USB_CMD_EXT_VCC 10 + +/* PCAN_USB_CMD_SET_BUS number arg */ +#define PCAN_USB_BUS_XCVER 2 +#define PCAN_USB_BUS_SILENT_MODE 3 + +/* PCAN_USB_CMD_xxx functions */ +#define PCAN_USB_GET 1 +#define PCAN_USB_SET 2 +/* PCAN-USB command timeout (ms.) */ #define PCAN_USB_COMMAND_TIMEOUT 1000
@@ -172,7 +188,8 @@ static int pcan_usb_set_sja1000(struct peak_usb_device *dev, u8 mode) [1] = mode, }; -return pcan_usb_send_cmd (dev,9 ,2 , args); +return pcan_usb_send_cmd (dev,PCAN_USB_CMD_REGISTER ,PCAN_USB_SET , + args); }static int pcan_usb_set_bus (struct peak_usb_device *dev,u8 onoff)
@@ -181,7 +198,8 @@ static int pcan_usb_set_bus(struct peak_usb_device *dev, u8 onoff) [0] = !!onoff, }; -return pcan_usb_send_cmd (dev,3 ,2 , args); +return pcan_usb_send_cmd (dev,PCAN_USB_CMD_SET_BUS ,PCAN_USB_BUS_XCVER , + args); }static int pcan_usb_set_silent (struct peak_usb_device *dev,u8 onoff)
@@ -190,7 +208,8 @@ static int pcan_usb_set_silent(struct peak_usb_device *dev, u8 onoff) [0] = !!onoff, }; -return pcan_usb_send_cmd (dev,3 ,3 , args); +return pcan_usb_send_cmd (dev,PCAN_USB_CMD_SET_BUS , +PCAN_USB_BUS_SILENT_MODE , args); }static int pcan_usb_set_ext_vcc (struct peak_usb_device *dev,u8 onoff)
@@ -199,7 +218,7 @@ static int pcan_usb_set_ext_vcc(struct peak_usb_device *dev, u8 onoff) [0] = !!onoff, }; -return pcan_usb_send_cmd (dev,10 ,2 , args); +return pcan_usb_send_cmd (dev,PCAN_USB_CMD_EXT_VCC ,PCAN_USB_SET , args); }/*
@@ -223,7 +242,7 @@ static int pcan_usb_set_bittiming(struct peak_usb_device *dev, args[0 ] = btr1; args[1 ] = btr0; -return pcan_usb_send_cmd (dev,1 ,2 , args); +return pcan_usb_send_cmd (dev,PCAN_USB_CMD_BITRATE ,PCAN_USB_SET , args); }/*
@@ -307,7 +326,7 @@ static int pcan_usb_get_serial(struct peak_usb_device *dev, u32 *serial_number)u8 args[PCAN_USB_CMD_ARGS_LEN ];int err; - err =pcan_usb_wait_rsp (dev,6 ,1 , args); + err =pcan_usb_wait_rsp (dev,PCAN_USB_CMD_SN ,PCAN_USB_GET , args);if (err) {netdev_err (dev->netdev,"getting serial failure: %d\n" , err); }else if (serial_number) {
@@ -328,7 +347,7 @@ static int pcan_usb_get_device_id(struct peak_usb_device *dev, u32 *device_id)u8 args[PCAN_USB_CMD_ARGS_LEN ];int err; - err =pcan_usb_wait_rsp (dev,4 ,1 , args); + err =pcan_usb_wait_rsp (dev,PCAN_USB_CMD_DEVID ,PCAN_USB_GET , args);if (err)netdev_err (dev->netdev,"getting device id failure: %d\n" , err);else if (device_id)
Signature · 1 line
2.28.0
Marc Kleine-Budde
maintainerPATCH 22/37 can: pcan_usb: add support of rxerr/txerr counters
In reply to Marc Kleine-BuddeFrom: Stephane Grosjean <[email protected]>
This patch adds the support of the rx/tx errors CAN counters to the driver of the PCAN-USB PC-CAN interface from PEAK-System GmbH.
The PCAN-USB is capable of giving back the values of the rx/tx errors counters, to provide more details and statistics to the linux-can layer. Getting these values allows the driver to better tune CAN_ERR_CRTL_TX_xxx and CAN_ERR_CRTL_RX_xxx bits in case of the interface enters any CAN_STATE_ERROR_xxx state.
--- drivers/net/can/usb/peak_usb/pcan_usb.c | 133 +++++++++++++++++++++--- 1 file changed, 117 insertions(+), 16 deletions(-)
drivers/net/can/usb/peak_usb/pcan_usb.c +117 -16
@@ -41,6 +41,7 @@ MODULE_SUPPORTED_DEVICE("PEAK-System PCAN-USB adapter");#define PCAN_USB_CMD_SN 6#define PCAN_USB_CMD_REGISTER 9#define PCAN_USB_CMD_EXT_VCC 10 +#define PCAN_USB_CMD_ERR_FR 11/* PCAN_USB_CMD_SET_BUS number arg */ #define PCAN_USB_BUS_XCVER 2
@@ -82,6 +83,10 @@ MODULE_SUPPORTED_DEVICE("PEAK-System PCAN-USB adapter");#define PCAN_USB_ERROR_QOVR 0x40#define PCAN_USB_ERROR_TXQFULL 0x80 +#define PCAN_USB_ERROR_BUS (PCAN_USB_ERROR_BUS_LIGHT | \ + PCAN_USB_ERROR_BUS_HEAVY | \ + PCAN_USB_ERROR_BUS_OFF) +/* SJA1000 modes */ #define SJA1000_MODE_NORMAL 0x00#define SJA1000_MODE_INIT 0x01
@@ -101,11 +106,25 @@ MODULE_SUPPORTED_DEVICE("PEAK-System PCAN-USB adapter");#define PCAN_USB_REC_TS 4#define PCAN_USB_REC_BUSEVT 5 +/* CAN bus events notifications selection mask */ +#define PCAN_USB_ERR_RXERR 0x02/* ask for rxerr counter */ +#define PCAN_USB_ERR_TXERR 0x04/* ask for txerr counter */ + +/* This mask generates an usb packet each time the state of the bus changes. +* In other words, its interest is to know which side among rx and tx is +* responsible of the change of the bus state. +*/ +#define PCAN_USB_BERR_MASK (PCAN_USB_ERR_RXERR | PCAN_USB_ERR_TXERR) + +/* identify bus event packets with rx/tx error counters */ +#define PCAN_USB_ERR_CNT 0x80 +/* private to PCAN-USB adapter */ struct pcan_usb {struct peak_usb_device dev;struct peak_time_ref time_ref;struct timer_list restart_timer; +struct can_berr_counter bec; };/* incoming message context for decoding */
@@ -212,6 +231,16 @@ static int pcan_usb_set_silent(struct peak_usb_device *dev, u8 onoff) PCAN_USB_BUS_SILENT_MODE, args); } +/* send the cmd to be notified from bus errors */ +static int pcan_usb_set_err_frame (struct peak_usb_device *dev,u8 err_mask) +{ +u8 args[PCAN_USB_CMD_ARGS_LEN ] = { + [0 ] = err_mask, + }; + +return pcan_usb_send_cmd (dev,PCAN_USB_CMD_ERR_FR ,PCAN_USB_SET , args); +} +static int pcan_usb_set_ext_vcc (struct peak_usb_device *dev,u8 onoff) {u8 args[PCAN_USB_CMD_ARGS_LEN ] = {
@@ -445,7 +474,7 @@ static int pcan_usb_decode_error(struct pcan_usb_msg_context *mc, u8 n, new_state =CAN_STATE_BUS_OFF ;break ; } -if (n & (PCAN_USB_ERROR_RXQOVR |PCAN_USB_ERROR_QOVR )) { +if (n & ~PCAN_USB_ERROR_BUS ) {/* * trick to bypass next comparison and process other * errors
@@ -469,7 +498,7 @@ static int pcan_usb_decode_error(struct pcan_usb_msg_context *mc, u8 n, new_state =CAN_STATE_ERROR_WARNING ;break ; } -if (n & (PCAN_USB_ERROR_RXQOVR |PCAN_USB_ERROR_QOVR )) { +if (n & ~PCAN_USB_ERROR_BUS ) {/* * trick to bypass next comparison and process other * errors
@@ -508,29 +537,50 @@ static int pcan_usb_decode_error(struct pcan_usb_msg_context *mc, u8 n,case CAN_STATE_ERROR_PASSIVE : cf->can_id |=CAN_ERR_CRTL ; - cf->data[1 ] |=CAN_ERR_CRTL_TX_PASSIVE | -CAN_ERR_CRTL_RX_PASSIVE ; + cf->data[1 ] = (mc->pdev->bec.txerr > mc->pdev->bec.rxerr) ? +CAN_ERR_CRTL_TX_PASSIVE : +CAN_ERR_CRTL_RX_PASSIVE ; + cf->data[6 ] = mc->pdev->bec.txerr; + cf->data[7 ] = mc->pdev->bec.rxerr; + mc->pdev->dev.can.can_stats.error_passive++;break ;case CAN_STATE_ERROR_WARNING : cf->can_id |=CAN_ERR_CRTL ; - cf->data[1 ] |=CAN_ERR_CRTL_TX_WARNING | -CAN_ERR_CRTL_RX_WARNING ; + cf->data[1 ] = (mc->pdev->bec.txerr > mc->pdev->bec.rxerr) ? +CAN_ERR_CRTL_TX_WARNING : +CAN_ERR_CRTL_RX_WARNING ; + cf->data[6 ] = mc->pdev->bec.txerr; + cf->data[7 ] = mc->pdev->bec.rxerr; + mc->pdev->dev.can.can_stats.error_warning++;break ;case CAN_STATE_ERROR_ACTIVE : cf->can_id |=CAN_ERR_CRTL ; cf->data[1 ] =CAN_ERR_CRTL_ACTIVE ; + +/* sync local copies of rxerr/txerr counters */ + mc->pdev->bec.txerr =0 ; + mc->pdev->bec.rxerr =0 ;break ;default :/* CAN_STATE_MAX (trick to handle other errors) */ - cf->can_id |=CAN_ERR_CRTL ; - cf->data[1 ] |=CAN_ERR_CRTL_RX_OVERFLOW ; - mc->netdev->stats.rx_over_errors++; - mc->netdev->stats.rx_errors++; +if (n &PCAN_USB_ERROR_TXQFULL ) +netdev_dbg (mc->netdev,"device Tx queue full)\n" ); + +if (n &PCAN_USB_ERROR_RXQOVR ) { +netdev_dbg (mc->netdev,"data overrun interrupt\n" ); + cf->can_id |=CAN_ERR_CRTL ; + cf->data[1 ] |=CAN_ERR_CRTL_RX_OVERFLOW ; + mc->netdev->stats.rx_over_errors++; + mc->netdev->stats.rx_errors++; + } + + cf->data[6 ] = mc->pdev->bec.txerr; + cf->data[7 ] = mc->pdev->bec.rxerr; new_state = mc->pdev->dev.can.state;break ;
@@ -552,6 +602,30 @@ static int pcan_usb_decode_error(struct pcan_usb_msg_context *mc, u8 n,return 0 ; } +/* decode bus event usb packet: first byte contains rxerr while 2nd one contains +* txerr. +*/ +static int pcan_usb_handle_bus_evt (struct pcan_usb_msg_context *mc,u8 ir) +{ +struct pcan_usb *pdev = mc->pdev; + +/* acccording to the content of the packet */ +switch (ir) { +case PCAN_USB_ERR_CNT : + +/* save rx/tx error counters from in the device context */ + pdev->bec.rxerr = mc->ptr[0 ]; + pdev->bec.txerr = mc->ptr[1 ]; +break ; + +default : +/* reserved */ +break ; + } + +return 0 ; +} +/* * decode non-data usb message */
@@ -606,9 +680,10 @@ static int pcan_usb_decode_status(struct pcan_usb_msg_context *mc,break ;case PCAN_USB_REC_BUSEVT : -/* error frame/bus event */ -if (n &PCAN_USB_ERROR_TXQFULL ) -netdev_dbg (mc->netdev,"device Tx queue full)\n" ); +/* bus event notifications (get rxerr/txerr) */ + err =pcan_usb_handle_bus_evt (mc, n); +if (err) +return err;break ;default :netdev_err (mc->netdev,"unexpected function %u\n" , f);
@@ -792,20 +867,44 @@ static int pcan_usb_encode_msg(struct peak_usb_device *dev, struct sk_buff *skb,return 0 ; } +/* socket callback used to copy berr counters values received through USB */ +static int pcan_usb_get_berr_counter (const struct net_device *netdev, +struct can_berr_counter *bec) +{ +struct peak_usb_device *dev =netdev_priv (netdev); + struct pcan_usb *pdev = container_of(dev, struct pcan_usb, dev); + + *bec = pdev->bec; + +/* must return 0 */ +return 0 ; +} +/* * start interface */ static int pcan_usb_start (struct peak_usb_device *dev) { struct pcan_usb *pdev = container_of(dev, struct pcan_usb, dev); +int err;/* number of bits used in timestamps read from adapter struct */ peak_usb_init_time_ref (&pdev->time_ref, &pcan_usb); + pdev->bec.rxerr =0 ; + pdev->bec.txerr =0 ; + +/* be notified on error counter changes (if requested by user) */ +if (dev->can.ctrlmode &CAN_CTRLMODE_BERR_REPORTING ) { + err =pcan_usb_set_err_frame (dev,PCAN_USB_BERR_MASK ); +if (err) +netdev_warn (dev->netdev, +"Asking for BERR reporting error %u\n" , + err); + } +/* if revision greater than 3, can put silent mode on/off */ if (dev->device_rev >3 ) { -int err; - err =pcan_usb_set_silent (dev, dev->can.ctrlmode &CAN_CTRLMODE_LISTENONLY );if (err)
@@ -892,7 +991,8 @@ const struct peak_usb_adapter pcan_usb = { .name = "PCAN-USB", .device_id = PCAN_USB_PRODUCT_ID, .ctrl_count = 1, - .ctrlmode_supported = CAN_CTRLMODE_3_SAMPLES | CAN_CTRLMODE_LISTENONLY, + .ctrlmode_supported =CAN_CTRLMODE_3_SAMPLES |CAN_CTRLMODE_LISTENONLY | + CAN_CTRLMODE_BERR_REPORTING, .clock = { .freq = PCAN_USB_CRYSTAL_HZ / 2 , },
@@ -925,4 +1025,5 @@ const struct peak_usb_adapter pcan_usb = { .dev_encode_msg = pcan_usb_encode_msg, .dev_start = pcan_usb_start, .dev_restart_async = pcan_usb_restart_async, + .do_get_berr_counter = pcan_usb_get_berr_counter, };
Signature · 1 line
2.28.0
Marc Kleine-Budde
maintainerPATCH 23/37 can: spi: Kconfig: remove unneeded dependencies form Kconfig symbols
In reply to Marc Kleine-BuddeSince commits
653ee35ce6d5 ("can: hi311x: remove custom DMA mapped buffer")
Fixes: df58525df395 ("can: mcp251x: remove custom DMA mapped buffer")both the hi3111x and the mcp251x driver don't make use of the DMA API any more. So we can safely remove the HAS_DMA dependency.
While we're here, remove the unneeded CAN_DEV and SPI dependencies from the CAN_HI311X symbol, as the parent menus already have these dependencies.
--- drivers/net/can/spi/Kconfig | 2 -- 1 file changed, 2 deletions(-)
drivers/net/can/spi/Kconfig +0 -2
@@ -4,13 +4,11 @@ menu "CAN SPI interfaces" config CAN_HI311X tristate "Holt HI311x SPI CAN controllers" - depends on CAN_DEV && SPI && HAS_DMA help Driver for the Holt HI311x SPI CAN controllers. config CAN_MCP251X tristate "Microchip MCP251x and MCP25625 SPI CAN controllers" - depends on HAS_DMA help Driver for the Microchip MCP251x and MCP25625 SPI CAN controllers.
Signature · 1 line
2.28.0
Marc Kleine-Budde
maintainerPATCH 24/37 dt-bindings: can: mcp251x: change example interrupt type to IRQ_TYPE_LEVEL_LOW
In reply to Marc Kleine-BuddeThe MCP2515 datasheet clearly describes a level-triggered interrupt pin. Change example bindings accordingly.
--- Documentation/devicetree/bindings/net/can/microchip,mcp251x.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
Documentation/devicetree/bindings/net/can/microchip,mcp251x.txt +1 -1
@@ -19,7 +19,7 @@ Example: reg = <1>; clocks = <&clk24m>; interrupt-parent = <&gpio4>; - interrupts = <13 0x2>; + interrupts = <13 IRQ_TYPE_LEVEL_LOW>; vdd-supply = <®5v0>; xceiver-supply = <®5v0>; };
Signature · 1 line
2.28.0
Marc Kleine-Budde
maintainerPATCH 25/37 dt-bindings: can: mcp251x: document GPIO support
In reply to Marc Kleine-BuddeThe next patch adds gpio controller support to the mcp251x driver. This patch updates the binding accordingly.
--- .../devicetree/bindings/net/can/microchip,mcp251x.txt | 5 +++++ 1 file changed, 5 insertions(+)
Documentation/devicetree/bindings/net/can/microchip,mcp251x.txt +5 -0
@@ -12,6 +12,9 @@ Required properties: Optional properties: - vdd-supply: Regulator that powers the CAN controller. - xceiver-supply: Regulator that powers the CAN transceiver. + - gpio-controller: Indicates this device is a GPIO controller. + - #gpio-cells: Should be two. The first cell is the pin number and + the second cell is used to specify the gpio polarity. Example: can0: can@1 {
@@ -22,4 +25,6 @@ Example: interrupts = <13 IRQ_TYPE_LEVEL_LOW>; vdd-supply = <®5v0>; xceiver-supply = <®5v0>; + gpio-controller; + #gpio-cells = <2>; };
Signature · 1 line
2.28.0
Marc Kleine-Budde
maintainerPATCH 26/37 can: mcp251x: sort include files alphabetically
In reply to Marc Kleine-BuddeThis patch sorts the include files alphabetically.
--- drivers/net/can/spi/mcp251x.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/net/can/spi/mcp251x.c +2 -2
@@ -32,12 +32,12 @@#include <linux/kernel.h> #include <linux/module.h> #include <linux/netdevice.h> -#include <linux/property.h> #include <linux/platform_device.h> +#include <linux/property.h> +#include <linux/regulator/consumer.h> #include <linux/slab.h> #include <linux/spi/spi.h> #include <linux/uaccess.h> -#include <linux/regulator/consumer.h> /* SPI interface instruction set */ #define INSTRUCTION_WRITE 0x02
Signature · 1 line
2.28.0
Marc Kleine-Budde
maintainerPATCH 27/37 can: mcp251x: add GPIO support
In reply to Marc Kleine-BuddeFrom: Timo Schlüßler <[email protected]>
The mcp251x variants feature 3 general purpose digital inputs and 2 outputs. With this patch they are accessible through the gpio framework.
--- drivers/net/can/spi/mcp251x.c | 243 ++++++++++++++++++++++++++++++++++ 1 file changed, 243 insertions(+)
drivers/net/can/spi/mcp251x.c +243 -0
@@ -19,6 +19,7 @@* Copyright 2007 */ +#include <linux/bitfield.h> #include <linux/can/core.h> #include <linux/can/dev.h> #include <linux/can/led.h>
@@ -27,6 +28,8 @@#include <linux/delay.h> #include <linux/device.h> #include <linux/freezer.h> +#include <linux/gpio.h> +#include <linux/gpio/driver.h> #include <linux/interrupt.h> #include <linux/io.h> #include <linux/kernel.h>
@@ -52,6 +55,30 @@#define INSTRUCTION_RTS (n) (0x80 | ((n) & 0x07))/* MPC251x registers */ +#define BFPCTRL 0x0c +# define BFPCTRL_B0BFM BIT(0) +# define BFPCTRL_B1BFM BIT(1) +# define BFPCTRL_BFM (n) (BFPCTRL_B0BFM << (n)) +# define BFPCTRL_BFM_MASK GENMASK(1, 0) +# define BFPCTRL_B0BFE BIT(2) +# define BFPCTRL_B1BFE BIT(3) +# define BFPCTRL_BFE (n) (BFPCTRL_B0BFE << (n)) +# define BFPCTRL_BFE_MASK GENMASK(3, 2) +# define BFPCTRL_B0BFS BIT(4) +# define BFPCTRL_B1BFS BIT(5) +# define BFPCTRL_BFS (n) (BFPCTRL_B0BFS << (n)) +# define BFPCTRL_BFS_MASK GENMASK(5, 4) +#define TXRTSCTRL 0x0d +# define TXRTSCTRL_B0RTSM BIT(0) +# define TXRTSCTRL_B1RTSM BIT(1) +# define TXRTSCTRL_B2RTSM BIT(2) +# define TXRTSCTRL_RTSM (n) (TXRTSCTRL_B0RTSM << (n)) +# define TXRTSCTRL_RTSM_MASK GENMASK(2, 0) +# define TXRTSCTRL_B0RTS BIT(3) +# define TXRTSCTRL_B1RTS BIT(4) +# define TXRTSCTRL_B2RTS BIT(5) +# define TXRTSCTRL_RTS (n) (TXRTSCTRL_B0RTS << (n)) +# define TXRTSCTRL_RTS_MASK GENMASK(5, 3)#define CANSTAT 0x0e#define CANCTRL 0x0f# define CANCTRL_REQOP_MASK 0xe0
@@ -225,6 +252,10 @@ struct mcp251x_priv {struct regulator *power;struct regulator *transceiver;struct clk *clk; +#ifdef CONFIG_GPIOLIB +struct gpio_chip gpio; +u8 reg_bfpctrl; +#endif };#define MCP251X_IS (_model) \
@@ -345,6 +376,213 @@ static void mcp251x_write_bits(struct spi_device *spi, u8 reg,mcp251x_spi_trans (spi,4 ); } +#ifdef CONFIG_GPIOLIB +enum { +MCP251X_GPIO_TX0RTS =0 ,/* inputs */ +MCP251X_GPIO_TX1RTS , +MCP251X_GPIO_TX2RTS , +MCP251X_GPIO_RX0BF ,/* outputs */ +MCP251X_GPIO_RX1BF , +}; + +#define MCP251X_GPIO_INPUT_MASK \ + GENMASK(MCP251X_GPIO_TX2RTS, MCP251X_GPIO_TX0RTS) +#define MCP251X_GPIO_OUTPUT_MASK \ + GENMASK(MCP251X_GPIO_RX1BF, MCP251X_GPIO_RX0BF) + +static const char *const mcp251x_gpio_names[] = { + [MCP251X_GPIO_TX0RTS ] ="TX0RTS" ,/* inputs */ + [MCP251X_GPIO_TX1RTS ] ="TX1RTS" , + [MCP251X_GPIO_TX2RTS ] ="TX2RTS" , + [MCP251X_GPIO_RX0BF ] ="RX0BF" ,/* outputs */ + [MCP251X_GPIO_RX1BF ] ="RX1BF" , +}; + +static inline bool mcp251x_gpio_is_input (unsigned int offset) +{ +return offset <=MCP251X_GPIO_TX2RTS ; +} + +static int mcp251x_gpio_request (struct gpio_chip *chip, +unsigned int offset) +{ +struct mcp251x_priv *priv =gpiochip_get_data (chip); +u8 val; + +/* nothing to be done for inputs */ +if (mcp251x_gpio_is_input (offset)) +return 0 ; + + val =BFPCTRL_BFE (offset -MCP251X_GPIO_RX0BF ); + +mutex_lock (&priv->mcp_lock); +mcp251x_write_bits (priv->spi,BFPCTRL , val, val); +mutex_unlock (&priv->mcp_lock); + + priv->reg_bfpctrl |= val; + +return 0 ; +} + +static void mcp251x_gpio_free (struct gpio_chip *chip, +unsigned int offset) +{ +struct mcp251x_priv *priv =gpiochip_get_data (chip); +u8 val; + +/* nothing to be done for inputs */ +if (mcp251x_gpio_is_input (offset)) +return ; + + val =BFPCTRL_BFE (offset -MCP251X_GPIO_RX0BF ); + +mutex_lock (&priv->mcp_lock); +mcp251x_write_bits (priv->spi,BFPCTRL , val,0 ); +mutex_unlock (&priv->mcp_lock); + + priv->reg_bfpctrl &= ~val; +} + +static int mcp251x_gpio_get_direction (struct gpio_chip *chip, +unsigned int offset) +{ +if (mcp251x_gpio_is_input (offset)) +return GPIOF_DIR_IN ; + +return GPIOF_DIR_OUT ; +} + +static int mcp251x_gpio_get (struct gpio_chip *chip,unsigned int offset) +{ +struct mcp251x_priv *priv =gpiochip_get_data (chip); +u8 reg, mask, val; + +if (mcp251x_gpio_is_input (offset)) { + reg =TXRTSCTRL ; + mask =TXRTSCTRL_RTS (offset); + }else { + reg =BFPCTRL ; + mask =BFPCTRL_BFS (offset -MCP251X_GPIO_RX0BF ); + } + +mutex_lock (&priv->mcp_lock); + val =mcp251x_read_reg (priv->spi, reg); +mutex_unlock (&priv->mcp_lock); + +return !!(val & mask); +} + +static int mcp251x_gpio_get_multiple (struct gpio_chip *chip, +unsigned long *maskp,unsigned long *bitsp) +{ +struct mcp251x_priv *priv =gpiochip_get_data (chip); +unsigned long bits =0 ; +u8 val; + +mutex_lock (&priv->mcp_lock); +if (maskp[0 ] &MCP251X_GPIO_INPUT_MASK ) { + val =mcp251x_read_reg (priv->spi,TXRTSCTRL ); + val =FIELD_GET (TXRTSCTRL_RTS_MASK , val); + bits |=FIELD_PREP (MCP251X_GPIO_INPUT_MASK , val); + } +if (maskp[0 ] &MCP251X_GPIO_OUTPUT_MASK ) { + val =mcp251x_read_reg (priv->spi,BFPCTRL ); + val =FIELD_GET (BFPCTRL_BFS_MASK , val); + bits |=FIELD_PREP (MCP251X_GPIO_OUTPUT_MASK , val); + } +mutex_unlock (&priv->mcp_lock); + + bitsp[0 ] = bits; +return 0 ; +} + +static void mcp251x_gpio_set (struct gpio_chip *chip,unsigned int offset, +int value) +{ +struct mcp251x_priv *priv =gpiochip_get_data (chip); +u8 mask, val; + + mask =BFPCTRL_BFS (offset -MCP251X_GPIO_RX0BF ); + val = value ? mask :0 ; + +mutex_lock (&priv->mcp_lock); +mcp251x_write_bits (priv->spi,BFPCTRL , mask, val); +mutex_unlock (&priv->mcp_lock); + + priv->reg_bfpctrl &= ~mask; + priv->reg_bfpctrl |= val; +} + +static void +mcp251x_gpio_set_multiple (struct gpio_chip *chip, +unsigned long *maskp,unsigned long *bitsp) +{ +struct mcp251x_priv *priv =gpiochip_get_data (chip); +u8 mask, val; + + mask =FIELD_GET (MCP251X_GPIO_OUTPUT_MASK , maskp[0 ]); + mask =FIELD_PREP (BFPCTRL_BFS_MASK , mask); + + val =FIELD_GET (MCP251X_GPIO_OUTPUT_MASK , bitsp[0 ]); + val =FIELD_PREP (BFPCTRL_BFS_MASK , val); + +if (!mask) +return ; + +mutex_lock (&priv->mcp_lock); +mcp251x_write_bits (priv->spi,BFPCTRL , mask, val); +mutex_unlock (&priv->mcp_lock); + + priv->reg_bfpctrl &= ~mask; + priv->reg_bfpctrl |= val; +} + +static void mcp251x_gpio_restore (struct spi_device *spi) +{ +struct mcp251x_priv *priv =spi_get_drvdata (spi); + +mcp251x_write_reg (spi,BFPCTRL , priv->reg_bfpctrl); +} + +static int mcp251x_gpio_setup (struct mcp251x_priv *priv) +{ +struct gpio_chip *gpio = &priv->gpio; + +if (!device_property_present (&priv->spi->dev,"gpio-controller" )) +return 0 ; + +/* gpiochip handles TX[0..2]RTS and RX[0..1]BF */ + gpio->label = priv->spi->modalias; + gpio->parent = &priv->spi->dev; + gpio->owner =THIS_MODULE ; + gpio->request = mcp251x_gpio_request; + gpio->free = mcp251x_gpio_free; + gpio->get_direction = mcp251x_gpio_get_direction; + gpio->get = mcp251x_gpio_get; + gpio->get_multiple = mcp251x_gpio_get_multiple; + gpio->set = mcp251x_gpio_set; + gpio->set_multiple = mcp251x_gpio_set_multiple; + gpio->base =-1 ; + gpio->ngpio =ARRAY_SIZE (mcp251x_gpio_names); + gpio->names = mcp251x_gpio_names; + gpio->can_sleep = true; +#ifdef CONFIG_OF_GPIO + gpio->of_node = priv->spi->dev.of_node; +#endif + +return devm_gpiochip_add_data (&priv->spi->dev, gpio, priv); +} +#else +static inline void mcp251x_gpio_restore (struct spi_device *spi) +{ +} + +static inline int mcp251x_gpio_setup (struct mcp251x_priv *priv) +{ +return 0 ; +} +#endif +static void mcp251x_hw_tx_frame (struct spi_device *spi,u8 *buf,int len,int tx_buf_idx) {
@@ -761,6 +999,7 @@ static void mcp251x_restart_work_handler(struct work_struct *ws)if (priv->after_suspend &AFTER_SUSPEND_POWER ) {mcp251x_hw_reset (spi);mcp251x_setup (net, spi); +mcp251x_gpio_restore (spi); }else {mcp251x_hw_wake (spi); }
@@ -1136,6 +1375,10 @@ static int mcp251x_can_probe(struct spi_device *spi)devm_can_led_init (net); + ret =mcp251x_gpio_setup (priv); +if (ret) + goto error_probe; +netdev_info (net,"MCP%x successfully initialized.\n" , priv->model);return 0 ;
Signature · 1 line
2.28.0
Marc Kleine-Budde
maintainerPATCH 28/37 can: mcp251x: Use readx_poll_timeout() helper
In reply to Marc Kleine-BuddeFrom: Andy Shevchenko <[email protected]>
We may use special helper macro to poll IO till condition or timeout occurs.
--- drivers/net/can/spi/mcp251x.c | 64 ++++++++++++++++++----------------- 1 file changed, 33 insertions(+), 31 deletions(-)
drivers/net/can/spi/mcp251x.c +33 -31
@@ -32,6 +32,7 @@#include <linux/gpio/driver.h> #include <linux/interrupt.h> #include <linux/io.h> +#include <linux/iopoll.h> #include <linux/kernel.h> #include <linux/module.h> #include <linux/netdevice.h>
@@ -376,6 +377,15 @@ static void mcp251x_write_bits(struct spi_device *spi, u8 reg,mcp251x_spi_trans (spi,4 ); } +static u8 mcp251x_read_stat (struct spi_device *spi) +{ +return mcp251x_read_reg (spi,CANSTAT ) &CANCTRL_REQOP_MASK ; +} + +#define mcp251x_read_stat_poll_timeout (addr, val, cond, delay_us, timeout_us) \ + readx_poll_timeout(mcp251x_read_stat, addr, val, cond, \ + delay_us, timeout_us) +#ifdef CONFIG_GPIOLIB enum { MCP251X_GPIO_TX0RTS = 0, /* inputs */
@@ -709,7 +719,8 @@ static void mcp251x_hw_sleep(struct spi_device *spi)/* May only be called when device is sleeping! */ static int mcp251x_hw_wake (struct spi_device *spi) { -unsigned long timeout; +u8 value; +int ret;/* Force wakeup interrupt to wake device, but don't execute IST */ disable_irq (spi->irq);
@@ -722,14 +733,12 @@ static int mcp251x_hw_wake(struct spi_device *spi)mcp251x_write_reg (spi,CANCTRL ,CANCTRL_REQOP_CONF );/* Wait for the device to enter config mode */ - timeout = jiffies +HZ ; -while ((mcp251x_read_reg (spi,CANSTAT ) &CANCTRL_REQOP_MASK ) != -CANCTRL_REQOP_CONF ) { -schedule (); -if (time_after (jiffies, timeout)) { -dev_err (&spi->dev,"MCP251x didn't enter in config mode\n" ); -return -EBUSY ; - } + ret =mcp251x_read_stat_poll_timeout (spi, value, value ==CANCTRL_REQOP_CONF , +MCP251X_OST_DELAY_MS *1000 , +USEC_PER_SEC ); +if (ret) { +dev_err (&spi->dev,"MCP251x didn't enter in config mode\n" ); +return ret; }/* Disable and clear pending interrupts */
@@ -784,7 +793,8 @@ static int mcp251x_do_set_mode(struct net_device *net, enum can_mode mode)static int mcp251x_set_normal_mode (struct spi_device *spi) {struct mcp251x_priv *priv =spi_get_drvdata (spi); -unsigned long timeout; +u8 value; +int ret;/* Enable interrupts */ mcp251x_write_reg(spi, CANINTE,
@@ -802,13 +812,12 @@ static int mcp251x_set_normal_mode(struct spi_device *spi)mcp251x_write_reg (spi,CANCTRL ,CANCTRL_REQOP_NORMAL );/* Wait for the device to enter normal mode */ - timeout = jiffies +HZ ; -while (mcp251x_read_reg (spi,CANSTAT ) &CANCTRL_REQOP_MASK ) { -schedule (); -if (time_after (jiffies, timeout)) { -dev_err (&spi->dev,"MCP251x didn't enter in normal mode\n" ); -return -EBUSY ; - } + ret =mcp251x_read_stat_poll_timeout (spi, value, value ==0 , +MCP251X_OST_DELAY_MS *1000 , +USEC_PER_SEC ); +if (ret) { +dev_err (&spi->dev,"MCP251x didn't enter in normal mode\n" ); +return ret; } } priv->can.state =CAN_STATE_ERROR_ACTIVE ;
@@ -852,7 +861,7 @@ static int mcp251x_setup(struct net_device *net, struct spi_device *spi)static int mcp251x_hw_reset (struct spi_device *spi) {struct mcp251x_priv *priv =spi_get_drvdata (spi); -unsigned long timeout; +u8 value;int ret;/* Wait for oscillator startup timer after power up */
@@ -867,19 +876,12 @@ static int mcp251x_hw_reset(struct spi_device *spi)mdelay (MCP251X_OST_DELAY_MS );/* Wait for reset to finish */ - timeout = jiffies +HZ ; -while ((mcp251x_read_reg (spi,CANSTAT ) &CANCTRL_REQOP_MASK ) != -CANCTRL_REQOP_CONF ) { -usleep_range (MCP251X_OST_DELAY_MS *1000 , -MCP251X_OST_DELAY_MS *1000 *2 ); - -if (time_after (jiffies, timeout)) { -dev_err (&spi->dev, -"MCP251x didn't enter in conf mode after reset\n" ); -return -EBUSY ; - } - } -return 0 ; + ret =mcp251x_read_stat_poll_timeout (spi, value, value ==CANCTRL_REQOP_CONF , +MCP251X_OST_DELAY_MS *1000 , +USEC_PER_SEC ); +if (ret) +dev_err (&spi->dev,"MCP251x didn't enter in conf mode after reset\n" ); +return ret; }static int mcp251x_hw_probe (struct spi_device *spi)
Signature · 1 line
2.28.0
Marc Kleine-Budde
maintainerPATCH 29/37 can: mcp251x: add support for half duplex controllers
In reply to Marc Kleine-BuddeFrom: Tim Harvey <[email protected]>
Some SPI host controllers do not support full-duplex SPI and are marked as such via the SPI_CONTROLLER_HALF_DUPLEX controller flag.
For such controllers use half duplex transactions but retain full duplex transactions for the controllers that can handle those.
--- drivers/net/can/spi/mcp251x.c | 34 +++++++++++++++++++++++++++------- 1 file changed, 27 insertions(+), 7 deletions(-)
drivers/net/can/spi/mcp251x.c +27 -7
@@ -322,8 +322,12 @@ static u8 mcp251x_read_reg(struct spi_device *spi, u8 reg) priv->spi_tx_buf[0 ] =INSTRUCTION_READ ; priv->spi_tx_buf[1 ] = reg; -mcp251x_spi_trans (spi,3 ); - val = priv->spi_rx_buf[2 ]; +if (spi->controller->flags &SPI_CONTROLLER_HALF_DUPLEX ) { +spi_write_then_read (spi, priv->spi_tx_buf,2 , &val,1 ); + }else { +mcp251x_spi_trans (spi,3 ); + val = priv->spi_rx_buf[2 ]; + }return val; }
@@ -335,10 +339,18 @@ static void mcp251x_read_2regs(struct spi_device *spi, u8 reg, u8 *v1, u8 *v2) priv->spi_tx_buf[0 ] =INSTRUCTION_READ ; priv->spi_tx_buf[1 ] = reg; -mcp251x_spi_trans (spi,4 ); +if (spi->controller->flags &SPI_CONTROLLER_HALF_DUPLEX ) { +u8 val[2 ] = {0 }; - *v1 = priv->spi_rx_buf[2 ]; - *v2 = priv->spi_rx_buf[3 ]; +spi_write_then_read (spi, priv->spi_tx_buf,2 , val,2 ); + *v1 = val[0 ]; + *v2 = val[1 ]; + }else { +mcp251x_spi_trans (spi,4 ); + + *v1 = priv->spi_rx_buf[2 ]; + *v2 = priv->spi_rx_buf[3 ]; + } }static void mcp251x_write_reg (struct spi_device *spi,u8 reg,u8 val)
@@ -657,8 +669,16 @@ static void mcp251x_hw_rx_frame(struct spi_device *spi, u8 *buf, buf[i] =mcp251x_read_reg (spi,RXBCTRL (buf_idx) + i); }else { priv->spi_tx_buf[RXBCTRL_OFF ] =INSTRUCTION_READ_RXB (buf_idx); -mcp251x_spi_trans (spi,SPI_TRANSFER_BUF_LEN ); -memcpy (buf, priv->spi_rx_buf,SPI_TRANSFER_BUF_LEN ); +if (spi->controller->flags &SPI_CONTROLLER_HALF_DUPLEX ) { +spi_write_then_read (spi, priv->spi_tx_buf,1 , + priv->spi_rx_buf, +SPI_TRANSFER_BUF_LEN ); +memcpy (buf +1 , priv->spi_rx_buf, +SPI_TRANSFER_BUF_LEN -1 ); + }else { +mcp251x_spi_trans (spi,SPI_TRANSFER_BUF_LEN ); +memcpy (buf, priv->spi_rx_buf,SPI_TRANSFER_BUF_LEN ); + } } }
Signature · 1 line
2.28.0
Marc Kleine-Budde
maintainerPATCH 30/37 can: mscan: mpc5xxx_can: update contact email
In reply to Marc Kleine-BuddeFrom: Wolfram Sang <[email protected]>
The 'pengutronix' address is defunct for years. Use the proper contact address.
--- drivers/net/can/mscan/mpc5xxx_can.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/can/mscan/mpc5xxx_can.c +1 -1
@@ -5,7 +5,7 @@* Copyright (C) 2004-2005 Andrey Volkov <[email protected]>, * Varma Electronics Oy * Copyright (C) 2008-2009 Wolfgang Grandegger <[email protected]> -* Copyright (C) 2009 Wolfram Sang, Pengutronix <[email protected]> +* Copyright (C) 2009 Wolfram Sang, Pengutronix <[email protected]> */ #include <linux/kernel.h>
Signature · 1 line
2.28.0
Marc Kleine-Budde
maintainerPATCH 31/37 can: mscan: simplify clock enable/disable
In reply to Marc Kleine-BuddeFrom: Zhang Changzhong <[email protected]>
All the NULL checks are pointless, clk_*() routines already deal with NULL just fine.
--- drivers/net/can/mscan/mscan.c | 28 ++++++++++------------------ 1 file changed, 10 insertions(+), 18 deletions(-)
drivers/net/can/mscan/mscan.c +10 -18
@@ -541,16 +541,12 @@ static int mscan_open(struct net_device *dev)struct mscan_priv *priv =netdev_priv (dev);struct mscan_regs __iomem *regs = priv->reg_base; -if (priv->clk_ipg) { - ret =clk_prepare_enable (priv->clk_ipg); -if (ret) - goto exit_retcode; - } -if (priv->clk_can) { - ret =clk_prepare_enable (priv->clk_can); -if (ret) - goto exit_dis_ipg_clock; - } + ret =clk_prepare_enable (priv->clk_ipg); +if (ret) + goto exit_retcode; + ret =clk_prepare_enable (priv->clk_can); +if (ret) + goto exit_dis_ipg_clock;/* common open */ ret =open_candev (dev);
@@ -584,11 +580,9 @@ static int mscan_open(struct net_device *dev)napi_disable (&priv->napi);close_candev (dev); exit_dis_can_clock: -if (priv->clk_can) -clk_disable_unprepare (priv->clk_can); +clk_disable_unprepare (priv->clk_can); exit_dis_ipg_clock: -if (priv->clk_ipg) -clk_disable_unprepare (priv->clk_ipg); +clk_disable_unprepare (priv->clk_ipg); exit_retcode:return ret; }
@@ -607,10 +601,8 @@ static int mscan_close(struct net_device *dev)close_candev (dev);free_irq (dev->irq, dev); -if (priv->clk_can) -clk_disable_unprepare (priv->clk_can); -if (priv->clk_ipg) -clk_disable_unprepare (priv->clk_ipg); +clk_disable_unprepare (priv->clk_can); +clk_disable_unprepare (priv->clk_ipg);return 0 ; }
Signature · 1 line
2.28.0
Marc Kleine-Budde
maintainerPATCH 32/37 can: rx-offload: can_rx_offload_add_manual(): add new initialization function
In reply to Marc Kleine-BuddeThis patch adds a new initialization function:can_rx_offload_add_manual()
It should be used to add support rx-offload to a driver, if the callback mechanism should not be used. Use e.g. can_rx_offload_queue_sorted() to queue skbs into rx-offload.
--- drivers/net/can/rx-offload.c | 11 +++++++++++ include/linux/can/rx-offload.h | 3 +++ 2 files changed, 14 insertions(+)
drivers/net/can/rx-offload.c +11 -0
@@ -351,6 +351,17 @@ int can_rx_offload_add_fifo(struct net_device *dev, }EXPORT_SYMBOL_GPL (can_rx_offload_add_fifo); +int can_rx_offload_add_manual (struct net_device *dev, +struct can_rx_offload *offload, +unsigned int weight) +{ +if (offload->mailbox_read) +return -EINVAL ; + +return can_rx_offload_init_queue (dev, offload, weight); +} +EXPORT_SYMBOL_GPL (can_rx_offload_add_manual); +void can_rx_offload_enable (struct can_rx_offload *offload) {napi_enable (&offload->napi);
include/linux/can/rx-offload.h +3 -0
@@ -35,6 +35,9 @@ int can_rx_offload_add_timestamp(struct net_device *dev,int can_rx_offload_add_fifo (struct net_device *dev,struct can_rx_offload *offload,unsigned int weight); +int can_rx_offload_add_manual (struct net_device *dev, +struct can_rx_offload *offload, +unsigned int weight);int can_rx_offload_irq_offload_timestamp (struct can_rx_offload *offload,u64 reg);int can_rx_offload_irq_offload_fifo (struct can_rx_offload *offload);
Signature · 1 line
2.28.0
Marc Kleine-Budde
maintainerPATCH 33/37 dt-binding: can: mcp25xxfd: document device tree bindings
In reply to Marc Kleine-BuddeFrom: Oleksij Rempel <[email protected]>
This patch adds the device-tree binding documentation for the Microchip MCP25xxFD SPI CAN controller family.
--- .../bindings/net/can/microchip,mcp25xxfd.yaml | 79 +++++++++++++++++++ 1 file changed, 79 insertions(+) create mode 100644 Documentation/devicetree/bindings/net/can/microchip,mcp25xxfd.yaml
Documentation/devicetree/bindings/net/can/microchip,mcp25xxfd.yaml new file +79 -0
@@ -0,0 +1,79 @@ +# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause) +%YAML 1.2 +--- +$id: http://devicetree.org/schemas/net/can/microchip,mcp25xxfd.yaml# +$schema: http://devicetree.org/meta-schemas/core.yaml# + +title: + Microchip MCP2517FD and MCP2518FD stand-alone CAN controller device tree + bindings + +maintainers: + - Marc Kleine-Budde <[email protected]> + +properties: + compatible: + oneOf: + - const: microchip,mcp2517fd + description: for MCP2517FD + - const: microchip,mcp2518fd + description: for MCP2518FD + - const: microchip,mcp25xxfd + description: to autodetect chip variant + + reg: + maxItems: 1 + + interrupts-extended: + maxItems: 1 + + clocks: + maxItems: 1 + + vdd-supply: + description: Regulator that powers the CAN controller. + maxItems: 1 + + xceiver-supply: + description: Regulator that powers the CAN transceiver. + maxItems: 1 + + microchip,rx-int-gpios: + description: + GPIO phandle of GPIO connected to to INT1 pin of the MCP25XXFD, which + signals a pending RX interrupt. + maxItems: 1 + + spi-max-frequency: + description: + Must be half or less of "clocks" frequency. + maximum: 20000000 + +required: + - compatible + - reg + - interrupts-extended + - clocks + +examples: + - | + #include <dt-bindings/gpio/gpio.h> + #include <dt-bindings/interrupt-controller/irq.h> + + spi0 { + #address-cells = <1>; + #size-cells = <0>; + + can@0 { + compatible = "microchip,mcp25xxfd"; + reg = <0>; + clocks = <&can0_osc>; + pinctrl-names = "default"; + pinctrl-0 = <&can0_pins>; + spi-max-frequency = <20000000>; + interrupts-extended = <&gpio 13 IRQ_TYPE_LEVEL_LOW>; + microchip,rx-int-gpios = <&gpio 27 GPIO_ACTIVE_LOW>; + vdd-supply = <®5v0>; + xceiver-supply = <®5v0>; + }; + };
Signature · 1 line
2.28.0
Marc Kleine-Budde
maintainerPATCH 34/37 can: mcp25xxfd: add regmap infrastructure
In reply to Marc Kleine-BuddeThis patch adds the regmap infrastructure for the Microchip MCP25xxFD SPI CAN controller family. The actual driver is added in the next commit.
--- drivers/net/can/spi/Kconfig | 2 + drivers/net/can/spi/Makefile | 1 + drivers/net/can/spi/mcp25xxfd/Kconfig | 17 + drivers/net/can/spi/mcp25xxfd/Makefile | 7 + .../net/can/spi/mcp25xxfd/mcp25xxfd-crc16.c | 89 ++ .../net/can/spi/mcp25xxfd/mcp25xxfd-regmap.c | 556 ++++++++++++ drivers/net/can/spi/mcp25xxfd/mcp25xxfd.h | 833 ++++++++++++++++++ 7 files changed, 1505 insertions(+) create mode 100644 drivers/net/can/spi/mcp25xxfd/Kconfig create mode 100644 drivers/net/can/spi/mcp25xxfd/Makefile create mode 100644 drivers/net/can/spi/mcp25xxfd/mcp25xxfd-crc16.c create mode 100644 drivers/net/can/spi/mcp25xxfd/mcp25xxfd-regmap.c create mode 100644 drivers/net/can/spi/mcp25xxfd/mcp25xxfd.h
drivers/net/can/spi/Kconfig +2 -0
@@ -13,4 +13,6 @@ config CAN_MCP251X Driver for the Microchip MCP251x and MCP25625 SPI CAN controllers. +source "drivers/net/can/spi/mcp25xxfd/Kconfig" + endmenu
drivers/net/can/spi/Makefile +1 -0
@@ -6,3 +6,4 @@ obj-$(CONFIG_CAN_HI311X) += hi311x.o obj-$(CONFIG_CAN_MCP251X) += mcp251x.o +obj-y += mcp25xxfd/
drivers/net/can/spi/mcp25xxfd/Kconfig new file +17 -0
@@ -0,0 +1,17 @@ +# SPDX-License-Identifier: GPL-2.0-only + +config CAN_MCP25XXFD + tristate "Microchip MCP25xxFD SPI CAN controllers" + select REGMAP + help + Driver for the Microchip MCP25XXFD SPI FD-CAN controller + family. + +config CAN_MCP25XXFD_SANITY + depends on CAN_MCP25XXFD + bool "Additional Sanity Checks" + help + This option enables additional sanity checks in the driver, + that compares various internal counters with the in chip + variants. This comes with a runtime overhead. + Disable if unsure.
drivers/net/can/spi/mcp25xxfd/Makefile new file +7 -0
@@ -0,0 +1,7 @@ +# SPDX-License-Identifier: GPL-2.0-only + +obj-$(CONFIG_CAN_MCP25XXFD) += mcp25xxfd.o + +mcp25xxfd-objs := +mcp25xxfd-objs += mcp25xxfd-crc16.o +mcp25xxfd-objs += mcp25xxfd-regmap.o
drivers/net/can/spi/mcp25xxfd/mcp25xxfd-crc16.c new file +89 -0
89 lines not on this page · raw message
drivers/net/can/spi/mcp25xxfd/mcp25xxfd-regmap.c new file +556 -0
556 lines not on this page · raw message
drivers/net/can/spi/mcp25xxfd/mcp25xxfd.h new file +833 -0
833 lines not on this page · raw message
Signature · 1 line
2.28.0
Marc Kleine-Budde
maintainerPATCH 35/37 can: mcp25xxfd: add driver for Microchip MCP25xxFD SPI CAN
In reply to Marc Kleine-BuddeThis patch adds support for the Microchip MCP25xxFD SPI CAN controller family.
--- drivers/net/can/spi/mcp25xxfd/Makefile | 1 + .../net/can/spi/mcp25xxfd/mcp25xxfd-core.c | 2900 +++++++++++++++++ 2 files changed, 2901 insertions(+) create mode 100644 drivers/net/can/spi/mcp25xxfd/mcp25xxfd-core.c
drivers/net/can/spi/mcp25xxfd/Makefile +1 -0
@@ -3,5 +3,6 @@ obj-$(CONFIG_CAN_MCP25XXFD) += mcp25xxfd.o mcp25xxfd-objs := +mcp25xxfd-objs += mcp25xxfd-core.o mcp25xxfd-objs += mcp25xxfd-crc16.o mcp25xxfd-objs += mcp25xxfd-regmap.o
drivers/net/can/spi/mcp25xxfd/mcp25xxfd-core.c new file +2900 -0
2,900 lines not on this page · raw message
Signature · 1 line
2.28.0
Marc Kleine-Budde
maintainerPATCH 36/37 can: mcp25xxfd: add listen-only mode
In reply to Marc Kleine-BuddeFrom: Kurt Van Dijck <[email protected]>
This commit enables listen-only mode, which works internally like CANFD mode.
--- drivers/net/can/spi/mcp25xxfd/mcp25xxfd-core.c | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-)
drivers/net/can/spi/mcp25xxfd/mcp25xxfd-core.c +10 -6
@@ -392,7 +392,8 @@ static int mcp25xxfd_ring_alloc(struct mcp25xxfd_priv *priv)int ram_free, i; tef_obj_size =sizeof (struct mcp25xxfd_hw_tef_obj ); -if (priv->can.ctrlmode &CAN_CTRLMODE_FD ) { +/* listen-only mode works like FD mode */ +if (priv->can.ctrlmode & (CAN_CTRLMODE_LISTENONLY |CAN_CTRLMODE_FD )) { tx_obj_num =MCP25XXFD_TX_OBJ_NUM_CANFD ; tx_obj_size =sizeof (struct mcp25xxfd_hw_tx_obj_canfd ); rx_obj_size =sizeof (struct mcp25xxfd_hw_rx_obj_canfd );
@@ -807,7 +808,7 @@ mcp25xxfd_chip_rx_fifo_init_one(const struct mcp25xxfd_priv *priv,MCP25XXFD_REG_FIFOCON_RXOVIE |MCP25XXFD_REG_FIFOCON_TFNRFNIE ; -if (priv->can.ctrlmode &CAN_CTRLMODE_FD ) +if (priv->can.ctrlmode & (CAN_CTRLMODE_LISTENONLY |CAN_CTRLMODE_FD )) fifo_con |=FIELD_PREP (MCP25XXFD_REG_FIFOCON_PLSIZE_MASK ,MCP25XXFD_REG_FIFOCON_PLSIZE_64 );else
@@ -857,7 +858,7 @@ static int mcp25xxfd_chip_fifo_init(const struct mcp25xxfd_priv *priv)MCP25XXFD_REG_FIFOCON_TXEN |MCP25XXFD_REG_FIFOCON_TXATIE ; -if (priv->can.ctrlmode &CAN_CTRLMODE_FD ) +if (priv->can.ctrlmode & (CAN_CTRLMODE_LISTENONLY |CAN_CTRLMODE_FD )) val |=FIELD_PREP (MCP25XXFD_REG_FIFOCON_PLSIZE_MASK ,MCP25XXFD_REG_FIFOCON_PLSIZE_64 );else
@@ -930,7 +931,9 @@ static u8 mcp25xxfd_get_normal_mode(const struct mcp25xxfd_priv *priv) {u8 mode; -if (priv->can.ctrlmode &CAN_CTRLMODE_FD ) +if (priv->can.ctrlmode &CAN_CTRLMODE_LISTENONLY ) + mode =MCP25XXFD_REG_CON_MODE_LISTENONLY ; +else if (priv->can.ctrlmode &CAN_CTRLMODE_FD ) mode =MCP25XXFD_REG_CON_MODE_MIXED ;else mode =MCP25XXFD_REG_CON_MODE_CAN2_0 ;
@@ -2787,8 +2790,9 @@ static int mcp25xxfd_probe(struct spi_device *spi) priv->can.do_get_berr_counter = mcp25xxfd_get_berr_counter; priv->can.bittiming_const = &mcp25xxfd_bittiming_const; priv->can.data_bittiming_const = &mcp25xxfd_data_bittiming_const; - priv->can.ctrlmode_supported =CAN_CTRLMODE_BERR_REPORTING | -CAN_CTRLMODE_FD |CAN_CTRLMODE_FD_NON_ISO ; + priv->can.ctrlmode_supported =CAN_CTRLMODE_LISTENONLY | +CAN_CTRLMODE_BERR_REPORTING |CAN_CTRLMODE_FD | +CAN_CTRLMODE_FD_NON_ISO ; priv->ndev = ndev; priv->spi = spi; priv->rx_int = rx_int;
Signature · 1 line
2.28.0
Marc Kleine-Budde
maintainerPATCH 37/37 MAINTAINERS: Add entry for Microchip MCP25XXFD SPI-CAN network driver
In reply to Marc Kleine-BuddeFrom: Manivannan Sadhasivam <[email protected]>
Add MAINTAINERS entry for Microchip MCP25XXFD SPI-CAN network driver.
--- MAINTAINERS | 8 ++++++++ 1 file changed, 8 insertions(+)
MAINTAINERS +8 -0
@@ -10671,6 +10671,14 @@ L: [email protected] S: Maintained F: drivers/hid/hid-mcp2221.c +MCP25XXFD SPI-CAN NETWORK DRIVER +M: Marc Kleine-Budde <[email protected]> +M: Manivannan Sadhasivam <[email protected]> +L: [email protected] +S: Maintained +F: Documentation/devicetree/bindings/net/can/microchip,mcp25xxfd.yaml +F: drivers/net/can/spi/mcp25xxfd/ + MCP4018 AND MCP4531 MICROCHIP DIGITAL POTENTIOMETER DRIVERS M: Peter Rosin <[email protected]> L: [email protected]
Signature · 1 line
2.28.0