aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/char/ipmi/ipmi_si_hardcode.c
diff options
context:
space:
mode:
authorCorey Minyard <cminyard@mvista.com>2019-02-21 14:21:17 -0600
committerCorey Minyard <cminyard@mvista.com>2019-02-22 07:12:41 -0600
commit3cd83bac481dc4fde8bedf09c8aecb3652e7e547 (patch)
treec9fe554281414cf03aa8ce0d6cfee870dbd4578c /drivers/char/ipmi/ipmi_si_hardcode.c
parentipmi_si: Rename addr_type to addr_space to match what it does (diff)
downloadlinux-dev-3cd83bac481dc4fde8bedf09c8aecb3652e7e547.tar.xz
linux-dev-3cd83bac481dc4fde8bedf09c8aecb3652e7e547.zip
ipmi: Consolidate the adding of platform devices
It was being done in two different places now that hard-coded devices use platform devices, and it's about to be three with hotmod switching to platform devices. So put the code in one place. This required some rework on some interfaces to make the type space clean. Signed-off-by: Corey Minyard <cminyard@mvista.com>
Diffstat (limited to 'drivers/char/ipmi/ipmi_si_hardcode.c')
-rw-r--r--drivers/char/ipmi/ipmi_si_hardcode.c117
1 files changed, 18 insertions, 99 deletions
diff --git a/drivers/char/ipmi/ipmi_si_hardcode.c b/drivers/char/ipmi/ipmi_si_hardcode.c
index 86ac9b8a3219..cb58298d80f5 100644
--- a/drivers/char/ipmi/ipmi_si_hardcode.c
+++ b/drivers/char/ipmi/ipmi_si_hardcode.c
@@ -5,6 +5,7 @@
#include <linux/moduleparam.h>
#include <linux/platform_device.h>
#include "ipmi_si.h"
+#include "ipmi_plat_data.h"
/*
* There can be 4 IO ports passed in (with or without IRQs), 4 addresses,
@@ -78,121 +79,39 @@ static struct platform_device *ipmi_hc_pdevs[SI_MAX_PARMS];
static void __init ipmi_hardcode_init_one(const char *si_type_str,
unsigned int i,
unsigned long addr,
- unsigned int flags)
+ enum ipmi_addr_space addr_space)
{
- struct platform_device *pdev;
- unsigned int num_r = 1, size;
- struct resource r[4];
- struct property_entry p[6];
- enum si_type si_type;
- unsigned int regspacing, regsize;
- int rv;
+ struct ipmi_plat_data p;
- memset(p, 0, sizeof(p));
- memset(r, 0, sizeof(r));
+ memset(&p, 0, sizeof(p));
if (!si_type_str || !*si_type_str || strcmp(si_type_str, "kcs") == 0) {
- size = 2;
- si_type = SI_KCS;
+ p.type = SI_KCS;
} else if (strcmp(si_type_str, "smic") == 0) {
- size = 2;
- si_type = SI_SMIC;
+ p.type = SI_SMIC;
} else if (strcmp(si_type_str, "bt") == 0) {
- size = 3;
- si_type = SI_BT;
+ p.type = SI_BT;
} else if (strcmp(si_type_str, "invalid") == 0) {
/*
* Allow a firmware-specified interface to be
* disabled.
*/
- size = 1;
- si_type = SI_TYPE_INVALID;
+ p.type = SI_TYPE_INVALID;
} else {
pr_warn("Interface type specified for interface %d, was invalid: %s\n",
i, si_type_str);
return;
}
- regsize = regsizes[i];
- if (regsize == 0)
- regsize = DEFAULT_REGSIZE;
+ p.regsize = regsizes[i];
+ p.slave_addr = slave_addrs[i];
+ p.addr_source = SI_HARDCODED;
+ p.regshift = regshifts[i];
+ p.regsize = regsizes[i];
+ p.addr = addr;
+ p.space = addr_space;
- p[0] = PROPERTY_ENTRY_U8("ipmi-type", si_type);
- p[1] = PROPERTY_ENTRY_U8("slave-addr", slave_addrs[i]);
- p[2] = PROPERTY_ENTRY_U8("addr-source", SI_HARDCODED);
- p[3] = PROPERTY_ENTRY_U8("reg-shift", regshifts[i]);
- p[4] = PROPERTY_ENTRY_U8("reg-size", regsize);
- /* Last entry must be left NULL to terminate it. */
-
- /*
- * Register spacing is derived from the resources in
- * the IPMI platform code.
- */
- regspacing = regspacings[i];
- if (regspacing == 0)
- regspacing = regsize;
-
- r[0].start = addr;
- r[0].end = r[0].start + regsize - 1;
- r[0].name = "IPMI Address 1";
- r[0].flags = flags;
-
- if (size > 1) {
- r[1].start = r[0].start + regspacing;
- r[1].end = r[1].start + regsize - 1;
- r[1].name = "IPMI Address 2";
- r[1].flags = flags;
- num_r++;
- }
-
- if (size > 2) {
- r[2].start = r[1].start + regspacing;
- r[2].end = r[2].start + regsize - 1;
- r[2].name = "IPMI Address 3";
- r[2].flags = flags;
- num_r++;
- }
-
- if (irqs[i]) {
- r[num_r].start = irqs[i];
- r[num_r].end = irqs[i];
- r[num_r].name = "IPMI IRQ";
- r[num_r].flags = IORESOURCE_IRQ;
- num_r++;
- }
-
- pdev = platform_device_alloc("hardcode-ipmi-si", i);
- if (!pdev) {
- pr_err("Error allocating IPMI platform device %d\n", i);
- return;
- }
-
- rv = platform_device_add_resources(pdev, r, num_r);
- if (rv) {
- dev_err(&pdev->dev,
- "Unable to add hard-code resources: %d\n", rv);
- goto err;
- }
-
- rv = platform_device_add_properties(pdev, p);
- if (rv) {
- dev_err(&pdev->dev,
- "Unable to add hard-code properties: %d\n", rv);
- goto err;
- }
-
- rv = platform_device_add(pdev);
- if (rv) {
- dev_err(&pdev->dev,
- "Unable to add hard-code device: %d\n", rv);
- goto err;
- }
-
- ipmi_hc_pdevs[i] = pdev;
- return;
-
-err:
- platform_device_put(pdev);
+ ipmi_hc_pdevs[i] = ipmi_platform_add("hardcode-ipmi-si", i, &p);
}
void __init ipmi_hardcode_init(void)
@@ -219,10 +138,10 @@ void __init ipmi_hardcode_init(void)
for (i = 0; i < SI_MAX_PARMS; i++) {
if (i < num_ports && ports[i])
ipmi_hardcode_init_one(si_type[i], i, ports[i],
- IORESOURCE_IO);
+ IPMI_IO_ADDR_SPACE);
if (i < num_addrs && addrs[i])
ipmi_hardcode_init_one(si_type[i], i, addrs[i],
- IORESOURCE_MEM);
+ IPMI_MEM_ADDR_SPACE);
}
}