Commit 1ef1c398 authored by Alexander Viro's avatar Alexander Viro Committed by Linus Torvalds

[PATCH] (1/4) eicon iomem annotations and fixes

 * adds new helpers ({GET,PUT}_{WORD,DWORD}) parallel to READ_WORD
   et.al., but used on normal memory instead of iomem.  Instances of
   READ_WORD and friends that are applied to vmalloc'ed memory and local
   variables switched to new helpers.
Signed-off-by: default avatarArmin Schindler <armin@melware.de>
Signed-off-by: default avatarAl Viro <viro@parcelfarce.linux.theplanet.co.uk>
Signed-off-by: default avatarLinus Torvalds <torvalds@osdl.org>
parent 4f5f573e
......@@ -240,13 +240,13 @@ void sendf(APPL * appl, word command, dword Id, word Number, byte * format, ...)
DBG_PRV1(("sendf(a=%d,cmd=%x,format=%s)",
appl->Id, command, (byte *) format))
WRITE_WORD(&msg.header.appl_id, appl->Id);
WRITE_WORD(&msg.header.command, command);
PUT_WORD(&msg.header.appl_id, appl->Id);
PUT_WORD(&msg.header.command, command);
if ((byte) (command >> 8) == 0x82)
Number = appl->Number++;
WRITE_WORD(&msg.header.number, Number);
PUT_WORD(&msg.header.number, Number);
WRITE_DWORD(((byte *) & msg.header.controller), Id);
PUT_DWORD(&msg.header.controller, Id);
write = (byte *) & msg;
write += 12;
......@@ -261,13 +261,13 @@ void sendf(APPL * appl, word command, dword Id, word Number, byte * format, ...)
break;
case 'w':
tmp = va_arg(ap, dword);
WRITE_WORD(write, (tmp & 0xffff));
PUT_WORD(write, (tmp & 0xffff));
write += 2;
length += 2;
break;
case 'd':
tmp = va_arg(ap, dword);
WRITE_DWORD(write, tmp);
PUT_DWORD(write, tmp);
write += 4;
length += 4;
break;
......@@ -282,11 +282,11 @@ void sendf(APPL * appl, word command, dword Id, word Number, byte * format, ...)
}
va_end(ap);
WRITE_WORD(&msg.header.length, length);
PUT_WORD(&msg.header.length, length);
msg.header.controller = UnMapController(msg.header.controller);
if (command == _DATA_B3_I)
dlength = READ_WORD(
dlength = GET_WORD(
((byte *) & msg.info.data_b3_ind.Data_Length));
if (!(dmb = diva_os_alloc_message_buffer(length + dlength,
......@@ -300,7 +300,7 @@ void sendf(APPL * appl, word command, dword Id, word Number, byte * format, ...)
/* if DATA_B3_IND, copy data too */
if (command == _DATA_B3_I) {
dword data = READ_DWORD(&msg.info.data_b3_ind.Data);
dword data = GET_DWORD(&msg.info.data_b3_ind.Data);
memcpy(write + length, (void *) data, dlength);
}
......@@ -318,7 +318,7 @@ void sendf(APPL * appl, word command, dword Id, word Number, byte * format, ...)
if (myDriverDebugHandle.dbgMask & DL_BLK) {
xlog("\x00\x02", &msg, 0x81, length);
for (i = 0; i < dlength; i += 256) {
DBG_BLK((((char *) READ_DWORD(&msg.info.data_b3_ind.Data)) + i,
DBG_BLK((((char *) GET_DWORD(&msg.info.data_b3_ind.Data)) + i,
((dlength - i) < 256) ? (dlength - i) : 256))
if (!(myDriverDebugHandle.dbgMask & DL_PRV0))
break; /* not more if not explicitely requested */
......@@ -700,7 +700,7 @@ static int diva_add_card(DESCRIPTOR * d)
}
/* profile information */
WRITE_WORD(&ctrl->profile.nbchannel, card->d.channels);
PUT_WORD(&ctrl->profile.nbchannel, card->d.channels);
ctrl->profile.goptions = a->profile.Global_Options;
ctrl->profile.support1 = a->profile.B1_Protocols;
ctrl->profile.support2 = a->profile.B2_Protocols;
......@@ -882,11 +882,11 @@ static u16 diva_send_message(struct capi_ctr *ctrl,
word ret = 0;
diva_os_spin_lock_magic_t old_irql;
CAPI_MSG *msg = (CAPI_MSG *) DIVA_MESSAGE_BUFFER_DATA(dmb);
APPL *this = &application[READ_WORD(&msg->header.appl_id) - 1];
APPL *this = &application[GET_WORD(&msg->header.appl_id) - 1];
diva_card *card = ctrl->driverdata;
__u32 length = DIVA_MESSAGE_BUFFER_LEN(dmb);
word clength = READ_WORD(&msg->header.length);
word command = READ_WORD(&msg->header.command);
word clength = GET_WORD(&msg->header.length);
word command = GET_WORD(&msg->header.command);
u16 retval = CAPI_NOERROR;
if (diva_os_in_irq()) {
......@@ -932,9 +932,9 @@ static u16 diva_send_message(struct capi_ctr *ctrl,
if (clength == 24)
clength = 22; /* workaround for PPcom bug */
/* header is always 22 */
if (READ_WORD(&msg->info.data_b3_req.Data_Length) >
if (GET_WORD(&msg->info.data_b3_req.Data_Length) >
this->MaxDataLength
|| READ_WORD(&msg->info.data_b3_req.Data_Length) >
|| GET_WORD(&msg->info.data_b3_req.Data_Length) >
(length - clength)) {
DBG_ERR(("Write - invalid message size"))
retval = CAPI_ILLCMDORSUBCMDORMSGTOSMALL;
......@@ -952,18 +952,18 @@ static u16 diva_send_message(struct capi_ctr *ctrl,
this->xbuffer_internal[i] = NULL;
memcpy(this->xbuffer_ptr[i], &((__u8 *) msg)[clength],
READ_WORD(&msg->info.data_b3_req.Data_Length));
GET_WORD(&msg->info.data_b3_req.Data_Length));
#ifndef DIVA_NO_DEBUGLIB
if ((myDriverDebugHandle.dbgMask & DL_BLK)
&& (myDriverDebugHandle.dbgMask & DL_XLOG)) {
int j;
for (j = 0; j <
READ_WORD(&msg->info.data_b3_req.Data_Length);
GET_WORD(&msg->info.data_b3_req.Data_Length);
j += 256) {
DBG_BLK((((char *) this->xbuffer_ptr[i]) + j,
((READ_WORD(&msg->info.data_b3_req.Data_Length) - j) <
256) ? (READ_WORD(&msg->info.data_b3_req.Data_Length) - j) : 256))
((GET_WORD(&msg->info.data_b3_req.Data_Length) - j) <
256) ? (GET_WORD(&msg->info.data_b3_req.Data_Length) - j) : 256))
if (!(myDriverDebugHandle.dbgMask & DL_PRV0))
break; /* not more if not explicitely requested */
}
......@@ -976,7 +976,7 @@ static u16 diva_send_message(struct capi_ctr *ctrl,
mapped_msg->header.controller = MapController(mapped_msg->header.controller);
mapped_msg->header.length = clength;
mapped_msg->header.command = command;
mapped_msg->header.number = READ_WORD(&msg->header.number);
mapped_msg->header.number = GET_WORD(&msg->header.number);
ret = api_put(this, mapped_msg);
switch (ret) {
......
......@@ -952,10 +952,10 @@ static void xdi_xlog_rc_event (byte Adapter,
byte Id, byte Ch, byte Rc, byte cb, byte type) {
#if defined(XDI_USE_XLOG)
word LogInfo[4];
WRITE_WORD(&LogInfo[0], ((word)Adapter | (word)(xdi_xlog_sec++ << 8)));
WRITE_WORD(&LogInfo[1], ((word)Id | (word)(Ch << 8)));
WRITE_WORD(&LogInfo[2], ((word)Rc | (word)(type << 8)));
WRITE_WORD(&LogInfo[3], cb);
PUT_WORD(&LogInfo[0], ((word)Adapter | (word)(xdi_xlog_sec++ << 8)));
PUT_WORD(&LogInfo[1], ((word)Id | (word)(Ch << 8)));
PUT_WORD(&LogInfo[2], ((word)Rc | (word)(type << 8)));
PUT_WORD(&LogInfo[3], cb);
xdi_xlog ((byte*)&LogInfo[0], 221, sizeof(LogInfo));
#endif
}
......@@ -976,9 +976,9 @@ static void xdi_xlog_request (byte Adapter, byte Id,
byte Ch, byte Req, byte type) {
#if defined(XDI_USE_XLOG)
word LogInfo[3];
WRITE_WORD(&LogInfo[0], ((word)Adapter | (word)(xdi_xlog_sec++ << 8)));
WRITE_WORD(&LogInfo[1], ((word)Id | (word)(Ch << 8)));
WRITE_WORD(&LogInfo[2], ((word)Req | (word)(type << 8)));
PUT_WORD(&LogInfo[0], ((word)Adapter | (word)(xdi_xlog_sec++ << 8)));
PUT_WORD(&LogInfo[1], ((word)Id | (word)(Ch << 8)));
PUT_WORD(&LogInfo[2], ((word)Req | (word)(type << 8)));
xdi_xlog ((byte*)&LogInfo[0], 220, sizeof(LogInfo));
#endif
}
......@@ -1020,10 +1020,10 @@ static void xdi_xlog_ind (byte Adapter,
byte type) {
#if defined(XDI_USE_XLOG)
word LogInfo[4];
WRITE_WORD(&LogInfo[0], ((word)Adapter | (word)(xdi_xlog_sec++ << 8)));
WRITE_WORD(&LogInfo[1], ((word)Id | (word)(Ch << 8)));
WRITE_WORD(&LogInfo[2], ((word)Ind | (word)(type << 8)));
WRITE_WORD(&LogInfo[3], ((word)rnr | (word)(rnr_valid << 8)));
PUT_WORD(&LogInfo[0], ((word)Adapter | (word)(xdi_xlog_sec++ << 8)));
PUT_WORD(&LogInfo[1], ((word)Id | (word)(Ch << 8)));
PUT_WORD(&LogInfo[2], ((word)Ind | (word)(type << 8)));
PUT_WORD(&LogInfo[3], ((word)rnr | (word)(rnr_valid << 8)));
xdi_xlog ((byte*)&LogInfo[0], 222, sizeof(LogInfo));
#endif
}
......@@ -95,13 +95,13 @@ dump_xlog_buffer (PISDN_ADAPTER IoAdapter, Xdesc *xlogDesc)
DBG_FTL(("Microcode: %s", &IoAdapter->ProtocolIdString[0]))
for ( ; logCnt > 0 ; --logCnt )
{
if ( !READ_WORD(&Xlog[logOut]) )
if ( !GET_WORD(&Xlog[logOut]) )
{
if ( --logCnt == 0 )
break ;
logOut = 0 ;
}
if ( READ_WORD(&Xlog[logOut]) <= (logOut * sizeof(*Xlog)) )
if ( GET_WORD(&Xlog[logOut]) <= (logOut * sizeof(*Xlog)) )
{
if ( logCnt > 2 )
{
......@@ -110,9 +110,9 @@ dump_xlog_buffer (PISDN_ADAPTER IoAdapter, Xdesc *xlogDesc)
}
break ;
}
logLen = (dword)(READ_WORD(&Xlog[logOut]) - (logOut * sizeof(*Xlog))) ;
logLen = (dword)(GET_WORD(&Xlog[logOut]) - (logOut * sizeof(*Xlog))) ;
DBG_FTL_MXLOG(( (char *)&Xlog[logOut + 1], (dword)(logLen - 2) ))
logOut = (READ_WORD(&Xlog[logOut]) + 1) / sizeof(*Xlog) ;
logOut = (GET_WORD(&Xlog[logOut]) + 1) / sizeof(*Xlog) ;
}
DBG_FTL(("%s: ***************** end of XLOG *****************",
&IoAdapter->Name[0]))
......
......@@ -1919,11 +1919,11 @@ static int diva_strace_read_int (diva_man_var_header_t* pVar, int* var) {
break;
case 2:
value = (short)READ_WORD(ptr);
value = (short)GET_WORD(ptr);
break;
case 4:
value = (int)READ_DWORD(ptr);
value = (int)GET_DWORD(ptr);
break;
default:
......@@ -1947,16 +1947,16 @@ static int diva_strace_read_uint (diva_man_var_header_t* pVar, dword* var) {
break;
case 2:
value = (word)READ_WORD(ptr);
value = (word)GET_WORD(ptr);
break;
case 3:
value = (dword)READ_DWORD(ptr);
value = (dword)GET_DWORD(ptr);
value &= 0x00ffffff;
break;
case 4:
value = (dword)READ_DWORD(ptr);
value = (dword)GET_DWORD(ptr);
break;
default:
......
This source diff could not be displayed because it is too large. You can view the blob instead.
......@@ -335,6 +335,9 @@ diva_os_atomic_decrement(diva_os_atomic_t* pv)
/*
** endian macros
**
** If only... In some cases we did use them for endianness conversion;
** unfortunately, other uses were real iomem accesses.
*/
#define READ_WORD(addr) readw(addr)
#define READ_DWORD(addr) readl(addr)
......@@ -342,6 +345,23 @@ diva_os_atomic_decrement(diva_os_atomic_t* pv)
#define WRITE_WORD(addr,v) writew(v,addr)
#define WRITE_DWORD(addr,v) writel(v,addr)
static inline __u16 GET_WORD(void *addr)
{
return le16_to_cpu(*(__le16 *)addr);
}
static inline __u32 GET_DWORD(void *addr)
{
return le32_to_cpu(*(__le32 *)addr);
}
static inline void PUT_WORD(void *addr, __u16 v)
{
*(__le16 *)addr = cpu_to_le16(v);
}
static inline void PUT_DWORD(void *addr, __u32 v)
{
*(__le32 *)addr = cpu_to_le32(v);
}
/*
** 32/64 bit macors
*/
......
......@@ -61,15 +61,15 @@ static void bri_cpu_trapped (PISDN_ADAPTER IoAdapter) {
/*
* check for trapped MIPS 3xxx CPU, dump only exception frame
*/
if ( READ_DWORD(&Xlog[0x80 / sizeof(Xlog[0])]) == 0x99999999 )
if ( GET_DWORD(&Xlog[0x80 / sizeof(Xlog[0])]) == 0x99999999 )
{
dump_trap_frame (IoAdapter, &((byte *)Xlog)[0x90]) ;
IoAdapter->trapped = 1 ;
}
regs[0] = READ_DWORD(&((byte *)Xlog)[0x70]);
regs[1] = READ_DWORD(&((byte *)Xlog)[0x74]);
regs[2] = READ_DWORD(&((byte *)Xlog)[0x78]);
regs[3] = READ_DWORD(&((byte *)Xlog)[0x7c]);
regs[0] = GET_DWORD(&((byte *)Xlog)[0x70]);
regs[1] = GET_DWORD(&((byte *)Xlog)[0x74]);
regs[2] = GET_DWORD(&((byte *)Xlog)[0x78]);
regs[3] = GET_DWORD(&((byte *)Xlog)[0x7c]);
outpp (addrHi, (regs[1] >> 16) & 0x7F) ;
outppw (addrLo, regs[1] & 0xFFFF) ;
xlogDesc.cnt = inppw(ioaddr) ;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment