Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1692989 > unrolled thread

[PATCH 2/4] ACPI: Make acpi_dev_get_resources() method agnostic

Started byLorenzo Pieralisi <lorenzo.pieralisi@arm.com>
First post2017-07-20 16:50 +0200
Last post2017-07-26 02:40 +0200
Articles 5 — 2 participants

Back to article view | Back to linux.kernel

This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by below is the oldest one visible, not the original post.


Contents

  [PATCH 2/4] ACPI: Make acpi_dev_get_resources() method agnostic Lorenzo Pieralisi <lorenzo.pieralisi@arm.com> - 2017-07-20 16:50 +0200
    Re: [PATCH 2/4] ACPI: Make acpi_dev_get_resources() method agnostic "Rafael J. Wysocki" <rjw@rjwysocki.net> - 2017-07-22 00:20 +0200
      Re: [PATCH 2/4] ACPI: Make acpi_dev_get_resources() method agnostic Lorenzo Pieralisi <lorenzo.pieralisi@arm.com> - 2017-07-24 11:30 +0200
      Re: [PATCH 2/4] ACPI: Make acpi_dev_get_resources() method agnostic Lorenzo Pieralisi <lorenzo.pieralisi@arm.com> - 2017-07-25 11:20 +0200
        Re: [PATCH 2/4] ACPI: Make acpi_dev_get_resources() method agnostic "Rafael J. Wysocki" <rjw@rjwysocki.net> - 2017-07-26 02:40 +0200

#1692989 — [PATCH 2/4] ACPI: Make acpi_dev_get_resources() method agnostic

FromLorenzo Pieralisi <lorenzo.pieralisi@arm.com>
Date2017-07-20 16:50 +0200
Subject[PATCH 2/4] ACPI: Make acpi_dev_get_resources() method agnostic
Message-ID<u5kW6-lk-3@gated-at.bofh.it>
The function acpi_dev_get_resources() is completely generic and
can be used to parse resource objects that are not necessarily
coming from the _CRS method but also from other objects eg _DMA
that have the same _CRS resource format.

Create an acpi_dev_get_resources() helper, internal to the ACPI
resources parsing compilation unit, acpi_dev_get_resources_method(),
that takes a char* parameter to detect which ACPI method should be
called to retrieve the resources list and make acpi_dev_get_resources()
call it with a method name _CRS leaving the API behaviour unchanged.

Signed-off-by: Lorenzo Pieralisi <lorenzo.pieralisi@arm.com>
Cc: "Rafael J. Wysocki" <rjw@rjwysocki.net>
---
 drivers/acpi/resource.c | 54 +++++++++++++++++++++++++++++--------------------
 1 file changed, 32 insertions(+), 22 deletions(-)

diff --git a/drivers/acpi/resource.c b/drivers/acpi/resource.c
index cd4c427..2b20a09 100644
--- a/drivers/acpi/resource.c
+++ b/drivers/acpi/resource.c
@@ -573,6 +573,36 @@ static acpi_status acpi_dev_process_resource(struct acpi_resource *ares,
 	return AE_OK;
 }
 
