kset-example.c (c39f2d9db0fd81ea20bb5cce9b3f082ca63753e2) kset-example.c (5a242d8547bdc5802d1e1200a85e69afc3c2d74e)
1// SPDX-License-Identifier: GPL-2.0
2/*
3 * Sample kset and ktype implementation
4 *
5 * Copyright (C) 2004-2007 Greg Kroah-Hartman <greg@kroah.com>
6 * Copyright (C) 2007 Novell Inc.
7 */
8#include <linux/kobject.h>

--- 98 unchanged lines hidden (view full) ---

107}
108
109/*
110 * The "foo" file where the .foo variable is read from and written to.
111 */
112static ssize_t foo_show(struct foo_obj *foo_obj, struct foo_attribute *attr,
113 char *buf)
114{
1// SPDX-License-Identifier: GPL-2.0
2/*
3 * Sample kset and ktype implementation
4 *
5 * Copyright (C) 2004-2007 Greg Kroah-Hartman <greg@kroah.com>
6 * Copyright (C) 2007 Novell Inc.
7 */
8#include <linux/kobject.h>

--- 98 unchanged lines hidden (view full) ---

107}
108
109/*
110 * The "foo" file where the .foo variable is read from and written to.
111 */
112static ssize_t foo_show(struct foo_obj *foo_obj, struct foo_attribute *attr,
113 char *buf)
114{
115 return sprintf(buf, "%d\n", foo_obj->foo);
115 return sysfs_emit(buf, "%d\n", foo_obj->foo);
116}
117
118static ssize_t foo_store(struct foo_obj *foo_obj, struct foo_attribute *attr,
119 const char *buf, size_t count)
120{
121 int ret;
122
123 ret = kstrtoint(buf, 10, &foo_obj->foo);

--- 15 unchanged lines hidden (view full) ---

139 char *buf)
140{
141 int var;
142
143 if (strcmp(attr->attr.name, "baz") == 0)
144 var = foo_obj->baz;
145 else
146 var = foo_obj->bar;
116}
117
118static ssize_t foo_store(struct foo_obj *foo_obj, struct foo_attribute *attr,
119 const char *buf, size_t count)
120{
121 int ret;
122
123 ret = kstrtoint(buf, 10, &foo_obj->foo);

--- 15 unchanged lines hidden (view full) ---

139 char *buf)
140{
141 int var;
142
143 if (strcmp(attr->attr.name, "baz") == 0)
144 var = foo_obj->baz;
145 else
146 var = foo_obj->bar;
147 return sprintf(buf, "%d\n", var);
147 return sysfs_emit(buf, "%d\n", var);
148}
149
150static ssize_t b_store(struct foo_obj *foo_obj, struct foo_attribute *attr,
151 const char *buf, size_t count)
152{
153 int var, ret;
154
155 ret = kstrtoint(buf, 10, &var);

--- 133 unchanged lines hidden ---
148}
149
150static ssize_t b_store(struct foo_obj *foo_obj, struct foo_attribute *attr,
151 const char *buf, size_t count)
152{
153 int var, ret;
154
155 ret = kstrtoint(buf, 10, &var);

--- 133 unchanged lines hidden ---