Commit b9f2cc1b authored by Stephane Grosjean's avatar Stephane Grosjean Committed by Marc Kleine-Budde

can: peak_usb: upgrade core to data bittiming specs

Upgrade PEAK-System USB adapters core to the new data structures (names) and
callbacks added for the support of the CANFD extension. This specific patch
does the mandatory changes to support new data bittiming specs.
Signed-off-by: default avatarStephane Grosjean <s.grosjean@peak-system.com>
Signed-off-by: default avatarMarc Kleine-Budde <mkl@pengutronix.de>
parent e3629f56
...@@ -678,19 +678,43 @@ static int peak_usb_set_mode(struct net_device *netdev, enum can_mode mode) ...@@ -678,19 +678,43 @@ static int peak_usb_set_mode(struct net_device *netdev, enum can_mode mode)
} }
/* /*
* candev callback used to set device bitrate. * candev callback used to set device nominal/arbitration bitrate.
*/ */
static int peak_usb_set_bittiming(struct net_device *netdev) static int peak_usb_set_bittiming(struct net_device *netdev)
{ {
struct peak_usb_device *dev = netdev_priv(netdev); struct peak_usb_device *dev = netdev_priv(netdev);
struct can_bittiming *bt = &dev->can.bittiming; const struct peak_usb_adapter *pa = dev->adapter;
if (dev->adapter->dev_set_bittiming) { if (pa->dev_set_bittiming) {
int err = dev->adapter->dev_set_bittiming(dev, bt); struct can_bittiming *bt = &dev->can.bittiming;
int err = pa->dev_set_bittiming(dev, bt);
if (err) if (err)
netdev_info(netdev, "couldn't set bitrate (err %d)\n", netdev_info(netdev, "couldn't set bitrate (err %d)\n",
err); err);
return err;
}
return 0;
}
/*
* candev callback used to set device data bitrate.
*/
static int peak_usb_set_data_bittiming(struct net_device *netdev)
{
struct peak_usb_device *dev = netdev_priv(netdev);
const struct peak_usb_adapter *pa = dev->adapter;
if (pa->dev_set_data_bittiming) {
struct can_bittiming *bt = &dev->can.data_bittiming;
int err = pa->dev_set_data_bittiming(dev, bt);
if (err)
netdev_info(netdev,
"couldn't set data bitrate (err %d)\n",
err);
return err; return err;
} }
...@@ -749,6 +773,8 @@ static int peak_usb_create_dev(const struct peak_usb_adapter *peak_usb_adapter, ...@@ -749,6 +773,8 @@ static int peak_usb_create_dev(const struct peak_usb_adapter *peak_usb_adapter,
dev->can.clock = peak_usb_adapter->clock; dev->can.clock = peak_usb_adapter->clock;
dev->can.bittiming_const = &peak_usb_adapter->bittiming_const; dev->can.bittiming_const = &peak_usb_adapter->bittiming_const;
dev->can.do_set_bittiming = peak_usb_set_bittiming; dev->can.do_set_bittiming = peak_usb_set_bittiming;
dev->can.data_bittiming_const = &peak_usb_adapter->data_bittiming_const;
dev->can.do_set_data_bittiming = peak_usb_set_data_bittiming;
dev->can.do_set_mode = peak_usb_set_mode; dev->can.do_set_mode = peak_usb_set_mode;
dev->can.do_get_berr_counter = peak_usb_adapter->do_get_berr_counter; dev->can.do_get_berr_counter = peak_usb_adapter->do_get_berr_counter;
dev->can.ctrlmode_supported = peak_usb_adapter->ctrlmode_supported; dev->can.ctrlmode_supported = peak_usb_adapter->ctrlmode_supported;
......
...@@ -47,6 +47,7 @@ struct peak_usb_adapter { ...@@ -47,6 +47,7 @@ struct peak_usb_adapter {
u32 ctrlmode_supported; u32 ctrlmode_supported;
struct can_clock clock; struct can_clock clock;
const struct can_bittiming_const bittiming_const; const struct can_bittiming_const bittiming_const;
const struct can_bittiming_const data_bittiming_const;
unsigned int ctrl_count; unsigned int ctrl_count;
int (*intf_probe)(struct usb_interface *intf); int (*intf_probe)(struct usb_interface *intf);
...@@ -58,6 +59,8 @@ struct peak_usb_adapter { ...@@ -58,6 +59,8 @@ struct peak_usb_adapter {
int (*dev_close)(struct peak_usb_device *dev); int (*dev_close)(struct peak_usb_device *dev);
int (*dev_set_bittiming)(struct peak_usb_device *dev, int (*dev_set_bittiming)(struct peak_usb_device *dev,
struct can_bittiming *bt); struct can_bittiming *bt);
int (*dev_set_data_bittiming)(struct peak_usb_device *dev,
struct can_bittiming *bt);
int (*dev_set_bus)(struct peak_usb_device *dev, u8 onoff); int (*dev_set_bus)(struct peak_usb_device *dev, u8 onoff);
int (*dev_get_device_id)(struct peak_usb_device *dev, u32 *device_id); int (*dev_get_device_id)(struct peak_usb_device *dev, u32 *device_id);
int (*dev_decode_buf)(struct peak_usb_device *dev, struct urb *urb); int (*dev_decode_buf)(struct peak_usb_device *dev, struct urb *urb);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment