Skip to content

Commit 386f275

Browse files
kaysieversgregkh
authored andcommitted
Driver Core: switch all dynamic ksets to kobj_sysfs_ops
Switch all dynamically created ksets, that export simple attributes, to kobj_attribute from subsys_attribute. Struct subsys_attribute will be removed. Signed-off-by: Kay Sievers <kay.sievers@vrfy.org> Cc: Mike Halcrow <mhalcrow@us.ibm.com> Cc: Phillip Hellewell <phillip@hellewell.homeip.net> Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
1 parent 23b5212 commit 386f275

6 files changed

Lines changed: 54 additions & 33 deletions

File tree

‎fs/ecryptfs/main.c‎

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -736,12 +736,13 @@ static int ecryptfs_init_kmem_caches(void)
736736

737737
static struct kset *ecryptfs_kset;
738738

739-
static ssize_t version_show(struct kset *kset, char *buff)
739+
static ssize_t version_show(struct kobject *kobj,
740+
struct kobj_attribute *attr, char *buff)
740741
{
741742
return snprintf(buff, PAGE_SIZE, "%d\n", ECRYPTFS_VERSIONING_MASK);
742743
}
743744

744-
static struct subsys_attribute version_attr = __ATTR_RO(version);
745+
static struct kobj_attribute version_attr = __ATTR_RO(version);
745746

