diff mbox series

[v3,1/4] ACPI: bus: Constify acpi_companion_match() returned value

Message ID 20230626110026.65825-2-andriy.shevchenko@linux.intel.com (mailing list archive)
State In Next, archived
Delegated to: Rafael Wysocki
Headers show
Series ACPI: platform: Fix SMB0001 enumeration on Kontron devices | expand

Commit Message

Andy Shevchenko June 26, 2023, 11 a.m. UTC
acpi_companion_match() doesn't alter the contents of the passed
parameter, so we don't expect that returned value can be altered
either. So constify it.

Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
---
 drivers/acpi/bus.c          | 6 +++---
 drivers/acpi/device_sysfs.c | 2 +-
 drivers/acpi/internal.h     | 2 +-
 3 files changed, 5 insertions(+), 5 deletions(-)

Comments

Rafael J. Wysocki June 29, 2023, 8:49 a.m. UTC | #1
On Mon, Jun 26, 2023 at 1:00 PM Andy Shevchenko
<andriy.shevchenko@linux.intel.com> wrote:
>
> acpi_companion_match() doesn't alter the contents of the passed
> parameter, so we don't expect that returned value can be altered
> either. So constify it.
>
> Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>

This makes sense even without the rest of the series, so I can queue
it up right away if you want me to do that.

