typedef struct tpam_card {
struct tpam_card *next; /* next card in list */
unsigned int irq; /* IRQ used by this board */
- unsigned long bar0; /* ioremapped bar0 */
+ void __iomem *bar0; /* ioremapped bar0 */
int id; /* id of the board */
isdn_if interface; /* isdn link-level pointer */
int channels_used; /* number of channels actually used */
extern u32 tpam_findchannel(tpam_card *, u32);
/* Function prototypes from tpam_memory.c */
-extern void copy_to_pam_dword(tpam_card *, const void *, u32);
-extern void copy_to_pam(tpam_card *, void *, const void *, u32);
-extern u32 copy_from_pam_dword(tpam_card *, const void *);
-extern void copy_from_pam(tpam_card *, void *, const void *, u32);
-extern int copy_from_pam_to_user(tpam_card *, void __user *, const void *, u32);
-extern int copy_from_user_to_pam(tpam_card *, void *, const void __user *, u32);
+extern void copy_to_pam_dword(tpam_card *, u32, u32);
+extern void copy_to_pam(tpam_card *, u32, const void *, u32);
+extern u32 copy_from_pam_dword(tpam_card *, u32);
+extern void copy_from_pam(tpam_card *, void *, u32, u32);
+extern int copy_from_pam_to_user(tpam_card *, void __user *, u32, u32);
+extern int copy_from_user_to_pam(tpam_card *, u32, const void __user *, u32);
extern int tpam_verify_area(u32, u32);
/* Function prototypes from tpam_nco.c */
#include "tpam.h"
/* Local functions prototypes */
-static int tpam_command_ioctl_dspload(tpam_card *, u32);
-static int tpam_command_ioctl_dspsave(tpam_card *, u32);
+static int tpam_command_ioctl_dspload(tpam_card *, unsigned long);
+static int tpam_command_ioctl_dspsave(tpam_card *, unsigned long);
static int tpam_command_ioctl_dsprun(tpam_card *);
static int tpam_command_ioctl_loopmode(tpam_card *, u8);
static int tpam_command_dial(tpam_card *, u32, u8 *);
*
* Return: 0 if OK, <0 on errors.
*/
-static int tpam_command_ioctl_dspload(tpam_card *card, u32 arg) {
+static int tpam_command_ioctl_dspload(tpam_card *card, unsigned long arg) {
tpam_dsp_ioctl tdl;
pr_debug("TurboPAM(tpam_command_ioctl_dspload): card=%d\n", card->id);
return -EPERM;
/* write the data in the board's memory */
- return copy_from_user_to_pam(card, (void *)tdl.address,
+ return copy_from_user_to_pam(card, tdl.address,
(void __user *)arg + sizeof(tpam_dsp_ioctl),
tdl.data_len);
}
*
* Return: 0 if OK, <0 on errors.
*/
-static int tpam_command_ioctl_dspsave(tpam_card *card, u32 arg) {
+static int tpam_command_ioctl_dspsave(tpam_card *card, unsigned long arg) {
tpam_dsp_ioctl tdl;
pr_debug("TurboPAM(tpam_command_ioctl_dspsave): card=%d\n", card->id);
/* read the data from the board's memory */
return copy_from_pam_to_user(card, (void __user *)arg + sizeof(tpam_dsp_ioctl),
- (void *)tdl.address, tdl.data_len);
+ tdl.address, tdl.data_len);
}
/*
/* reset the board */
spin_lock_irq(&card->lock);
- copy_to_pam_dword(card, (void *)TPAM_MAGICNUMBER_REGISTER, 0xdeadface);
+ copy_to_pam_dword(card, TPAM_MAGICNUMBER_REGISTER, 0xdeadface);
readl(card->bar0 + TPAM_DSPINT_REGISTER);
readl(card->bar0 + TPAM_HINTACK_REGISTER);
spin_unlock_irq(&card->lock);
while (time_before(jiffies, timeout)) {
spin_lock_irq(&card->lock);
signature = copy_from_pam_dword(card,
- (void *)TPAM_MAGICNUMBER_REGISTER);
+ TPAM_MAGICNUMBER_REGISTER);
spin_unlock_irq(&card->lock);
if (signature == TPAM_MAGICNUMBER)
break;
if (!(tempdata = (void *)__get_free_page(GFP_ATOMIC))) {
printk(KERN_ERR "TurboPAM(tpam_writebuf_skb): "
"get_free_page failed\n");
- free_page((u32)finaldata);
+ free_page((unsigned long)finaldata);
return -ENOMEM;
}
hdlc_no_accm_encode(skb->data, skb->len, tempdata, &templen);
finallen = tpam_hdlc_encode(tempdata, finaldata,
&card->channels[channel].hdlcshift,
templen);
- free_page((u32)tempdata);
+ free_page((unsigned long)tempdata);
}
/* free the old sk_buff */
skb = build_U3DataReq(card->channels[channel].ncoid, finaldata,
finallen, ack, orig_size);
if (!skb) {
- free_page((u32)finaldata);
+ free_page((unsigned long)finaldata);
return -ENOMEM;
}
tpam_enqueue_data(&card->channels[channel], skb);
/* free the temporary memory */
- free_page((u32)finaldata);
+ free_page((unsigned long)finaldata);
return orig_size;
}
if (!(result = alloc_skb(templen, GFP_ATOMIC))) {
printk(KERN_ERR "TurboPAM(tpam_recv_U3DataInd): "
"alloc_skb failed\n");
- free_page((u32)tempdata);
+ free_page((unsigned long)tempdata);
return;
}
memcpy(skb_put(result, templen), tempdata, templen);
- free_page((u32)tempdata);
+ free_page((unsigned long)tempdata);
}
else {
/* modem mode */
}
/* remap board memory */
- if (!(card->bar0 = (unsigned long) ioremap(pci_resource_start(dev, 0),
+ if (!(card->bar0 = ioremap(pci_resource_start(dev, 0),
0x800000))) {
printk(KERN_ERR "TurboPAM: tpam_register_card: "
"unable to remap bar0\n");
readl(card->bar0 + TPAM_RESETPAM_REGISTER);
/* initialisation magic :-( */
- copy_to_pam_dword(card, (void *)0x01800008, 0x00000030);
- copy_to_pam_dword(card, (void *)0x01800010, 0x00000030);
- copy_to_pam_dword(card, (void *)0x01800014, 0x42240822);
- copy_to_pam_dword(card, (void *)0x01800018, 0x07114000);
- copy_to_pam_dword(card, (void *)0x0180001c, 0x00000400);
- copy_to_pam_dword(card, (void *)0x01840070, 0x00000010);
+ copy_to_pam_dword(card, 0x01800008, 0x00000030);
+ copy_to_pam_dword(card, 0x01800010, 0x00000030);
+ copy_to_pam_dword(card, 0x01800014, 0x42240822);
+ copy_to_pam_dword(card, 0x01800018, 0x07114000);
+ copy_to_pam_dword(card, 0x0180001c, 0x00000400);
+ copy_to_pam_dword(card, 0x01840070, 0x00000010);
/* fill the ISDN link layer structure */
card->interface.owner = THIS_MODULE;
return 0;
err_out_iounmap:
- iounmap((void *)card->bar0);
+ iounmap(card->bar0);
err_out_free_irq:
free_irq(card->irq, card);
free_irq(card->irq, card);
/* release mapped memory */
- iounmap((void *)card->bar0);
+ iounmap(card->bar0);
pci_disable_device(pcidev);
}
* addr: the address (in the board memory)
* val: the value to put into the memory.
*/
-void copy_to_pam_dword(tpam_card *card, const void *addr, u32 val) {
+void copy_to_pam_dword(tpam_card *card, u32 addr, u32 val) {
/* set the page register */
- writel(((unsigned long)addr) | TPAM_PAGE_SIZE,
+ writel(addr | TPAM_PAGE_SIZE,
card->bar0 + TPAM_PAGE_REGISTER);
/* write the value */
- writel(val, card->bar0 + (((unsigned long)addr) & TPAM_PAGE_SIZE));
+ writel(val, card->bar0 + (addr & TPAM_PAGE_SIZE));
}
/*
* from: the source address (in the kernel memory)
* n: number of bytes
*/
-void copy_to_pam(tpam_card *card, void *to, const void *from, u32 n) {
+void copy_to_pam(tpam_card *card, u32 to, const void *from, u32 n) {
u32 page, offset, count;
/* need to write in dword ! */
while (n & 3) n++;
while (n) {
- page = ((u32)to) | TPAM_PAGE_SIZE;
- offset = ((u32)to) & TPAM_PAGE_SIZE;
+ page = to | TPAM_PAGE_SIZE;
+ offset = to & TPAM_PAGE_SIZE;
count = n < TPAM_PAGE_SIZE - offset
? n
: TPAM_PAGE_SIZE - offset;
writel(page, card->bar0 + TPAM_PAGE_REGISTER);
/* copy the data */
- memcpy_toio((void *)(card->bar0 + offset), from, count);
+ memcpy_toio(card->bar0 + offset, from, count);
from += count;
to += count;
*
* Return: the value read into the memory.
*/
-u32 copy_from_pam_dword(tpam_card *card, const void *addr) {
+u32 copy_from_pam_dword(tpam_card *card, u32 addr) {
/* set the page register */
writel(((u32)addr) | TPAM_PAGE_SIZE,
card->bar0 + TPAM_PAGE_REGISTER);
/* read the data */
- return readl(card->bar0 + (((u32)addr) & TPAM_PAGE_SIZE));
+ return readl(card->bar0 + (addr & TPAM_PAGE_SIZE));
}
/*
* from: the source address (in the board memory)
* n: number of bytes
*/
-void copy_from_pam(tpam_card *card, void *to, const void *from, u32 n) {
+void copy_from_pam(tpam_card *card, void *to, u32 from, u32 n) {
u32 page, offset, count;
while (n) {
- page = ((u32)from) | TPAM_PAGE_SIZE;
- offset = ((u32)from) & TPAM_PAGE_SIZE;
+ page = from | TPAM_PAGE_SIZE;
+ offset = from & TPAM_PAGE_SIZE;
count = n < TPAM_PAGE_SIZE - offset
? n
: TPAM_PAGE_SIZE - offset;
writel(page, card->bar0 + TPAM_PAGE_REGISTER);
/* read the data */
- memcpy_fromio(to, (void *)(card->bar0 + offset), count);
+ memcpy_fromio(to, card->bar0 + offset, count);
from += count;
to += count;
*
* Return: 0 if OK, <0 if error.
*/
-int copy_from_pam_to_user(tpam_card *card, void __user *to, const void *from, u32 n) {
+int copy_from_pam_to_user(tpam_card *card, void __user *to, u32 from, u32 n) {
void *page;
u32 count;
if (copy_to_user(to, page, count)) {
/* this can fail... */
- free_page((u32)page);
+ free_page((unsigned long)page);
return -EFAULT;
}
from += count;
}
/* release allocated memory */
- free_page((u32)page);
+ free_page((unsigned long)page);
return 0;
}
*
* Return: 0 if OK, <0 if error.
*/
-int copy_from_user_to_pam(tpam_card *card, void *to, const void __user *from, u32 n) {
+int copy_from_user_to_pam(tpam_card *card, u32 to, const void __user *from, u32 n) {
void *page;
u32 count;
/* copy data from the user memory into the kernel memory */
if (copy_from_user(page, from, count)) {
/* this can fail... */
- free_page((u32)page);
+ free_page((unsigned long)page);
return -EFAULT;
}
}
/* release allocated memory */
- free_page((u32)page);
+ free_page((unsigned long)page);
return 0;
}
spin_lock(&card->lock);
/* get the message type */
- ackupload = copy_from_pam_dword(card, (void *)TPAM_ACKUPLOAD_REGISTER);
+ ackupload = copy_from_pam_dword(card, TPAM_ACKUPLOAD_REGISTER);
/* acknowledge the interrupt */
- copy_to_pam_dword(card, (void *)TPAM_INTERRUPTACK_REGISTER, 0);
+ copy_to_pam_dword(card, TPAM_INTERRUPTACK_REGISTER, 0);
readl(card->bar0 + TPAM_HINTACK_REGISTER);
if (!ackupload) {
/* get the upload pointer */
uploadptr = copy_from_pam_dword(card,
- (void *)TPAM_UPLOADPTR_REGISTER);
+ TPAM_UPLOADPTR_REGISTER);
/* get the beginning of the message (pci_mpb part) */
- copy_from_pam(card, &mpb, (void *)uploadptr, sizeof(pci_mpb));
+ copy_from_pam(card, &mpb, uploadptr, sizeof(pci_mpb));
/* allocate the sk_buff */
if (!(skb = alloc_skb(sizeof(skb_header) + sizeof(pci_mpb) +
/* copy the TLV block into the sk_buff */
copy_from_pam(card, skb_put(skb, mpb.actualBlockTLVSize),
- (void *)uploadptr + sizeof(pci_mpb),
+ uploadptr + sizeof(pci_mpb),
mpb.actualBlockTLVSize);
/* if existent, copy the data block into the sk_buff */
if (mpb.actualDataSize)
copy_from_pam(card, skb_put(skb, mpb.actualDataSize),
- (void *)uploadptr + sizeof(pci_mpb) + 4096,
+ uploadptr + sizeof(pci_mpb) + 4096,
mpb.actualDataSize);
/* wait for the board to become ready */
} while (hpic & 0x00000002);
/* acknowledge the message */
- copy_to_pam_dword(card, (void *)TPAM_ACKDOWNLOAD_REGISTER,
+ copy_to_pam_dword(card, TPAM_ACKDOWNLOAD_REGISTER,
0xffffffff);
readl(card->bar0 + TPAM_DSPINT_REGISTER);
card->id, skbh->size, skbh->data_size);
/* get the board's download pointer */
- downloadptr = copy_from_pam_dword(card,
- (void *)TPAM_DOWNLOADPTR_REGISTER);
+ downloadptr = copy_from_pam_dword(card, TPAM_DOWNLOADPTR_REGISTER);
/* copy the packet to the board at the downloadptr location */
- copy_to_pam(card, (void *)downloadptr, skb->data + sizeof(skb_header),
+ copy_to_pam(card, downloadptr, skb->data + sizeof(skb_header),
skbh->size);
if (skbh->data_size)
/* if there is some data in the packet, copy it too */
- copy_to_pam(card, (void *)downloadptr + sizeof(pci_mpb) + 4096,
+ copy_to_pam(card, downloadptr + sizeof(pci_mpb) + 4096,
skb->data + sizeof(skb_header) + skbh->size,
skbh->data_size);
card->busy = 1;
/* interrupt the board */
- copy_to_pam_dword(card, (void *)TPAM_ACKDOWNLOAD_REGISTER, 0);
+ copy_to_pam_dword(card, TPAM_ACKDOWNLOAD_REGISTER, 0);
readl(card->bar0 + TPAM_DSPINT_REGISTER);
/* release the lock */