From 7047c1729b371cf42d08b5cfe743d860c6df1f8f Mon Sep 17 00:00:00 2001 From: Gleb Chesnokov Date: Tue, 12 Apr 2022 16:38:37 +0300 Subject: [PATCH] scst_mem: Use default_groups in kobj_type There were 2 ways to create a set of sysfs files for a kobj_type, through the default_attrs field, and the default_groups field. The default_groups field was introduced in aa30f47cf666 ("kobject: Add support for default attribute groups to kobj_type") # v5.2 The default_attrs field was dropped in cdb4f26a63c3 ("kobject: kobj_type: remove default_attrs") # v5.18 Hence move the scst_mem sysfs code to use default_groups field since Linux Kernel v5.2 --- scst/src/scst_mem.c | 22 ++++++++++++++++++---- 1 file changed, 18 insertions(+), 4 deletions(-) diff --git a/scst/src/scst_mem.c b/scst/src/scst_mem.c index 2b655eaa7..5202548f7 100644 --- a/scst/src/scst_mem.c +++ b/scst/src/scst_mem.c @@ -2012,10 +2012,13 @@ static struct kobj_attribute sgv_stat_attr = __ATTR(stats, S_IRUGO | S_IWUSR, sgv_sysfs_stat_show, sgv_sysfs_stat_reset); -static struct attribute *sgv_attrs[] = { +static struct attribute *sgv_pool_attrs[] = { &sgv_stat_attr.attr, NULL, }; +#if LINUX_VERSION_CODE >= KERNEL_VERSION(5, 2, 0) +ATTRIBUTE_GROUPS(sgv_pool); +#endif static void sgv_kobj_release(struct kobject *kobj) { @@ -2034,7 +2037,11 @@ static void sgv_kobj_release(struct kobject *kobj) static struct kobj_type sgv_pool_ktype = { .sysfs_ops = &scst_sysfs_ops, .release = sgv_kobj_release, - .default_attrs = sgv_attrs, +#if LINUX_VERSION_CODE >= KERNEL_VERSION(5, 2, 0) + .default_groups = sgv_pool_groups, +#else + .default_attrs = sgv_pool_attrs, +#endif }; static int scst_sgv_sysfs_create(struct sgv_pool *pool) @@ -2075,10 +2082,13 @@ static struct kobj_attribute sgv_global_stat_attr = __ATTR(global_stats, S_IRUGO | S_IWUSR, sgv_sysfs_global_stat_show, sgv_sysfs_global_stat_reset); -static struct attribute *sgv_default_attrs[] = { +static struct attribute *sgv_def_attrs[] = { &sgv_global_stat_attr.attr, NULL, }; +#if LINUX_VERSION_CODE >= KERNEL_VERSION(5, 2, 0) +ATTRIBUTE_GROUPS(sgv_def); +#endif static void scst_sysfs_release(struct kobject *kobj) { @@ -2088,7 +2098,11 @@ static void scst_sysfs_release(struct kobject *kobj) static struct kobj_type sgv_ktype = { .sysfs_ops = &scst_sysfs_ops, .release = scst_sysfs_release, - .default_attrs = sgv_default_attrs, +#if LINUX_VERSION_CODE >= KERNEL_VERSION(5, 2, 0) + .default_groups = sgv_def_groups, +#else + .default_attrs = sgv_def_attrs, +#endif }; /*