Skip to contentSkip to conversation

sysfs: constify sysfs create/remove files harder

PATCH In review Jani Nikula 4 participants 15 messages Oct 4, 2018 – Oct 31, 2018

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/2 sysfs: constify sysfs create/remove files harder

Let the passed in array be const (and thus placed in rodata) instead of a mutable array of const pointers.

Cc Greg Kroah-Hartman <[email protected]>
Cc "Rafael J. Wysocki" <[email protected]>
---
 fs/sysfs/file.c       | 4 ++--
 include/linux/sysfs.h | 8 ++++----
 2 files changed, 6 insertions(+), 6 deletions(-)
fs/sysfs/file.c +2 -2
index 0a7252aecfa5..bb71db63c99c 100644
@@ -334,7 +334,7 @@ int sysfs_create_file_ns(struct kobject *kobj, const struct attribute *attr,
 }
 EXPORT_SYMBOL_GPL(sysfs_create_file_ns);
 
-int sysfs_create_files(struct kobject *kobj, const struct attribute **ptr)
+int sysfs_create_files(struct kobject *kobj, const struct attribute * const *ptr)
 {
 	int err = 0;
 	int i;
@@ -493,7 +493,7 @@ bool sysfs_remove_file_self(struct kobject *kobj, const struct attribute *attr)
 	return ret;
 }
 
-void sysfs_remove_files(struct kobject *kobj, const struct attribute **ptr)
+void sysfs_remove_files(struct kobject *kobj, const struct attribute * const *ptr)
 {
 	int i;
 	for (i = 0; ptr[i]; i++)
include/linux/sysfs.h +4 -4
index 987cefa337de..786816cf4aa5 100644
@@ -234,7 +234,7 @@ int __must_check sysfs_create_file_ns(struct kobject *kobj,
 				      const struct attribute *attr,
 				      const void *ns);
 int __must_check sysfs_create_files(struct kobject *kobj,
-				   const struct attribute **attr);
+				   const struct attribute * const *attr);
 int __must_check sysfs_chmod_file(struct kobject *kobj,
 				  const struct attribute *attr, umode_t mode);
 struct kernfs_node *sysfs_break_active_protection(struct kobject *kobj,
@@ -243,7 +243,7 @@ void sysfs_unbreak_active_protection(struct kernfs_node *kn);
 void sysfs_remove_file_ns(struct kobject *kobj, const struct attribute *attr,
 			  const void *ns);
 bool sysfs_remove_file_self(struct kobject *kobj, const struct attribute *attr);
-void sysfs_remove_files(struct kobject *kobj, const struct attribute **attr);
+void sysfs_remove_files(struct kobject *kobj, const struct attribute * const *attr);
 
 int __must_check sysfs_create_bin_file(struct kobject *kobj,
 				       const struct bin_attribute *attr);
@@ -342,7 +342,7 @@ static inline int sysfs_create_file_ns(struct kobject *kobj,
 }
 
 static inline int sysfs_create_files(struct kobject *kobj,
-				    const struct attribute **attr)
+				    const struct attribute * const *attr)
 {
 	return 0;
 }
@@ -377,7 +377,7 @@ static inline bool sysfs_remove_file_self(struct kobject *kobj,
 }
 
 static inline void sysfs_remove_files(struct kobject *kobj,
-				     const struct attribute **attr)
+				     const struct attribute * const *attr)
 {
 }
 
Signature · 6 lines
2.11.0

_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
#1 lore raw

PATCH 2/2 drm/i915/sysfs: make attrs arrays const

They don't need to be modified.

Cc Greg Kroah-Hartman <[email protected]>
Cc "Rafael J. Wysocki" <[email protected]>
---
 drivers/gpu/drm/i915/i915_sysfs.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/gpu/drm/i915/i915_sysfs.c +2 -2
index e5e6f6bb2b05..b9aa8515254e 100644
@@ -483,7 +483,7 @@ static ssize_t gt_rp_mhz_show(struct device *kdev, struct device_attribute *attr
 	return snprintf(buf, PAGE_SIZE, "%d\n", val);
 }
 
