* [PATCH] can/peak_usb: upgrade core to new CANFD extension
@ 2015-01-19 16:15 Stephane Grosjean
2015-01-19 16:15 ` [PATCH] can/peak_usb: export ctrlmode_supported to adapter specific Stephane Grosjean
` (2 more replies)
0 siblings, 3 replies; 8+ messages in thread
From: Stephane Grosjean @ 2015-01-19 16:15 UTC (permalink / raw)
To: linux-can; +Cc: Oliver Hartkopp, Stephane Grosjean
Upgrade PEAK-System USB adapters core to the new data structures (names)
and callbacks added for the support of the CANFD extension.
Signed-off-by: Stephane Grosjean <s.grosjean@peak-system.com>
---
drivers/net/can/usb/peak_usb/pcan_usb_core.c | 59 ++++++++++++++++++++++++----
drivers/net/can/usb/peak_usb/pcan_usb_core.h | 9 ++++-
2 files changed, 58 insertions(+), 10 deletions(-)
diff --git a/drivers/net/can/usb/peak_usb/pcan_usb_core.c b/drivers/net/can/usb/peak_usb/pcan_usb_core.c
index c62f48a..be267af 100644
--- a/drivers/net/can/usb/peak_usb/pcan_usb_core.c
+++ b/drivers/net/can/usb/peak_usb/pcan_usb_core.c
@@ -165,6 +165,21 @@ void peak_usb_get_ts_tv(struct peak_time_ref *time_ref, u32 ts,
}
/*
+ * post received skb after having set any hw timestamp
+ */
+int peak_usb_netif_rx(struct sk_buff *skb,
+ struct peak_time_ref *time_ref, u32 ts_low, u32 ts_high)
+{
+ struct skb_shared_hwtstamps *hwts = skb_hwtstamps(skb);
+ struct timeval tv;
+
+ peak_usb_get_ts_tv(time_ref, ts_low, &tv);
+ hwts->hwtstamp = timeval_to_ktime(tv);
+
+ return netif_rx(skb);
+}
+
+/*
* callback for bulk Rx urb
*/
static void peak_usb_read_bulk_callback(struct urb *urb)
@@ -253,7 +268,7 @@ static void peak_usb_write_bulk_callback(struct urb *urb)
case 0:
/* transmission complete */
netdev->stats.tx_packets++;
- netdev->stats.tx_bytes += context->dlc;
+ netdev->stats.tx_bytes += context->data_len;
/* prevent tx timeout */
netdev->trans_start = jiffies;
@@ -289,7 +304,7 @@ static netdev_tx_t peak_usb_ndo_start_xmit(struct sk_buff *skb,
struct peak_usb_device *dev = netdev_priv(netdev);
struct peak_tx_urb_context *context = NULL;
struct net_device_stats *stats = &netdev->stats;
- struct can_frame *cf = (struct can_frame *)skb->data;
+ struct canfd_frame *cfd = (struct canfd_frame *)skb->data;
struct urb *urb;
u8 *obuf;
int i, err;
@@ -322,7 +337,9 @@ static netdev_tx_t peak_usb_ndo_start_xmit(struct sk_buff *skb,
}
context->echo_index = i;
- context->dlc = cf->can_dlc;
+
+ /* Note: this works with CANFD frames too */
+ context->data_len = cfd->len;
usb_anchor_urb(urb, &dev->tx_submitted);
@@ -679,19 +696,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)
{
struct peak_usb_device *dev = netdev_priv(netdev);
- struct can_bittiming *bt = &dev->can.bittiming;
+ struct peak_usb_adapter *pa = dev->adapter;
- if (dev->adapter->dev_set_bittiming) {
- int err = dev->adapter->dev_set_bittiming(dev, bt);
+ if (pa->dev_set_bittiming) {
+ struct can_bittiming *bt = &dev->can.bittiming;
+ int err = pa->dev_set_bittiming(dev, bt);
if (err)
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);
+ 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;
}
@@ -750,6 +791,8 @@ static int peak_usb_create_dev(struct peak_usb_adapter *peak_usb_adapter,
dev->can.clock = peak_usb_adapter->clock;
dev->can.bittiming_const = &peak_usb_adapter->bittiming_const;
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.ctrlmode_supported = CAN_CTRLMODE_3_SAMPLES |
CAN_CTRLMODE_LISTENONLY;
diff --git a/drivers/net/can/usb/peak_usb/pcan_usb_core.h b/drivers/net/can/usb/peak_usb/pcan_usb_core.h
index 073b47f..928012f 100644
--- a/drivers/net/can/usb/peak_usb/pcan_usb_core.h
+++ b/drivers/net/can/usb/peak_usb/pcan_usb_core.h
@@ -46,6 +46,7 @@ struct peak_usb_adapter {
u32 device_id;
struct can_clock clock;
const struct can_bittiming_const bittiming_const;
+ const struct can_bittiming_const data_bittiming_const;
unsigned int ctrl_count;
int (*intf_probe)(struct usb_interface *intf);
@@ -57,6 +58,8 @@ struct peak_usb_adapter {
int (*dev_close)(struct peak_usb_device *dev);
int (*dev_set_bittiming)(struct peak_usb_device *dev,
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_get_device_id)(struct peak_usb_device *dev, u32 *device_id);
int (*dev_decode_buf)(struct peak_usb_device *dev, struct urb *urb);
@@ -92,7 +95,7 @@ struct peak_time_ref {
struct peak_tx_urb_context {
struct peak_usb_device *dev;
u32 echo_index;
- u8 dlc;
+ u8 data_len;
struct urb *urb;
};
@@ -139,7 +142,9 @@ void peak_usb_update_ts_now(struct peak_time_ref *time_ref, u32 ts_now);
void peak_usb_set_ts_now(struct peak_time_ref *time_ref, u32 ts_now);
void peak_usb_get_ts_tv(struct peak_time_ref *time_ref, u32 ts,
struct timeval *tv);
-
+int peak_usb_netif_rx(struct sk_buff *skb,
+ struct peak_time_ref *time_ref, u32 ts_low, u32 ts_high);
void peak_usb_async_complete(struct urb *urb);
void peak_usb_restart_complete(struct peak_usb_device *dev);
+
#endif
--
1.9.1
^ permalink raw reply related [flat|nested] 8+ messages in thread
* [PATCH] can/peak_usb: export ctrlmode_supported to adapter specific
2015-01-19 16:15 [PATCH] can/peak_usb: upgrade core to new CANFD extension Stephane Grosjean
@ 2015-01-19 16:15 ` Stephane Grosjean
2015-01-20 14:18 ` Marc Kleine-Budde
2015-01-19 16:15 ` [PATCH] can/peak_usb: add adapter BEC callback definition Stephane Grosjean
2015-01-20 14:17 ` [PATCH] can/peak_usb: upgrade core to new CANFD extension Marc Kleine-Budde
2 siblings, 1 reply; 8+ messages in thread
From: Stephane Grosjean @ 2015-01-19 16:15 UTC (permalink / raw)
To: linux-can; +Cc: Oliver Hartkopp, Stephane Grosjean
Export the ctrlmode_supported value from the core file to each adapter
specific file. This has been mandatory for supporting the new CANFD
extension.
Signed-off-by: Stephane Grosjean <s.grosjean@peak-system.com>
---
drivers/net/can/usb/peak_usb/pcan_usb.c | 1 +
drivers/net/can/usb/peak_usb/pcan_usb_core.c | 3 +--
drivers/net/can/usb/peak_usb/pcan_usb_core.h | 1 +
drivers/net/can/usb/peak_usb/pcan_usb_pro.c | 1 +
4 files changed, 4 insertions(+), 2 deletions(-)
diff --git a/drivers/net/can/usb/peak_usb/pcan_usb.c b/drivers/net/can/usb/peak_usb/pcan_usb.c
index 4e1659d..5972c7a 100644
--- a/drivers/net/can/usb/peak_usb/pcan_usb.c
+++ b/drivers/net/can/usb/peak_usb/pcan_usb.c
@@ -858,6 +858,7 @@ 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,
.clock = {
.freq = PCAN_USB_CRYSTAL_HZ / 2 ,
},
diff --git a/drivers/net/can/usb/peak_usb/pcan_usb_core.c b/drivers/net/can/usb/peak_usb/pcan_usb_core.c
index be267af..c23609a 100644
--- a/drivers/net/can/usb/peak_usb/pcan_usb_core.c
+++ b/drivers/net/can/usb/peak_usb/pcan_usb_core.c
@@ -794,8 +794,7 @@ static int peak_usb_create_dev(struct peak_usb_adapter *peak_usb_adapter,
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.ctrlmode_supported = CAN_CTRLMODE_3_SAMPLES |
- CAN_CTRLMODE_LISTENONLY;
+ dev->can.ctrlmode_supported = peak_usb_adapter->ctrlmode_supported;
netdev->netdev_ops = &peak_usb_netdev_ops;
diff --git a/drivers/net/can/usb/peak_usb/pcan_usb_core.h b/drivers/net/can/usb/peak_usb/pcan_usb_core.h
index 928012f..a58d971 100644
--- a/drivers/net/can/usb/peak_usb/pcan_usb_core.h
+++ b/drivers/net/can/usb/peak_usb/pcan_usb_core.h
@@ -44,6 +44,7 @@ struct peak_usb_device;
struct peak_usb_adapter {
char *name;
u32 device_id;
+ u32 ctrlmode_supported;
struct can_clock clock;
const struct can_bittiming_const bittiming_const;
const struct can_bittiming_const data_bittiming_const;
diff --git a/drivers/net/can/usb/peak_usb/pcan_usb_pro.c b/drivers/net/can/usb/peak_usb/pcan_usb_pro.c
index 4cfa3b8..a2fc94a 100644
--- a/drivers/net/can/usb/peak_usb/pcan_usb_pro.c
+++ b/drivers/net/can/usb/peak_usb/pcan_usb_pro.c
@@ -1015,6 +1015,7 @@ struct peak_usb_adapter pcan_usb_pro = {
.name = "PCAN-USB Pro",
.device_id = PCAN_USBPRO_PRODUCT_ID,
.ctrl_count = PCAN_USBPRO_CHANNEL_COUNT,
+ .ctrlmode_supported = CAN_CTRLMODE_3_SAMPLES | CAN_CTRLMODE_LISTENONLY,
.clock = {
.freq = PCAN_USBPRO_CRYSTAL_HZ,
},
--
1.9.1
^ permalink raw reply related [flat|nested] 8+ messages in thread
* [PATCH] can/peak_usb: add adapter BEC callback definition
2015-01-19 16:15 [PATCH] can/peak_usb: upgrade core to new CANFD extension Stephane Grosjean
2015-01-19 16:15 ` [PATCH] can/peak_usb: export ctrlmode_supported to adapter specific Stephane Grosjean
@ 2015-01-19 16:15 ` Stephane Grosjean
2015-01-20 14:19 ` Marc Kleine-Budde
2015-01-20 14:17 ` [PATCH] can/peak_usb: upgrade core to new CANFD extension Marc Kleine-Budde
2 siblings, 1 reply; 8+ messages in thread
From: Stephane Grosjean @ 2015-01-19 16:15 UTC (permalink / raw)
To: linux-can; +Cc: Oliver Hartkopp, Stephane Grosjean
Add the definition of a new callback that enable any PEAK-System CAN USB
adapter to grant read access to its Bus Error Counters value.
This ability is not supported by all the PEAK-System adapters, thus,
for those, the callback pointer will be initiaized to NULL, which is
correct regarding the linux-can device driver specs.
Signed-off-by: Stephane Grosjean <s.grosjean@peak-system.com>
---
drivers/net/can/usb/peak_usb/pcan_usb_core.c | 2 ++
drivers/net/can/usb/peak_usb/pcan_usb_core.h | 2 ++
2 files changed, 4 insertions(+)
diff --git a/drivers/net/can/usb/peak_usb/pcan_usb_core.c b/drivers/net/can/usb/peak_usb/pcan_usb_core.c
index c23609a..7a73060 100644
--- a/drivers/net/can/usb/peak_usb/pcan_usb_core.c
+++ b/drivers/net/can/usb/peak_usb/pcan_usb_core.c
@@ -794,6 +794,8 @@ static int peak_usb_create_dev(struct peak_usb_adapter *peak_usb_adapter,
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_get_berr_counter =
+ peak_usb_adapter->candev_get_berr_counter;
dev->can.ctrlmode_supported = peak_usb_adapter->ctrlmode_supported;
netdev->netdev_ops = &peak_usb_netdev_ops;
diff --git a/drivers/net/can/usb/peak_usb/pcan_usb_core.h b/drivers/net/can/usb/peak_usb/pcan_usb_core.h
index a58d971..fb402d2 100644
--- a/drivers/net/can/usb/peak_usb/pcan_usb_core.h
+++ b/drivers/net/can/usb/peak_usb/pcan_usb_core.h
@@ -70,6 +70,8 @@ struct peak_usb_adapter {
int (*dev_stop)(struct peak_usb_device *dev);
int (*dev_restart_async)(struct peak_usb_device *dev, struct urb *urb,
u8 *buf);
+ int (*candev_get_berr_counter)(const struct net_device *netdev,
+ struct can_berr_counter *bec);
u8 ep_msg_in;
u8 ep_msg_out[PCAN_USB_MAX_CHANNEL];
u8 ts_used_bits;
--
1.9.1
^ permalink raw reply related [flat|nested] 8+ messages in thread
* Re: [PATCH] can/peak_usb: upgrade core to new CANFD extension
2015-01-19 16:15 [PATCH] can/peak_usb: upgrade core to new CANFD extension Stephane Grosjean
2015-01-19 16:15 ` [PATCH] can/peak_usb: export ctrlmode_supported to adapter specific Stephane Grosjean
2015-01-19 16:15 ` [PATCH] can/peak_usb: add adapter BEC callback definition Stephane Grosjean
@ 2015-01-20 14:17 ` Marc Kleine-Budde
2 siblings, 0 replies; 8+ messages in thread
From: Marc Kleine-Budde @ 2015-01-20 14:17 UTC (permalink / raw)
To: Stephane Grosjean, linux-can; +Cc: Oliver Hartkopp
[-- Attachment #1: Type: text/plain, Size: 6651 bytes --]
On 01/19/2015 05:15 PM, Stephane Grosjean wrote:
> Upgrade PEAK-System USB adapters core to the new data structures (names)
> and callbacks added for the support of the CANFD extension.
>
> Signed-off-by: Stephane Grosjean <s.grosjean@peak-system.com>
> ---
> drivers/net/can/usb/peak_usb/pcan_usb_core.c | 59 ++++++++++++++++++++++++----
> drivers/net/can/usb/peak_usb/pcan_usb_core.h | 9 ++++-
> 2 files changed, 58 insertions(+), 10 deletions(-)
>
> diff --git a/drivers/net/can/usb/peak_usb/pcan_usb_core.c b/drivers/net/can/usb/peak_usb/pcan_usb_core.c
> index c62f48a..be267af 100644
> --- a/drivers/net/can/usb/peak_usb/pcan_usb_core.c
> +++ b/drivers/net/can/usb/peak_usb/pcan_usb_core.c
> @@ -165,6 +165,21 @@ void peak_usb_get_ts_tv(struct peak_time_ref *time_ref, u32 ts,
> }
>
> /*
> + * post received skb after having set any hw timestamp
> + */
> +int peak_usb_netif_rx(struct sk_buff *skb,
> + struct peak_time_ref *time_ref, u32 ts_low, u32 ts_high)
> +{
Why do we have this function? It's only used in pcan_usb_fd.c.
I've moved it into a seperate patch.
> + struct skb_shared_hwtstamps *hwts = skb_hwtstamps(skb);
> + struct timeval tv;
> +
> + peak_usb_get_ts_tv(time_ref, ts_low, &tv);
> + hwts->hwtstamp = timeval_to_ktime(tv);
> +
> + return netif_rx(skb);
> +}
> +
> +/*
> * callback for bulk Rx urb
> */
> static void peak_usb_read_bulk_callback(struct urb *urb)
> @@ -253,7 +268,7 @@ static void peak_usb_write_bulk_callback(struct urb *urb)
> case 0:
> /* transmission complete */
> netdev->stats.tx_packets++;
> - netdev->stats.tx_bytes += context->dlc;
> + netdev->stats.tx_bytes += context->data_len;
>
> /* prevent tx timeout */
> netdev->trans_start = jiffies;
> @@ -289,7 +304,7 @@ static netdev_tx_t peak_usb_ndo_start_xmit(struct sk_buff *skb,
> struct peak_usb_device *dev = netdev_priv(netdev);
> struct peak_tx_urb_context *context = NULL;
> struct net_device_stats *stats = &netdev->stats;
> - struct can_frame *cf = (struct can_frame *)skb->data;
> + struct canfd_frame *cfd = (struct canfd_frame *)skb->data;
> struct urb *urb;
> u8 *obuf;
> int i, err;
> @@ -322,7 +337,9 @@ static netdev_tx_t peak_usb_ndo_start_xmit(struct sk_buff *skb,
> }
>
> context->echo_index = i;
> - context->dlc = cf->can_dlc;
> +
> + /* Note: this works with CANFD frames too */
> + context->data_len = cfd->len;
>
> usb_anchor_urb(urb, &dev->tx_submitted);
>
> @@ -679,19 +696,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)
> {
> struct peak_usb_device *dev = netdev_priv(netdev);
> - struct can_bittiming *bt = &dev->can.bittiming;
> + struct peak_usb_adapter *pa = dev->adapter;
>
> - if (dev->adapter->dev_set_bittiming) {
> - int err = dev->adapter->dev_set_bittiming(dev, bt);
> + if (pa->dev_set_bittiming) {
> + struct can_bittiming *bt = &dev->can.bittiming;
> + int err = pa->dev_set_bittiming(dev, bt);
>
> if (err)
> 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);
> + 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;
> }
I've moved the bittiming changes into a seperate patch.
>
> @@ -750,6 +791,8 @@ static int peak_usb_create_dev(struct peak_usb_adapter *peak_usb_adapter,
> dev->can.clock = peak_usb_adapter->clock;
> dev->can.bittiming_const = &peak_usb_adapter->bittiming_const;
> 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.ctrlmode_supported = CAN_CTRLMODE_3_SAMPLES |
> CAN_CTRLMODE_LISTENONLY;
> diff --git a/drivers/net/can/usb/peak_usb/pcan_usb_core.h b/drivers/net/can/usb/peak_usb/pcan_usb_core.h
> index 073b47f..928012f 100644
> --- a/drivers/net/can/usb/peak_usb/pcan_usb_core.h
> +++ b/drivers/net/can/usb/peak_usb/pcan_usb_core.h
> @@ -46,6 +46,7 @@ struct peak_usb_adapter {
> u32 device_id;
> struct can_clock clock;
> const struct can_bittiming_const bittiming_const;
> + const struct can_bittiming_const data_bittiming_const;
> unsigned int ctrl_count;
>
> int (*intf_probe)(struct usb_interface *intf);
> @@ -57,6 +58,8 @@ struct peak_usb_adapter {
> int (*dev_close)(struct peak_usb_device *dev);
> int (*dev_set_bittiming)(struct peak_usb_device *dev,
> 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_get_device_id)(struct peak_usb_device *dev, u32 *device_id);
> int (*dev_decode_buf)(struct peak_usb_device *dev, struct urb *urb);
> @@ -92,7 +95,7 @@ struct peak_time_ref {
> struct peak_tx_urb_context {
> struct peak_usb_device *dev;
> u32 echo_index;
> - u8 dlc;
> + u8 data_len;
> struct urb *urb;
> };
>
> @@ -139,7 +142,9 @@ void peak_usb_update_ts_now(struct peak_time_ref *time_ref, u32 ts_now);
> void peak_usb_set_ts_now(struct peak_time_ref *time_ref, u32 ts_now);
> void peak_usb_get_ts_tv(struct peak_time_ref *time_ref, u32 ts,
> struct timeval *tv);
> -
> +int peak_usb_netif_rx(struct sk_buff *skb,
> + struct peak_time_ref *time_ref, u32 ts_low, u32 ts_high);
> void peak_usb_async_complete(struct urb *urb);
> void peak_usb_restart_complete(struct peak_usb_device *dev);
> +
> #endif
>
Marc
--
Pengutronix e.K. | Marc Kleine-Budde |
Industrial Linux Solutions | Phone: +49-231-2826-924 |
Vertretung West/Dortmund | Fax: +49-5121-206917-5555 |
Amtsgericht Hildesheim, HRA 2686 | http://www.pengutronix.de |
[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 819 bytes --]
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH] can/peak_usb: export ctrlmode_supported to adapter specific
2015-01-19 16:15 ` [PATCH] can/peak_usb: export ctrlmode_supported to adapter specific Stephane Grosjean
@ 2015-01-20 14:18 ` Marc Kleine-Budde
0 siblings, 0 replies; 8+ messages in thread
From: Marc Kleine-Budde @ 2015-01-20 14:18 UTC (permalink / raw)
To: Stephane Grosjean, linux-can; +Cc: Oliver Hartkopp
[-- Attachment #1: Type: text/plain, Size: 570 bytes --]
On 01/19/2015 05:15 PM, Stephane Grosjean wrote:
> Export the ctrlmode_supported value from the core file to each adapter
> specific file. This has been mandatory for supporting the new CANFD
> extension.
Looks good, although the subject could be improved, it looks unfinished.
Marc
--
Pengutronix e.K. | Marc Kleine-Budde |
Industrial Linux Solutions | Phone: +49-231-2826-924 |
Vertretung West/Dortmund | Fax: +49-5121-206917-5555 |
Amtsgericht Hildesheim, HRA 2686 | http://www.pengutronix.de |
[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 819 bytes --]
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH] can/peak_usb: add adapter BEC callback definition
2015-01-19 16:15 ` [PATCH] can/peak_usb: add adapter BEC callback definition Stephane Grosjean
@ 2015-01-20 14:19 ` Marc Kleine-Budde
2015-01-20 14:46 ` Stephane Grosjean
0 siblings, 1 reply; 8+ messages in thread
From: Marc Kleine-Budde @ 2015-01-20 14:19 UTC (permalink / raw)
To: Stephane Grosjean, linux-can; +Cc: Oliver Hartkopp
[-- Attachment #1: Type: text/plain, Size: 2388 bytes --]
On 01/19/2015 05:15 PM, Stephane Grosjean wrote:
> Add the definition of a new callback that enable any PEAK-System CAN USB
> adapter to grant read access to its Bus Error Counters value.
> This ability is not supported by all the PEAK-System adapters, thus,
> for those, the callback pointer will be initiaized to NULL, which is
> correct regarding the linux-can device driver specs.
>
> Signed-off-by: Stephane Grosjean <s.grosjean@peak-system.com>
> ---
> drivers/net/can/usb/peak_usb/pcan_usb_core.c | 2 ++
> drivers/net/can/usb/peak_usb/pcan_usb_core.h | 2 ++
> 2 files changed, 4 insertions(+)
>
> diff --git a/drivers/net/can/usb/peak_usb/pcan_usb_core.c b/drivers/net/can/usb/peak_usb/pcan_usb_core.c
> index c23609a..7a73060 100644
> --- a/drivers/net/can/usb/peak_usb/pcan_usb_core.c
> +++ b/drivers/net/can/usb/peak_usb/pcan_usb_core.c
> @@ -794,6 +794,8 @@ static int peak_usb_create_dev(struct peak_usb_adapter *peak_usb_adapter,
> 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_get_berr_counter =
> + peak_usb_adapter->candev_get_berr_counter;
> dev->can.ctrlmode_supported = peak_usb_adapter->ctrlmode_supported;
>
> netdev->netdev_ops = &peak_usb_netdev_ops;
> diff --git a/drivers/net/can/usb/peak_usb/pcan_usb_core.h b/drivers/net/can/usb/peak_usb/pcan_usb_core.h
> index a58d971..fb402d2 100644
> --- a/drivers/net/can/usb/peak_usb/pcan_usb_core.h
> +++ b/drivers/net/can/usb/peak_usb/pcan_usb_core.h
> @@ -70,6 +70,8 @@ struct peak_usb_adapter {
> int (*dev_stop)(struct peak_usb_device *dev);
> int (*dev_restart_async)(struct peak_usb_device *dev, struct urb *urb,
> u8 *buf);
> + int (*candev_get_berr_counter)(const struct net_device *netdev,
^^^^^^
I think this prefix can be removed. I've done so in my series.
> + struct can_berr_counter *bec);
> u8 ep_msg_in;
> u8 ep_msg_out[PCAN_USB_MAX_CHANNEL];
> u8 ts_used_bits;
>
Marc
--
Pengutronix e.K. | Marc Kleine-Budde |
Industrial Linux Solutions | Phone: +49-231-2826-924 |
Vertretung West/Dortmund | Fax: +49-5121-206917-5555 |
Amtsgericht Hildesheim, HRA 2686 | http://www.pengutronix.de |
[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 819 bytes --]
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH] can/peak_usb: add adapter BEC callback definition
2015-01-20 14:19 ` Marc Kleine-Budde
@ 2015-01-20 14:46 ` Stephane Grosjean
2015-01-20 14:50 ` Marc Kleine-Budde
0 siblings, 1 reply; 8+ messages in thread
From: Stephane Grosjean @ 2015-01-20 14:46 UTC (permalink / raw)
To: Marc Kleine-Budde, linux-can; +Cc: Oliver Hartkopp
Le 20/01/2015 15:19, Marc Kleine-Budde a écrit :
> On 01/19/2015 05:15 PM, Stephane Grosjean wrote:
>> Add the definition of a new callback that enable any PEAK-System CAN USB
>> adapter to grant read access to its Bus Error Counters value.
>> This ability is not supported by all the PEAK-System adapters, thus,
>> for those, the callback pointer will be initiaized to NULL, which is
>> correct regarding the linux-can device driver specs.
>>
>> Signed-off-by: Stephane Grosjean <s.grosjean@peak-system.com>
>> ---
>> drivers/net/can/usb/peak_usb/pcan_usb_core.c | 2 ++
>> drivers/net/can/usb/peak_usb/pcan_usb_core.h | 2 ++
>> 2 files changed, 4 insertions(+)
>>
>> diff --git a/drivers/net/can/usb/peak_usb/pcan_usb_core.c b/drivers/net/can/usb/peak_usb/pcan_usb_core.c
>> index c23609a..7a73060 100644
>> --- a/drivers/net/can/usb/peak_usb/pcan_usb_core.c
>> +++ b/drivers/net/can/usb/peak_usb/pcan_usb_core.c
>> @@ -794,6 +794,8 @@ static int peak_usb_create_dev(struct peak_usb_adapter *peak_usb_adapter,
>> 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_get_berr_counter =
>> + peak_usb_adapter->candev_get_berr_counter;
>> dev->can.ctrlmode_supported = peak_usb_adapter->ctrlmode_supported;
>>
>> netdev->netdev_ops = &peak_usb_netdev_ops;
>> diff --git a/drivers/net/can/usb/peak_usb/pcan_usb_core.h b/drivers/net/can/usb/peak_usb/pcan_usb_core.h
>> index a58d971..fb402d2 100644
>> --- a/drivers/net/can/usb/peak_usb/pcan_usb_core.h
>> +++ b/drivers/net/can/usb/peak_usb/pcan_usb_core.h
>> @@ -70,6 +70,8 @@ struct peak_usb_adapter {
>> int (*dev_stop)(struct peak_usb_device *dev);
>> int (*dev_restart_async)(struct peak_usb_device *dev, struct urb *urb,
>> u8 *buf);
>> + int (*candev_get_berr_counter)(const struct net_device *netdev,
> ^^^^^^
>
> I think this prefix can be removed. I've done so in my series.
FYI: I added this specific prefix because this is the only callback I'm
obliged to use with the "struct net_device *" argument.
No other way to setup a specific callback to get the BEC.
>
>> + struct can_berr_counter *bec);
>> u8 ep_msg_in;
>> u8 ep_msg_out[PCAN_USB_MAX_CHANNEL];
>> u8 ts_used_bits;
>>
> Marc
--
PEAK-System Technik GmbH
Sitz der Gesellschaft Darmstadt
Handelsregister Darmstadt HRB 9183
Geschaeftsfuehrung: Alexander Gach, Uwe Wilhelm
--
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH] can/peak_usb: add adapter BEC callback definition
2015-01-20 14:46 ` Stephane Grosjean
@ 2015-01-20 14:50 ` Marc Kleine-Budde
0 siblings, 0 replies; 8+ messages in thread
From: Marc Kleine-Budde @ 2015-01-20 14:50 UTC (permalink / raw)
To: Stephane Grosjean, linux-can; +Cc: Oliver Hartkopp
[-- Attachment #1: Type: text/plain, Size: 2725 bytes --]
On 01/20/2015 03:46 PM, Stephane Grosjean wrote:
>
> Le 20/01/2015 15:19, Marc Kleine-Budde a écrit :
>> On 01/19/2015 05:15 PM, Stephane Grosjean wrote:
>>> Add the definition of a new callback that enable any PEAK-System CAN USB
>>> adapter to grant read access to its Bus Error Counters value.
>>> This ability is not supported by all the PEAK-System adapters, thus,
>>> for those, the callback pointer will be initiaized to NULL, which is
>>> correct regarding the linux-can device driver specs.
>>>
>>> Signed-off-by: Stephane Grosjean <s.grosjean@peak-system.com>
>>> ---
>>> drivers/net/can/usb/peak_usb/pcan_usb_core.c | 2 ++
>>> drivers/net/can/usb/peak_usb/pcan_usb_core.h | 2 ++
>>> 2 files changed, 4 insertions(+)
>>>
>>> diff --git a/drivers/net/can/usb/peak_usb/pcan_usb_core.c b/drivers/net/can/usb/peak_usb/pcan_usb_core.c
>>> index c23609a..7a73060 100644
>>> --- a/drivers/net/can/usb/peak_usb/pcan_usb_core.c
>>> +++ b/drivers/net/can/usb/peak_usb/pcan_usb_core.c
>>> @@ -794,6 +794,8 @@ static int peak_usb_create_dev(struct peak_usb_adapter *peak_usb_adapter,
>>> 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_get_berr_counter =
>>> + peak_usb_adapter->candev_get_berr_counter;
>>> dev->can.ctrlmode_supported = peak_usb_adapter->ctrlmode_supported;
>>>
>>> netdev->netdev_ops = &peak_usb_netdev_ops;
>>> diff --git a/drivers/net/can/usb/peak_usb/pcan_usb_core.h b/drivers/net/can/usb/peak_usb/pcan_usb_core.h
>>> index a58d971..fb402d2 100644
>>> --- a/drivers/net/can/usb/peak_usb/pcan_usb_core.h
>>> +++ b/drivers/net/can/usb/peak_usb/pcan_usb_core.h
>>> @@ -70,6 +70,8 @@ struct peak_usb_adapter {
>>> int (*dev_stop)(struct peak_usb_device *dev);
>>> int (*dev_restart_async)(struct peak_usb_device *dev, struct urb *urb,
>>> u8 *buf);
>>> + int (*candev_get_berr_counter)(const struct net_device *netdev,
>> ^^^^^^
>>
>> I think this prefix can be removed. I've done so in my series.
>
> FYI: I added this specific prefix because this is the only callback I'm
> obliged to use with the "struct net_device *" argument.
> No other way to setup a specific callback to get the BEC.
IC, however the compiler will warn you, if you use the wrong arguments.
Marc
--
Pengutronix e.K. | Marc Kleine-Budde |
Industrial Linux Solutions | Phone: +49-231-2826-924 |
Vertretung West/Dortmund | Fax: +49-5121-206917-5555 |
Amtsgericht Hildesheim, HRA 2686 | http://www.pengutronix.de |
[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 819 bytes --]
^ permalink raw reply [flat|nested] 8+ messages in thread
end of thread, other threads:[~2015-01-20 14:50 UTC | newest]
Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-01-19 16:15 [PATCH] can/peak_usb: upgrade core to new CANFD extension Stephane Grosjean
2015-01-19 16:15 ` [PATCH] can/peak_usb: export ctrlmode_supported to adapter specific Stephane Grosjean
2015-01-20 14:18 ` Marc Kleine-Budde
2015-01-19 16:15 ` [PATCH] can/peak_usb: add adapter BEC callback definition Stephane Grosjean
2015-01-20 14:19 ` Marc Kleine-Budde
2015-01-20 14:46 ` Stephane Grosjean
2015-01-20 14:50 ` Marc Kleine-Budde
2015-01-20 14:17 ` [PATCH] can/peak_usb: upgrade core to new CANFD extension Marc Kleine-Budde
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.