> ---
>  drivers/acpi/bus.c          | 6 +++---
>  drivers/acpi/device_sysfs.c | 2 +-
>  drivers/acpi/internal.h     | 2 +-
>  3 files changed, 5 insertions(+), 5 deletions(-)
>
> diff --git a/drivers/acpi/bus.c b/drivers/acpi/bus.c
> index e3e0bd0c5a50..20cdfb37da79 100644
> --- a/drivers/acpi/bus.c
> +++ b/drivers/acpi/bus.c
> @@ -682,7 +682,7 @@ bool acpi_device_is_first_physical_node(struct acpi_device *adev,
>   * resources available from it but they will be matched normally using functions
>   * provided by their bus types (and analogously for their modalias).
>   */
> -struct acpi_device *acpi_companion_match(const struct device *dev)
> +const struct acpi_device *acpi_companion_match(const struct device *dev)
>  {
>         struct acpi_device *adev;
>
> @@ -706,7 +706,7 @@ struct acpi_device *acpi_companion_match(const struct device *dev)
>   * identifiers and a _DSD object with the "compatible" property, use that
>   * property to match against the given list of identifiers.
>   */
> -static bool acpi_of_match_device(struct acpi_device *adev,
> +static bool acpi_of_match_device(const struct acpi_device *adev,
>                                  const struct of_device_id *of_match_table,
>                                  const struct of_device_id **of_id)
>  {
> @@ -808,7 +808,7 @@ static bool __acpi_match_device_cls(const struct acpi_device_id *id,
>         return true;
>  }
>
> -static bool __acpi_match_device(struct acpi_device *device,
> +static bool __acpi_match_device(const struct acpi_device *device,
>                                 const struct acpi_device_id *acpi_ids,
>                                 const struct of_device_id *of_ids,
>                                 const struct acpi_device_id **acpi_id,
> diff --git a/drivers/acpi/device_sysfs.c b/drivers/acpi/device_sysfs.c
> index 0fbfbaa8d8e3..b9bbf0746199 100644
> --- a/drivers/acpi/device_sysfs.c
> +++ b/drivers/acpi/device_sysfs.c
> @@ -283,7 +283,7 @@ int acpi_device_uevent_modalias(const struct device *dev, struct kobj_uevent_env
>  }
>  EXPORT_SYMBOL_GPL(acpi_device_uevent_modalias);
>
> -static int __acpi_device_modalias(struct acpi_device *adev, char *buf, int size)
> +static int __acpi_device_modalias(const struct acpi_device *adev, char *buf, int size)
>  {
>         int len, count;
>
> diff --git a/drivers/acpi/internal.h b/drivers/acpi/internal.h
> index 50dcb35c9965..f4148dc50b9c 100644
> --- a/drivers/acpi/internal.h
> +++ b/drivers/acpi/internal.h
> @@ -121,7 +121,7 @@ int acpi_bus_register_early_device(int type);
>  /* --------------------------------------------------------------------------
>                       Device Matching and Notification
>     -------------------------------------------------------------------------- */
> -struct acpi_device *acpi_companion_match(const struct device *dev);
> +const struct acpi_device *acpi_companion_match(const struct device *dev);
>  int __acpi_device_uevent_modalias(const struct acpi_device *adev,
>                                   struct kobj_uevent_env *env);
>
> --
> 2.40.0.1.gaa8946217a0b
>
Andy Shevchenko June 29, 2023, 9:08 a.m. UTC | #2
On Thu, Jun 29, 2023 at 10:49:17AM +0200, Rafael J. Wysocki wrote:
> On Mon, Jun 26, 2023 at 1:00 PM Andy Shevchenko
> <andriy.shevchenko@linux.intel.com> wrote:
> >
> > acpi_companion_match() doesn't alter the contents of the passed
> > parameter, so we don't expect that returned value can be altered
> > either. So constify it.
> >
> > Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
> 
> This makes sense even without the rest of the series, so I can queue
> it up right away if you want me to do that.

Please, go ahead and thank you!
Rafael J. Wysocki June 29, 2023, 9:43 a.m. UTC | #3
On Thu, Jun 29, 2023 at 11:08 AM Andy Shevchenko
<andriy.shevchenko@linux.intel.com> wrote:
>
> On Thu, Jun 29, 2023 at 10:49:17AM +0200, Rafael J. Wysocki wrote:
> > On Mon, Jun 26, 2023 at 1:00 PM Andy Shevchenko
> > <andriy.shevchenko@linux.intel.com> wrote:
> > >
> > > acpi_companion_match() doesn't alter the contents of the passed
> > > parameter, so we don't expect that returned value can be altered
> > > either. So constify it.
> > >
> > > Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
> >
> > This makes sense even without the rest of the series, so I can queue
> > it up right away if you want me to do that.
>
> Please, go ahead and thank you!

Done, thanks!
Andi Shyti June 29, 2023, 3:52 p.m. UTC | #4
Hi Andy,

On Mon, Jun 26, 2023 at 02:00:23PM +0300, Andy Shevchenko wrote:
> acpi_companion_match() doesn't alter the contents of the passed
> parameter, so we don't expect that returned value can be altered
> either. So constify it.
> 
> Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>

I guess I'm late for adding my

Reviewed-by: Andi Shyti <andi.shyti@kernel.org> 

here.

Andi
diff mbox series

Patch

diff --git a/drivers/acpi/bus.c b/drivers/acpi/bus.c
index e3e0bd0c5a50..20cdfb37da79 100644
--- a/drivers/acpi/bus.c
+++ b/drivers/acpi/bus.c
@@ -682,7 +682,7 @@  bool acpi_device_is_first_physical_node(struct acpi_device *adev,
  * resources available from it but they will be matched normally using functions
  * provided by their bus types (and analogously for their modalias).
  */
-struct acpi_device *acpi_companion_match(const struct device *dev)
+const struct acpi_device *acpi_companion_match(const struct device *dev)
 {
 	struct acpi_device *adev;
 
@@ -706,7 +706,7 @@  struct acpi_device *acpi_companion_match(const struct device *dev)
  * identifiers and a _DSD object with the "compatible" property, use that
  * property to match against the given list of identifiers.
  */
-static bool acpi_of_match_device(struct acpi_device *adev,
+static bool acpi_of_match_device(const struct acpi_device *adev,
 				 const struct of_device_id *of_match_table,
 				 const struct of_device_id **of_id)
 {
@@ -808,7 +808,7 @@  static bool __acpi_match_device_cls(const struct acpi_device_id *id,
 	return true;
 }
 
-static bool __acpi_match_device(struct acpi_device *device,
+static bool __acpi_match_device(const struct acpi_device *device,
 				const struct acpi_device_id *acpi_ids,
 				const struct of_device_id *of_ids,
 				const struct acpi_device_id **acpi_id,
diff --git a/drivers/acpi/device_sysfs.c b/drivers/acpi/device_sysfs.c
index 0fbfbaa8d8e3..b9bbf0746199 100644
--- a/drivers/acpi/device_sysfs.c
+++ b/drivers/acpi/device_sysfs.c
@@ -283,7 +283,7 @@  int acpi_device_uevent_modalias(const struct device *dev, struct kobj_uevent_env
 }
 EXPORT_SYMBOL_GPL(acpi_device_uevent_modalias);
 
-static int __acpi_device_modalias(struct acpi_device *adev, char *buf, int size)
+static int __acpi_device_modalias(const struct acpi_device *adev, char *buf, int size)
 {
 	int len, count;
 
diff --git a/drivers/acpi/internal.h b/drivers/acpi/internal.h
index 50dcb35c9965..f4148dc50b9c 100644
--- a/drivers/acpi/internal.h
+++ b/drivers/acpi/internal.h
@@ -121,7 +121,7 @@  int acpi_bus_register_early_device(int type);
 /* --------------------------------------------------------------------------
                      Device Matching and Notification
    -------------------------------------------------------------------------- */
-struct acpi_device *acpi_companion_match(const struct device *dev);
+const struct acpi_device *acpi_companion_match(const struct device *dev);
 int __acpi_device_uevent_modalias(const struct acpi_device *adev,
 				  struct kobj_uevent_env *env);