}
#endif
+static void ipmi_set_addr_data_and_space(struct resource *r, struct si_sm_io *io)
+{
+ if (resource_type(r) == IORESOURCE_IO)
+ io->addr_space = IPMI_IO_ADDR_SPACE;
+ else
+ io->addr_space = IPMI_MEM_ADDR_SPACE;
+ io->addr_data = r->start;
+}
+
static struct resource *
ipmi_get_info_from_resources(struct platform_device *pdev,
struct si_sm_io *io)
{
struct resource *res, *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) {
+ res_second = platform_get_mem_or_io(pdev, 1);
+ if (res_second && resource_type(res_second) == resource_type(res)) {
if (res_second->start > io->addr_data)
io->regspacing = res_second->start - io->addr_data;
}
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;