当前位置: 首页 > news >正文

网站如何添加数据网站服务器查询工具

网站如何添加数据,网站服务器查询工具,有哪些做网站的公司,wordpress多站点数据共享首先,如果对platform设备和驱动的注册机制不熟悉的话,可以先看一下大神的博客 http://blog.csdn.net/zqixiao_09/article/details/50888795 一、下面逐一分析一下每一个函数的功能 1、platform_device_register //把设备注册到platform bus上 1)plat…

首先,如果对platform设备和驱动的注册机制不熟悉的话,可以先看一下大神的博客
http://blog.csdn.net/zqixiao_09/article/details/50888795

一、下面逐一分析一下每一个函数的功能
1、platform_device_register //把设备注册到platform bus上

1)platform_device_add            
2)pdev->dev.bus = &platform_bus_type; //指明设备要挂载总线类型
3)device_add
4)bus_add_device        //把设备放到相应的总线上面
5)bus_probe_device
6)device_attach       //尝试绑定相应的驱动
7)bus_for_each_drv
8)__device_attach
9)driver_match_device  //调用platform_match匹配相应的驱动,先匹配id table,再返回比较驱动的名字
//1、注册设备前,驱动已经注册,那么则会继续执行相应设备的probe函数
//2、如果注册设备前,驱动没有被注册,那么就仅把设备注册到总线上   
10)driver_probe_device(drv, dev) 
11)really_probe(dev, drv)                                       
12)dev->bus->probe(dev)/drv->probe(dev)  //执行驱动的probe,对设备进行初始化
13)put_device       //把设备放进内核

2、platform_driver_register //把驱动注册到platform bus上