-static const struct attribute *gen6_attrs[] = {
+static const struct attribute * const gen6_attrs[] = {
 	&dev_attr_gt_act_freq_mhz.attr,
 	&dev_attr_gt_cur_freq_mhz.attr,
 	&dev_attr_gt_boost_freq_mhz.attr,
@@ -495,7 +495,7 @@ static const struct attribute *gen6_attrs[] = {
 	NULL,
 };
 
-static const struct attribute *vlv_attrs[] = {
+static const struct attribute * const vlv_attrs[] = {
 	&dev_attr_gt_act_freq_mhz.attr,
 	&dev_attr_gt_cur_freq_mhz.attr,
 	&dev_attr_gt_boost_freq_mhz.attr,
Signature · 1 line
2.11.0
maintainer Reviewed-by on v1 2/2
#2 lore raw

Re: [PATCH 2/2] drm/i915/sysfs: make attrs arrays const

Quoted 6 lines · Jani Nikula

They don't need to be modified.

Cc Greg Kroah-Hartman <[email protected]>
Cc "Rafael J. Wysocki" <[email protected]>
Quoted 27 lines
---
 drivers/gpu/drm/i915/i915_sysfs.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/gpu/drm/i915/i915_sysfs.c +2 -3
index e5e6f6bb2b05..b9aa8515254e 100644
@@ -483,7 +483,7 @@ static ssize_t gt_rp_mhz_show(struct device *kdev, struct device_attribute *attr
        return snprintf(buf, PAGE_SIZE, "%d\n", val);
 }
 
-static const struct attribute *gen6_attrs[] = {
+static const struct attribute * const gen6_attrs[] = {
        &dev_attr_gt_act_freq_mhz.attr,
        &dev_attr_gt_cur_freq_mhz.attr,
        &dev_attr_gt_boost_freq_mhz.attr,
@@ -495,7 +495,7 @@ static const struct attribute *gen6_attrs[] = {
        NULL,
 };
 
-static const struct attribute *vlv_attrs[] = {
+static const struct attribute * const vlv_attrs[] = {
        &dev_attr_gt_act_freq_mhz.attr,
        &dev_attr_gt_cur_freq_mhz.attr,
        &dev_attr_gt_boost_freq_mhz.attr,
--
Quoted 2 lines

2.11.0

_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

#3 lore raw

✗ Fi.CI.CHECKPATCH: warning for series starting with [1/2] sysfs: constify sysfs create/remove files harder

In reply to Jani Nikula
== Series Details ==

== Series Details ==

Series: series starting with [1/2] sysfs: constify sysfs create/remove files harder
URL : https://patchwork.freedesktop.org/series/50558/
State : warning

== Summary ==

$ dim checkpatch origin/drm-tip
fd1ccbdbc465 sysfs: constify sysfs create/remove files harder
-:53: WARNING:FUNCTION_ARGUMENTS: function definition argument 'const struct attribute * const' should also have an identifier name
#53: FILE: include/linux/sysfs.h:246:
+void sysfs_remove_files(struct kobject *kobj, const struct attribute * const *attr);

total: 0 errors, 1 warnings, 0 checks, 48 lines checked bac4039c6292 drm/i915/sysfs: make attrs arrays const

_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

#4 lore raw

✓ Fi.CI.BAT: success for series starting with [1/2] sysfs: constify sysfs create/remove files harder

In reply to Jani Nikula
== Series Details ==

== Series Details ==

Series: series starting with [1/2] sysfs: constify sysfs create/remove files harder
URL : https://patchwork.freedesktop.org/series/50558/
State : success

== Summary ==

= CI Bug Log - changes from CI_DRM_4931 -> Patchwork_10362 =

== Summary - SUCCESS ==

No regressions found.

External URL: https://patchwork.freedesktop.org/api/1.0/series/50558/revisions/1/mbox/

== Known issues ==

Here are the changes found in Patchwork_10362 that come from known issues:

=== IGT changes ===

    ==== Issues hit ====

    igt@amdgpu/amd_cs_nop@sync-fork-compute0:
      fi-kbl-8809g:       PASS -> DMESG-WARN (fdo#107762)

    igt@gem_exec_suspend@basic-s3:
      fi-bdw-samus:       NOTRUN -> INCOMPLETE (fdo#107773)

    igt@kms_pipe_crc_basic@suspend-read-crc-pipe-a:
      fi-byt-clapper:     PASS -> FAIL (fdo#107362, fdo#103191)

    
    ==== Possible fixes ====

    igt@gem_ctx_param@basic-default:
      fi-pnv-d510:        INCOMPLETE (fdo#106007) -> SKIP

    igt@kms_pipe_crc_basic@hang-read-crc-pipe-a:
      fi-byt-clapper:     FAIL (fdo#107362, fdo#103191) -> PASS

    igt@kms_pipe_crc_basic@read-crc-pipe-a:
      fi-byt-clapper:     FAIL (fdo#107362) -> PASS

    igt@kms_pipe_crc_basic@suspend-read-crc-pipe-b:
      fi-cfl-8109u:       INCOMPLETE (fdo#106070, fdo#108126) -> PASS

fdo#103191 https://bugs.freedesktop.org/show_bug.cgi?id=103191
fdo#106007 https://bugs.freedesktop.org/show_bug.cgi?id=106007
fdo#106070 https://bugs.freedesktop.org/show_bug.cgi?id=106070
fdo#107362 https://bugs.freedesktop.org/show_bug.cgi?id=107362
fdo#107762 https://bugs.freedesktop.org/show_bug.cgi?id=107762
fdo#107773 https://bugs.freedesktop.org/show_bug.cgi?id=107773
fdo#108126 https://bugs.freedesktop.org/show_bug.cgi?id=108126

== Participating hosts (48 -> 43) ==

Additional (2): fi-icl-u fi-bdw-samus
Missing (7): fi-ilk-m540 fi-hsw-4200u fi-byt-squawks fi-icl-u2 fi-bsw-cyan fi-ctg-p8600 fi-kbl-7560u

== Build changes ==

* Linux: CI_DRM_4931 -> Patchwork_10362

CI_DRM_4931: 826702bf60ae2b37841c051ed769b44af194fbb1 @ git://anongit.freedesktop.org/gfx-ci/linux
IGT_4667: 596f48dcd59fd2f8c16671514f3e69d4a2891374 @ git://anongit.freedesktop.org/xorg/app/intel-gpu-tools
Patchwork_10362: bac4039c629245599634a1a25a4029671408cc7a @ git://anongit.freedesktop.org/gfx-ci/linux

== Linux commits ==

bac4039c6292 drm/i915/sysfs: make attrs arrays const fd1ccbdbc465 sysfs: constify sysfs create/remove files harder

== Logs ==

For more details see: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_10362/issues.html
_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

#5 lore raw

✗ Fi.CI.IGT: failure for series starting with [1/2] sysfs: constify sysfs create/remove files harder

In reply to Jani Nikula
== Series Details ==

== Series Details ==

Series: series starting with [1/2] sysfs: constify sysfs create/remove files harder
URL : https://patchwork.freedesktop.org/series/50558/
State : failure

== Summary ==

= CI Bug Log - changes from CI_DRM_4931_full -> Patchwork_10362_full =

== Summary - FAILURE ==

Serious unknown changes coming with Patchwork_10362_full absolutely need to be verified manually.

If you think the reported changes have nothing to do with the changes introduced in Patchwork_10362_full, please notify your bug team to allow them to document this new failure mode, which will reduce false positives in CI.

== Possible new issues ==

Here are the unknown changes that may have been introduced in Patchwork_10362_full:

=== IGT changes ===

    ==== Possible regressions ====

    igt@kms_atomic_interruptible@legacy-pageflip:
      shard-kbl:          PASS -> DMESG-WARN

    igt@kms_flip_tiling@flip-to-x-tiled:
      shard-skl:          PASS -> FAIL

== Known issues ==

Here are the changes found in Patchwork_10362_full that come from known issues:

=== IGT changes ===

    ==== Issues hit ====

    igt@drv_suspend@shrink:
      shard-skl:          NOTRUN -> INCOMPLETE (fdo#106886)

    igt@gem_exec_schedule@pi-ringfull-bsd:
      shard-skl:          NOTRUN -> FAIL (fdo#103158)

    igt@gem_ppgtt@blt-vs-render-ctxn:
      shard-skl:          NOTRUN -> TIMEOUT (fdo#108039)

    igt@gem_softpin@softpin:
      shard-apl:          PASS -> INCOMPLETE (fdo#103927)

    igt@kms_available_modes_crc@available_mode_test_crc:
      shard-apl:          PASS -> FAIL (fdo#106641)

    igt@kms_busy@extended-modeset-hang-newfb-render-a:
      shard-skl:          NOTRUN -> DMESG-WARN (fdo#107956)

    igt@kms_busy@extended-modeset-hang-newfb-with-reset-render-b:
      shard-snb:          PASS -> DMESG-WARN (fdo#107956)

    igt@kms_cursor_crc@cursor-256x256-random:
      shard-apl:          PASS -> FAIL (fdo#103232) +2

    igt@kms_cursor_crc@cursor-64x64-sliding:
      shard-glk:          PASS -> FAIL (fdo#103232) +2

    igt@kms_cursor_legacy@cursorb-vs-flipb-toggle:
      shard-glk:          PASS -> DMESG-WARN (fdo#105763, fdo#106538) +1

    igt@kms_fbcon_fbt@fbc-suspend:
      shard-glk:          PASS -> FAIL (fdo#105681, fdo#103833)

    igt@kms_frontbuffer_tracking@fbc-1p-primscrn-spr-indfb-onoff:
      shard-glk:          PASS -> FAIL (fdo#103167)
      shard-apl:          PASS -> FAIL (fdo#103167)

    igt@kms_plane@pixel-format-pipe-a-planes:
      shard-skl:          NOTRUN -> DMESG-WARN (fdo#106885)

    igt@kms_plane@plane-position-covered-pipe-c-planes:
      shard-apl:          PASS -> FAIL (fdo#103166)

    {igt@kms_plane_alpha_blend@pipe-c-alpha-transparant-fb}:
      shard-skl:          NOTRUN -> FAIL (fdo#108145)

    igt@kms_plane_multiple@atomic-pipe-a-tiling-yf:
      shard-glk:          PASS -> FAIL (fdo#103166)

    igt@pm_rpm@fences-dpms:
      shard-skl:          PASS -> INCOMPLETE (fdo#107807)

    
    ==== Possible fixes ====

    igt@drv_suspend@fence-restore-untiled:
      shard-kbl:          INCOMPLETE (fdo#103665) -> PASS

    igt@kms_cursor_crc@cursor-256x256-sliding:
      shard-glk:          FAIL (fdo#103232) -> PASS +1

    igt@kms_cursor_crc@cursor-256x85-sliding:
      shard-apl:          FAIL (fdo#103232) -> PASS +1

    igt@kms_draw_crc@draw-method-xrgb8888-mmap-cpu-xtiled:
      shard-skl:          FAIL (fdo#107791) -> PASS

    igt@kms_draw_crc@fill-fb:
      shard-skl:          FAIL -> PASS

    igt@kms_flip@flip-vs-expired-vblank-interruptible:
      shard-skl:          FAIL (fdo#105363) -> PASS

    igt@kms_frontbuffer_tracking@fbc-1p-primscrn-spr-indfb-draw-render:
      shard-apl:          FAIL (fdo#103167) -> PASS

    igt@kms_frontbuffer_tracking@fbc-2p-primscrn-spr-indfb-draw-mmap-cpu:
      shard-glk:          FAIL (fdo#103167) -> PASS

    igt@kms_frontbuffer_tracking@fbcpsr-1p-offscren-pri-shrfb-draw-mmap-cpu:
      shard-skl:          FAIL (fdo#103167) -> PASS +2

    {igt@kms_plane_alpha_blend@pipe-a-coverage-7efc}:
      shard-skl:          FAIL (fdo#108145) -> PASS

    igt@kms_plane_multiple@atomic-pipe-a-tiling-y:
      shard-glk:          FAIL (fdo#103166) -> PASS

    igt@kms_universal_plane@universal-plane-pipe-c-functional:
      shard-apl:          FAIL (fdo#103166) -> PASS

{name}: This element is suppressed. This means it is ignored when computing
the status of the difference (SUCCESS, WARNING, or FAILURE).

fdo#103158 https://bugs.freedesktop.org/show_bug.cgi?id=103158
fdo#103166 https://bugs.freedesktop.org/show_bug.cgi?id=103166
fdo#103167 https://bugs.freedesktop.org/show_bug.cgi?id=103167
fdo#103232 https://bugs.freedesktop.org/show_bug.cgi?id=103232
fdo#103665 https://bugs.freedesktop.org/show_bug.cgi?id=103665
fdo#103833 https://bugs.freedesktop.org/show_bug.cgi?id=103833
fdo#103927 https://bugs.freedesktop.org/show_bug.cgi?id=103927
fdo#105363 https://bugs.freedesktop.org/show_bug.cgi?id=105363
fdo#105681 https://bugs.freedesktop.org/show_bug.cgi?id=105681
fdo#105763 https://bugs.freedesktop.org/show_bug.cgi?id=105763
fdo#106538 https://bugs.freedesktop.org/show_bug.cgi?id=106538
fdo#106641 https://bugs.freedesktop.org/show_bug.cgi?id=106641
fdo#106885 https://bugs.freedesktop.org/show_bug.cgi?id=106885
fdo#106886 https://bugs.freedesktop.org/show_bug.cgi?id=106886
fdo#107791 https://bugs.freedesktop.org/show_bug.cgi?id=107791
fdo#107807 https://bugs.freedesktop.org/show_bug.cgi?id=107807
fdo#107956 https://bugs.freedesktop.org/show_bug.cgi?id=107956
fdo#108039 https://bugs.freedesktop.org/show_bug.cgi?id=108039
fdo#108145 https://bugs.freedesktop.org/show_bug.cgi?id=108145

== Participating hosts (6 -> 6) ==

No changes in participating hosts

== Build changes ==

* Linux: CI_DRM_4931 -> Patchwork_10362

CI_DRM_4931: 826702bf60ae2b37841c051ed769b44af194fbb1 @ git://anongit.freedesktop.org/gfx-ci/linux
IGT_4667: 596f48dcd59fd2f8c16671514f3e69d4a2891374 @ git://anongit.freedesktop.org/xorg/app/intel-gpu-tools
Patchwork_10362: bac4039c629245599634a1a25a4029671408cc7a @ git://anongit.freedesktop.org/gfx-ci/linux
piglit_4509: fdc5a4ca11124ab8413c7988896eec4c97336694 @ git://anongit.freedesktop.org/piglit

== Logs ==

For more details see: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_10362/shards.html
_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

maintainer Reviewed-by on v1 1/2
#6 lore raw
In reply to Jani Nikula
Quoted 3 lines · Jani Nikula

Let the passed in array be const (and thus placed in rodata) instead of a mutable array of const pointers.

I'm not sure if the changes guarantee what you want. If I'm not mistaken, they just mean that the function itself cannot modify either the pointer passed to it, or the contents of the array pointed to by that pointer. They don't imply the location of the array itself, though.

As for the changes:

Quoted 71 lines
Cc Greg Kroah-Hartman <[email protected]>
Cc "Rafael J. Wysocki" <[email protected]>
---
 fs/sysfs/file.c       | 4 ++--
 include/linux/sysfs.h | 8 ++++----
 2 files changed, 6 insertions(+), 6 deletions(-)
fs/sysfs/file.c +2 -2
index 0a7252aecfa5..bb71db63c99c 100644
@@ -334,7 +334,7 @@ int sysfs_create_file_ns(struct kobject *kobj, const struct attribute *attr,
 }
 EXPORT_SYMBOL_GPL(sysfs_create_file_ns);
 
-int sysfs_create_files(struct kobject *kobj, const struct attribute **ptr)
+int sysfs_create_files(struct kobject *kobj, const struct attribute * const *ptr)
 {
        int err = 0;
        int i;
@@ -493,7 +493,7 @@ bool sysfs_remove_file_self(struct kobject *kobj, const struct attribute *attr)
        return ret;
 }
 
-void sysfs_remove_files(struct kobject *kobj, const struct attribute **ptr)
+void sysfs_remove_files(struct kobject *kobj, const struct attribute * const *ptr)
 {
        int i;
        for (i = 0; ptr[i]; i++)
include/linux/sysfs.h +4 -5
index 987cefa337de..786816cf4aa5 100644
@@ -234,7 +234,7 @@ int __must_check sysfs_create_file_ns(struct kobject *kobj,
                                      const struct attribute *attr,
                                      const void *ns);
 int __must_check sysfs_create_files(struct kobject *kobj,
-                                  const struct attribute **attr);
+                                  const struct attribute * const *attr);
 int __must_check sysfs_chmod_file(struct kobject *kobj,
                                  const struct attribute *attr, umode_t mode);
 struct kernfs_node *sysfs_break_active_protection(struct kobject *kobj,
@@ -243,7 +243,7 @@ void sysfs_unbreak_active_protection(struct kernfs_node *kn);
 void sysfs_remove_file_ns(struct kobject *kobj, const struct attribute *attr,
                          const void *ns);
 bool sysfs_remove_file_self(struct kobject *kobj, const struct attribute *attr);
-void sysfs_remove_files(struct kobject *kobj, const struct attribute **attr);
+void sysfs_remove_files(struct kobject *kobj, const struct attribute * const *attr);
 
 int __must_check sysfs_create_bin_file(struct kobject *kobj,
                                       const struct bin_attribute *attr);
@@ -342,7 +342,7 @@ static inline int sysfs_create_file_ns(struct kobject *kobj,
 }
 
 static inline int sysfs_create_files(struct kobject *kobj,
-                                   const struct attribute **attr)
+                                   const struct attribute * const *attr)
 {
        return 0;
 }
@@ -377,7 +377,7 @@ static inline bool sysfs_remove_file_self(struct kobject *kobj,
 }
 
 static inline void sysfs_remove_files(struct kobject *kobj,
-                                    const struct attribute **attr)
+                                    const struct attribute * const *attr)
 {
 }
 
--
Quoted 2 lines

2.11.0

_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

#7 lore raw
Quoted 10 lines · Rafael J. Wysocki
Quoted 3 lines · Jani Nikula

Let the passed in array be const (and thus placed in rodata) instead of a mutable array of const pointers.

I'm not sure if the changes guarantee what you want. If I'm not mistaken, they just mean that the function itself cannot modify either the pointer passed to it, or the contents of the array pointed to by that pointer. They don't imply the location of the array itself, though.

I mean, this change allows the caller to add the appropriate const qualifiers to the array definition, allowing the placement in rodata. Can't do that withouth the extra const in the function.

Quoted 3 lines

As for the changes:

Thanks for the review.

BR,
Jani.

Quoted 74 lines
Quoted 74 lines
Cc Greg Kroah-Hartman <[email protected]>
Cc "Rafael J. Wysocki" <[email protected]>
---
 fs/sysfs/file.c       | 4 ++--
 include/linux/sysfs.h | 8 ++++----
 2 files changed, 6 insertions(+), 6 deletions(-)
fs/sysfs/file.c +2 -2
index 0a7252aecfa5..bb71db63c99c 100644
@@ -334,7 +334,7 @@ int sysfs_create_file_ns(struct kobject *kobj, const struct attribute *attr,
 }
 EXPORT_SYMBOL_GPL(sysfs_create_file_ns);
 
-int sysfs_create_files(struct kobject *kobj, const struct attribute **ptr)
+int sysfs_create_files(struct kobject *kobj, const struct attribute * const *ptr)
 {
        int err = 0;
        int i;
@@ -493,7 +493,7 @@ bool sysfs_remove_file_self(struct kobject *kobj, const struct attribute *attr)
        return ret;
 }
 
-void sysfs_remove_files(struct kobject *kobj, const struct attribute **ptr)
+void sysfs_remove_files(struct kobject *kobj, const struct attribute * const *ptr)
 {
        int i;
        for (i = 0; ptr[i]; i++)
include/linux/sysfs.h +4 -5
index 987cefa337de..786816cf4aa5 100644
@@ -234,7 +234,7 @@ int __must_check sysfs_create_file_ns(struct kobject *kobj,
                                      const struct attribute *attr,
                                      const void *ns);
 int __must_check sysfs_create_files(struct kobject *kobj,
-                                  const struct attribute **attr);
+                                  const struct attribute * const *attr);
 int __must_check sysfs_chmod_file(struct kobject *kobj,
                                  const struct attribute *attr, umode_t mode);
 struct kernfs_node *sysfs_break_active_protection(struct kobject *kobj,
@@ -243,7 +243,7 @@ void sysfs_unbreak_active_protection(struct kernfs_node *kn);
 void sysfs_remove_file_ns(struct kobject *kobj, const struct attribute *attr,
                          const void *ns);
 bool sysfs_remove_file_self(struct kobject *kobj, const struct attribute *attr);
-void sysfs_remove_files(struct kobject *kobj, const struct attribute **attr);
+void sysfs_remove_files(struct kobject *kobj, const struct attribute * const *attr);
 
 int __must_check sysfs_create_bin_file(struct kobject *kobj,
                                       const struct bin_attribute *attr);
@@ -342,7 +342,7 @@ static inline int sysfs_create_file_ns(struct kobject *kobj,
 }
 
 static inline int sysfs_create_files(struct kobject *kobj,
-                                   const struct attribute **attr)
+                                   const struct attribute * const *attr)
 {
        return 0;
 }
@@ -377,7 +377,7 @@ static inline bool sysfs_remove_file_self(struct kobject *kobj,
 }
 
 static inline void sysfs_remove_files(struct kobject *kobj,
-                                    const struct attribute **attr)
+                                    const struct attribute * const *attr)
 {
 }
 
--

2.11.0

Signature · 5 lines
Jani Nikula, Intel Open Source Graphics Center
_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
#8 lore raw
Quoted 13 lines · Jani Nikula
Quoted 10 lines · Rafael J. Wysocki
Quoted 3 lines · Jani Nikula

Let the passed in array be const (and thus placed in rodata) instead of a mutable array of const pointers.

I'm not sure if the changes guarantee what you want. If I'm not mistaken, they just mean that the function itself cannot modify either the pointer passed to it, or the contents of the array pointed to by that pointer. They don't imply the location of the array itself, though.

Quoted 3 lines

I mean, this change allows the caller to add the appropriate const qualifiers to the array definition, allowing the placement in rodata. Can't do that withouth the extra const in the function.

I figured that out, but the changelog is a bit unclear. If you said "Allow ..." instead of "Let ...", it would be somewhat clearer IMO. :-)

maintainer Reviewed-by on v1 1/2
#9 lore raw
In reply to Jani Nikula
Quoted 10 lines · Jani Nikula

Let the passed in array be const (and thus placed in rodata) instead of a mutable array of const pointers.

Cc Greg Kroah-Hartman <[email protected]>
Cc "Rafael J. Wysocki" <[email protected]>
---
 fs/sysfs/file.c       | 4 ++--
 include/linux/sysfs.h | 8 ++++----
 2 files changed, 6 insertions(+), 6 deletions(-)

_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

#10 lore raw
Quoted 12 lines · Greg Kroah-Hartman
Quoted 10 lines · Jani Nikula

Let the passed in array be const (and thus placed in rodata) instead of a mutable array of const pointers.

Cc Greg Kroah-Hartman <[email protected]>
Cc "Rafael J. Wysocki" <[email protected]>
---
 fs/sysfs/file.c       | 4 ++--
 include/linux/sysfs.h | 8 ++++----
 2 files changed, 6 insertions(+), 6 deletions(-)
Quoted 1 line

Thanks; who should pick them up?

BR,
Jani.

Signature · 5 lines
Jani Nikula, Intel Open Source Graphics Center
_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
#11 lore raw
Quoted 13 lines · Jani Nikula
Quoted 12 lines · Greg Kroah-Hartman
Quoted 10 lines · Jani Nikula

Let the passed in array be const (and thus placed in rodata) instead of a mutable array of const pointers.

Cc Greg Kroah-Hartman <[email protected]>
Cc "Rafael J. Wysocki" <[email protected]>
---
 fs/sysfs/file.c       | 4 ++--
 include/linux/sysfs.h | 8 ++++----
 2 files changed, 6 insertions(+), 6 deletions(-)
Quoted 3 lines
Quoted 1 line

Thanks; who should pick them up?

I could pick the first one up, but as you need this for a drm patch, both should probably go through that tree, right?

thanks,

greg k-h
_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

#12 lore raw
Quoted 14 lines · Greg Kroah-Hartman
Quoted 13 lines · Jani Nikula
Quoted 12 lines · Greg Kroah-Hartman
Quoted 10 lines · Jani Nikula

Let the passed in array be const (and thus placed in rodata) instead of a mutable array of const pointers.

Cc Greg Kroah-Hartman <[email protected]>
Cc "Rafael J. Wysocki" <[email protected]>
---
 fs/sysfs/file.c       | 4 ++--
 include/linux/sysfs.h | 8 ++++----
 2 files changed, 6 insertions(+), 6 deletions(-)
Quoted 6 lines
Quoted 3 lines
Quoted 1 line

Thanks; who should pick them up?

I could pick the first one up, but as you need this for a drm patch, both should probably go through that tree, right?

I can pick them both if it doesn't bother you that the sysfs parts will be merged in the merge window for v4.21 i.e. the change would be in drm trees for an entire release cycle. We've been done for v4.20 merge window for a while now.

BR,
Jani.

Signature · 5 lines
Jani Nikula, Intel Open Source Graphics Center
_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
#13 lore raw
Quoted 19 lines · Jani Nikula
Quoted 18 lines · Greg Kroah-Hartman
Quoted 16 lines · Jani Nikula
Quoted 12 lines · Greg Kroah-Hartman
Quoted 10 lines · Jani Nikula

Let the passed in array be const (and thus placed in rodata) instead of a mutable array of const pointers.

Cc Greg Kroah-Hartman <[email protected]>
Cc "Rafael J. Wysocki" <[email protected]>
---
 fs/sysfs/file.c       | 4 ++--
 include/linux/sysfs.h | 8 ++++----
 2 files changed, 6 insertions(+), 6 deletions(-)
Quoted 1 line

Thanks; who should pick them up?

Quoted 7 lines
Quoted 2 lines

I could pick the first one up, but as you need this for a drm patch, both should probably go through that tree, right?

I can pick them both if it doesn't bother you that the sysfs parts will be merged in the merge window for v4.21 i.e. the change would be in drm trees for an entire release cycle. We've been done for v4.20 merge window for a while now.

No objection from me.

greg k-h
_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

#14 lore raw
Quoted 23 lines · Greg Kroah-Hartman
Quoted 22 lines · Jani Nikula
Quoted 20 lines · Greg Kroah-Hartman
Quoted 13 lines · Jani Nikula
Quoted 12 lines · Greg Kroah-Hartman
Quoted 10 lines · Jani Nikula

Let the passed in array be const (and thus placed in rodata) instead of a mutable array of const pointers.

Cc Greg Kroah-Hartman <[email protected]>
Cc "Rafael J. Wysocki" <[email protected]>
---
 fs/sysfs/file.c       | 4 ++--
 include/linux/sysfs.h | 8 ++++----
 2 files changed, 6 insertions(+), 6 deletions(-)
Quoted 3 lines
Quoted 1 line

Thanks; who should pick them up?

I could pick the first one up, but as you need this for a drm patch, both should probably go through that tree, right?

Quoted 6 lines
Quoted 4 lines

I can pick them both if it doesn't bother you that the sysfs parts will be merged in the merge window for v4.21 i.e. the change would be in drm trees for an entire release cycle. We've been done for v4.20 merge window for a while now.

No objection from me.

Argh, I dropped the ball a bit. May I take that as an ack to merge via drm-intel? I try to be careful not to assume acks and reviews.

Thanks,
Jani.

Signature · 5 lines
Jani Nikula, Intel Open Source Graphics Center
_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx