Skip to content

Commit 2d6be4a

Browse files
committed
Merge tag 'for-linus-4.11' of git://git.code.sf.net/p/openipmi/linux-ipmi
Pull IPMI updates from Corey Minyard: "This is a few small fixes to the main IPMI driver, make some things const, fix typos, etc. The last patch came in about a week ago, but IMHO it's best to go in now. It is not for the main driver, it's for the bt-bmc driver, which runs on the managment controller side, not on the host side, so the scope is limited and the change is necessary" * tag 'for-linus-4.11' of git://git.code.sf.net/p/openipmi/linux-ipmi: ipmi: bt-bmc: Use a regmap for register access char: ipmi: constify ipmi_smi_handlers structures acpi:ipmi: Make IPMI user handler const ipmi: make ipmi_usr_hndl const Documentation: Fix a typo in IPMI.txt.
2 parents cf39319 + eb99459 commit 2d6be4a

File tree

9 files changed

+69
-30
lines changed

9 files changed

+69
-30
lines changed

Documentation/IPMI.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -257,7 +257,7 @@ and tell you when they come and go.
257257

258258
Creating the User
259259

260-
To user the message handler, you must first create a user using
260+
To use the message handler, you must first create a user using
261261
ipmi_create_user. The interface number specifies which SMI you want
262262
to connect to, and you must supply callback functions to be called
263263
when data comes in. The callback function can run at interrupt level,