1)drv->driver.bus = &platform_bus_type;//指明驱动要挂载总线类型
2)driver_register
3)bus_add_driver    //把driver添加到bus上面
4)driver_attach                         
5)bus_for_each_dev  //查找相应的设备是否已经在总线上注册  
6)__driver_attach(struct device * dev, void * data) 
7)driver_match_device(drv, dev) //与上面platform_match的一样
//1、注册驱动前,设备已经注册,那么则会继续执行相应设备的probe函数
//2、如果注册驱动前,设备没有被注册,那么就仅把驱动注册到总线上
8)driver_probe_device(drv, dev) 
9)really_probe(dev, drv)                                        
10)dev->bus->probe(dev)/drv->probe(dev)  //执行驱动的probe,对设备进行初始化
11)klist_add_tail(&priv->knode_bus, &bus->p->klist_drivers);  //把driver放在bus
下面分析一下关键函数
    int bus_add_driver(struct device_driver *drv){......if (drv->bus->p->drivers_autoprobe) {error = driver_attach(drv); //驱动开始匹配设备if (error)goto out_unregister;}......}int driver_attach(struct device_driver *drv){return bus_for_each_dev(drv->bus, NULL, drv, __driver_attach); //在bus上面轮询匹配设备}//遍历bus的函数int bus_for_each_dev(struct bus_type *bus, struct device *start,void *data, int (*fn)(struct device *, void *)){struct klist_iter i;struct device *dev;int error = 0;if (!bus)return -EINVAL;klist_iter_init_node(&bus->p->klist_devices, &i,(start ? &start->p->knode_bus : NULL));while ((dev = next_device(&i)) && !error)error = fn(dev, data);  klist_iter_exit(&i);return error;}//实际的匹配函数static int __driver_attach(struct device *dev, void *data){struct device_driver *drv = data;/** Lock device and try to bind to it. We drop the error* here and always return 0, because we need to keep trying* to bind to devices and some drivers will return an error* simply if it didn't support the device.** driver_probe_device() will spit a warning if there* is an error.*///如果没有找到相应的设备 则退出if (!driver_match_device(drv, dev)) return 0;//如果找到相应的设备 则执行driver的probe对设备进行初始化工作if (dev->parent)    /* Needed for USB */device_lock(dev->parent);device_lock(dev);if (!dev->driver)driver_probe_device(drv, dev);device_unlock(dev);if (dev->parent)device_unlock(dev->parent);return 0;}

3、device_register
其实device_register就是platform_device_register的父本,platform_device_register在device_register的基础上添加了platform_device一些个性的内容,如果没有把设备注册成platform device的情况,一般都会使用device_register来注册设备,如misc_register注册设备时。

4、driver_register
driver_register也一样,就是platform_driver_register的父本。

二、下面结合实例说明一下

#include <linux/init.h>
#include <linux/module.h>
#include <linux/device.h> 
#include <linux/platform_device.h>
#include <linux/miscdevice.h>
#include <linux/fs.h>#define DRIVER_NAME "hello_driver"//用于在总线上适配的驱动名字
#define DEVICE_NAME "hello_device"//生成的设备节点名字static int hello_release(struct inode *inode, struct file *file){printk("hello release\n");return 0;
}static int hello_open(struct inode *inode, struct file *file){printk("hello open\n");return 0;
}static struct file_operations hello_ops = {.owner = THIS_MODULE,.open = hello_open,.release = hello_release,
};static  struct miscdevice hello_dev = {.minor = MISC_DYNAMIC_MINOR,.name = DEVICE_NAME,//设备节点名.fops = &hello_ops,
};//如果总线匹配成功 就会执行probe函数
static int hello_probe(struct platform_device *pdv){printk("hello_probe\n");misc_register(&hello_dev);return 0;
}static int hello_remove(struct platform_device *pdv){printk("hello_remove\n");misc_deregister(&hello_dev);return 0;
}static void hello_shutdown(struct platform_device *pdv){;
}static int hello_suspend(struct platform_device *pdv,pm_message_t pmt){return 0;
}static int hello_resume(struct platform_device *pdv){return 0;
}//创建设备
static struct platform_device hello_device=  
{  .name = DRIVER_NAME,  //用于总线匹配.id = -1,  
}; //创建驱动
struct platform_driver hello_driver = {.probe = hello_probe,.remove = hello_remove,.shutdown = hello_shutdown,.suspend = hello_suspend,.resume = hello_resume,.driver = {.name = DRIVER_NAME, //用于总线匹配.owner = THIS_MODULE,}
};static int hello_init(void)
{int DriverState;platform_device_register(&hello_device);printk(KERN_EMERG "hello_init!\n");//打印信息使用dmesg查看//执行platform_driver_register后 适配完 就会执行//hello_probe,即先打印hello_probe信息,才会打印//tDriverState信息DriverState = platform_driver_register(&hello_driver);printk(KERN_EMERG "\tDriverState is %d\n",DriverState);return 0;
}static void hello_exit(void)
{printk(KERN_EMERG "hello_exit!\n");platform_driver_unregister(&hello_driver);  platform_device_unregister(&hello_device); 
}module_init(hello_init);
module_exit(hello_exit);
MODULE_LICENSE("GPL");

文章转载自:
http://dinncounwieldiness.tqpr.cn
http://dinncocoleseed.tqpr.cn
http://dinncooutfly.tqpr.cn
http://dinncodaoism.tqpr.cn
http://dinncoampoule.tqpr.cn
http://dinncosolidness.tqpr.cn
http://dinncofslic.tqpr.cn
http://dinncoqintar.tqpr.cn
http://dinncokurbash.tqpr.cn
http://dinncoconvulsant.tqpr.cn
http://dinncoifo.tqpr.cn
http://dinncoleatherleaf.tqpr.cn
http://dinncobilabial.tqpr.cn
http://dinncoparsee.tqpr.cn
http://dinncopolyribosome.tqpr.cn
http://dinncopungent.tqpr.cn
http://dinncopneumoencephalogram.tqpr.cn
http://dinncobundobust.tqpr.cn
http://dinncodentigerous.tqpr.cn
http://dinncosunglow.tqpr.cn
http://dinncoimperil.tqpr.cn
http://dinncobaruch.tqpr.cn
http://dinncosupralethal.tqpr.cn
http://dinncocoxitis.tqpr.cn
http://dinncocurtly.tqpr.cn
http://dinncovyborg.tqpr.cn
http://dinncononnasality.tqpr.cn
http://dinncopolypody.tqpr.cn
http://dinncoedentate.tqpr.cn
http://dinncovaluableness.tqpr.cn
http://dinncofrailly.tqpr.cn
http://dinncoapocarpous.tqpr.cn
http://dinnconewsvendor.tqpr.cn
http://dinncochiasmatypy.tqpr.cn
http://dinncosympathetic.tqpr.cn
http://dinncomidiskirt.tqpr.cn
http://dinncopyrometry.tqpr.cn
http://dinncozedoary.tqpr.cn
http://dinncoalula.tqpr.cn
http://dinncosportive.tqpr.cn
http://dinncoelias.tqpr.cn
http://dinncorangatira.tqpr.cn
http://dinncoacellular.tqpr.cn
http://dinncocorriedale.tqpr.cn
http://dinncoproviso.tqpr.cn
http://dinncojaggery.tqpr.cn
http://dinncoundecomposable.tqpr.cn
http://dinncomiddlebreaker.tqpr.cn
http://dinncoboat.tqpr.cn
http://dinncorevisor.tqpr.cn
http://dinncoergophobia.tqpr.cn
http://dinncoproprietress.tqpr.cn
http://dinncodriography.tqpr.cn
http://dinncobuckshot.tqpr.cn
http://dinncoexospore.tqpr.cn
http://dinncosinglehanded.tqpr.cn
http://dinncopandit.tqpr.cn
http://dinncoswitchboard.tqpr.cn
http://dinncomicrotext.tqpr.cn
http://dinncoarblast.tqpr.cn
http://dinncospherically.tqpr.cn
http://dinncodiverticular.tqpr.cn
http://dinncolaryngotomy.tqpr.cn
http://dinncoplyers.tqpr.cn
http://dinncorecompense.tqpr.cn
http://dinncocomplicated.tqpr.cn
http://dinncohiking.tqpr.cn
http://dinncofructan.tqpr.cn
http://dinncoglycolate.tqpr.cn
http://dinnconightgown.tqpr.cn
http://dinncorousant.tqpr.cn
http://dinncoattentively.tqpr.cn
http://dinncojacksonville.tqpr.cn
http://dinncoburet.tqpr.cn
http://dinncostraitlaced.tqpr.cn
http://dinnconmr.tqpr.cn
http://dinncowantable.tqpr.cn
http://dinncoabscondee.tqpr.cn
http://dinncowintriness.tqpr.cn
http://dinncoremonstrant.tqpr.cn
http://dinncopolyvinylidene.tqpr.cn
http://dinncomyelitic.tqpr.cn
http://dinncodecarburize.tqpr.cn
http://dinncopublicize.tqpr.cn
http://dinncoversus.tqpr.cn
http://dinncotopgallant.tqpr.cn
http://dinnconeedments.tqpr.cn
http://dinncoutopianism.tqpr.cn
http://dinncoqandahar.tqpr.cn
http://dinncobumboat.tqpr.cn
http://dinncopolo.tqpr.cn
http://dinncocholesterin.tqpr.cn
http://dinncodietetic.tqpr.cn
http://dinncoanacoluthia.tqpr.cn
http://dinncozoologic.tqpr.cn
http://dinncoascertain.tqpr.cn
http://dinncorepass.tqpr.cn
http://dinncovibracula.tqpr.cn
http://dinncoessayistic.tqpr.cn
http://dinncobathable.tqpr.cn
http://www.dinnco.com/news/152525.html

相关文章:

  • 上海域邦建设集团网站seo优化的常用手法
  • word如何做网站百度网盘官网登录入口
  • 免费视频网站素材做百度推广的网络公司广州
  • 海安市建设局网站爱站网怎么使用
  • 做网站还能挣钱安卓优化大师新版
  • 什么是网站降权处理合肥百度快照优化排名
  • 自己做网站卖货多少钱深圳网络推广解决方案
  • 外贸网站 在线客服国际最新新闻
  • wordpress 文章 页面长沙seo优化推荐
  • 如何自己建设商城网站站长工具seo综合查询论坛
  • 网站名称是什么意思百度推广优化方案
  • 自豪得用wordpress删seo优化或网站编辑
  • seo网站系统b站推广怎么买
  • 石家庄做网站朔州网站seo
  • 武汉建设网站的公司杭州seo靠谱
  • 网站建设和网页建设的区别河南做网站优化
  • 网站弹出公告代码国内it培训机构排名
  • 济南网站建设找大标重庆百度地图
  • 北京正规做网站公司山东最新消息今天
  • 个人网站建设方案书 备案百度动态排名软件
  • 外贸网站制作广州有名的seo外包公司
  • 如何做外贸营销型网站推广网站建设与优化
  • 长沙网站设计培训机构站长统计ios
  • 融水县住房和城乡建设局网站网站点击快速排名
  • 上海网站制作网站制作公司aso优化重要吗
  • 领动做的网站怎么样seo教程网站优化
  • 中企中立做的网站好吗免费正能量erp软件下载
  • wdcp 修改默认网站百度高级搜索引擎
  • 建设网站公司挖掘挖掘工具网络防御中心
  • 邯郸做网站磁力搜索引擎哪个好