linux/drivers/net/can/usb/peak_usb/pcan_usb_core.c

// SPDX-License-Identifier: GPL-2.0-only
/*
 * CAN driver for PEAK System USB adapters
 * Derived from the PCAN project file driver/src/pcan_usb_core.c
 *
 * Copyright (C) 2003-2010 PEAK System-Technik GmbH
 * Copyright (C) 2010-2012 Stephane Grosjean <[email protected]>
 *
 * Many thanks to Klaus Hitschler <[email protected]>
 */
#include <linux/device.h>
#include <linux/ethtool.h>
#include <linux/init.h>
#include <linux/module.h>
#include <linux/netdevice.h>
#include <linux/signal.h>
#include <linux/slab.h>
#include <linux/sysfs.h>
#include <linux/usb.h>

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

#include "pcan_usb_core.h"

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

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

MODULE_DEVICE_TABLE(usb, peak_usb_table);

static ssize_t can_channel_id_show(struct device *dev, struct device_attribute *attr, char *buf)
{}
static DEVICE_ATTR_RO(can_channel_id);

/* mutable to avoid cast in attribute_group */
static struct attribute *peak_usb_sysfs_attrs[] =;

static const struct attribute_group peak_usb_sysfs_group =;

/*
 * dump memory
 */
#define DUMP_WIDTH
void pcan_dump_mem(const char *prompt, const void *p, int l)
{}

/*
 * initialize a time_ref object with usb adapter own settings
 */
void peak_usb_init_time_ref(struct peak_time_ref *time_ref,
			    const struct peak_usb_adapter *adapter)
{}

/*
 * sometimes, another now may be  more recent than current one...
 */
void peak_usb_update_ts_now(struct peak_time_ref *time_ref, u32 ts_now)
{}

/*
 * register device timestamp as now
 */
void peak_usb_set_ts_now(struct peak_time_ref *time_ref, u32 ts_now)
{}

/*
 * compute time according to current ts and time_ref data
 */
void peak_usb_get_ts_time(struct peak_time_ref *time_ref, u32 ts, ktime_t *time)
{}

/* post received skb with native 64-bit hw timestamp */
int peak_usb_netif_rx_64(struct sk_buff *skb, u32 ts_low, u32 ts_high)
{}

/*
 * callback for bulk Rx urb
 */
static void peak_usb_read_bulk_callback(struct urb *urb)
{}

/*
 * callback for bulk Tx urb
 */
static void peak_usb_write_bulk_callback(struct urb *urb)
{}

/*
 * called by netdev to send one skb on the CAN interface.
 */
static netdev_tx_t peak_usb_ndo_start_xmit(struct sk_buff *skb,
					   struct net_device *netdev)
{}

/*
 * start the CAN interface.
 * Rx and Tx urbs are allocated here. Rx urbs are submitted here.
 */
static int peak_usb_start(struct peak_usb_device *dev)
{}

/*
 * called by netdev to open the corresponding CAN interface.
 */
static int peak_usb_ndo_open(struct net_device *netdev)
{}

/*
 * unlink in-flight Rx and Tx urbs and free their memory.
 */
static void peak_usb_unlink_all_urbs(struct peak_usb_device *dev)
{}

/*
 * called by netdev to close the corresponding CAN interface.
 */
static int peak_usb_ndo_stop(struct net_device *netdev)
{}

/*
 * handle end of waiting for the device to reset
 */
void peak_usb_restart_complete(struct peak_usb_device *dev)
{}

void peak_usb_async_complete(struct urb *urb)
{}

/*
 * device (auto-)restart mechanism runs in a timer context =>
 * MUST handle restart with asynchronous usb transfers
 */
static int peak_usb_restart(struct peak_usb_device *dev)
{}

/*
 * candev callback used to change CAN mode.
 * Warning: this is called from a timer context!
 */
static int peak_usb_set_mode(struct net_device *netdev, enum can_mode mode)
{}

/*
 * candev callback used to set device nominal/arbitration bitrate.
 */
static int peak_usb_set_bittiming(struct net_device *netdev)
{}

/*
 * candev callback used to set device data bitrate.
 */
static int peak_usb_set_data_bittiming(struct net_device *netdev)
{}

static int peak_eth_ioctl(struct net_device *netdev, struct ifreq *ifr, int cmd)
{}

static const struct net_device_ops peak_usb_netdev_ops =;

/* CAN-USB devices generally handle 32-bit CAN channel IDs.
 * In case one doesn't, then it have to overload this function.
 */
int peak_usb_get_eeprom_len(struct net_device *netdev)
{}

/* Every CAN-USB device exports the dev_get_can_channel_id() operation. It is used
 * here to fill the data buffer with the user defined CAN channel ID.
 */
int peak_usb_get_eeprom(struct net_device *netdev,
			struct ethtool_eeprom *eeprom, u8 *data)
{}

/* Every CAN-USB device exports the dev_get_can_channel_id()/dev_set_can_channel_id()
 * operations. They are used here to set the new user defined CAN channel ID.
 */
int peak_usb_set_eeprom(struct net_device *netdev,
			struct ethtool_eeprom *eeprom, u8 *data)
{}

int pcan_get_ts_info(struct net_device *dev, struct kernel_ethtool_ts_info *info)
{}

/*
 * create one device which is attached to CAN controller #ctrl_idx of the
 * usb adapter.
 */
static int peak_usb_create_dev(const struct peak_usb_adapter *peak_usb_adapter,
			       struct usb_interface *intf, int ctrl_idx)
{}

/*
 * called by the usb core when the device is unplugged from the system
 */
static void peak_usb_disconnect(struct usb_interface *intf)
{}

/*
 * probe function for new PEAK-System devices
 */
static int peak_usb_probe(struct usb_interface *intf,
			  const struct usb_device_id *id)
{}

/* usb specific object needed to register this driver with the usb subsystem */
static struct usb_driver peak_usb_driver =;

static int __init peak_usb_init(void)
{}

static int peak_usb_do_device_exit(struct device *d, void *arg)
{}

static void __exit peak_usb_exit(void)
{}

module_init();
module_exit(peak_usb_exit);