diff options
author | David S. Miller <davem@davemloft.net> | 2017-04-25 11:20:30 -0400 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2017-04-25 11:20:30 -0400 |
commit | fccb4422d045263fa021438e2c52a07b037683f2 (patch) | |
tree | 71f60ad901dbf5879fa2e10287e7d14add193c47 | |
parent | a53d26eb888ab1c41779c443daf1af948c641e0b (diff) | |
parent | b05c73bd1e3ec60357580eb042ee932a5ed754d5 (diff) |
Merge tag 'linux-can-fixes-for-4.11-20170425' of git://git.kernel.org/pub/scm/linux/kernel/git/mkl/linux-can
Marc Kleine-Budde says:
====================
pull-request: can 2017-04-25
this is a pull request of three patches for net/master.
There are two patches by Stephane Grosjean for that add a new variant to the
PCAN-Chip USB driver. The other patch is by Maksim Salau, which swtiches the
memory for USB transfers from heap to stack.
====================
Signed-off-by: David S. Miller <davem@davemloft.net>
-rw-r--r-- | drivers/net/can/usb/Kconfig | 2 | ||||
-rw-r--r-- | drivers/net/can/usb/gs_usb.c | 17 | ||||
-rw-r--r-- | drivers/net/can/usb/peak_usb/pcan_usb_core.c | 2 | ||||
-rw-r--r-- | drivers/net/can/usb/peak_usb/pcan_usb_core.h | 2 | ||||
-rw-r--r-- | drivers/net/can/usb/peak_usb/pcan_usb_fd.c | 72 |
5 files changed, 90 insertions, 5 deletions
diff --git a/drivers/net/can/usb/Kconfig b/drivers/net/can/usb/Kconfig index 8483a40e7e9e..5f9e0e6301d0 100644 --- a/drivers/net/can/usb/Kconfig +++ b/drivers/net/can/usb/Kconfig | |||
@@ -72,6 +72,8 @@ config CAN_PEAK_USB | |||
72 | PCAN-USB Pro dual CAN 2.0b channels USB adapter | 72 | PCAN-USB Pro dual CAN 2.0b channels USB adapter |
73 | PCAN-USB FD single CAN-FD channel USB adapter | 73 | PCAN-USB FD single CAN-FD channel USB adapter |
74 | PCAN-USB Pro FD dual CAN-FD channels USB adapter | 74 | PCAN-USB Pro FD dual CAN-FD channels USB adapter |
75 | PCAN-Chip USB CAN-FD to USB stamp module | ||
76 | PCAN-USB X6 6 CAN-FD channels USB adapter | ||
75 | 77 | ||
76 | (see also http://www.peak-system.com). | 78 | (see also http://www.peak-system.com). |
77 | 79 | ||
diff --git a/drivers/net/can/usb/gs_usb.c b/drivers/net/can/usb/gs_usb.c index 300349fe8dc0..eecee7f8dfb7 100644 --- a/drivers/net/can/usb/gs_usb.c +++ b/drivers/net/can/usb/gs_usb.c | |||
@@ -739,13 +739,18 @@ static const struct net_device_ops gs_usb_netdev_ops = { | |||
739 | static int gs_usb_set_identify(struct net_device *netdev, bool do_identify) | 739 | static int gs_usb_set_identify(struct net_device *netdev, bool do_identify) |
740 | { | 740 | { |
741 | struct gs_can *dev = netdev_priv(netdev); | 741 | struct gs_can *dev = netdev_priv(netdev); |
742 | struct gs_identify_mode imode; | 742 | struct gs_identify_mode *imode; |
743 | int rc; | 743 | int rc; |
744 | 744 | ||
745 | imode = kmalloc(sizeof(*imode), GFP_KERNEL); | ||
746 | |||
747 | if (!imode) | ||
748 | return -ENOMEM; | ||
749 | |||
745 | if (do_identify) | 750 | if (do_identify) |
746 | imode.mode = GS_CAN_IDENTIFY_ON; | 751 | imode->mode = GS_CAN_IDENTIFY_ON; |
747 | else | 752 | else |
748 | imode.mode = GS_CAN_IDENTIFY_OFF; | 753 | imode->mode = GS_CAN_IDENTIFY_OFF; |
749 | 754 | ||
750 | rc = usb_control_msg(interface_to_usbdev(dev->iface), | 755 | rc = usb_control_msg(interface_to_usbdev(dev->iface), |
751 | usb_sndctrlpipe(interface_to_usbdev(dev->iface), | 756 | usb_sndctrlpipe(interface_to_usbdev(dev->iface), |
@@ -755,10 +760,12 @@ static int gs_usb_set_identify(struct net_device *netdev, bool do_identify) | |||
755 | USB_RECIP_INTERFACE, | 760 | USB_RECIP_INTERFACE, |
756 | dev->channel, | 761 | dev->channel, |
757 | 0, | 762 | 0, |
758 | &imode, | 763 | imode, |
759 | sizeof(imode), | 764 | sizeof(*imode), |
760 | 100); | 765 | 100); |
761 | 766 | ||
767 | kfree(imode); | ||
768 | |||
762 | return (rc > 0) ? 0 : rc; | 769 | return (rc > 0) ? 0 : rc; |
763 | } | 770 | } |
764 | 771 | ||
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 0b0302af3bd2..57913dbbae0a 100644 --- a/drivers/net/can/usb/peak_usb/pcan_usb_core.c +++ b/drivers/net/can/usb/peak_usb/pcan_usb_core.c | |||
@@ -39,6 +39,7 @@ static struct usb_device_id peak_usb_table[] = { | |||
39 | {USB_DEVICE(PCAN_USB_VENDOR_ID, PCAN_USBPRO_PRODUCT_ID)}, | 39 | {USB_DEVICE(PCAN_USB_VENDOR_ID, PCAN_USBPRO_PRODUCT_ID)}, |
40 | {USB_DEVICE(PCAN_USB_VENDOR_ID, PCAN_USBFD_PRODUCT_ID)}, | 40 | {USB_DEVICE(PCAN_USB_VENDOR_ID, PCAN_USBFD_PRODUCT_ID)}, |
41 | {USB_DEVICE(PCAN_USB_VENDOR_ID, PCAN_USBPROFD_PRODUCT_ID)}, | 41 | {USB_DEVICE(PCAN_USB_VENDOR_ID, PCAN_USBPROFD_PRODUCT_ID)}, |
42 | {USB_DEVICE(PCAN_USB_VENDOR_ID, PCAN_USBCHIP_PRODUCT_ID)}, | ||
42 | {USB_DEVICE(PCAN_USB_VENDOR_ID, PCAN_USBX6_PRODUCT_ID)}, | 43 | {USB_DEVICE(PCAN_USB_VENDOR_ID, PCAN_USBX6_PRODUCT_ID)}, |
43 | {} /* Terminating entry */ | 44 | {} /* Terminating entry */ |
44 | }; | 45 | }; |
@@ -51,6 +52,7 @@ static const struct peak_usb_adapter *const peak_usb_adapters_list[] = { | |||
51 | &pcan_usb_pro, | 52 | &pcan_usb_pro, |
52 | &pcan_usb_fd, | 53 | &pcan_usb_fd, |
53 | &pcan_usb_pro_fd, | 54 | &pcan_usb_pro_fd, |
55 | &pcan_usb_chip, | ||
54 | &pcan_usb_x6, | 56 | &pcan_usb_x6, |
55 | }; | 57 | }; |
56 | 58 | ||
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 3cbfb069893d..c01316cac354 100644 --- a/drivers/net/can/usb/peak_usb/pcan_usb_core.h +++ b/drivers/net/can/usb/peak_usb/pcan_usb_core.h | |||
@@ -27,6 +27,7 @@ | |||
27 | #define PCAN_USBPRO_PRODUCT_ID 0x000d | 27 | #define PCAN_USBPRO_PRODUCT_ID 0x000d |
28 | #define PCAN_USBPROFD_PRODUCT_ID 0x0011 | 28 | #define PCAN_USBPROFD_PRODUCT_ID 0x0011 |
29 | #define PCAN_USBFD_PRODUCT_ID 0x0012 | 29 | #define PCAN_USBFD_PRODUCT_ID 0x0012 |
30 | #define PCAN_USBCHIP_PRODUCT_ID 0x0013 | ||
30 | #define PCAN_USBX6_PRODUCT_ID 0x0014 | 31 | #define PCAN_USBX6_PRODUCT_ID 0x0014 |
31 | 32 | ||
32 | #define PCAN_USB_DRIVER_NAME "peak_usb" | 33 | #define PCAN_USB_DRIVER_NAME "peak_usb" |
@@ -90,6 +91,7 @@ struct peak_usb_adapter { | |||
90 | extern const struct peak_usb_adapter pcan_usb; | 91 | extern const struct peak_usb_adapter pcan_usb; |
91 | extern const struct peak_usb_adapter pcan_usb_pro; | 92 | extern const struct peak_usb_adapter pcan_usb_pro; |
92 | extern const struct peak_usb_adapter pcan_usb_fd; | 93 | extern const struct peak_usb_adapter pcan_usb_fd; |
94 | extern const struct peak_usb_adapter pcan_usb_chip; | ||
93 | extern const struct peak_usb_adapter pcan_usb_pro_fd; | 95 | extern const struct peak_usb_adapter pcan_usb_pro_fd; |
94 | extern const struct peak_usb_adapter pcan_usb_x6; | 96 | extern const struct peak_usb_adapter pcan_usb_x6; |
95 | 97 | ||
diff --git a/drivers/net/can/usb/peak_usb/pcan_usb_fd.c b/drivers/net/can/usb/peak_usb/pcan_usb_fd.c index 304732550f0a..528d3bb4917f 100644 --- a/drivers/net/can/usb/peak_usb/pcan_usb_fd.c +++ b/drivers/net/can/usb/peak_usb/pcan_usb_fd.c | |||
@@ -1061,6 +1061,78 @@ const struct peak_usb_adapter pcan_usb_fd = { | |||
1061 | .do_get_berr_counter = pcan_usb_fd_get_berr_counter, | 1061 | .do_get_berr_counter = pcan_usb_fd_get_berr_counter, |
1062 | }; | 1062 | }; |
1063 | 1063 | ||
1064 | /* describes the PCAN-CHIP USB */ | ||
1065 | static const struct can_bittiming_const pcan_usb_chip_const = { | ||
1066 | .name = "pcan_chip_usb", | ||
1067 | .tseg1_min = 1, | ||
1068 | .tseg1_max = (1 << PUCAN_TSLOW_TSGEG1_BITS), | ||
1069 | .tseg2_min = 1, | ||
1070 | .tseg2_max = (1 << PUCAN_TSLOW_TSGEG2_BITS), | ||
1071 | .sjw_max = (1 << PUCAN_TSLOW_SJW_BITS), | ||
1072 | .brp_min = 1, | ||
1073 | .brp_max = (1 << PUCAN_TSLOW_BRP_BITS), | ||
1074 | .brp_inc = 1, | ||
1075 | }; | ||
1076 | |||
1077 | static const struct can_bittiming_const pcan_usb_chip_data_const = { | ||
1078 | .name = "pcan_chip_usb", | ||
1079 | .tseg1_min = 1, | ||
1080 | .tseg1_max = (1 << PUCAN_TFAST_TSGEG1_BITS), | ||
1081 | .tseg2_min = 1, | ||
1082 | .tseg2_max = (1 << PUCAN_TFAST_TSGEG2_BITS), | ||
1083 | .sjw_max = (1 << PUCAN_TFAST_SJW_BITS), | ||
1084 | .brp_min = 1, | ||
1085 | .brp_max = (1 << PUCAN_TFAST_BRP_BITS), | ||
1086 | .brp_inc = 1, | ||
1087 | }; | ||
1088 | |||
1089 | const struct peak_usb_adapter pcan_usb_chip = { | ||
1090 | .name = "PCAN-Chip USB", | ||
1091 | .device_id = PCAN_USBCHIP_PRODUCT_ID, | ||
1092 | .ctrl_count = PCAN_USBFD_CHANNEL_COUNT, | ||
1093 | .ctrlmode_supported = CAN_CTRLMODE_FD | | ||
1094 | CAN_CTRLMODE_3_SAMPLES | CAN_CTRLMODE_LISTENONLY, | ||
1095 | .clock = { | ||
1096 | .freq = PCAN_UFD_CRYSTAL_HZ, | ||
1097 | }, | ||
1098 | .bittiming_const = &pcan_usb_chip_const, | ||
1099 | .data_bittiming_const = &pcan_usb_chip_data_const, | ||
1100 | |||
1101 | /* size of device private data */ | ||
1102 | .sizeof_dev_private = sizeof(struct pcan_usb_fd_device), | ||
1103 | |||
1104 | /* timestamps usage */ | ||
1105 | .ts_used_bits = 32, | ||
1106 | .ts_period = 1000000, /* calibration period in ts. */ | ||
1107 | .us_per_ts_scale = 1, /* us = (ts * scale) >> shift */ | ||
1108 | .us_per_ts_shift = 0, | ||
1109 | |||
1110 | /* give here messages in/out endpoints */ | ||
1111 | .ep_msg_in = PCAN_USBPRO_EP_MSGIN, | ||
1112 | .ep_msg_out = {PCAN_USBPRO_EP_MSGOUT_0}, | ||
1113 | |||
1114 | /* size of rx/tx usb buffers */ | ||
1115 | .rx_buffer_size = PCAN_UFD_RX_BUFFER_SIZE, | ||
1116 | .tx_buffer_size = PCAN_UFD_TX_BUFFER_SIZE, | ||
1117 | |||
1118 | /* device callbacks */ | ||
1119 | .intf_probe = pcan_usb_pro_probe, /* same as PCAN-USB Pro */ | ||
1120 | .dev_init = pcan_usb_fd_init, | ||
1121 | |||
1122 | .dev_exit = pcan_usb_fd_exit, | ||
1123 | .dev_free = pcan_usb_fd_free, | ||
1124 | .dev_set_bus = pcan_usb_fd_set_bus, | ||
1125 | .dev_set_bittiming = pcan_usb_fd_set_bittiming_slow, | ||
1126 | .dev_set_data_bittiming = pcan_usb_fd_set_bittiming_fast, | ||
1127 | .dev_decode_buf = pcan_usb_fd_decode_buf, | ||
1128 | .dev_start = pcan_usb_fd_start, | ||
1129 | .dev_stop = pcan_usb_fd_stop, | ||
1130 | .dev_restart_async = pcan_usb_fd_restart_async, | ||
1131 | .dev_encode_msg = pcan_usb_fd_encode_msg, | ||
1132 | |||
1133 | .do_get_berr_counter = pcan_usb_fd_get_berr_counter, | ||
1134 | }; | ||
1135 | |||
1064 | /* describes the PCAN-USB Pro FD adapter */ | 1136 | /* describes the PCAN-USB Pro FD adapter */ |
1065 | static const struct can_bittiming_const pcan_usb_pro_fd_const = { | 1137 | static const struct can_bittiming_const pcan_usb_pro_fd_const = { |
1066 | .name = "pcan_usb_pro_fd", | 1138 | .name = "pcan_usb_pro_fd", |