[Fwd: PCMCIA services with development kernel 2.1.5]

Shawn C. Jury (jury@email-bosnia.22sig.army.mil)
Wed, 23 Oct 1996 12:36:48 +0200


X-POP3-Rcpt: jury@email-bosnia
Return-Path: owner-linux-laptop-outgoing@vger.rutgers.edu
Received: from vger.rutgers.edu (vger.rutgers.edu [128.6.190.2]) by email-bosnia.22sig.army.mil (8.6.11/8.6.9) with ESMTP id MAA08610 for <jury@email-bosnia.22sig.army.mil>; Wed, 23 Oct 1996 12:17:25 GMT
Received: by vger.rutgers.edu id <106040-9550>; Wed, 23 Oct 1996 06:21:42 -0400
Message-ID: <326DECE1.79BD6CEF@email-bosnia.22sig.army.mil>
Date: Wed, 23 Oct 1996 12:01:05 +0200
From: "Shawn C. Jury" <jury@email-bosnia.22sig.army.mil>
Organization: 22d Signal Brigade
X-Mailer: Mozilla 3.0 (X11; I; Linux 2.1.5 i586)
MIME-Version: 1.0
To: David Hinds <dhinds@allegro.stanford.edu>
CC: Linux Laptop Mailing List <linux-laptop@vger.rutgers.edu>,
Linux Kernel Mailing List <linux_kernel@vger.rutgers.edu>
Subject: PCMCIA services with development kernel 2.1.5
Content-Type: multipart/mixed; boundary="------------26584B8530733EBE6A62AF6B"
Sender: owner-linux-laptop@vger.rutgers.edu
Precedence: bulk
X-Status:

This is a multi-part message in MIME format.

--------------26584B8530733EBE6A62AF6B
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit

Dave,

I changed the code for the PCMCIA cards to get them working with kernel
v2.1.5. I have attached the patch for this. The patch is against
PCMCIA 2.8.23. I have gotten it to work with the pcnet_cs.o.
I don't have any other cards that I can try at this time. I hope this
helps.

Shawn

--------------26584B8530733EBE6A62AF6B
Content-Type: text/plain; charset=us-ascii; name="pcm-new.patch"
Content-Transfer-Encoding: 7bit
Content-Disposition: inline; filename="pcm-new.patch"

diff -u --recursive pcmcia-cs-2.8.23/Configure pcmcia-cs-2.8.23-new/Configure
--- pcmcia-cs-2.8.23/Configure Tue Oct 22 22:53:36 1996
+++ pcmcia-cs-2.8.23-new/Configure Mon Oct 21 19:09:34 1996
@@ -281,7 +281,7 @@
echo "AHAFLAG=-DDEBUG_AHA152X" >> $CONFIG_MK
fi
;;
-1.99|2.0)
+1.99|2.0|2.1)
echo 'MFLAG=-DMODVERSIONS -include' \
'$(LINUX)/include/linux/modversions.h' >> $CONFIG_MK
if [ $PATCHLEVEL -ne 99 -o $SUBLEVEL -ge 6 ] ; then
diff -u --recursive pcmcia-cs-2.8.23/modules/ciscode.h pcmcia-cs-2.8.23-new/modules/ciscode.h
--- pcmcia-cs-2.8.23/modules/ciscode.h Tue Oct 22 22:53:36 1996
+++ pcmcia-cs-2.8.23-new/modules/ciscode.h Mon Oct 21 19:10:21 1996
@@ -1,5 +1,5 @@
/*
- * ciscode.h $Revision: 1.5 $ $Date: 1996/07/24 15:27:27 $ (David Hinds)
+ * ciscode.h $Revision: 1.1 $ $Date: 1996/10/21 14:20:09 $ (David Hinds)
*/

#ifndef _LINUX_CISCODE_H
diff -u --recursive pcmcia-cs-2.8.23/modules/ds.c pcmcia-cs-2.8.23-new/modules/ds.c
--- pcmcia-cs-2.8.23/modules/ds.c Tue Oct 22 22:53:36 1996
+++ pcmcia-cs-2.8.23-new/modules/ds.c Mon Oct 21 19:10:21 1996
@@ -582,7 +582,7 @@
return -EINTR;
}
val = get_queued_event(user);
- put_fs_long(val, buf);
+ put_user(val, buf);
return 4;
} /* ds_read */

@@ -613,7 +613,7 @@

if (s->req_pending) {
s->req_pending--;
- s->req_result = get_fs_long(buf);
+ get_user(s->req_result, (int *) buf);
if ((s->req_result != 0) || (s->req_pending == 0))
wake_up_interruptible(&s->request);
}
@@ -702,7 +702,7 @@

err = ret = 0;

- if (cmd & IOC_IN) memcpy_fromfs((char *)&buf, (char *)arg, size);
+ if (cmd & IOC_IN) copy_from_user((char *)&buf, (char *)arg, size);

switch (cmd) {
case DS_ADJUST_RESOURCE_INFO:
@@ -808,7 +808,7 @@
}
}

