linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v1 1/1] drivers/perf: thunderx2_pmu: Replace open coded acpi_match_device()
@ 2022-06-30 19:51 Andy Shevchenko
  2022-07-01 11:31 ` Will Deacon
  0 siblings, 1 reply; 3+ messages in thread
From: Andy Shevchenko @ 2022-06-30 19:51 UTC (permalink / raw)
  To: Will Deacon, Andy Shevchenko, linux-arm-kernel, linux-kernel; +Cc: Mark Rutland

Replace open coded acpi_match_device() in get_tx2_pmu_type().

Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
---
 drivers/perf/thunderx2_pmu.c | 19 +++++++------------
 1 file changed, 7 insertions(+), 12 deletions(-)

diff --git a/drivers/perf/thunderx2_pmu.c b/drivers/perf/thunderx2_pmu.c
index 1edb9c03704f..b5a70cc42495 100644
--- a/drivers/perf/thunderx2_pmu.c
+++ b/drivers/perf/thunderx2_pmu.c
@@ -504,24 +504,19 @@ static void tx2_uncore_event_update(struct perf_event *event)
 
 static enum tx2_uncore_type get_tx2_pmu_type(struct acpi_device *adev)
 {
-	int i = 0;
-	struct acpi_tx2_pmu_device {
-		__u8 id[ACPI_ID_LEN];
-		enum tx2_uncore_type type;
-	} devices[] = {
+	struct acpi_device_id devices[] = {
 		{"CAV901D", PMU_TYPE_L3C},
 		{"CAV901F", PMU_TYPE_DMC},
 		{"CAV901E", PMU_TYPE_CCPI2},
-		{"", PMU_TYPE_INVALID}
+		{}
 	};
+	const struct acpi_device_id *id;
 
-	while (devices[i].type != PMU_TYPE_INVALID) {
-		if (!strcmp(acpi_device_hid(adev), devices[i].id))
-			break;
-		i++;
-	}
+	id = acpi_match_device(adev, devices);
+	if (!id)
+		return PMU_TYPE_INVALID;
 
-	return devices[i].type;
+	return (enum tx2_uncore_type)id->driver_data;
 }
 
 static bool tx2_uncore_validate_event(struct pmu *pmu,
-- 
2.35.1


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH v1 1/1] drivers/perf: thunderx2_pmu: Replace open coded acpi_match_device()
  2022-06-30 19:51 [PATCH v1 1/1] drivers/perf: thunderx2_pmu: Replace open coded acpi_match_device() Andy Shevchenko
@ 2022-07-01 11:31 ` Will Deacon
  2022-07-01 11:38   ` Andy Shevchenko
  0 siblings, 1 reply; 3+ messages in thread
From: Will Deacon @ 2022-07-01 11:31 UTC (permalink / raw)
  To: Andy Shevchenko; +Cc: linux-arm-kernel, linux-kernel, Mark Rutland

On Thu, Jun 30, 2022 at 10:51:03PM +0300, Andy Shevchenko wrote:
> Replace open coded acpi_match_device() in get_tx2_pmu_type().
> 
> Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
> ---
>  drivers/perf/thunderx2_pmu.c | 19 +++++++------------
>  1 file changed, 7 insertions(+), 12 deletions(-)
> 
> diff --git a/drivers/perf/thunderx2_pmu.c b/drivers/perf/thunderx2_pmu.c
> index 1edb9c03704f..b5a70cc42495 100644
> --- a/drivers/perf/thunderx2_pmu.c
> +++ b/drivers/perf/thunderx2_pmu.c
> @@ -504,24 +504,19 @@ static void tx2_uncore_event_update(struct perf_event *event)
>  
>  static enum tx2_uncore_type get_tx2_pmu_type(struct acpi_device *adev)
>  {
> -	int i = 0;
> -	struct acpi_tx2_pmu_device {
> -		__u8 id[ACPI_ID_LEN];
> -		enum tx2_uncore_type type;
> -	} devices[] = {
> +	struct acpi_device_id devices[] = {
>  		{"CAV901D", PMU_TYPE_L3C},
>  		{"CAV901F", PMU_TYPE_DMC},
>  		{"CAV901E", PMU_TYPE_CCPI2},
> -		{"", PMU_TYPE_INVALID}
> +		{}
>  	};
> +	const struct acpi_device_id *id;
>  
> -	while (devices[i].type != PMU_TYPE_INVALID) {
> -		if (!strcmp(acpi_device_hid(adev), devices[i].id))
> -			break;
> -		i++;
> -	}
> +	id = acpi_match_device(adev, devices);
> +	if (!id)
> +		return PMU_TYPE_INVALID;
>  
> -	return devices[i].type;
> +	return (enum tx2_uncore_type)id->driver_data;

This doesn't even build for me:

 | drivers/perf/thunderx2_pmu.c:515:25: error: incompatible pointer types passing 'struct acpi_device *' to parameter of type 'const struct acpi_device_id *' [-Werror,-Wincompatible-pointer-types]
 |         id = acpi_match_device(adev, devices);
 |                                ^~~~
 | ./include/linux/acpi.h:713:77: note: passing argument to parameter 'ids' here
 | const struct acpi_device_id *acpi_match_device(const struct acpi_device_id *ids,
 |                                                                             ^
 | drivers/perf/thunderx2_pmu.c:515:31: error: incompatible pointer types passing 'struct acpi_device_id [4]' to parameter of type 'const struct device *' [-Werror,-Wincompatible-pointer-types]
 |         id = acpi_match_device(adev, devices);
 |                                      ^~~~~~~
 | ./include/linux/acpi.h:714:34: note: passing argument to parameter 'dev' here
 |                                                const struct device *dev);
 |                                                                     ^
 | 2 errors generated.
 | make[2]: *** [scripts/Makefile.build:249: drivers/perf/thunderx2_pmu.o] Error 1
 | make[2]: *** Waiting for unfinished jobs....
 | make[1]: *** [scripts/Makefile.build:466: drivers/perf] Error 2
 | make[1]: *** Waiting for unfinished jobs....
 | make: *** [Makefile:1843: drivers] Error 2
 |

Have you tested this at all?

Will

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH v1 1/1] drivers/perf: thunderx2_pmu: Replace open coded acpi_match_device()
  2022-07-01 11:31 ` Will Deacon
@ 2022-07-01 11:38   ` Andy Shevchenko
  0 siblings, 0 replies; 3+ messages in thread
From: Andy Shevchenko @ 2022-07-01 11:38 UTC (permalink / raw)
  To: Will Deacon
  Cc: Andy Shevchenko, linux-arm Mailing List,
	Linux Kernel Mailing List, Mark Rutland

On Fri, Jul 1, 2022 at 1:33 PM Will Deacon <will@kernel.org> wrote:
> On Thu, Jun 30, 2022 at 10:51:03PM +0300, Andy Shevchenko wrote:
> > Replace open coded acpi_match_device() in get_tx2_pmu_type().

> This doesn't even build for me:

Neither to me :-(

> Have you tested this at all?

It was a last minute change from __acpi_match_device() to
acpi_match_device() where arguments were swapped and obviously this
wasn't properly tested, sorry.

-- 
With Best Regards,
Andy Shevchenko

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2022-07-01 11:38 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-06-30 19:51 [PATCH v1 1/1] drivers/perf: thunderx2_pmu: Replace open coded acpi_match_device() Andy Shevchenko
2022-07-01 11:31 ` Will Deacon
2022-07-01 11:38   ` Andy Shevchenko

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).