百度空间 | 百度首页 
 
查看文章
 
Power Management in the Linux Driver Model(2.6.14)(转)
2008-07-11 10:51
Power Management in the Linux Driver Model(2.6.14)

                                                                   --for device_add()





/**
*    device_add - add device to device hierarchy.
*    @dev:    device.
*
*    This is part 2 of device_register(), though may be called
*    separately _iff_ device_initialize() has been called separately.
*
*    This adds it to the kobject hierarchy via kobject_add(), adds it
*    to the global and sibling lists for the device, then
*    adds it to the other relevant subsystems of the driver model.
*/
int device_add(struct device *dev)
{
    struct device *parent = NULL;
    int error = -EINVAL;

    dev = get_device(dev);
    if (!dev || !strlen(dev->bus_id))
        goto Error;

    parent = get_device(dev->parent);

    pr_debug("DEV: registering device: ID = '%s'\n", dev->bus_id);

    /* first, register with generic layer. */
    kobject_set_name(&dev->kobj, "%s", dev->bus_id);
    if (parent)
        dev->kobj.parent = &parent->kobj;

    if ((error = kobject_add(&dev->kobj)))
        goto Error;
    kobject_hotplug(&dev->kobj, KOBJ_ADD);
    if ((error = device_pm_add(dev)))
        goto PMError;
    if ((error = bus_add_device(dev)))
        goto BusError;
    if (parent)
        klist_add_tail(&dev->knode_parent, &parent->klist_children);

    /* notify platform of device entry */
    if (platform_notify)
        platform_notify(dev);
Done:
    put_device(dev);
    return error;
BusError:
    device_pm_remove(dev);
PMError:
    kobject_hotplug(&dev->kobj, KOBJ_REMOVE);
    kobject_del(&dev->kobj);
Error:
    if (parent)
        put_device(parent);
    goto Done;
}



int device_pm_add(struct device * dev)
{
    int error;

    pr_debug("PM: Adding info for %s:%s\n",
        dev->bus ? dev->bus->name : "No Bus", dev->kobj.name);
    atomic_set(&dev->power.pm_users, 0);
    down(&dpm_list_sem);
    list_add_tail(&dev->power.entry, &dpm_active);
    device_pm_set_parent(dev, dev->parent);

    if ((error = dpm_sysfs_add(dev)))
        list_del(&dev->power.entry);
    up(&dpm_list_sem);
    return error;
}


/**
*    device_pm_set_parent - Specify power dependency.
*    @dev:        Device who needs power.
*    @parent:    Device that supplies power.
*
*    This function is used to manually describe a power-dependency
*    relationship. It may be used to specify a transversal relationship
*    (where the power supplier is not the physical (or electrical)
*    ancestor of a specific device.

*    The effect of this is that the supplier will not be powered down
*    before the power dependent.
*/

void device_pm_set_parent(struct device * dev, struct device * parent)
{
    struct device * old_parent = dev->power.pm_parent;
    device_pm_release(old_parent);
    dev->power.pm_parent = parent;
    device_pm_hold(parent);
}

原文: http://hi.baidu.com/rwen2012/blog/item/c3aad00ae429061c94ca6b6d.html

博客文章汇总:

如何科学饮水   供应WIFI(提供 wince linux下驱动)  

合肥市政府原副秘书长受贿240万被判13   百度C2C支付平台定名百付宝 域名地址昨曝光

LHC 的加速过程   什么是百度蜘蛛?百度爬虫是什么?    百度确定推C2C支付平台 电子商务大战一触即发   

无线音箱(出售)  

LINUX下无线网卡驱动程式安装的一般步骤  

云时代来临之云计算的四个显著特点 云计算时代来临 云计算到底指什么 随着安全云计算的热潮 您准备好了吗  

云计算的基本原理和概念  

发现一个靠点击广告就能赚美元的网站

Writing Linux LCD drivers

WinCELCD驱动程序编写指南

关于MODULE_PARM()  

Linux环境下USB的原理、驱动和配置2

Linux环境下USB的原理、驱动和配置1

腾讯发布QQ for Linux 1.0 Preview  

搜索引擎正在逐步抹杀人类的记忆和思考

[转载] Linux内核2.4.x的网络接口源码的结构  

Zigbee入门开发  

中国会面临金融战争的灭顶之灾吗?    不断增长的外汇储备,是中国政府的心病  

两粒电子的爱情  

zigbee简介  

银监会令深上报断供真相MTK是什么?  

[出售]WIFI模块,WIFI方案VT6656+RFUSB接口,MINIPCI接口   

鸟巢山寨机,玩的就是心跳   

ARM Bootloader的共性  

Jennic-zigbee开发套件

供应jennic无线模块 > jn5139高功率模块

吴宇森首度回应质疑萌萌是可爱的错误   

《赤壁》中的精彩与搞笑  

日本第一钻石王老五”--青山光司 日本第一钻王老五”--青山光司  

谁来拯救中国3760亿美元财富  

什么是无线网卡?

电磁辐射会失忆

中国产山寨手机热销巴基斯坦 难定位恐怖分子  

Zigbee标准可能成为自动化的未来动力

无线网络知识收集 无线增益天线认识和选购  

功率放大器"增益放大器"的区别   

无线问题面面观

噪声与信噪比  

zigbee软件设计  

什么是ZigBee无线网络?  

PLC 电力载波通信  

Introduction to IT800D  

超外差和超再生模块有何区别?  

飞弹发射失败怎么办?用 Photoshop 补一枚上去!   

Linux Driver Model()  

Power   Management in the Linux Driver Model(2.6.14)()  

WDM(Windows Driver Model)学习()  

Google问:手机还能拿来做什么?   

USB Dongle VT6656   

IEEE1394  

接收灵敏度   

JN5139 Wireless   Microcontroller  

JN5139-xxx-M02 高功率模块   

ZigBee架构WG议长:ZigBee与蓝牙可以共存  

基于ZigBee的无线网络技术及其应用  

Zigbee可能成为自动化的未来动力  

zigbee简介  

JN51xx开发套件  

ZigBee网络层


类别:默认分类 | 添加到搜藏 | 浏览() | 评论 (0)
 
最近读者:
 
网友评论:
发表评论:
姓 名:
网址或邮箱: (选填)
内 容:
验证码: 请点击后输入四位验证码,字母不区分大小写
      

     

©2009 Baidu