- if (cmd & IOC_OUT) memcpy_tofs((char *)arg, (char *)&buf, size);
+ if (cmd & IOC_OUT) copy_to_user((char *)arg, (char *)&buf, size);

return err;
} /* ds_ioctl */
diff -u --recursive pcmcia-cs-2.8.23/modules/ftl_cs.c pcmcia-cs-2.8.23-new/modules/ftl_cs.c
--- pcmcia-cs-2.8.23/modules/ftl_cs.c Tue Oct 22 22:53:37 1996
+++ pcmcia-cs-2.8.23-new/modules/ftl_cs.c Mon Oct 21 19:33:28 1996
@@ -542,7 +542,7 @@

/* Set up virtual page map */
blocks = header.FormattedSize >> header.BlockSize;
- part->VirtualBlockMap = vmalloc(blocks * sizeof(u_long));
+ part->VirtualBlockMap = vmalloc (blocks * sizeof(u_long));
memset(part->VirtualBlockMap, 0xff, blocks * sizeof(u_long));
part->BlocksPerUnit = (1 << header.EraseUnitSize) >> header.BlockSize;
req.Count = part->BlocksPerUnit * sizeof(u_long);
@@ -1092,7 +1092,7 @@
CardServices(CloseMemory, part->handle);
part->handle = NULL;
if (part->VirtualBlockMap) {
- vfree(part->VirtualBlockMap);
+ vfree (part->VirtualBlockMap);
part->VirtualBlockMap = NULL;
}
if (part->VirtualPageMap) {
@@ -1348,7 +1348,7 @@
else {
ret = verify_area(VERIFY_WRITE, (long *)arg, sizeof(long));
if (ret) break;
- put_fs_long(partition->header.FormattedSize/SECTOR_SIZE,
+ put_user(partition->header.FormattedSize/SECTOR_SIZE,
(long *)arg);
}
break;
diff -u --recursive pcmcia-cs-2.8.23/modules/iflash2+_mtd.c pcmcia-cs-2.8.23-new/modules/iflash2+_mtd.c
--- pcmcia-cs-2.8.23/modules/iflash2+_mtd.c Sat Jun 8 06:07:47 1996
+++ pcmcia-cs-2.8.23-new/modules/iflash2+_mtd.c Mon Oct 21 19:41:24 1996
@@ -788,6 +788,7 @@
{
u_short npb;
int ret;
+ int src = 0;

/* Enable interrupts on write complete */
set_rdy_mode((u_short *)esr, IF_RDY_PULSE_WRITE);
@@ -800,8 +801,9 @@
"at 0x%p...\n", dest);
#endif
ret = page_setup(queue, (u_short *)esr, (u_short *)dest, 1);
+ get_user(src, (u_char *) buf);
if (ret != CS_SUCCESS) return ret;
- writeb((is_krnl) ? (*buf) : get_fs_byte(buf), dest);
+ writeb((is_krnl) ? (*buf) : src, dest);
ret = page_write((u_short *)esr, (u_short *)dest, 1);
if (ret != CS_SUCCESS) return ret;
dest++; buf++; nb--;
diff -u --recursive pcmcia-cs-2.8.23/modules/iflash2_mtd.c pcmcia-cs-2.8.23-new/modules/iflash2_mtd.c
--- pcmcia-cs-2.8.23/modules/iflash2_mtd.c Tue May 28 17:14:27 1996
+++ pcmcia-cs-2.8.23-new/modules/iflash2_mtd.c Mon Oct 21 19:41:19 1996
@@ -682,6 +682,7 @@
{
char *start = dest;
int ret;
+ int src = 0;

*(u_short *)dest = IF_READ_CSR;
if (is_krnl) {
@@ -697,12 +698,14 @@
}
else {
if (nb & 1) {
- ret = byte_write(dest, get_fs_byte(buf));
+ get_user(src, (u_char *) buf);
+ ret = byte_write(dest, src);
if (ret != CS_SUCCESS) return ret;
dest++; buf++; nb--;
}
for (; nb != 0; dest += 2, buf += 2, nb -= 2) {
- ret = word_write((u_short *)dest, get_fs_word((u_short *)buf));
+ get_user(src, (u_short *) buf);
+ ret = word_write((u_short *)dest, src);
if (ret != CS_SUCCESS) return ret;
}
}
diff -u --recursive pcmcia-cs-2.8.23/modules/mem_op.h pcmcia-cs-2.8.23-new/modules/mem_op.h
--- pcmcia-cs-2.8.23/modules/mem_op.h Mon Jun 10 18:12:54 1996
+++ pcmcia-cs-2.8.23-new/modules/mem_op.h Mon Oct 21 19:32:52 1996
@@ -22,23 +22,27 @@
size_t odd = (n & 3);
n -= odd;
while (n) {
- put_fs_long(readl(from), to);
+ put_user(readl(from), to);
from += 4; to += 4; n -= 4;
}
while (odd--)
- put_fs_byte(readb(from++), to++);
+ put_user(readb(from++), to++);
}

extern inline void memcpy_fromfs_topc(void *to, const void *from, size_t n)
{
+ int src = 0;
+
size_t odd = (n & 3);
n -= odd;
while (n) {
- writel(get_fs_long(from), to);
+ get_user(src, (int *) from);
+ writel(src, to);
to += 4; from += 4; n -= 4;
}
while (odd--)
- writeb(get_fs_byte(from++), to++);
+ get_user(src, (int *) from++);
+ writeb(src, to++);
}

#else /* UNSAFE_MEMCPY */
@@ -72,23 +76,27 @@
size_t odd = (n & 1);
n -= odd;
while (n) {
- put_fs_word(readw(from), to);
+ put_user(readw(from),(u_char *) to);
to += 2; from += 2; n -= 2;
}
if (odd)
- put_fs_byte(readb(from), to);
+ put_user(readb(from), (u_short *) to);
}

extern inline void memcpy_fromfs_topc(void *to, const void *from, size_t n)
{
size_t odd = (n & 1);
+ int src = 0;
+
n -= odd;
while (n) {
- writew(get_fs_word(from), to);
+ get_user(src, (int *) from);
+ writew(src, to);
to += 2; from += 2; n -= 2;
}
if (odd)
- writeb(get_fs_byte(from), to);
+ get_user(src, (int *) from);
+ writeb(src, to);
}

#endif /* UNSAFE_MEMCPY */
diff -u --recursive pcmcia-cs-2.8.23/modules/memory_cs.c pcmcia-cs-2.8.23-new/modules/memory_cs.c
--- pcmcia-cs-2.8.23/modules/memory_cs.c Tue Aug 6 05:13:56 1996
+++ pcmcia-cs-2.8.23-new/modules/memory_cs.c Mon Oct 21 19:27:22 1996
@@ -669,15 +669,15 @@
ret = 0;
switch (cmd) {
case BLKGETSIZE:
- put_fs_long(minor_dev->region.RegionSize/SECTOR_SIZE,
+ put_user(minor_dev->region.RegionSize/SECTOR_SIZE,
(long *)arg);
break;
case MEMGETINFO:
- memcpy_tofs((region_info_t *)arg, &minor_dev->region,
+ copy_to_user((region_info_t *)arg, &minor_dev->region,
sizeof(struct region_info_t));
break;
case MEMERASE:
- memcpy_fromfs(&erase, (erase_info_t *)arg,
+ copy_from_user(&erase, (erase_info_t *)arg,
sizeof(struct erase_info_t));
ret = memory_erase(dev, minor_dev, erase.Offset, erase.Size);
break;
diff -u --recursive pcmcia-cs-2.8.23/modules/pcmem_cs.c pcmcia-cs-2.8.23-new/modules/pcmem_cs.c
--- pcmcia-cs-2.8.23/modules/pcmem_cs.c Tue Oct 22 22:53:37 1996
+++ pcmcia-cs-2.8.23-new/modules/pcmem_cs.c Mon Oct 21 19:14:05 1996
@@ -644,7 +644,7 @@
nb = (from+count > WINDOW_SIZE) ? WINDOW_SIZE-from : count;
if (minor & 1) {
for (i = 0; i < nb; i += 2, buf++)
- put_fs_byte(readb(dev->Base+from+i), buf);
+ put_user(readb(dev->Base+from+i), buf);
read += nb>>1;
}
else {
@@ -674,6 +674,7 @@
pcmem_dev_t *dev;
u_long p, wrote, to, nb;
int i, ret;
+ int src = 0;
modwin_t mod;
memreq_t mem;

@@ -728,7 +729,8 @@
nb = (to+count > WINDOW_SIZE) ? WINDOW_SIZE-to : count;
if (minor & 1) {
for (i = 0; i < nb; i += 2, buf++)
- writeb(get_fs_byte(buf), dev->Base+to+i);
+ get_user(src, (int *) buf);
+ writeb(src, dev->Base+to+i);
wrote += nb>>1;
}
else {
@@ -770,7 +772,7 @@
}
ret = verify_area(VERIFY_WRITE, (long *)arg, sizeof(long));
if (ret) break;
- put_fs_long(dev->size/SECTOR_SIZE, (long *)arg);
+ put_user(dev->size/SECTOR_SIZE, (long *)arg);
break;
default:
ret = -EINVAL;
diff -u --recursive pcmcia-cs-2.8.23/modules/wavelan_cs.c pcmcia-cs-2.8.23-new/modules/wavelan_cs.c
--- pcmcia-cs-2.8.23/modules/wavelan_cs.c Tue Oct 22 22:53:37 1996
+++ pcmcia-cs-2.8.23-new/modules/wavelan_cs.c Mon Oct 21 19:39:43 1996
@@ -1954,7 +1954,7 @@
if (count + file->f_pos > length)
count = length - file->f_pos;
end = count + file->f_pos;
- memcpy_tofs(buf, page + file->f_pos, count);
+ copy_to_user(buf, page + file->f_pos, count);
free_page((unsigned long) page);
file->f_pos = end;
return(count);

--------------26584B8530733EBE6A62AF6B--