ImageVerifierCode 换一换
格式:DOCX , 页数:37 ,大小:25.02KB ,
资源ID:17215915      下载积分:12 金币
快捷下载
登录下载
邮箱/手机:
温馨提示:
快捷下载时,用户名和密码都是您填写的邮箱或者手机号,方便查询和重复下载(系统自动生成)。 如填写123,账号就是123,密码也是123。
特别说明:
请自助下载,系统不会自动发送文件的哦; 如果您已付费,想二次下载,请登录后访问:我的下载记录
支付方式: 支付宝    微信支付   
验证码:   换一换

加入VIP,免费下载
 

温馨提示:由于个人手机设置不同,如果发现不能下载,请复制以下地址【https://www.bdocx.com/down/17215915.html】到电脑端继续下载(重复下载不扣费)。

已注册用户请登录:
账号:
密码:
验证码:   换一换
  忘记密码?
三方登录: 微信登录   QQ登录  

下载须知

1: 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。
2: 试题试卷类文档,如果标题没有明确说明有答案则都视为没有答案,请知晓。
3: 文件的所有权益归上传用户所有。
4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
5. 本站仅提供交流平台,并不能对任何下载内容负责。
6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。

版权提示 | 免责声明

本文(USB串口驱动Word文档下载推荐.docx)为本站会员(b****6)主动上传,冰豆网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对上载内容本身不做任何修改或编辑。 若此文所含内容侵犯了您的版权或隐私,请立即通知冰豆网(发送邮件至service@bdocx.com或直接QQ联系客服),我们立即给予删除!

USB串口驱动Word文档下载推荐.docx

1、linux/usb/serial.h#include pl2303.h * Version Information#define DRIVER_AUTHOR Greg Kroah-Hartman, greg, #define DRIVER_DESC USB Serial Driver corestatic void port_free(struct usb_serial_port *port);/* Driver structure we register with the USB core */static struct usb_driver usb_serial_driver = .nam