746747
static struct ecryptfs_version_str_map_elem {
747748
u32 flag;
@@ -755,7 +756,8 @@ static struct ecryptfs_version_str_map_elem {
755756
{ECRYPTFS_VERSIONING_MULTKEY, "multiple keys per file"}
756757
};
757758

758-
static ssize_t version_str_show(struct kset *kset, char *buff)
759+
static ssize_t version_str_show(struct kobject *kobj,
760+
struct kobj_attribute *attr, char *buff)
759761
{
760762
int i;
761763
int remaining = PAGE_SIZE;
@@ -782,7 +784,7 @@ static ssize_t version_str_show(struct kset *kset, char *buff)
782784
return total_written;
783785
}
784786

785-
static struct subsys_attribute version_attr_str = __ATTR_RO(version_str);
787+
static struct kobj_attribute version_attr_str = __ATTR_RO(version_str);
786788

787789
static struct attribute *attributes[] = {
788790
&version_attr.attr,

‎kernel/ksysfs.c‎

Lines changed: 21 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -17,30 +17,34 @@
1717
#include <linux/sched.h>
1818

1919
#define KERNEL_ATTR_RO(_name) \
20-
static struct subsys_attribute _name##_attr = __ATTR_RO(_name)
20+
static struct kobj_attribute _name##_attr = __ATTR_RO(_name)
2121

2222
#define KERNEL_ATTR_RW(_name) \
23-
static struct subsys_attribute _name##_attr = \
23+
static struct kobj_attribute _name##_attr = \
2424
__ATTR(_name, 0644, _name##_show, _name##_store)
2525

2626
#if defined(CONFIG_HOTPLUG) && defined(CONFIG_NET)
2727
/* current uevent sequence number */
28-
static ssize_t uevent_seqnum_show(struct kset *kset, char *page)
28+
static ssize_t uevent_seqnum_show(struct kobject *kobj,
29+
struct kobj_attribute *attr, char *buf)
2930
{
30-
return sprintf(page, "%llu\n", (unsigned long long)uevent_seqnum);
31+
return sprintf(buf, "%llu\n", (unsigned long long)uevent_seqnum);
3132
}
3233
KERNEL_ATTR_RO(uevent_seqnum);
3334

3435
/* uevent helper program, used during early boo */
35-
static ssize_t uevent_helper_show(struct kset *kset, char *page)
36+
static ssize_t uevent_helper_show(struct kobject *kobj,
37+
struct kobj_attribute *attr, char *buf)
3638
{
37-
return sprintf(page, "%s\n", uevent_helper);
39+
return sprintf(buf, "%s\n", uevent_helper);
3840
}
39-
static ssize_t uevent_helper_store(struct kset *kset, const char *page, size_t count)
41+
static ssize_t uevent_helper_store(struct kobject *kobj,
42+
struct kobj_attribute *attr,
43+
const char *buf, size_t count)
4044
{
4145
if (count+1 > UEVENT_HELPER_PATH_LEN)
4246
return -ENOENT;
43-
memcpy(uevent_helper, page, count);
47+
memcpy(uevent_helper, buf, count);
4448
uevent_helper[count] = '\0';
4549
if (count && uevent_helper[count-1] == '\n')
4650
uevent_helper[count-1] = '\0';
@@ -50,21 +54,24 @@ KERNEL_ATTR_RW(uevent_helper);
5054
#endif
5155

5256
#ifdef CONFIG_KEXEC
53-
static ssize_t kexec_loaded_show(struct kset *kset, char *page)
57+
static ssize_t kexec_loaded_show(struct kobject *kobj,
58+
struct kobj_attribute *attr, char *buf)
5459
{
55-
return sprintf(page, "%d\n", !!kexec_image);
60+
return sprintf(buf, "%d\n", !!kexec_image);
5661
}
5762
KERNEL_ATTR_RO(kexec_loaded);
5863

59-
static ssize_t kexec_crash_loaded_show(struct kset *kset, char *page)
64+
static ssize_t kexec_crash_loaded_show(struct kobject *kobj,
65+
struct kobj_attribute *attr, char *buf)
6066
{
61-
return sprintf(page, "%d\n", !!kexec_crash_image);
67+
return sprintf(buf, "%d\n", !!kexec_crash_image);
6268
}
6369
KERNEL_ATTR_RO(kexec_crash_loaded);
6470

65-
static ssize_t vmcoreinfo_show(struct kset *kset, char *page)
71+
static ssize_t vmcoreinfo_show(struct kobject *kobj,
72+
struct kobj_attribute *attr, char *buf)
6673
{
67-
return sprintf(page, "%lx %x\n",
74+
return sprintf(buf, "%lx %x\n",
6875
paddr_vmcoreinfo_note(),
6976
(unsigned int)vmcoreinfo_max_size);
7077
}

‎kernel/power/disk.c‎

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -567,7 +567,8 @@ static const char * const hibernation_modes[] = {
567567
* supports it (as determined by having hibernation_ops).
568568
*/
569569

570-
static ssize_t disk_show(struct kset *kset, char *buf)
570+
static ssize_t disk_show(struct kobject *kobj, struct kobj_attribute *attr,
571+
char *buf)
571572
{
572573
int i;
573574
char *start = buf;
@@ -597,7 +598,8 @@ static ssize_t disk_show(struct kset *kset, char *buf)
597598
}
598599

599600

600-
static ssize_t disk_store(struct kset *kset, const char *buf, size_t n)
601+
static ssize_t disk_store(struct kobject *kobj, struct kobj_attribute *attr,
602+
const char *buf, size_t n)
601603
{
602604
int error = 0;
603605
int i;
@@ -642,13 +644,15 @@ static ssize_t disk_store(struct kset *kset, const char *buf, size_t n)
642644

643645
power_attr(disk);
644646

645-
static ssize_t resume_show(struct kset *kset, char *buf)
647+
static ssize_t resume_show(struct kobject *kobj, struct kobj_attribute *attr,
648+
char *buf)
646649
{
647650
return sprintf(buf,"%d:%d\n", MAJOR(swsusp_resume_device),
648651
MINOR(swsusp_resume_device));
649652
}
650653

651-
static ssize_t resume_store(struct kset *kset, const char *buf, size_t n)
654+
static ssize_t resume_store(struct kobject *kobj, struct kobj_attribute *attr,
655+
const char *buf, size_t n)
652656
{
653657
unsigned int maj, min;
654658
dev_t res;
@@ -674,12 +678,14 @@ static ssize_t resume_store(struct kset *kset, const char *buf, size_t n)
674678

675679
power_attr(resume);
676680

677-
static ssize_t image_size_show(struct kset *kset, char *buf)
681+
static ssize_t image_size_show(struct kobject *kobj, struct kobj_attribute *attr,
682+
char *buf)
678683
{
679684
return sprintf(buf, "%lu\n", image_size);
680685
}
681686

682-
static ssize_t image_size_store(struct kset *kset, const char *buf, size_t n)
687+
static ssize_t image_size_store(struct kobject *kobj, struct kobj_attribute *attr,
688+
const char *buf, size_t n)
683689
{
684690
unsigned long size;
685691

‎kernel/power/main.c‎

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -289,7 +289,8 @@ struct kset *power_kset;
289289
* proper enumerated value, and initiates a suspend transition.
290290
*/
291291

292-
static ssize_t state_show(struct kset *kset, char *buf)
292+
static ssize_t state_show(struct kobject *kobj, struct kobj_attribute *attr,
293+
char *buf)
293294
{
294295
char *s = buf;
295296
#ifdef CONFIG_SUSPEND
@@ -310,7 +311,8 @@ static ssize_t state_show(struct kset *kset, char *buf)
310311
return (s - buf);
311312
}
312313

313-
static ssize_t state_store(struct kset *kset, const char *buf, size_t n)
314+
static ssize_t state_store(struct kobject *kobj, struct kobj_attribute *attr,
315+
const char *buf, size_t n)
314316
{
315317
#ifdef CONFIG_SUSPEND
316318
suspend_state_t state = PM_SUSPEND_STANDBY;
@@ -347,13 +349,15 @@ power_attr(state);
347349
#ifdef CONFIG_PM_TRACE
348350
int pm_trace_enabled;
349351

350-
static ssize_t pm_trace_show(struct kset *kset, char *buf)
352+
static ssize_t pm_trace_show(struct kobject *kobj, struct kobj_attribute *attr,
353+
char *buf)
351354
{
352355
return sprintf(buf, "%d\n", pm_trace_enabled);
353356
}
354357

355358
static ssize_t
356-
pm_trace_store(struct kset *kset, const char *buf, size_t n)
359+
pm_trace_store(struct kobject *kobj, struct kobj_attribute *attr,
360+
const char *buf, size_t n)
357361
{
358362
int val;
359363

‎kernel/power/power.h‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ extern int pfn_is_nosave(unsigned long);
5454
extern struct mutex pm_mutex;
5555

5656
#define power_attr(_name) \
57-
static struct subsys_attribute _name##_attr = { \
57+
static struct kobj_attribute _name##_attr = { \
5858
.attr = { \
5959
.name = __stringify(_name), \
6060
.mode = 0644, \

‎lib/kobject.c‎

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -626,7 +626,8 @@ static void dynamic_kobj_release(struct kobject *kobj)
626626
}
627627

628628
static struct kobj_type dynamic_kobj_ktype = {
629-
.release = dynamic_kobj_release,
629+
.release = dynamic_kobj_release,
630+
.sysfs_ops = &kobj_sysfs_ops,
630631
};
631632

632633
/**
@@ -836,7 +837,8 @@ static void kset_release(struct kobject *kobj)
836837
kfree(kset);
837838
}
838839

839-
static struct kobj_type kset_type = {
840+
static struct kobj_type kset_ktype = {
841+
.sysfs_ops = &kobj_sysfs_ops,
840842
.release = kset_release,
841843
};
842844

@@ -869,11 +871,11 @@ static struct kset *kset_create(const char *name,
869871
kset->kobj.parent = parent_kobj;
870872

871873
/*
872-
* The kobject of this kset will have a type of kset_type and belong to
874+
* The kobject of this kset will have a type of kset_ktype and belong to
873875
* no kset itself. That way we can properly free it when it is
874876
* finished being used.
875877
*/
876-
kset->kobj.ktype = &kset_type;
878+
kset->kobj.ktype = &kset_ktype;
877879
kset->kobj.kset = NULL;
878880

879881
return kset;

0 commit comments

Comments
 (0)