资源简介
LINUX设备驱动程序(第3版)_含实例源码.zip
代码片段和文件信息
/*
* A virtual bus for LDD sample code devices to plug into. This
* code is heavily borrowed from drivers/base/sys.c
*
* Copyright (C) 2001 Alessandro Rubini and Jonathan Corbet
* Copyright (C) 2001 O‘Reilly & Associates
*
* The source code in this file can be freely used adapted
* and redistributed in source or binary form so long as an
* acknowledgment appears in derived source files. The citation
* should list that the code comes from the book “Linux Device
* Drivers“ by Alessandro Rubini and Jonathan Corbet published
* by O‘Reilly & Associates. No warranty is attached;
* we cannot take responsibility for errors or fitness for use.
*
*/
/* $Id: lddbus.cv 1.9 2004/09/26 08:12:27 gregkh Exp $ */
#include
#include
#include
#include
#include
#include “lddbus.h“
MODULE_AUTHOR(“Jonathan Corbet“);
MODULE_LICENSE(“Dual BSD/GPL“);
static char *Version = “$Revision: 1.9 $“;
/*
* Respond to hotplug events.
*/
static int ldd_hotplug(struct device *dev char **envp int num_envp
char *buffer int buffer_size)
{
envp[0] = buffer;
if (snprintf(buffer buffer_size “LDDBUS_VERSION=%s“
Version) >= buffer_size)
return -ENOMEM;
envp[1] = NULL;
return 0;
}
/*
* Match LDD devices to drivers. Just do a simple name test.
*/
static int ldd_match(struct device *dev struct device_driver *driver)
{
return !strncmp(dev->bus_id driver->name strlen(driver->name));
}
/*
* The LDD bus device.
*/
static void ldd_bus_release(struct device *dev)
{
printk(KERN_DEBUG “lddbus release\n“);
}
struct device ldd_bus = {
.bus_id = “ldd0“
.release = ldd_bus_release
};
/*
* And the bus type.
*/
struct bus_type ldd_bus_type = {
.name = “ldd“
.match = ldd_match
.hotplug = ldd_hotplug
};
/*
* Export a simple attribute.
*/
static ssize_t show_bus_version(struct bus_type *bus char *buf)
{
return snprintf(buf PAGE_SIZE “%s\n“ Version);
}
static BUS_ATTR(version S_IRUGO show_bus_version NULL);
/*
* LDD devices.
*/
/*
* For now no references to LDDbus devices go out which are not
* tracked via the module reference count so we use a no-op
* release function.
*/
static void ldd_dev_release(struct device *dev)
{ }
int register_ldd_device(struct ldd_device *ldddev)
{
ldddev->dev.bus = &ldd_bus_type;
ldddev->dev.parent = &ldd_bus;
ldddev->dev.release = ldd_dev_release;
strncpy(ldddev->dev.bus_id ldddev->name BUS_ID_SIZE);
return device_register(&ldddev->dev);
}
EXPORT_SYMBOL(register_ldd_device);
void unregister_ldd_device(struct ldd_device *ldddev)
{
device_unregister(&ldddev->dev);
}
EXPORT_SYMBOL(unregister_ldd_device);
/*
* Crude driver interface.
*/
static ssize_t show_version(struct device_driver *driver char *buf)
{
struct ldd_driver *ldriver = to_ldd_driver(driver);
sprintf(buf “%s\n“ ldriver->version);
return strlen(buf);
}
int register_ldd_driver(struct ldd_driver *driver)
{
int ret
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
目录 0 2019-06-06 18:09 examples\
目录 0 2019-06-06 18:09 examples\include\
文件 855 2005-02-01 04:31 examples\include\lddbus.h
目录 0 2019-06-06 18:09 examples\lddbus\
文件 4058 2005-02-01 04:31 examples\lddbus\lddbus.c
文件 710 2005-02-01 04:31 examples\lddbus\Makefile
文件 1091 2005-02-01 04:31 examples\LICENSE
文件 289 2005-02-01 04:31 examples\Makefile
目录 0 2019-06-06 18:09 examples\misc-modules\
文件 2128 2005-02-01 04:31 examples\misc-modules\complete.c
文件 2000 2005-02-01 04:31 examples\misc-modules\faulty.c
文件 463 2005-02-01 04:31 examples\misc-modules\hello.c
文件 1130 2005-02-01 04:31 examples\misc-modules\hellop.c
文件 6194 2005-02-01 04:31 examples\misc-modules\jiq.c
文件 7571 2005-02-01 04:31 examples\misc-modules\jit.c
文件 2293 2005-02-01 04:31 examples\misc-modules\kdataalign.c
文件 1489 2005-02-01 04:31 examples\misc-modules\kdatasize.c
文件 987 2005-02-01 04:31 examples\misc-modules\Makefile
文件 2044 2005-02-01 04:31 examples\misc-modules\seq.c
文件 6200 2005-02-01 04:31 examples\misc-modules\silly.c
文件 2161 2005-02-01 04:31 examples\misc-modules\sleepy.c
目录 0 2019-06-06 18:09 examples\misc-progs\
文件 1483 2005-02-01 04:31 examples\misc-progs\asynctest.c
文件 2088 2005-02-01 04:31 examples\misc-progs\dataalign.c
文件 1287 2005-02-01 04:31 examples\misc-progs\datasize.c
文件 417 2005-02-01 04:31 examples\misc-progs\gdbline
文件 3372 2005-02-01 04:31 examples\misc-progs\inp.c
文件 925 2005-02-01 04:31 examples\misc-progs\load50.c
文件 297 2005-02-01 04:31 examples\misc-progs\Makefile
文件 1975 2005-02-01 04:31 examples\misc-progs\mapcmp.c
文件 2170 2005-02-01 04:31 examples\misc-progs\mapper.c
............此处省略86个文件信息
相关资源
- 《Windows设备驱动程序WDF开发》源码
- Windows.7设备驱动程序开发.pdf
- 精通Linux设备驱动程序开发(中英文版
- Windows设备驱动程序WDF开发
- 深入Linux设备驱动程序内核机制- 扫描
- Windows设备驱动程序WDF开发清晰完全版
- HI35xx平台MPEG解码
- LINUX设备驱动程序 第三版 PDF
- LINUX设备驱动程序 第3版 高清PDF 中文
- Vue全家桶之Vuex代码
- linux设备驱动程序开发 第四版 源码
- linux 添加字符设备驱动程序及测试程
- AT91RM9200的SPI设备驱动程序开发.pdf
- Dell PowerEdge R820 服务器 安装 server20
- WindowsXP环境下USB设备驱动程序的开发
- linux 字符设备驱动程序
- lpc1768+FreeRTOS+Keil
- 操作系统课程设计-简单字符设备和块
- 基于Windows+WDM的USB设备驱动程序开发与
- ftp客户端 实例源码下载24903
- linux设备驱动程序数码管
- MUI项目实战源码
- 操作系统课程设计—linux字符设备驱动
评论
共有 条评论