2、e = usbserial, .probe = usb_serial_probe, .disconnect = usb_serial_disconnect, .suspend = usb_serial_suspend, .resume = usb_serial_resume, .no_dynamic_id = 1,;/* There is no MODULE_DEVICE_TABLE for usbserial.c. Instead the MODULE_DEVICE_TABLE declarations in each serial driver cause the hotplug prog

3、ram to pull in whatever module is necessary via modprobe, and modprobe will load usbserial because the serial drivers depend on it.*/static int debug;/* initially all NULL */static struct usb_serial *serial_tableSERIAL_TTY_MINORS;static DEFINE_MUTEX(table_lock);static LIST_HEAD(usb_serial_driver_lis

4、t);struct usb_serial *usb_serial_get_by_index(unsigned index) struct usb_serial *serial; mutex_lock(&table_lock); serial = serial_tableindex; if (serial) kref_get(&serial-kref); mutex_unlock(& return serial;static struct usb_serial *get_free_serial(struct usb_serial *serial, int num_ports, unsigned

5、int *minor) unsigned int i, j; int good_spot; dbg(%s %d, _func_, num_ports); *minor = 0; for (i = 0; i SERIAL_TTY_MINORS; +i) if (serial_tablei) continue; good_spot = 1; for (j = 1; j = SERIAL_TTY_MINORS) | (serial_tablei+j) good_spot = 0; i += j; break; if (good_spot = 0) *minor = i; j = 0; dbg(%s

6、- minor base = %d, _func_, *minor); for (i = *minor; (i portj+-number = i; mutex_unlock(& return serial; return NULL;static void return_serial(struct usb_serial *serial) int i;%s, _func_); serial-num_ports; +i) serial_tableserial-minor + i = NULL;static void destroy_serial(struct kref *kref) struct

7、usb_serial_port *port; serial = to_usb_serial(kref);%s - %s, _func_, serial-type-description); /* return the minor range that this device had */ if (serial-minor != SERIAL_TTY_NO_MINOR) return_serial(serial);release(serial); port = serial-porti; if (port) put_device(&port-dev); /* If this is a fake

8、port, we have to clean it up here, as it will * not get cleaned up in port_release() as it was never registered with * the driver core */num_ports i if (port) port_free(port); usb_put_dev(serial- /* free up any memory that we allocated */ kfree(serial);void usb_serial_put(struct usb_serial *serial)

9、kref_put(&kref, destroy_serial);/* * Driver tty interface functions */static int serial_open (struct tty_struct *tty, struct file *filp) unsigned int portNumber; int retval = 0; /* get the serial object associated with this tty pointer */ serial = usb_serial_get_by_index(tty-index); if (!serial) tty

10、-driver_data = NULL; return -ENODEV;disc_mutex); portNumber = tty-index - serial-minor; port = serial-portportNumber;port | serial-disconnected) retval = -ENODEV; else get_device(& /* * Note: Our locking order requirement does not allow port-mutex * to be acquired while serial-disc_mutex is held. if

11、 (retval) goto bailout_serial_put; if (mutex_lock_interruptible(&mutex) retval = -ERESTARTSYS; goto bailout_port_put; +port-port.count; /* set up our port structure making the tty driver * remember our port object, and us it */ tty-driver_data = port; tty_port_tty_set(&port, tty); if (port-port.coun

12、t = 1) /* lock this module before we call it * this may fail, which means we must bail out, * safe because we are called with BKL held */ if (!try_module_get(serial-driver.owner) retval = -ENODEV; goto bailout_mutex_unlock; mutex_lock(& if (serial- else retval = usb_autopm_get_interface(serial-inter

13、face); if (retval) goto bailout_module_put; /* only call the device specific open if this * is the first time the port is opened */ retval = serial-open(tty, port, filp); goto bailout_interface_put;mutex); return 0;bailout_interface_put: usb_autopm_put_interface(serial-bailout_module_put: module_put

14、(serial-driver.owner);bailout_mutex_unlock: port-port.count = 0;port, NULL);bailout_port_put: put_device(&bailout_serial_put: usb_serial_put(serial); return retval;static void serial_close(struct tty_struct *tty, struct file *filp) struct usb_serial_port *port = tty-driver_data; struct module *owner

15、; int count;port) return;%s - port %d, _func_, port-number); serial = port-serial; owner = serial-driver.owner;port.count = 0) port.count = 1) /* only call the device specific close if this * port is being closed by the last owner. Ensure we do * this before we drop the port count. The call is prote

16、cted * by the port mutex */ serial-close(tty, port, filp);port.count = (port-console ? 2 : 1) struct tty_struct *tty = tty_port_tty_get(&port); if (tty) /* We must do this before we drop the port count to zero. */ if (tty-driver_data) tty- tty_port_tty_set(& tty_kref_put(tty); -port- count = port- /

17、* Mustnt dereference port any more */ if (count = 0) usb_autopm_put_interface(serial-t dereference serial any more */ if (count = 0) module_put(owner);static int serial_write(struct tty_struct *tty, const unsigned char *buf, int count) int retval = -ENODEV;dev-state = USB_STATE_NOTATTACHED) goto exi

18、t;%s - port %d, %d byte(s)number, count); /* count is managed under the mutex lock for the tty so cannot drop to zero until after the last close completes */ WARN_ON(!port.count); /* pass on to the driver specific version of this function */ retval = port-write(tty, port, buf, count);exit:static int

19、 serial_write_room(struct tty_struct *tty) return port-write_room(tty);static int serial_chars_in_buffer(struct tty_struct *tty)%s = port %d /* if the device was unplugged then any remaining characters fell out of the connector ;) */ return 0;chars_in_buffer(tty);static void serial_throttle(struct tty_struct *tty)th

copyright@ 2008-2022 冰豆网网站版权所有

经营许可证编号:鄂ICP备2022015515号-1