There are at least few existing users of the proposed API which
retrieves either MEM or IO resource from platform device.
Make it common to utilize in the existing and new users.
Signed-off-by: Andy Shevchenko <[email protected]>
Cc: Eric Auger <[email protected]>
Cc: Alex Williamson <[email protected]>
Cc: Cornelia Huck <[email protected]>
Cc: [email protected]
Cc: [email protected]
Cc: Peng Hao <[email protected]>
Cc: Arnd Bergmann <[email protected]>
---
include/linux/platform_device.h | 13 +++++++++++++
1 file changed, 13 insertions(+)
diff --git a/include/linux/platform_device.h b/include/linux/platform_device.h
index 77a2aada106d..eb8d74744e29 100644
--- a/include/linux/platform_device.h
+++ b/include/linux/platform_device.h
@@ -52,6 +52,19 @@ extern struct device platform_bus;
extern struct resource *platform_get_resource(struct platform_device *,
unsigned int, unsigned int);
+static inline
+struct resource *platform_get_mem_or_io_resource(struct platform_device *pdev,
+ unsigned int num)
+{
+ struct resource *res;
+
+ res = platform_get_resource(pdev, IORESOURCE_MEM, num);
+ if (res)
+ return res;
+
+ return platform_get_resource(pdev, IORESOURCE_IO, num);
+}
+
extern struct device *
platform_find_device_by_driver(struct device *start,
const struct device_driver *drv);
--
2.28.0
Switch to use new platform_get_mem_or_io_resource() instead of
home grown analogue.
Cc: Eric Auger <[email protected]>
Cc: Alex Williamson <[email protected]>
Cc: Cornelia Huck <[email protected]>
Cc: [email protected]
Signed-off-by: Andy Shevchenko <[email protected]>
---
drivers/vfio/platform/vfio_platform.c | 13 +------------
1 file changed, 1 insertion(+), 12 deletions(-)
diff --git a/drivers/vfio/platform/vfio_platform.c b/drivers/vfio/platform/vfio_platform.c
index 1e2769010089..84afafb6941b 100644
--- a/drivers/vfio/platform/vfio_platform.c
+++ b/drivers/vfio/platform/vfio_platform.c
@@ -25,19 +25,8 @@ static struct resource *get_platform_resource(struct vfio_platform_device *vdev,
int num)
{
struct platform_device *dev = (struct platform_device *) vdev->opaque;
- int i;
- for (i = 0; i < dev->num_resources; i++) {
- struct resource *r = &dev->resource[i];
-
- if (resource_type(r) & (IORESOURCE_MEM|IORESOURCE_IO)) {
- if (!num)
- return r;
-
- num--;
- }
- }
- return NULL;
+ return platform_get_mem_or_io_resource(dev, num);
}
static int get_platform_irq(struct vfio_platform_device *vdev, int i)
--
2.28.0
Switch to use new platform_get_mem_or_io_resource() instead of
home grown analogue.
Note, the code has been moved upper in the function to allow farther cleanups,
such as resource sanity check.
Cc: [email protected]
Signed-off-by: Andy Shevchenko <[email protected]>
---
drivers/usb/host/sl811-hcd.c | 20 +++++++++-----------
1 file changed, 9 insertions(+), 11 deletions(-)
diff --git a/drivers/usb/host/sl811-hcd.c b/drivers/usb/host/sl811-hcd.c
index adaf4063690a..7e0d6f686231 100644
--- a/drivers/usb/host/sl811-hcd.c
+++ b/drivers/usb/host/sl811-hcd.c
@@ -1614,12 +1614,18 @@ sl811h_probe(struct platform_device *dev)
void __iomem *addr_reg;
void __iomem *data_reg;
int retval;
- u8 tmp, ioaddr = 0;
+ u8 tmp, ioaddr;
unsigned long irqflags;
if (usb_disabled())
return -ENODEV;
+ /* the chip may be wired for either kind of addressing */
+ addr = platform_get_mem_or_io_resource(dev, 0);
+ data = platform_get_mem_or_io_resource(dev, 1);
+ if (!addr || !data || resource_type(addr) != resource_type(data))
+ return -ENODEV;
+
/* basic sanity checks first. board-specific init logic should
* have initialized these three resources and probably board
* specific platform_data. we don't probe for IRQs, and do only
@@ -1632,16 +1638,8 @@ sl811h_probe(struct platform_device *dev)
irq = ires->start;
irqflags = ires->flags & IRQF_TRIGGER_MASK;
- /* the chip may be wired for either kind of addressing */
- addr = platform_get_resource(dev, IORESOURCE_MEM, 0);
- data = platform_get_resource(dev, IORESOURCE_MEM, 1);
- retval = -EBUSY;
- if (!addr || !data) {
- addr = platform_get_resource(dev, IORESOURCE_IO, 0);
- data = platform_get_resource(dev, IORESOURCE_IO, 1);
- if (!addr || !data)
- return -ENODEV;
- ioaddr = 1;
+ ioaddr = resource_type(addr) == IORESOURCE_IO;
+ if (ioaddr) {
/*
* NOTE: 64-bit resource->start is getting truncated
* to avoid compiler warning, assuming that ->start
--
2.28.0
There is no use for OF headers in the driver, but mod_devicetable.h
must be included. Update driver accordingly.
Cc: Peng Hao <[email protected]>
Cc: Arnd Bergmann <[email protected]>
Signed-off-by: Andy Shevchenko <[email protected]>
---
drivers/misc/pvpanic.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/drivers/misc/pvpanic.c b/drivers/misc/pvpanic.c
index 103a09ed651d..a45e70c5b6b9 100644
--- a/drivers/misc/pvpanic.c
+++ b/drivers/misc/pvpanic.c
@@ -11,11 +11,11 @@
#include <linux/io.h>
#include <linux/kernel.h>
#include <linux/kexec.h>
+#include <linux/mod_devicetable.h>
#include <linux/module.h>
-#include <linux/of.h>
-#include <linux/of_address.h>
#include <linux/platform_device.h>
#include <linux/types.h>
+
#include <uapi/misc/pvpanic.h>
static void __iomem *base;
--
2.28.0
Hi Andy,
On 10/27/20 6:58 PM, Andy Shevchenko wrote:
> Switch to use new platform_get_mem_or_io_resource() instead of
> home grown analogue.
>
> Cc: Eric Auger <[email protected]>
> Cc: Alex Williamson <[email protected]>
> Cc: Cornelia Huck <[email protected]>
> Cc: [email protected]
> Signed-off-by: Andy Shevchenko <[email protected]>
Acked-by: Eric Auger <[email protected]>
Thanks
Eric
> ---
> drivers/vfio/platform/vfio_platform.c | 13 +------------
> 1 file changed, 1 insertion(+), 12 deletions(-)
>
> diff --git a/drivers/vfio/platform/vfio_platform.c b/drivers/vfio/platform/vfio_platform.c
> index 1e2769010089..84afafb6941b 100644
> --- a/drivers/vfio/platform/vfio_platform.c
> +++ b/drivers/vfio/platform/vfio_platform.c
> @@ -25,19 +25,8 @@ static struct resource *get_platform_resource(struct vfio_platform_device *vdev,
> int num)
> {
> struct platform_device *dev = (struct platform_device *) vdev->opaque;
> - int i;
>
> - for (i = 0; i < dev->num_resources; i++) {
> - struct resource *r = &dev->resource[i];
> -
> - if (resource_type(r) & (IORESOURCE_MEM|IORESOURCE_IO)) {
> - if (!num)
> - return r;
> -
> - num--;
> - }
> - }
> - return NULL;
> + return platform_get_mem_or_io_resource(dev, num);
> }
>
> static int get_platform_irq(struct vfio_platform_device *vdev, int i)
>
On Thu, Dec 03, 2020 at 01:54:38PM +0100, Auger Eric wrote:
> Hi Andy,
>
> On 10/27/20 6:58 PM, Andy Shevchenko wrote:
> > Switch to use new platform_get_mem_or_io_resource() instead of
> > home grown analogue.
> >
> > Cc: Eric Auger <[email protected]>
> > Cc: Alex Williamson <[email protected]>
> > Cc: Cornelia Huck <[email protected]>
> > Cc: [email protected]
> > Signed-off-by: Andy Shevchenko <[email protected]>
> Acked-by: Eric Auger <[email protected]>
Thanks!
Greg, do I need to do anything else with this series?
--
With Best Regards,
Andy Shevchenko
On Tue, 27 Oct 2020 19:58:02 +0200
Andy Shevchenko <[email protected]> wrote:
> There are at least few existing users of the proposed API which
> retrieves either MEM or IO resource from platform device.
>
> Make it common to utilize in the existing and new users.
>
> Signed-off-by: Andy Shevchenko <[email protected]>
> Cc: Eric Auger <[email protected]>
> Cc: Alex Williamson <[email protected]>
> Cc: Cornelia Huck <[email protected]>
> Cc: [email protected]
> Cc: [email protected]
> Cc: Peng Hao <[email protected]>
> Cc: Arnd Bergmann <[email protected]>
> ---
> include/linux/platform_device.h | 13 +++++++++++++
> 1 file changed, 13 insertions(+)
>
> diff --git a/include/linux/platform_device.h b/include/linux/platform_device.h
> index 77a2aada106d..eb8d74744e29 100644
> --- a/include/linux/platform_device.h
> +++ b/include/linux/platform_device.h
> @@ -52,6 +52,19 @@ extern struct device platform_bus;
>
> extern struct resource *platform_get_resource(struct platform_device *,
> unsigned int, unsigned int);
> +static inline
> +struct resource *platform_get_mem_or_io_resource(struct platform_device *pdev,
Minor nit: If I would want to break up the long line, I'd use
static inline struct resource *
platform_get_mem_or_io_resource(...)
> + unsigned int num)
> +{
> + struct resource *res;
> +
> + res = platform_get_resource(pdev, IORESOURCE_MEM, num);
> + if (res)
> + return res;
> +
> + return platform_get_resource(pdev, IORESOURCE_IO, num);
> +}
> +
> extern struct device *
> platform_find_device_by_driver(struct device *start,
> const struct device_driver *drv);
Reviewed-by: Cornelia Huck <[email protected]>
On Tue, 27 Oct 2020 19:58:03 +0200
Andy Shevchenko <[email protected]> wrote:
> Switch to use new platform_get_mem_or_io_resource() instead of
> home grown analogue.
>
> Cc: Eric Auger <[email protected]>
> Cc: Alex Williamson <[email protected]>
> Cc: Cornelia Huck <[email protected]>
> Cc: [email protected]
> Signed-off-by: Andy Shevchenko <[email protected]>
> ---
> drivers/vfio/platform/vfio_platform.c | 13 +------------
> 1 file changed, 1 insertion(+), 12 deletions(-)
Reviewed-by: Cornelia Huck <[email protected]>
On Tue, 27 Oct 2020 19:58:03 +0200
Andy Shevchenko <[email protected]> wrote:
> Switch to use new platform_get_mem_or_io_resource() instead of
> home grown analogue.
>
> Cc: Eric Auger <[email protected]>
> Cc: Alex Williamson <[email protected]>
> Cc: Cornelia Huck <[email protected]>
> Cc: [email protected]
> Signed-off-by: Andy Shevchenko <[email protected]>
> ---
> drivers/vfio/platform/vfio_platform.c | 13 +------------
> 1 file changed, 1 insertion(+), 12 deletions(-)
Acked-by: Alex Williamson <[email protected]>
On Wed, Dec 09, 2020 at 03:47:06PM +0100, Greg Kroah-Hartman wrote:
> On Thu, Dec 03, 2020 at 03:07:19PM +0200, Andy Shevchenko wrote:
> > On Thu, Dec 03, 2020 at 01:54:38PM +0100, Auger Eric wrote:
> > > On 10/27/20 6:58 PM, Andy Shevchenko wrote:
> > > > Switch to use new platform_get_mem_or_io_resource() instead of
> > > > home grown analogue.
> > > >
> > > > Cc: Eric Auger <[email protected]>
> > > > Cc: Alex Williamson <[email protected]>
> > > > Cc: Cornelia Huck <[email protected]>
> > > > Cc: [email protected]
> > > > Signed-off-by: Andy Shevchenko <[email protected]>
> > > Acked-by: Eric Auger <[email protected]>
> >
> > Thanks!
> >
> > Greg, do I need to do anything else with this series?
>
> Have them taken by the vfio maintainers? I'm not that person :)
But it can't be done with a first patch that provides a new API.
The rest seems under your realm, if I didn't miss anything.
Btw, VFIO agreed on the change (as per given tags).
--
With Best Regards,
Andy Shevchenko
On Wed, Dec 09, 2020 at 06:48:16PM +0200, Andy Shevchenko wrote:
> On Wed, Dec 09, 2020 at 03:47:06PM +0100, Greg Kroah-Hartman wrote:
> > On Thu, Dec 03, 2020 at 03:07:19PM +0200, Andy Shevchenko wrote:
> > > On Thu, Dec 03, 2020 at 01:54:38PM +0100, Auger Eric wrote:
> > > > On 10/27/20 6:58 PM, Andy Shevchenko wrote:
> > > > > Switch to use new platform_get_mem_or_io_resource() instead of
> > > > > home grown analogue.
> > > > >
> > > > > Cc: Eric Auger <[email protected]>
> > > > > Cc: Alex Williamson <[email protected]>
> > > > > Cc: Cornelia Huck <[email protected]>
> > > > > Cc: [email protected]
> > > > > Signed-off-by: Andy Shevchenko <[email protected]>
> > > > Acked-by: Eric Auger <[email protected]>
> > >
> > > Thanks!
> > >
> > > Greg, do I need to do anything else with this series?
> >
> > Have them taken by the vfio maintainers? I'm not that person :)
>
> But it can't be done with a first patch that provides a new API.
> The rest seems under your realm, if I didn't miss anything.
> Btw, VFIO agreed on the change (as per given tags).
Ok, can you resend all of these, with the vfio tags added, so I know to
take them all?
thanks,
greg k-h
On Wed, Dec 09, 2020 at 05:53:45PM +0100, Greg Kroah-Hartman wrote:
> On Wed, Dec 09, 2020 at 06:48:16PM +0200, Andy Shevchenko wrote:
> > On Wed, Dec 09, 2020 at 03:47:06PM +0100, Greg Kroah-Hartman wrote:
> > > On Thu, Dec 03, 2020 at 03:07:19PM +0200, Andy Shevchenko wrote:
> > > > On Thu, Dec 03, 2020 at 01:54:38PM +0100, Auger Eric wrote:
...
> > > > Greg, do I need to do anything else with this series?
> > > Have them taken by the vfio maintainers? I'm not that person :)
> > But it can't be done with a first patch that provides a new API.
> > The rest seems under your realm, if I didn't miss anything.
> > Btw, VFIO agreed on the change (as per given tags).
> Ok, can you resend all of these, with the vfio tags added, so I know to
> take them all?
Sure. Will do soon.
--
With Best Regards,
Andy Shevchenko
On Thu, Dec 03, 2020 at 03:07:19PM +0200, Andy Shevchenko wrote:
> On Thu, Dec 03, 2020 at 01:54:38PM +0100, Auger Eric wrote:
> > Hi Andy,
> >
> > On 10/27/20 6:58 PM, Andy Shevchenko wrote:
> > > Switch to use new platform_get_mem_or_io_resource() instead of
> > > home grown analogue.
> > >
> > > Cc: Eric Auger <[email protected]>
> > > Cc: Alex Williamson <[email protected]>
> > > Cc: Cornelia Huck <[email protected]>
> > > Cc: [email protected]
> > > Signed-off-by: Andy Shevchenko <[email protected]>
> > Acked-by: Eric Auger <[email protected]>
>
> Thanks!
>
> Greg, do I need to do anything else with this series?
Have them taken by the vfio maintainers? I'm not that person :)