[PATCH 11/17] can: ems_usb: Added ems_usb_write_mode_fd and its call in device probe routine. Fixed indentation.

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Signed-off-by: Gerhard Uttenthaler <uttenthaler@xxxxxxxxxxxxxxxx>
---
 drivers/net/can/usb/ems_usb.c | 49 +++++++++++++++++++++++++++--------
 1 file changed, 38 insertions(+), 11 deletions(-)

diff --git a/drivers/net/can/usb/ems_usb.c b/drivers/net/can/usb/ems_usb.c
index a4d9a1b2d2f0..b51a5eb65946 100644
--- a/drivers/net/can/usb/ems_usb.c
+++ b/drivers/net/can/usb/ems_usb.c
@@ -683,6 +683,32 @@ static int ems_usb_write_mode_arm7(struct ems_usb *dev, u32 mode)
 	return ems_usb_command_msg(dev, &dev->active_params);
 }
 
+static int ems_usb_write_mode_fd(struct ems_usb *dev, u32 mode)
+{
+	struct cpc_generic_can_params *gcp =
+		&dev->active_params.msg.can_params.cc_params.generic;
+
+	if (mode == CPC_USB_RESET_MODE) {
+		gcp->config |= CPC_GENERICCONF_RESET_MODE;
+	} else if (mode == CPC_USB_RUN_MODE) {
+		gcp->config &= ~CPC_GENERICCONF_RESET_MODE;
+
+		if (dev->can.ctrlmode & CAN_CTRLMODE_LISTENONLY)
+			gcp->config |= CPC_GENERICCONF_LISTEN_ONLY;
+		else
+			gcp->config &= ~CPC_GENERICCONF_LISTEN_ONLY;
+
+		if (dev->can.ctrlmode & CAN_CTRLMODE_ONE_SHOT)
+			gcp->config |= CPC_GENERICCONF_SINGLE_SHOT;
+		else
+			gcp->config &= ~CPC_GENERICCONF_SINGLE_SHOT;
+	} else {
+		return -EINVAL;
+	}
+
+	return ems_usb_command_msg(dev, &dev->active_params);
+}
+
 /* Send a CPC_Control command to change behaviour when interface receives a CAN
  * message, bus error or CAN state changed notifications.
  */
@@ -1241,17 +1267,16 @@ static int ems_usb_probe(struct usb_interface *intf,
 	/* Select CPC-USB/ARM7 or CPC-USB/FD */
 	switch (dev->udev->descriptor.idProduct) {
 	case USB_CPCUSB_ARM7_PRODUCT_ID:
-
-	dev->can.clock.freq = EMS_USB_ARM7_CLOCK;
-	dev->can.bittiming_const = &ems_usb_bittiming_const_arm7;
-	dev->can.do_set_bittiming = ems_usb_set_bittiming_arm7;
-	dev->can.do_set_mode = ems_usb_set_mode;
-	dev->can.ctrlmode_supported = CAN_CTRLMODE_3_SAMPLES |
+		dev->can.clock.freq = EMS_USB_ARM7_CLOCK;
+		dev->can.bittiming_const = &ems_usb_bittiming_const_arm7;
+		dev->can.do_set_bittiming = ems_usb_set_bittiming_arm7;
+		dev->can.do_set_mode = ems_usb_set_mode;
+		dev->can.ctrlmode_supported = CAN_CTRLMODE_3_SAMPLES |
 				      CAN_CTRLMODE_LISTENONLY;
-	init_params_sja1000(&dev->active_params);
-	dev->ems_usb_write_mode = ems_usb_write_mode_arm7;
-	dev->bulk_rd_buf_size = 64;
-	break;
+		init_params_sja1000(&dev->active_params);
+		dev->ems_usb_write_mode = ems_usb_write_mode_arm7;
+		dev->bulk_rd_buf_size = 64;
+		break;
 
 	case USB_CPCUSB_FD_PRODUCT_ID:
 		dev->can.clock.freq = EMS_USB_FD_CLOCK;
@@ -1259,14 +1284,16 @@ static int ems_usb_probe(struct usb_interface *intf,
 		dev->can.data_bittiming_const = &ems_usb_bittiming_const_generic_data;
 		dev->can.do_set_bittiming = ems_usb_set_bittiming_generic;
 		dev->can.do_set_data_bittiming = ems_usb_set_bittiming_generic_data;
+		dev->can.do_set_mode = ems_usb_set_mode;
 		dev->can.ctrlmode_supported = CAN_CTRLMODE_LISTENONLY |
 				CAN_CTRLMODE_ONE_SHOT |
 				CAN_CTRLMODE_BERR_REPORTING |
 				CAN_CTRLMODE_FD |
 				CAN_CTRLMODE_FD_NON_ISO;
 		init_params_generic(&dev->active_params);
+		dev->ems_usb_write_mode = ems_usb_write_mode_fd;
 		dev->bulk_rd_buf_size = 512;
-	break;
+		break;
 
 	default:
 		err = -ENODEV;
-- 
2.26.2

-- 
EMS Dr. Thomas Wuensche e.K.
Sonnenhang 3
85304 Ilmmuenster
HR Ingolstadt, HRA 170106

Phone: +49-8441-490260
Fax  : +49-8441-81860
http://www.ems-wuensche.com



[Index of Archives]     [Automotive Discussions]     [Linux ARM Kernel]     [Linux ARM]     [Linux Omap]     [Fedora ARM]     [IETF Annouce]     [Security]     [Bugtraq]     [Linux]     [Linux OMAP]     [Linux MIPS]     [eCos]     [Asterisk Internet PBX]     [Linux API]     [CAN Bus]

  Powered by Linux