update
Signed-off-by: Wenchao Hao <haowenchao@huawei.com>
This commit is contained in:
parent
1e969fa88f
commit
66986deed1
|
|
@ -13,6 +13,13 @@ static void global_ref_release(struct percpu_ref *)
|
|||
printk("%s %d\n", __func__, __LINE__);
|
||||
}
|
||||
|
||||
static ssize_t atomic_show(struct kobject *kobj, struct kobj_attribute *attr,
|
||||
char *buf)
|
||||
{
|
||||
return sysfs_emit(buf, "%ld\n", atomic_long_read(&global_ref.data->count));
|
||||
}
|
||||
static struct kobj_attribute atomic_attribute = __ATTR_RO(atomic);
|
||||
|
||||
static ssize_t is_percpu_show(struct kobject *kobj, struct kobj_attribute *attr,
|
||||
char *buf)
|
||||
{
|
||||
|
|
@ -74,7 +81,24 @@ static ssize_t switch_to_percpu_store(struct kobject *kobj, struct kobj_attribut
|
|||
}
|
||||
static struct kobj_attribute switch_to_percpu_attribute = __ATTR_WO(switch_to_percpu);
|
||||
|
||||
static ssize_t get_store(struct kobject *kobj, struct kobj_attribute *attr,
|
||||
const char *buf, size_t count)
|
||||
{
|
||||
percpu_ref_get(&global_ref);
|
||||
return count;
|
||||
}
|
||||
static struct kobj_attribute get_attribute = __ATTR_WO(get);
|
||||
|
||||
static ssize_t put_store(struct kobject *kobj, struct kobj_attribute *attr,
|
||||
const char *buf, size_t count)
|
||||
{
|
||||
percpu_ref_put(&global_ref);
|
||||
return count;
|
||||
}
|
||||
static struct kobj_attribute put_attribute = __ATTR_WO(put);
|
||||
|
||||
static struct attribute *attrs[] = {
|
||||
&atomic_attribute.attr,
|
||||
&is_dying_attribute.attr,
|
||||
&is_zero_attribute.attr,
|
||||
&is_percpu_attribute.attr,
|
||||
|
|
@ -83,6 +107,8 @@ static struct attribute *attrs[] = {
|
|||
&kill_attribute.attr,
|
||||
&resurrect_attribute.attr,
|
||||
&switch_to_percpu_attribute.attr,
|
||||
&get_attribute.attr,
|
||||
&put_attribute.attr,
|
||||
NULL,
|
||||
};
|
||||
static struct attribute_group attr_group = {
|
||||
|
|
|
|||
Loading…
Reference in New Issue