zoukankan      html  css  js  c++  java
  • static inline extern等概念

    写驱动时碰到如下函数调用,涉及知识点 static inline extern

    include/of.h中有如下定义:

    extern struct device_node *of_find_node_by_name(struct device_node *from,
    const char *name);

    static inline struct device_node *of_find_node_by_name(struct device_node *from,
    const char *name)
    {
    return NULL;
    }

    drivers/of/base.c中定义如下:

    /**
    * of_find_node_by_name - Find a node by its "name" property
    * @from: The node to start searching from or NULL, the node
    * you pass will not be searched, only the next one
    * will; typically, you pass what the previous call
    * returned. of_node_put() will be called on it
    * @name: The name string to match against
    *
    * Returns a node pointer with refcount incremented, use
    * of_node_put() on it when done.
    */
    struct device_node *of_find_node_by_name(struct device_node *from,
    const char *name)
    {
    struct device_node *np;
    unsigned long flags;

    raw_spin_lock_irqsave(&devtree_lock, flags);
    for_each_of_allnodes_from(from, np)
    if (np->name && (of_node_cmp(np->name, name) == 0)
    && of_node_get(np))
    break;
    of_node_put(from);
    raw_spin_unlock_irqrestore(&devtree_lock, flags);
    return np;
    }
    EXPORT_SYMBOL(of_find_node_by_name);

    后来发觉是一场误会:

    #ifdef CONFIG_OF

    extern struct device_node *of_find_node_by_name(struct device_node *from,
    const char *name);

    #else /* CONFIG_OF */

    static inline struct device_node *of_find_node_by_name(struct device_node *from,
    const char *name)
    {
    return NULL;
    }

    #endif /* CONFIG_OF */

  • 相关阅读:
    258. Add Digits 数位相加到只剩一位数
    7. Reverse Integer 反转整数
    9. Palindrome Number 回文数的判断
    824. Goat Latin山羊拉丁文
    819. Most Common Word 统计高频词(暂未被禁止)
    Angular 2 模板语法
    HTML DOM Style opacity 属性
    Basic concepts (C language) – C 中文开发手册
    JavaScript手册 | JS Array 对象中的fill()方法
    HTML <form> 标签
  • 原文地址:https://www.cnblogs.com/idyllcheung/p/13186884.html
Copyright © 2011-2022 走看看