[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-Id: <20210330181649.66496-1-andriy.shevchenko@linux.intel.com>
Date: Tue, 30 Mar 2021 21:16:40 +0300
From: Andy Shevchenko <andriy.shevchenko@...ux.intel.com>
To: Corey Minyard <cminyard@...sta.com>,
Andy Shevchenko <andriy.shevchenko@...ux.intel.com>,
openipmi-developer@...ts.sourceforge.net,
linux-kernel@...r.kernel.org
Cc: Corey Minyard <minyard@....org>
Subject: [PATCH v1 01/10] ipmi_si: Switch to use platform_get_mem_or_io()
Switch to use new platform_get_mem_or_io() instead of home grown analogue.
Note, we also introduce ipmi_set_addr_data_and_space() helper here.
Signed-off-by: Andy Shevchenko <andriy.shevchenko@...ux.intel.com>
---
drivers/char/ipmi/ipmi_si_platform.c | 40 +++++++++++-----------------
1 file changed, 16 insertions(+), 24 deletions(-)
diff --git a/drivers/char/ipmi/ipmi_si_platform.c b/drivers/char/ipmi/ipmi_si_platform.c
index 129b5713f187..d7bd093f80e9 100644
--- a/drivers/char/ipmi/ipmi_si_platform.c
+++ b/drivers/char/ipmi/ipmi_si_platform.c
@@ -100,35 +100,32 @@ static int acpi_gpe_irq_setup(struct si_sm_io *io)
}
#endif
+static void ipmi_set_addr_data_and_space(struct resource *r, struct si_sm_io *io)
+{
+ io->addr_data = r->start;
+ if (resource_type(r) == IORESOURCE_IO)
+ io->addr_space = IPMI_IO_ADDR_SPACE;
+ else
+ io->addr_space = IPMI_MEM_ADDR_SPACE;
+}
+
static struct resource *
ipmi_get_info_from_resources(struct platform_device *pdev,
struct si_sm_io *io)
{
- struct resource *res, *res_second;
+ struct resource *res, *second;
- res = platform_get_resource(pdev, IORESOURCE_IO, 0);
- if (res) {
- io->addr_space = IPMI_IO_ADDR_SPACE;
- } else {
- res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
- if (res)
- io->addr_space = IPMI_MEM_ADDR_SPACE;
- }
+ res = platform_get_mem_or_io(pdev, 0);
if (!res) {
dev_err(&pdev->dev, "no I/O or memory address\n");
return NULL;
}
- io->addr_data = res->start;
+ ipmi_set_addr_data_and_space(res, io);
io->regspacing = DEFAULT_REGSPACING;
- res_second = platform_get_resource(pdev,
- (io->addr_space == IPMI_IO_ADDR_SPACE) ?
- IORESOURCE_IO : IORESOURCE_MEM,
- 1);
- if (res_second) {
- if (res_second->start > io->addr_data)
- io->regspacing = res_second->start - io->addr_data;
- }
+ second = platform_get_mem_or_io(pdev, 1);
+ if (second && resource_type(second) == resource_type(res) && second->start > io->addr_data)
+ io->regspacing = second->start - io->addr_data;
return res;
}
@@ -275,12 +272,7 @@ static int of_ipmi_probe(struct platform_device *pdev)
io.addr_source = SI_DEVICETREE;
io.irq_setup = ipmi_std_irq_setup;
- if (resource.flags & IORESOURCE_IO)
- io.addr_space = IPMI_IO_ADDR_SPACE;
- else
- io.addr_space = IPMI_MEM_ADDR_SPACE;
-
- io.addr_data = resource.start;
+ ipmi_set_addr_data_and_space(&resource, &io);
io.regsize = regsize ? be32_to_cpup(regsize) : DEFAULT_REGSIZE;
io.regspacing = regspacing ? be32_to_cpup(regspacing) : DEFAULT_REGSPACING;
--
2.30.2
Powered by blists - more mailing lists