linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Jani Nikula <jani.nikula@intel.com>
To: "Rafael J. Wysocki" <rafael@kernel.org>
Cc: Linux Kernel Mailing List <linux-kernel@vger.kernel.org>,
	intel-gfx <intel-gfx@lists.freedesktop.org>,
	Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
	"Rafael J. Wysocki" <rafael@kernel.org>
Subject: Re: [PATCH 1/2] sysfs: constify sysfs create/remove files harder
Date: Fri, 05 Oct 2018 10:36:29 +0300	[thread overview]
Message-ID: <87lg7cq1z6.fsf@intel.com> (raw)
In-Reply-To: <CAJZ5v0iOR=PLHWtuJDVSsjpeTp_BLsheRM_dR_AL00hN-6bUhQ@mail.gmail.com>

On Fri, 05 Oct 2018, "Rafael J. Wysocki" <rafael@kernel.org> wrote:
> On Thu, Oct 4, 2018 at 4:38 PM Jani Nikula <jani.nikula@intel.com> wrote:
>>
>> 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.

> As for the changes:
>
> Reviewed-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>

Thanks for the review.

BR,
Jani.


>
>> Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
>> Cc: "Rafael J. Wysocki" <rafael@kernel.org>
>> Signed-off-by: Jani Nikula <jani.nikula@intel.com>
>> ---
>>  fs/sysfs/file.c       | 4 ++--
>>  include/linux/sysfs.h | 8 ++++----
>>  2 files changed, 6 insertions(+), 6 deletions(-)
>>
>> diff --git a/fs/sysfs/file.c b/fs/sysfs/file.c
>> index 0a7252aecfa5..bb71db63c99c 100644
>> --- a/fs/sysfs/file.c
>> +++ b/fs/sysfs/file.c
>> @@ -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++)
>> diff --git a/include/linux/sysfs.h b/include/linux/sysfs.h
>> index 987cefa337de..786816cf4aa5 100644
>> --- a/include/linux/sysfs.h
>> +++ b/include/linux/sysfs.h
>> @@ -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
>>

-- 
Jani Nikula, Intel Open Source Graphics Center

  reply	other threads:[~2018-10-05  7:36 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-10-04 14:37 [PATCH 1/2] sysfs: constify sysfs create/remove files harder Jani Nikula
2018-10-04 14:37 ` [PATCH 2/2] drm/i915/sysfs: make attrs arrays const Jani Nikula
2018-10-05  6:55   ` Rafael J. Wysocki
2018-10-05  6:54 ` [PATCH 1/2] sysfs: constify sysfs create/remove files harder Rafael J. Wysocki
2018-10-05  7:36   ` Jani Nikula [this message]
2018-10-05  7:41     ` Rafael J. Wysocki
2018-10-16 10:48 ` Greg Kroah-Hartman
2018-10-16 11:38   ` Jani Nikula
2018-10-16 11:43     ` Greg Kroah-Hartman
2018-10-16 12:10       ` Jani Nikula
2018-10-16 12:47         ` Greg Kroah-Hartman
2018-10-31 10:05           ` Jani Nikula

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87lg7cq1z6.fsf@intel.com \
    --to=jani.nikula@intel.com \
    --cc=gregkh@linuxfoundation.org \
    --cc=intel-gfx@lists.freedesktop.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=rafael@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).