linux/drivers/net/can/usb/usb_8dev.c

// SPDX-License-Identifier: GPL-2.0-only
/*
 * CAN driver for "8 devices" USB2CAN converter
 *
 * Copyright (C) 2012 Bernd Krumboeck ([email protected])
 *
 * This driver is inspired by the 3.2.0 version of drivers/net/can/usb/ems_usb.c
 * and drivers/net/can/usb/esd_usb2.c
 *
 * Many thanks to Gerhard Bertelsmann ([email protected])
 * for testing and fixing this driver. Also many thanks to "8 devices",
 * who were very cooperative and answered my questions.
 */

#include <linux/ethtool.h>
#include <linux/signal.h>
#include <linux/slab.h>
#include <linux/module.h>
#include <linux/netdevice.h>
#include <linux/usb.h>

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

/* driver constants */
#define MAX_RX_URBS
#define MAX_TX_URBS
#define RX_BUFFER_SIZE

/* vendor and product id */
#define USB_8DEV_VENDOR_ID
#define USB_8DEV_PRODUCT_ID

/* endpoints */
enum usb_8dev_endpoint {};

/* device CAN clock */
#define USB_8DEV_ABP_CLOCK

/* setup flags */
#define USB_8DEV_SILENT
#define USB_8DEV_LOOPBACK
#define USB_8DEV_DISABLE_AUTO_RESTRANS
#define USB_8DEV_STATUS_FRAME

/* commands */
enum usb_8dev_cmd {};

/* command options */
#define USB_8DEV_BAUD_MANUAL
#define USB_8DEV_CMD_START
#define USB_8DEV_CMD_END

#define USB_8DEV_CMD_SUCCESS
#define USB_8DEV_CMD_ERROR

#define USB_8DEV_CMD_TIMEOUT

/* frames */
#define USB_8DEV_DATA_START
#define USB_8DEV_DATA_END

#define USB_8DEV_TYPE_CAN_FRAME
#define USB_8DEV_TYPE_ERROR_FRAME

#define USB_8DEV_EXTID
#define USB_8DEV_RTR
#define USB_8DEV_ERR_FLAG

/* status */
#define USB_8DEV_STATUSMSG_OK
#define USB_8DEV_STATUSMSG_OVERRUN
#define USB_8DEV_STATUSMSG_BUSLIGHT
#define USB_8DEV_STATUSMSG_BUSHEAVY
#define USB_8DEV_STATUSMSG_BUSOFF
#define USB_8DEV_STATUSMSG_STUFF
#define USB_8DEV_STATUSMSG_FORM
#define USB_8DEV_STATUSMSG_ACK
#define USB_8DEV_STATUSMSG_BIT0
#define USB_8DEV_STATUSMSG_BIT1
#define USB_8DEV_STATUSMSG_CRC

#define USB_8DEV_RP_MASK


/* table of devices that work with this driver */
static const struct usb_device_id usb_8dev_table[] =;

MODULE_DEVICE_TABLE(usb, usb_8dev_table);

struct usb_8dev_tx_urb_context {};

/* Structure to hold all of our device specific stuff */
struct usb_8dev_priv {};

/* tx frame */
struct __packed usb_8dev_tx_msg {};

/* rx frame */
struct __packed usb_8dev_rx_msg {};

/* command frame */
struct __packed usb_8dev_cmd_msg {};

static int usb_8dev_send_cmd_msg(struct usb_8dev_priv *priv, u8 *msg, int size)
{}

static int usb_8dev_wait_cmd_msg(struct usb_8dev_priv *priv, u8 *msg, int size,
				int *actual_length)
{}

/* Send command to device and receive result.
 * Command was successful when opt1 = 0.
 */
static int usb_8dev_send_cmd(struct usb_8dev_priv *priv,
			     struct usb_8dev_cmd_msg *out,
			     struct usb_8dev_cmd_msg *in)
{}

/* Send open command to device */
static int usb_8dev_cmd_open(struct usb_8dev_priv *priv)
{}

/* Send close command to device */
static int usb_8dev_cmd_close(struct usb_8dev_priv *priv)
{}

/* Get firmware and hardware version */
static int usb_8dev_cmd_version(struct usb_8dev_priv *priv, u32 *res)
{}

/* Set network device mode
 *
 * Maybe we should leave this function empty, because the device
 * set mode variable with open command.
 */
static int usb_8dev_set_mode(struct net_device *netdev, enum can_mode mode)
{}

/* Read error/status frames */
static void usb_8dev_rx_err_msg(struct usb_8dev_priv *priv,
				struct usb_8dev_rx_msg *msg)
{}

/* Read data and status frames */
static void usb_8dev_rx_can_msg(struct usb_8dev_priv *priv,
				struct usb_8dev_rx_msg *msg)
{}

/* Callback for reading data from device
 *
 * Check urb status, call read function and resubmit urb read operation.
 */
static void usb_8dev_read_bulk_callback(struct urb *urb)
{}

/* Callback handler for write operations
 *
 * Free allocated buffers, check transmit status and
 * calculate statistic.
 */
static void usb_8dev_write_bulk_callback(struct urb *urb)
{}

/* Send data to device */
static netdev_tx_t usb_8dev_start_xmit(struct sk_buff *skb,
				      struct net_device *netdev)
{}

static int usb_8dev_get_berr_counter(const struct net_device *netdev,
				     struct can_berr_counter *bec)
{}

/* Start USB device */
static int usb_8dev_start(struct usb_8dev_priv *priv)
{}

/* Open USB device */
static int usb_8dev_open(struct net_device *netdev)
{}

static void unlink_all_urbs(struct usb_8dev_priv *priv)
{}

/* Close USB device */
static int usb_8dev_close(struct net_device *netdev)
{}

static const struct net_device_ops usb_8dev_netdev_ops =;

static const struct ethtool_ops usb_8dev_ethtool_ops =;

static const struct can_bittiming_const usb_8dev_bittiming_const =;

/* Probe USB device
 *
 * Check device and firmware.
 * Set supported modes and bittiming constants.
 * Allocate some memory.
 */
static int usb_8dev_probe(struct usb_interface *intf,
			 const struct usb_device_id *id)
{}

/* Called by the usb core when driver is unloaded or device is removed */
static void usb_8dev_disconnect(struct usb_interface *intf)
{}

static struct usb_driver usb_8dev_driver =;

module_usb_driver();

MODULE_AUTHOR();
MODULE_DESCRIPTION();
MODULE_LICENSE();