- 追加された行はこの色です。
- 削除された行はこの色です。
*参照元 [#c08a558f]
#backlinks
*説明 [#jb6f37a0]
-パス: [[linux-2.6.25/include/linux/sysfs.h]]
-属性(ATTRibutes)の実装を楽にするためのマクロである。
--属性の名前、モード、取得用の関数、設定用の関数、を指定する。
典型的な使い方(具体例は [[linux-2.6.25/include/linux/device.h]] を見よ)
典型的な使い方(他の例は [[linux-2.6.25/include/linux/device.h]] を見よ)
struct xxx_attribute {
struct bus_attribute {
struct attribute attr;
ssize_t (*show)(struct bus_type *bus, char *buf);
ssize_t (*store)(struct bus_type *bus, const char *buf, size_t count);
};
#define BUS_ATTR(_name, _mode, _show, _store) \
struct bus_attribute bus_attr_##_name = __ATTR(_name, _mode, _show, _store)
**引数 [#fa3ca962]
-_name
--属性の名前を指定する。
マクロ内で文字列リテラルに変換されるため、二重引用符で囲う必要はない。
-_mode
--モードを指定する。
-_show
--取得用の関数ポインタを指定する。
-_store
--設定用の関数ポインタを指定する。
**返り値 [#g9a0325d]
-attr(attribute 構造体)と、show, store メンバを持つ構造体の値を生成して返す。
--変数宣言時に用いることが一般的であるが、
最近の C コンパイラであれば、拡張構文を用いた変数への
代入も可能だと思われる。
--[[linux-2.6.25/attribute]]
**参考 [#h2883245]
*実装 [#n54b11ee]
#define __ATTR(_name,_mode,_show,_store) { \
.attr = {.name = __stringify(_name), .mode = _mode }, \
.show = _show, \
.store = _store, \
}
-_name を文字列化する以外は渡された値をそのまま使う。
--[[linux-2.6.25/__stringify()]]
--先述したとおり attr は struct attribute 型である。
---[[linux-2.6.25/attribute]]
*コメント [#fd429414]
#comment