From: Anton Blanchard <anton@ozlabs.org>
To: alistair@popple.id.au, joel@jms.id.au, andrew@aj.id.au,
clg@kaod.org, mikey@neuling.org, jk@codeconstruct.com.au
Cc: linuxppc-dev@lists.ozlabs.org
Subject: [RFC 3/5] ipmi:bt-bmc: Put arch specific function into bt_bmc_ops
Date: Wed, 6 Oct 2021 13:12:03 +1100 [thread overview]
Message-ID: <20211006021205.2579057-3-anton@ozlabs.org> (raw)
In-Reply-To: <20211006021205.2579057-1-anton@ozlabs.org>
While most of the driver is arch agnostic, setting up and handling
interrupts, and enabling the hardware is not. Create bt_bmc_ops to
handle these functions.
Signed-off-by: Anton Blanchard <anton@ozlabs.org>
---
drivers/char/ipmi/bt-bmc.c | 24 ++++++++++++++++++++----
1 file changed, 20 insertions(+), 4 deletions(-)
diff --git a/drivers/char/ipmi/bt-bmc.c b/drivers/char/ipmi/bt-bmc.c
index 2b0fe1255026..b48e04405ac4 100644
--- a/drivers/char/ipmi/bt-bmc.c
+++ b/drivers/char/ipmi/bt-bmc.c
@@ -17,6 +17,7 @@
#include <linux/regmap.h>
#include <linux/sched.h>
#include <linux/timer.h>
+#include <linux/of_device.h>
/*
* This is a BMC device used to communicate to the host
@@ -435,15 +436,30 @@ static void aspeed_enable_bt(struct bt_bmc *bt_bmc)
BT_CR0_ENABLE_IBT);
}
+struct bt_bmc_ops {
+ int (*config_irq)(struct bt_bmc *bt_bmc, struct platform_device *pdev);
+ void (*enable_bt)(struct bt_bmc *bt_bmc);
+};
+
+static const struct bt_bmc_ops aspeed_bt_bmc_ops = {
+ .config_irq = aspeed_bt_bmc_config_irq,
+ .enable_bt = aspeed_enable_bt,
+};
+
static int bt_bmc_probe(struct platform_device *pdev)
{
struct bt_bmc *bt_bmc;
struct device *dev;
int rc;
+ const struct bt_bmc_ops *ops;
dev = &pdev->dev;
dev_info(dev, "Found bt bmc device\n");
+ ops = of_device_get_match_data(&pdev->dev);
+ if (!ops)
+ return -ENODEV;
+
bt_bmc = devm_kzalloc(dev, sizeof(*bt_bmc), GFP_KERNEL);
if (!bt_bmc)
return -ENOMEM;
@@ -483,7 +499,7 @@ static int bt_bmc_probe(struct platform_device *pdev)
return rc;
}
- aspeed_bt_bmc_config_irq(bt_bmc, pdev);
+ ops->config_irq(bt_bmc, pdev);
if (bt_bmc->irq >= 0) {
dev_info(dev, "Using IRQ %d\n", bt_bmc->irq);
@@ -494,7 +510,7 @@ static int bt_bmc_probe(struct platform_device *pdev)
add_timer(&bt_bmc->poll_timer);
}
- aspeed_enable_bt(bt_bmc);
+ ops->enable_bt(bt_bmc);
clr_b_busy(bt_bmc);
@@ -512,8 +528,8 @@ static int bt_bmc_remove(struct platform_device *pdev)
}
static const struct of_device_id bt_bmc_match[] = {
- { .compatible = "aspeed,ast2400-ibt-bmc" },
- { .compatible = "aspeed,ast2500-ibt-bmc" },
+ { .compatible = "aspeed,ast2400-ibt-bmc", .data = &aspeed_bt_bmc_ops },
+ { .compatible = "aspeed,ast2500-ibt-bmc", .data = &aspeed_bt_bmc_ops },
{ },
};
--
2.31.1
next prev parent reply other threads:[~2021-10-06 2:14 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-10-06 2:12 [RFC 1/5] ipmi:bt-bmc: Separate out ASPEED specific bits Anton Blanchard
2021-10-06 2:12 ` [RFC 2/5] ipmi:bt-bmc: Prefix ASPEED specific registers with ASPEED_ Anton Blanchard
2021-10-06 2:12 ` Anton Blanchard [this message]
2021-10-06 6:01 ` [RFC 3/5] ipmi:bt-bmc: Put arch specific function into bt_bmc_ops Cédric Le Goater
2021-10-06 2:12 ` [RFC 4/5] ipmi:bt-bmc: No longer ASPEED specific Anton Blanchard
2021-10-06 2:12 ` [RFC 5/5] ipmi:bt-bmc: Add Microwatt Anton Blanchard
2021-10-06 2:35 ` Joel Stanley
2021-10-06 3:06 ` Anton Blanchard
2021-10-06 6:00 ` Cédric Le Goater
2021-10-06 6:02 ` [RFC 1/5] ipmi:bt-bmc: Separate out ASPEED specific bits Cédric Le Goater
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20211006021205.2579057-3-anton@ozlabs.org \
--to=anton@ozlabs.org \
--cc=alistair@popple.id.au \
--cc=andrew@aj.id.au \
--cc=clg@kaod.org \
--cc=jk@codeconstruct.com.au \
--cc=joel@jms.id.au \
--cc=linuxppc-dev@lists.ozlabs.org \
--cc=mikey@neuling.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).