5 static unsigned char port_inb(const struct si_sm_io
*io
, unsigned int offset
)
7 unsigned int addr
= io
->addr_data
;
9 return inb(addr
+ (offset
* io
->regspacing
));
12 static void port_outb(const struct si_sm_io
*io
, unsigned int offset
,
15 unsigned int addr
= io
->addr_data
;
17 outb(b
, addr
+ (offset
* io
->regspacing
));
20 static unsigned char port_inw(const struct si_sm_io
*io
, unsigned int offset
)
22 unsigned int addr
= io
->addr_data
;
24 return (inw(addr
+ (offset
* io
->regspacing
)) >> io
->regshift
) & 0xff;
27 static void port_outw(const struct si_sm_io
*io
, unsigned int offset
,
30 unsigned int addr
= io
->addr_data
;
32 outw(b
<< io
->regshift
, addr
+ (offset
* io
->regspacing
));
35 static unsigned char port_inl(const struct si_sm_io
*io
, unsigned int offset
)
37 unsigned int addr
= io
->addr_data
;
39 return (inl(addr
+ (offset
* io
->regspacing
)) >> io
->regshift
) & 0xff;
42 static void port_outl(const struct si_sm_io
*io
, unsigned int offset
,
45 unsigned int addr
= io
->addr_data
;
47 outl(b
<< io
->regshift
, addr
+(offset
* io
->regspacing
));
50 static void port_cleanup(struct si_sm_io
*io
)
52 unsigned int addr
= io
->addr_data
;
56 for (idx
= 0; idx
< io
->io_size
; idx
++)
57 release_region(addr
+ idx
* io
->regspacing
,
62 int ipmi_si_port_setup(struct si_sm_io
*io
)
64 unsigned int addr
= io
->addr_data
;
70 io
->io_cleanup
= port_cleanup
;
73 * Figure out the actual inb/inw/inl/etc routine to use based
74 * upon the register size.
76 switch (io
->regsize
) {
78 io
->inputb
= port_inb
;
79 io
->outputb
= port_outb
;
82 io
->inputb
= port_inw
;
83 io
->outputb
= port_outw
;
86 io
->inputb
= port_inl
;
87 io
->outputb
= port_outl
;
90 dev_warn(io
->dev
, "Invalid register size: %d\n",
96 * Some BIOSes reserve disjoint I/O regions in their ACPI
97 * tables. This causes problems when trying to register the
98 * entire I/O region. Therefore we must register each I/O
101 for (idx
= 0; idx
< io
->io_size
; idx
++) {
102 if (request_region(addr
+ idx
* io
->regspacing
,
103 io
->regsize
, DEVICE_NAME
) == NULL
) {
104 /* Undo allocations */
106 release_region(addr
+ idx
* io
->regspacing
,