drivers/acpi/acpi_ipmi.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ struct acpi_ipmi_device {
5656
struct ipmi_driver_data {
5757
struct list_head ipmi_devices;
5858
struct ipmi_smi_watcher bmc_events;
59-
struct ipmi_user_hndl ipmi_hndlrs;
59+
const struct ipmi_user_hndl ipmi_hndlrs;
6060
struct mutex ipmi_lock;
6161

6262
/*

drivers/char/ipmi/Kconfig

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,8 @@ config IPMI_POWEROFF
7878
endif # IPMI_HANDLER
7979

8080
config ASPEED_BT_IPMI_BMC
81-
depends on ARCH_ASPEED
81+
depends on ARCH_ASPEED || COMPILE_TEST
82+
depends on REGMAP && REGMAP_MMIO && MFD_SYSCON
8283
tristate "BT IPMI bmc driver"
8384
help
8485
Provides a driver for the BT (Block Transfer) IPMI interface

drivers/char/ipmi/bt-bmc.c

Lines changed: 59 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,13 @@
1212
#include <linux/errno.h>
1313
#include <linux/interrupt.h>
1414
#include <linux/io.h>
15+
#include <linux/mfd/syscon.h>
1516
#include <linux/miscdevice.h>
1617
#include <linux/module.h>
18+
#include <linux/of.h>
1719
#include <linux/platform_device.h>
1820
#include <linux/poll.h>
21+
#include <linux/regmap.h>
1922
#include <linux/sched.h>
2023
#include <linux/timer.h>
2124

@@ -60,7 +63,8 @@
6063
struct bt_bmc {
6164
struct device dev;
6265
struct miscdevice miscdev;
63-
void __iomem *base;
66+
struct regmap *map;
67+
int offset;
6468
int irq;
6569
wait_queue_head_t queue;
6670
struct timer_list poll_timer;
@@ -69,14 +73,29 @@ struct bt_bmc {
6973

7074
static atomic_t open_count = ATOMIC_INIT(0);
7175

76+
static const struct regmap_config bt_regmap_cfg = {
77+
.reg_bits = 32,
78+
.val_bits = 32,
79+
.reg_stride = 4,
80+
};
81+
7282
static u8 bt_inb(struct bt_bmc *bt_bmc, int reg)
7383
{
74-
return ioread8(bt_bmc->base + reg);
84+
uint32_t val = 0;
85+
int rc;
86+
87+
rc = regmap_read(bt_bmc->map, bt_bmc->offset + reg, &val);
88+
WARN(rc != 0, "regmap_read() failed: %d\n", rc);
89+
90+
return rc == 0 ? (u8) val : 0;
7591
}
7692

7793
static void bt_outb(struct bt_bmc *bt_bmc, u8 data, int reg)
7894
{
79-
iowrite8(data, bt_bmc->base + reg);
95+
int rc;
96+
97+
rc = regmap_write(bt_bmc->map, bt_bmc->offset + reg, data);
98+
WARN(rc != 0, "regmap_write() failed: %d\n", rc);
8099
}
81100

82101
static void clr_rd_ptr(struct bt_bmc *bt_bmc)
@@ -367,14 +386,18 @@ static irqreturn_t bt_bmc_irq(int irq, void *arg)
367386
{
368387
struct bt_bmc *bt_bmc = arg;
369388
u32 reg;
389+
int rc;
390+
391+
rc = regmap_read(bt_bmc->map, bt_bmc->offset + BT_CR2, &reg);
392+
if (rc)
393+
return IRQ_NONE;
370394

371-
reg = ioread32(bt_bmc->base + BT_CR2);
372395
reg &= BT_CR2_IRQ_H2B | BT_CR2_IRQ_HBUSY;
373396
if (!reg)
374397
return IRQ_NONE;
375398

376399
/* ack pending IRQs */
377-
iowrite32(reg, bt_bmc->base + BT_CR2);
400+
regmap_write(bt_bmc->map, bt_bmc->offset + BT_CR2, reg);
378401

379402
wake_up(&bt_bmc->queue);
380403
return IRQ_HANDLED;
@@ -384,7 +407,6 @@ static int bt_bmc_config_irq(struct bt_bmc *bt_bmc,
384407
struct platform_device *pdev)
385408
{
386409
struct device *dev = &pdev->dev;
387-
u32 reg;
388410
int rc;
389411

390412
bt_bmc->irq = platform_get_irq(pdev, 0);
@@ -405,18 +427,17 @@ static int bt_bmc_config_irq(struct bt_bmc *bt_bmc,
405427
* will be cleared (along with B2H) when we can write the next
406428
* message to the BT buffer
407429
*/
408-
reg = ioread32(bt_bmc->base + BT_CR1);
409-
reg |= BT_CR1_IRQ_H2B | BT_CR1_IRQ_HBUSY;
410-
iowrite32(reg, bt_bmc->base + BT_CR1);
430+
rc = regmap_update_bits(bt_bmc->map, bt_bmc->offset + BT_CR1,
431+
(BT_CR1_IRQ_H2B | BT_CR1_IRQ_HBUSY),
432+
(BT_CR1_IRQ_H2B | BT_CR1_IRQ_HBUSY));
411433

412-
return 0;
434+
return rc;
413435
}
414436

415437
static int bt_bmc_probe(struct platform_device *pdev)
416438
{
417439
struct bt_bmc *bt_bmc;
418440
struct device *dev;
419-
struct resource *res;
420441
int rc;
421442

422443
if (!pdev || !pdev->dev.of_node)
@@ -431,10 +452,27 @@ static int bt_bmc_probe(struct platform_device *pdev)
431452

432453
dev_set_drvdata(&pdev->dev, bt_bmc);
433454

434-
res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
435-
bt_bmc->base = devm_ioremap_resource(&pdev->dev, res);
436-
if (IS_ERR(bt_bmc->base))
437-
return PTR_ERR(bt_bmc->base);
455+
bt_bmc->map = syscon_node_to_regmap(pdev->dev.parent->of_node);
456+
if (IS_ERR(bt_bmc->map)) {
457+
struct resource *res;
458+
void __iomem *base;
459+
460+
/*
461+
* Assume it's not the MFD-based devicetree description, in
462+
* which case generate a regmap ourselves
463+
*/
464+
res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
465+
base = devm_ioremap_resource(&pdev->dev, res);
466+
if (IS_ERR(base))
467+
return PTR_ERR(base);
468+
469+
bt_bmc->map = devm_regmap_init_mmio(dev, base, &bt_regmap_cfg);
470+
bt_bmc->offset = 0;
471+
} else {
472+
rc = of_property_read_u32(dev->of_node, "reg", &bt_bmc->offset);
473+
if (rc)
474+
return rc;
475+
}
438476

439477
mutex_init(&bt_bmc->mutex);
440478
init_waitqueue_head(&bt_bmc->queue);
@@ -461,12 +499,12 @@ static int bt_bmc_probe(struct platform_device *pdev)
461499
add_timer(&bt_bmc->poll_timer);
462500
}
463501

464-
iowrite32((BT_IO_BASE << BT_CR0_IO_BASE) |
465-
(BT_IRQ << BT_CR0_IRQ) |
466-
BT_CR0_EN_CLR_SLV_RDP |
467-
BT_CR0_EN_CLR_SLV_WRP |
468-
BT_CR0_ENABLE_IBT,
469-
bt_bmc->base + BT_CR0);
502+
regmap_write(bt_bmc->map, bt_bmc->offset + BT_CR0,
503+
(BT_IO_BASE << BT_CR0_IO_BASE) |
504+
(BT_IRQ << BT_CR0_IRQ) |
505+
BT_CR0_EN_CLR_SLV_RDP |
506+
BT_CR0_EN_CLR_SLV_WRP |
507+
BT_CR0_ENABLE_IBT);
470508

471509
clr_b_busy(bt_bmc);
472510

drivers/char/ipmi/ipmi_devintf.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ static int ipmi_fasync(int fd, struct file *file, int on)
108108
return (result);
109109
}
110110

111-
static struct ipmi_user_hndl ipmi_hndlrs =
111+
static const struct ipmi_user_hndl ipmi_hndlrs =
112112
{
113113
.ipmi_recv_hndl = file_receive_handler,
114114
};

drivers/char/ipmi/ipmi_msghandler.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ struct ipmi_user {
102102
struct kref refcount;
103103

104104
/* The upper layer that handles receive messages. */
105-
struct ipmi_user_hndl *handler;
105+
const struct ipmi_user_hndl *handler;
106106
void *handler_data;
107107

108108
/* The interface this user is bound to. */
@@ -919,7 +919,7 @@ static int intf_err_seq(ipmi_smi_t intf,
919919

920920

921921
int ipmi_create_user(unsigned int if_num,
922-
struct ipmi_user_hndl *handler,
922+
const struct ipmi_user_hndl *handler,
923923
void *handler_data,
924924
ipmi_user_t *user)
925925
{

drivers/char/ipmi/ipmi_powernv.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -196,7 +196,7 @@ static void ipmi_powernv_poll(void *send_info)
196196
ipmi_powernv_recv(smi);
197197
}
198198

199-
static struct ipmi_smi_handlers ipmi_powernv_smi_handlers = {
199+
static const struct ipmi_smi_handlers ipmi_powernv_smi_handlers = {
200200
.owner = THIS_MODULE,
201201
.start_processing = ipmi_powernv_start_processing,
202202
.sender = ipmi_powernv_send,

drivers/char/ipmi/ipmi_watchdog.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -985,7 +985,7 @@ static void ipmi_wdog_pretimeout_handler(void *handler_data)
985985
pretimeout_since_last_heartbeat = 1;
986986
}
987987

988-
static struct ipmi_user_hndl ipmi_hndlrs = {
988+
static const struct ipmi_user_hndl ipmi_hndlrs = {
989989
.ipmi_recv_hndl = ipmi_wdog_msg_handler,
990990
.ipmi_watchdog_pretimeout = ipmi_wdog_pretimeout_handler
991991
};

include/linux/ipmi.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ struct ipmi_user_hndl {
100100

101101
/* Create a new user of the IPMI layer on the given interface number. */
102102
int ipmi_create_user(unsigned int if_num,
103-
struct ipmi_user_hndl *handler,
103+
const struct ipmi_user_hndl *handler,
104104
void *handler_data,
105105
ipmi_user_t *user);
106106

0 commit comments

Comments
 (0)