+static
+int acpi_dev_get_resources_method(struct acpi_device *adev,
+				  struct list_head *list,
+				  int (*preproc)(struct acpi_resource *, void *),
+				  void *preproc_data, char *method)
+{
+	struct res_proc_context c;
+	acpi_status status;
+
+	if (!adev || !adev->handle || !list_empty(list))
+		return -EINVAL;
+
+	if (!acpi_has_method(adev->handle, method))
+		return 0;
+
+	c.list = list;
+	c.preproc = preproc;
+	c.preproc_data = preproc_data;
+	c.count = 0;
+	c.error = 0;
+	status = acpi_walk_resources(adev->handle, method,
+				     acpi_dev_process_resource, &c);
+	if (ACPI_FAILURE(status)) {
+		acpi_dev_free_resource_list(list);
+		return c.error ? c.error : -EIO;
+	}
+
+	return c.count;
+}
+
 /**
  * acpi_dev_get_resources - Get current resources of a device.
  * @adev: ACPI device node to get the resources for.
@@ -601,28 +631,8 @@ int acpi_dev_get_resources(struct acpi_device *adev, struct list_head *list,
 			   int (*preproc)(struct acpi_resource *, void *),
 			   void *preproc_data)
 {
-	struct res_proc_context c;
-	acpi_status status;
-
-	if (!adev || !adev->handle || !list_empty(list))
-		return -EINVAL;
-
-	if (!acpi_has_method(adev->handle, METHOD_NAME__CRS))
-		return 0;
-
-	c.list = list;
-	c.preproc = preproc;
-	c.preproc_data = preproc_data;
-	c.count = 0;
-	c.error = 0;
-	status = acpi_walk_resources(adev->handle, METHOD_NAME__CRS,
-				     acpi_dev_process_resource, &c);
-	if (ACPI_FAILURE(status)) {
-		acpi_dev_free_resource_list(list);
-		return c.error ? c.error : -EIO;
-	}
-
-	return c.count;
+	return acpi_dev_get_resources_method(adev, list, preproc,
+					     preproc_data, METHOD_NAME__CRS);
 }
 EXPORT_SYMBOL_GPL(acpi_dev_get_resources);
 
-- 
2.10.0

[toc] | [next] | [standalone]


#1694020

From"Rafael J. Wysocki" <rjw@rjwysocki.net>
Date2017-07-22 00:20 +0200
Message-ID<u5Or7-240-7@gated-at.bofh.it>
In reply to#1692989
On Thursday, July 20, 2017 03:45:14 PM Lorenzo Pieralisi wrote:
> The function acpi_dev_get_resources() is completely generic and
> can be used to parse resource objects that are not necessarily
> coming from the _CRS method but also from other objects eg _DMA
> that have the same _CRS resource format.
> 
> Create an acpi_dev_get_resources() helper, internal to the ACPI
> resources parsing compilation unit, acpi_dev_get_resources_method(),
> that takes a char* parameter to detect which ACPI method should be
> called to retrieve the resources list and make acpi_dev_get_resources()
> call it with a method name _CRS leaving the API behaviour unchanged.
> 
> Signed-off-by: Lorenzo Pieralisi <lorenzo.pieralisi@arm.com>
> Cc: "Rafael J. Wysocki" <rjw@rjwysocki.net>
> ---
>  drivers/acpi/resource.c | 54 +++++++++++++++++++++++++++++--------------------
>  1 file changed, 32 insertions(+), 22 deletions(-)
> 
> diff --git a/drivers/acpi/resource.c b/drivers/acpi/resource.c
> index cd4c427..2b20a09 100644
> --- a/drivers/acpi/resource.c
> +++ b/drivers/acpi/resource.c
> @@ -573,6 +573,36 @@ static acpi_status acpi_dev_process_resource(struct acpi_resource *ares,
>  	return AE_OK;
>  }
>  
> +static
> +int acpi_dev_get_resources_method(struct acpi_device *adev,

Do not break lines like this, please.

It should be

static int acpi_dev_get...

Also I would call it differently, maybe simply __acpi_dev_get_resources()?

> +				  struct list_head *list,
> +				  int (*preproc)(struct acpi_resource *, void *),
> +				  void *preproc_data, char *method)

const char *method ?

Thanks,
Rafael

[toc] | [prev] | [next] | [standalone]


#1694573

FromLorenzo Pieralisi <lorenzo.pieralisi@arm.com>
Date2017-07-24 11:30 +0200
Message-ID<u6HQC-2Si-13@gated-at.bofh.it>
In reply to#1694020
On Sat, Jul 22, 2017 at 12:05:39AM +0200, Rafael J. Wysocki wrote:
> On Thursday, July 20, 2017 03:45:14 PM Lorenzo Pieralisi wrote:
> > The function acpi_dev_get_resources() is completely generic and
> > can be used to parse resource objects that are not necessarily
> > coming from the _CRS method but also from other objects eg _DMA
> > that have the same _CRS resource format.
> > 
> > Create an acpi_dev_get_resources() helper, internal to the ACPI
> > resources parsing compilation unit, acpi_dev_get_resources_method(),
> > that takes a char* parameter to detect which ACPI method should be
> > called to retrieve the resources list and make acpi_dev_get_resources()
> > call it with a method name _CRS leaving the API behaviour unchanged.
> > 
> > Signed-off-by: Lorenzo Pieralisi <lorenzo.pieralisi@arm.com>
> > Cc: "Rafael J. Wysocki" <rjw@rjwysocki.net>
> > ---
> >  drivers/acpi/resource.c | 54 +++++++++++++++++++++++++++++--------------------
> >  1 file changed, 32 insertions(+), 22 deletions(-)
> > 
> > diff --git a/drivers/acpi/resource.c b/drivers/acpi/resource.c
> > index cd4c427..2b20a09 100644
> > --- a/drivers/acpi/resource.c
> > +++ b/drivers/acpi/resource.c
> > @@ -573,6 +573,36 @@ static acpi_status acpi_dev_process_resource(struct acpi_resource *ares,
> >  	return AE_OK;
> >  }
> >  
> > +static
> > +int acpi_dev_get_resources_method(struct acpi_device *adev,
> 
> Do not break lines like this, please.
> 
> It should be
> 
> static int acpi_dev_get...
> 
> Also I would call it differently, maybe simply __acpi_dev_get_resources()?

Ok, it was how I wanted to call it but was not sure you would be happy
with it, I will rename it.

> > +				  struct list_head *list,
> > +				  int (*preproc)(struct acpi_resource *, void *),
> > +				  void *preproc_data, char *method)
> 
> const char *method ?

Yes, will update.

Thanks !
Lorenzo

[toc] | [prev] | [next] | [standalone]


#1695523

FromLorenzo Pieralisi <lorenzo.pieralisi@arm.com>
Date2017-07-25 11:20 +0200
Message-ID<u74au-VK-7@gated-at.bofh.it>
In reply to#1694020
On Sat, Jul 22, 2017 at 12:05:39AM +0200, Rafael J. Wysocki wrote:
> On Thursday, July 20, 2017 03:45:14 PM Lorenzo Pieralisi wrote:
> > The function acpi_dev_get_resources() is completely generic and
> > can be used to parse resource objects that are not necessarily
> > coming from the _CRS method but also from other objects eg _DMA
> > that have the same _CRS resource format.
> > 
> > Create an acpi_dev_get_resources() helper, internal to the ACPI
> > resources parsing compilation unit, acpi_dev_get_resources_method(),
> > that takes a char* parameter to detect which ACPI method should be
> > called to retrieve the resources list and make acpi_dev_get_resources()
> > call it with a method name _CRS leaving the API behaviour unchanged.
> > 
> > Signed-off-by: Lorenzo Pieralisi <lorenzo.pieralisi@arm.com>
> > Cc: "Rafael J. Wysocki" <rjw@rjwysocki.net>
> > ---
> >  drivers/acpi/resource.c | 54 +++++++++++++++++++++++++++++--------------------
> >  1 file changed, 32 insertions(+), 22 deletions(-)
> > 
> > diff --git a/drivers/acpi/resource.c b/drivers/acpi/resource.c
> > index cd4c427..2b20a09 100644
> > --- a/drivers/acpi/resource.c
> > +++ b/drivers/acpi/resource.c
> > @@ -573,6 +573,36 @@ static acpi_status acpi_dev_process_resource(struct acpi_resource *ares,
> >  	return AE_OK;
> >  }
> >  
> > +static
> > +int acpi_dev_get_resources_method(struct acpi_device *adev,
> 
> Do not break lines like this, please.
> 
> It should be
> 
> static int acpi_dev_get...
> 
> Also I would call it differently, maybe simply __acpi_dev_get_resources()?
> 
> > +				  struct list_head *list,
> > +				  int (*preproc)(struct acpi_resource *, void *),
> > +				  void *preproc_data, char *method)
> 
> const char *method ?

drivers/acpi/resource.c: In function '__acpi_dev_get_resources':
drivers/acpi/resource.c:587:37: warning: passing argument 2 of
'acpi_has_method' discards 'const' qualifier from pointer target type
[-Wdiscarded-qualifiers]
  if (!acpi_has_method(adev->handle, method))
                                       ^~~~~~
In file included from ./include/linux/acpi.h:44:0,
                 from drivers/acpi/resource.c:21:
		 ./include/acpi/acpi_bus.h:55:6: note: expected 'char *'
		 but argument is of type 'const char *'
		  bool acpi_has_method(acpi_handle handle, char *name);

Same problem with acpi_walk_resources().

So either I fiddle (eg cast the const away) with the method string 
in __acpi_dev_get_resources() or I can add an int/bool to detect
which method to use ( _CRS or _DMA) instead of passing a const char *.

Thanks,
Lorenzo

[toc] | [prev] | [next] | [standalone]


#1696694

From"Rafael J. Wysocki" <rjw@rjwysocki.net>
Date2017-07-26 02:40 +0200
Message-ID<u7iwO-1zY-27@gated-at.bofh.it>
In reply to#1695523
On Tuesday, July 25, 2017 10:15:38 AM Lorenzo Pieralisi wrote:
> On Sat, Jul 22, 2017 at 12:05:39AM +0200, Rafael J. Wysocki wrote:
> > On Thursday, July 20, 2017 03:45:14 PM Lorenzo Pieralisi wrote:
> > > The function acpi_dev_get_resources() is completely generic and
> > > can be used to parse resource objects that are not necessarily
> > > coming from the _CRS method but also from other objects eg _DMA
> > > that have the same _CRS resource format.
> > > 
> > > Create an acpi_dev_get_resources() helper, internal to the ACPI
> > > resources parsing compilation unit, acpi_dev_get_resources_method(),
> > > that takes a char* parameter to detect which ACPI method should be
> > > called to retrieve the resources list and make acpi_dev_get_resources()
> > > call it with a method name _CRS leaving the API behaviour unchanged.
> > > 
> > > Signed-off-by: Lorenzo Pieralisi <lorenzo.pieralisi@arm.com>
> > > Cc: "Rafael J. Wysocki" <rjw@rjwysocki.net>
> > > ---
> > >  drivers/acpi/resource.c | 54 +++++++++++++++++++++++++++++--------------------
> > >  1 file changed, 32 insertions(+), 22 deletions(-)
> > > 
> > > diff --git a/drivers/acpi/resource.c b/drivers/acpi/resource.c
> > > index cd4c427..2b20a09 100644
> > > --- a/drivers/acpi/resource.c
> > > +++ b/drivers/acpi/resource.c
> > > @@ -573,6 +573,36 @@ static acpi_status acpi_dev_process_resource(struct acpi_resource *ares,
> > >  	return AE_OK;
> > >  }
> > >  
> > > +static
> > > +int acpi_dev_get_resources_method(struct acpi_device *adev,
> > 
> > Do not break lines like this, please.
> > 
> > It should be
> > 
> > static int acpi_dev_get...
> > 
> > Also I would call it differently, maybe simply __acpi_dev_get_resources()?
> > 
> > > +				  struct list_head *list,
> > > +				  int (*preproc)(struct acpi_resource *, void *),
> > > +				  void *preproc_data, char *method)
> > 
> > const char *method ?
> 
> drivers/acpi/resource.c: In function '__acpi_dev_get_resources':
> drivers/acpi/resource.c:587:37: warning: passing argument 2 of
> 'acpi_has_method' discards 'const' qualifier from pointer target type
> [-Wdiscarded-qualifiers]
>   if (!acpi_has_method(adev->handle, method))
>                                        ^~~~~~
> In file included from ./include/linux/acpi.h:44:0,
>                  from drivers/acpi/resource.c:21:
> 		 ./include/acpi/acpi_bus.h:55:6: note: expected 'char *'
> 		 but argument is of type 'const char *'
> 		  bool acpi_has_method(acpi_handle handle, char *name);
> 
> Same problem with acpi_walk_resources().
> 
> So either I fiddle (eg cast the const away) with the method string 
> in __acpi_dev_get_resources() or I can add an int/bool to detect
> which method to use ( _CRS or _DMA) instead of passing a const char *.

No, that'd be overkill.  Let's keep the (char *) in there.

Thanks,
Rafael

[toc] | [prev] | [standalone]


Back to top | Article view | linux.kernel


csiph-web