Commit 8c6b3424 authored by Alexander Viro's avatar Alexander Viro Committed by Linus Torvalds

[PATCH] iomem annotations and fixes + isa_-ectomy in msnd

 * switched to ioremap() + normal operations
 * split msnd_fifo_write() (and msnd_fifo_read()) into iomem and normal
   versions (original was even worse - it used to do __user and __iomem
   versions in the same code and in atomic context; when that bogosity
   got fixed, the difference between these cases (now normal memory and
   iomem) had been lost).
Signed-off-by: default avatarAl Viro <viro@parcelfarce.linux.theplanet.co.uk>
Signed-off-by: default avatarLinus Torvalds <torvalds@osdl.org>
parent dbdc3bfe
...@@ -81,12 +81,12 @@ void msnd_unregister(multisound_dev_t *dev) ...@@ -81,12 +81,12 @@ void msnd_unregister(multisound_dev_t *dev)
--num_devs; --num_devs;
} }
void msnd_init_queue(unsigned long base, int start, int size) void msnd_init_queue(void __iomem *base, int start, int size)
{ {
isa_writew(PCTODSP_BASED(start), base + JQS_wStart); writew(PCTODSP_BASED(start), base + JQS_wStart);
isa_writew(PCTODSP_OFFSET(size) - 1, base + JQS_wSize); writew(PCTODSP_OFFSET(size) - 1, base + JQS_wSize);
isa_writew(0, base + JQS_wHead); writew(0, base + JQS_wHead);
isa_writew(0, base + JQS_wTail); writew(0, base + JQS_wTail);
} }
void msnd_fifo_init(msnd_fifo *f) void msnd_fifo_init(msnd_fifo *f)
...@@ -122,6 +122,37 @@ void msnd_fifo_make_empty(msnd_fifo *f) ...@@ -122,6 +122,37 @@ void msnd_fifo_make_empty(msnd_fifo *f)
f->len = f->tail = f->head = 0; f->len = f->tail = f->head = 0;
} }
int msnd_fifo_write_io(msnd_fifo *f, char __iomem *buf, size_t len)
{
int count = 0;
while ((count < len) && (f->len != f->n)) {
int nwritten;
if (f->head <= f->tail) {
nwritten = len - count;
if (nwritten > f->n - f->tail)
nwritten = f->n - f->tail;
}
else {
nwritten = f->head - f->tail;
if (nwritten > len - count)
nwritten = len - count;
}
memcpy_fromio(f->data + f->tail, buf, nwritten);
count += nwritten;
buf += nwritten;
f->len += nwritten;
f->tail += nwritten;
f->tail %= f->n;
}
return count;
}
int msnd_fifo_write(msnd_fifo *f, const char *buf, size_t len) int msnd_fifo_write(msnd_fifo *f, const char *buf, size_t len)
{ {
int count = 0; int count = 0;
...@@ -141,7 +172,7 @@ int msnd_fifo_write(msnd_fifo *f, const char *buf, size_t len) ...@@ -141,7 +172,7 @@ int msnd_fifo_write(msnd_fifo *f, const char *buf, size_t len)
nwritten = len - count; nwritten = len - count;
} }
isa_memcpy_fromio(f->data + f->tail, (unsigned long) buf, nwritten); memcpy(f->data + f->tail, buf, nwritten);
count += nwritten; count += nwritten;
buf += nwritten; buf += nwritten;
...@@ -153,6 +184,37 @@ int msnd_fifo_write(msnd_fifo *f, const char *buf, size_t len) ...@@ -153,6 +184,37 @@ int msnd_fifo_write(msnd_fifo *f, const char *buf, size_t len)
return count; return count;
} }
int msnd_fifo_read_io(msnd_fifo *f, char __iomem *buf, size_t len)
{
int count = 0;
while ((count < len) && (f->len > 0)) {
int nread;
if (f->tail <= f->head) {
nread = len - count;
if (nread > f->n - f->head)
nread = f->n - f->head;
}
else {
nread = f->tail - f->head;
if (nread > len - count)
nread = len - count;
}
memcpy_toio(buf, f->data + f->head, nread);
count += nread;
buf += nread;
f->len -= nread;
f->head += nread;
f->head %= f->n;
}
return count;
}
int msnd_fifo_read(msnd_fifo *f, char *buf, size_t len) int msnd_fifo_read(msnd_fifo *f, char *buf, size_t len)
{ {
int count = 0; int count = 0;
...@@ -172,7 +234,7 @@ int msnd_fifo_read(msnd_fifo *f, char *buf, size_t len) ...@@ -172,7 +234,7 @@ int msnd_fifo_read(msnd_fifo *f, char *buf, size_t len)
nread = len - count; nread = len - count;
} }
isa_memcpy_toio((unsigned long) buf, f->data + f->head, nread); memcpy(buf, f->data + f->head, nread);
count += nread; count += nread;
buf += nread; buf += nread;
...@@ -327,6 +389,8 @@ EXPORT_SYMBOL(msnd_fifo_init); ...@@ -327,6 +389,8 @@ EXPORT_SYMBOL(msnd_fifo_init);
EXPORT_SYMBOL(msnd_fifo_free); EXPORT_SYMBOL(msnd_fifo_free);
EXPORT_SYMBOL(msnd_fifo_alloc); EXPORT_SYMBOL(msnd_fifo_alloc);
EXPORT_SYMBOL(msnd_fifo_make_empty); EXPORT_SYMBOL(msnd_fifo_make_empty);
EXPORT_SYMBOL(msnd_fifo_write_io);
EXPORT_SYMBOL(msnd_fifo_read_io);
EXPORT_SYMBOL(msnd_fifo_write); EXPORT_SYMBOL(msnd_fifo_write);
EXPORT_SYMBOL(msnd_fifo_read); EXPORT_SYMBOL(msnd_fifo_read);
......
...@@ -183,7 +183,7 @@ typedef u8 BYTE; ...@@ -183,7 +183,7 @@ typedef u8 BYTE;
typedef u16 USHORT; typedef u16 USHORT;
typedef u16 WORD; typedef u16 WORD;
typedef u32 DWORD; typedef u32 DWORD;
typedef unsigned long LPDAQD; typedef void __iomem * LPDAQD;
/* Generic FIFO */ /* Generic FIFO */
typedef struct { typedef struct {
...@@ -203,12 +203,12 @@ typedef struct multisound_dev { ...@@ -203,12 +203,12 @@ typedef struct multisound_dev {
int memid, irqid; int memid, irqid;
int irq, irq_ref; int irq, irq_ref;
unsigned char info; unsigned char info;
unsigned long base; void __iomem *base;
/* Motorola 56k DSP SMA */ /* Motorola 56k DSP SMA */
unsigned long SMA; void __iomem *SMA;
unsigned long DAPQ, DARQ, MODQ, MIDQ, DSPQ; void __iomem *DAPQ, *DARQ, *MODQ, *MIDQ, *DSPQ;
unsigned long pwDSPQData, pwMIDQData, pwMODQData; void __iomem *pwDSPQData, *pwMIDQData, *pwMODQData;
int dspq_data_buff, dspq_buff_size; int dspq_data_buff, dspq_buff_size;
/* State variables */ /* State variables */
...@@ -259,12 +259,14 @@ typedef struct multisound_dev { ...@@ -259,12 +259,14 @@ typedef struct multisound_dev {
int msnd_register(multisound_dev_t *dev); int msnd_register(multisound_dev_t *dev);
void msnd_unregister(multisound_dev_t *dev); void msnd_unregister(multisound_dev_t *dev);
void msnd_init_queue(unsigned long, int start, int size); void msnd_init_queue(void __iomem *, int start, int size);
void msnd_fifo_init(msnd_fifo *f); void msnd_fifo_init(msnd_fifo *f);
void msnd_fifo_free(msnd_fifo *f); void msnd_fifo_free(msnd_fifo *f);
int msnd_fifo_alloc(msnd_fifo *f, size_t n); int msnd_fifo_alloc(msnd_fifo *f, size_t n);
void msnd_fifo_make_empty(msnd_fifo *f); void msnd_fifo_make_empty(msnd_fifo *f);
int msnd_fifo_write_io(msnd_fifo *f, char __iomem *buf, size_t len);
int msnd_fifo_read_io(msnd_fifo *f, char __iomem *buf, size_t len);
int msnd_fifo_write(msnd_fifo *f, const char *buf, size_t len); int msnd_fifo_write(msnd_fifo *f, const char *buf, size_t len);
int msnd_fifo_read(msnd_fifo *f, char *buf, size_t len); int msnd_fifo_read(msnd_fifo *f, char *buf, size_t len);
......
This diff is collapsed.
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