#include <asm/uaccess.h>
#include <linux/usb.h>
#include <linux/ioctl.h>
-
-
+#include "usb-serial.h"
#include "kobil_sct.h"
-//#include "../core/usb-debug.c"
-#ifdef CONFIG_USB_SERIAL_DEBUG
- static int debug = 1;
-#else
- static int debug;
-#endif
-
-#include "usb-serial.h"
+static int debug;
/* Version Information */
#define DRIVER_VERSION "21/05/2004"
static void kobil_shutdown (struct usb_serial *serial);
static int kobil_open (struct usb_serial_port *port, struct file *filp);
static void kobil_close (struct usb_serial_port *port, struct file *filp);
-static int kobil_write (struct usb_serial_port *port, int from_user,
+static int kobil_write (struct usb_serial_port *port,
const unsigned char *buf, int count);
static int kobil_write_room(struct usb_serial_port *port);
static int kobil_ioctl(struct usb_serial_port *port, struct file *file,
priv->filled = 0;
priv->cur_pos = 0;
- priv->device_type = serial->product;
+ priv->device_type = le16_to_cpu(serial->dev->descriptor.idProduct);
priv->line_state = 0;
switch (priv->device_type){
{
dbg("%s - port %d", __FUNCTION__, port->number);
- if (port->write_urb){
- usb_unlink_urb( port->write_urb );
+ if (port->write_urb) {
+ usb_kill_urb(port->write_urb);
usb_free_urb( port->write_urb );
- port->write_urb = 0;
- }
- if (port->interrupt_in_urb){
- usb_unlink_urb (port->interrupt_in_urb);
+ port->write_urb = NULL;
}
+ if (port->interrupt_in_urb)
+ usb_kill_urb(port->interrupt_in_urb);
}
}
-static int kobil_write (struct usb_serial_port *port, int from_user,
+static int kobil_write (struct usb_serial_port *port,
const unsigned char *buf, int count)
{
int length = 0;
}
// Copy data to buffer
- if (from_user) {
- if (copy_from_user(priv->buf + priv->filled, buf, count)) {
- return -EFAULT;
- }
- } else {
- memcpy (priv->buf + priv->filled, buf, count);
- }
+ memcpy (priv->buf + priv->filled, buf, count);
- usb_serial_debug_data (__FILE__, __FUNCTION__, count, priv->buf + priv->filled);
+ usb_serial_debug_data(debug, &port->dev, __FUNCTION__, count, priv->buf + priv->filled);
priv->filled = priv->filled + count;
((priv->device_type == KOBIL_ADAPTER_B_PRODUCT_ID) && (priv->filled > 3) && (priv->filled >= (priv->buf[2] + 4))) ) {
// stop reading (except TWIN and KAAN SIM)
- if ( (priv->device_type == KOBIL_ADAPTER_B_PRODUCT_ID) || (priv->device_type == KOBIL_ADAPTER_K_PRODUCT_ID) ) {
- usb_unlink_urb( port->interrupt_in_urb );
- }
+ if ( (priv->device_type == KOBIL_ADAPTER_B_PRODUCT_ID) || (priv->device_type == KOBIL_ADAPTER_K_PRODUCT_ID) )
+ usb_kill_urb(port->interrupt_in_urb);
todo = priv->filled - priv->cur_pos;
unsigned char *transfer_buffer;
int transfer_buffer_length = 8;
char *settings;
+ void __user *user_arg = (void __user *)arg;
priv = usb_get_serial_port_data(port);
if ((priv->device_type == KOBIL_USBTWIN_PRODUCT_ID) || (priv->device_type == KOBIL_KAAN_SIM_PRODUCT_ID)) {
switch (cmd) {
case TCGETS: // 0x5401
- result = verify_area(VERIFY_WRITE, (void *)arg, sizeof(struct termios));
+ result = verify_area(VERIFY_WRITE, user_arg, sizeof(struct termios));
if (result) {
dbg("%s - port %d Error in verify_area", __FUNCTION__, port->number);
return(result);
}
- if (kernel_termios_to_user_termios((struct termios *)arg,
+ if (kernel_termios_to_user_termios((struct termios __user *)arg,
&priv->internal_termios))
return -EFAULT;
return 0;
dbg("%s - port %d Error: port->tty->termios is NULL", __FUNCTION__, port->number);
return -ENOTTY;
}
- result = verify_area(VERIFY_READ, (void *)arg, sizeof(struct termios));
+ result = verify_area(VERIFY_READ, user_arg, sizeof(struct termios));
if (result) {
dbg("%s - port %d Error in verify_area", __FUNCTION__, port->number);
return result;
}
if (user_termios_to_kernel_termios(&priv->internal_termios,
- (struct termios *)arg))
+ (struct termios __user *)arg))
return -EFAULT;
settings = (unsigned char *) kmalloc(50, GFP_KERNEL);
MODULE_DESCRIPTION( DRIVER_DESC );
MODULE_LICENSE( "GPL" );
-MODULE_PARM(debug, "i");
+module_param(debug, bool, S_IRUGO | S_IWUSR);
MODULE_PARM_DESC(debug, "Debug enabled or not");