Re: [syzbot] BUG: unable to handle kernel access to user memory in sock_ioctl

2021-03-18 Thread Ben Dooks

On 18/03/2021 15:18, Dmitry Vyukov wrote:

On Mon, Mar 15, 2021 at 3:41 PM Ben Dooks  wrote:


On 15/03/2021 11:52, Dmitry Vyukov wrote:

On Mon, Mar 15, 2021 at 12:30 PM Ben Dooks  wrote:


On 14/03/2021 11:03, Dmitry Vyukov wrote:

On Sun, Mar 14, 2021 at 11:01 AM Dmitry Vyukov  wrote:

On Wed, Mar 10, 2021 at 7:28 PM syzbot
 wrote:


Hello,

syzbot found the following issue on:

HEAD commit:0d7588ab riscv: process: Fix no prototype for arch_dup_tas..
git tree:   git://git.kernel.org/pub/scm/linux/kernel/git/riscv/linux.git 
fixes
console output: https://syzkaller.appspot.com/x/log.txt?x=122c343ad0
kernel config:  https://syzkaller.appspot.com/x/.config?x=e3c595255fb2d136
dashboard link: https://syzkaller.appspot.com/bug?extid=c23c5421600e9b454849
userspace arch: riscv64

Unfortunately, I don't have any reproducer for this issue yet.

IMPORTANT: if you fix the issue, please add the following tag to the commit:
Reported-by: syzbot+c23c5421600e9b454...@syzkaller.appspotmail.com


+riscv maintainers

Another case of put_user crashing.


There are 58 crashes in sock_ioctl already. Somehow there is a very
significant skew towards crashing with this "user memory without
uaccess routines" in schedule_tail and sock_ioctl of all places in the
kernel that use put_user... This looks very strange... Any ideas
what's special about these 2 locations?


I could imagine if such a crash happens after a previous stack
overflow and now task data structures are corrupted. But f_getown does
not look like a function that consumes way more than other kernel
syscalls...


The last crash I looked at suggested somehow put_user got re-entered
with the user protection turned back on. Either there is a path through
one of the kernel handlers where this happens or there's something
weird going on with qemu.


Is there any kind of tracking/reporting that would help to localize
it? I could re-reproduce with that code.


I'm not sure. I will have a go at debugging on qemu today just to make
sure I can reproduce here before I have to go into the office and fix
my Icicle board for real hardware tests.

I think my first plan post reproduction is to stuff some trace points
into the fault handlers to see if we can get a idea of faults being
processed, etc.

Maybe also add a check in the fault handler to see if the fault was
in a fixable region and post an error if that happens / maybe retry
the instruction with the relevant SR_SUM flag set.

Hopefully tomorrow I can get a run on real hardware to confirm.
Would have been better if the Unmatched board I ordered last year
would turn up.


In retrospect it's obvious what's common between these 2 locations:
they both call a function inside of put_user.

#syz dup:
BUG: unable to handle kernel access to user memory in schedule_tail


I think so. I've posted a patch that you can test, which should force
the flags to be saved over switch_to(). I think the sanitisers are just
making it easier to see.

There is a seperate issue of passing complicated things to put_user()
as for security, the function may be executed with the user-space
protections turned off. I plan to raise this on the kernel list later
once I've done some more testing.

--
Ben Dooks   http://www.codethink.co.uk/
Senior Engineer Codethink - Providing Genius

https://www.codethink.co.uk/privacy.html


Re: [syzbot] BUG: unable to handle kernel access to user memory in sock_ioctl

2021-03-15 Thread Ben Dooks

On 15/03/2021 11:52, Dmitry Vyukov wrote:

On Mon, Mar 15, 2021 at 12:30 PM Ben Dooks  wrote:


On 14/03/2021 11:03, Dmitry Vyukov wrote:

On Sun, Mar 14, 2021 at 11:01 AM Dmitry Vyukov  wrote:

On Wed, Mar 10, 2021 at 7:28 PM syzbot
 wrote:


Hello,

syzbot found the following issue on:

HEAD commit:0d7588ab riscv: process: Fix no prototype for arch_dup_tas..
git tree:   git://git.kernel.org/pub/scm/linux/kernel/git/riscv/linux.git 
fixes
console output: https://syzkaller.appspot.com/x/log.txt?x=122c343ad0
kernel config:  https://syzkaller.appspot.com/x/.config?x=e3c595255fb2d136
dashboard link: https://syzkaller.appspot.com/bug?extid=c23c5421600e9b454849
userspace arch: riscv64

Unfortunately, I don't have any reproducer for this issue yet.

IMPORTANT: if you fix the issue, please add the following tag to the commit:
Reported-by: syzbot+c23c5421600e9b454...@syzkaller.appspotmail.com


+riscv maintainers

Another case of put_user crashing.


There are 58 crashes in sock_ioctl already. Somehow there is a very
significant skew towards crashing with this "user memory without
uaccess routines" in schedule_tail and sock_ioctl of all places in the
kernel that use put_user... This looks very strange... Any ideas
what's special about these 2 locations?


I could imagine if such a crash happens after a previous stack
overflow and now task data structures are corrupted. But f_getown does
not look like a function that consumes way more than other kernel
syscalls...


The last crash I looked at suggested somehow put_user got re-entered
with the user protection turned back on. Either there is a path through
one of the kernel handlers where this happens or there's something
weird going on with qemu.


Is there any kind of tracking/reporting that would help to localize
it? I could re-reproduce with that code.


I'm not sure. I will have a go at debugging on qemu today just to make
sure I can reproduce here before I have to go into the office and fix
my Icicle board for real hardware tests.

I think my first plan post reproduction is to stuff some trace points
into the fault handlers to see if we can get a idea of faults being
processed, etc.

Maybe also add a check in the fault handler to see if the fault was
in a fixable region and post an error if that happens / maybe retry
the instruction with the relevant SR_SUM flag set.

Hopefully tomorrow I can get a run on real hardware to confirm.
Would have been better if the Unmatched board I ordered last year
would turn up.




--
Ben Dooks   http://www.codethink.co.uk/
Senior Engineer Codethink - Providing Genius

https://www.codethink.co.uk/privacy.html


Re: [syzbot] BUG: unable to handle kernel access to user memory in sock_ioctl

2021-03-15 Thread Ben Dooks

On 14/03/2021 11:03, Dmitry Vyukov wrote:

On Sun, Mar 14, 2021 at 11:01 AM Dmitry Vyukov  wrote:

On Wed, Mar 10, 2021 at 7:28 PM syzbot
 wrote:


Hello,

syzbot found the following issue on:

HEAD commit:0d7588ab riscv: process: Fix no prototype for arch_dup_tas..
git tree:   git://git.kernel.org/pub/scm/linux/kernel/git/riscv/linux.git 
fixes
console output: https://syzkaller.appspot.com/x/log.txt?x=122c343ad0
kernel config:  https://syzkaller.appspot.com/x/.config?x=e3c595255fb2d136
dashboard link: https://syzkaller.appspot.com/bug?extid=c23c5421600e9b454849
userspace arch: riscv64

Unfortunately, I don't have any reproducer for this issue yet.

IMPORTANT: if you fix the issue, please add the following tag to the commit:
Reported-by: syzbot+c23c5421600e9b454...@syzkaller.appspotmail.com


+riscv maintainers

Another case of put_user crashing.


There are 58 crashes in sock_ioctl already. Somehow there is a very
significant skew towards crashing with this "user memory without
uaccess routines" in schedule_tail and sock_ioctl of all places in the
kernel that use put_user... This looks very strange... Any ideas
what's special about these 2 locations?


I could imagine if such a crash happens after a previous stack
overflow and now task data structures are corrupted. But f_getown does
not look like a function that consumes way more than other kernel
syscalls...


The last crash I looked at suggested somehow put_user got re-entered
with the user protection turned back on. Either there is a path through
one of the kernel handlers where this happens or there's something
weird going on with qemu.

I'll be trying to get this run up on real hardware this week, the nvme
with my debian install died last week so I have to go and re-install
the machine to get development work done on it.

--
Ben Dooks   http://www.codethink.co.uk/
Senior Engineer Codethink - Providing Genius

https://www.codethink.co.uk/privacy.html


Re: [PATCH 0/6] ks8851 fixes & cleanups

2019-03-20 Thread Ben Dooks

On 20/03/2019 14:02, Lukas Wunner wrote:

Four fixes and two cleanups for the Microchip (formerly Micrel) KSZ8851
SPI Ethernet driver.

Some of the fixes might even pass as stable material, but I haven't marked
them as such for cautiousness: Doesn't hurt letting them bake in linux-next
for a few weeks to raise the confidence, even though we've tested them
extensively on our Revolution Pi open source PLCs.


I have done a visual review, but have not had the hardware to do any
testing on this in a long time.

--
Ben Dooks   http://www.codethink.co.uk/
Senior Engineer Codethink - Providing Genius

https://www.codethink.co.uk/privacy.html


[PATCH] net: fixup address-space warnings in compat_mc_{get,set}sockopt()

2019-03-01 Thread Ben Dooks
Add __user attributes in some of the casts in this function to avoid
the following sparse warnings:

net/compat.c:592:57: warning: cast removes address space of expression
net/compat.c:592:57: warning: incorrect type in initializer (different address 
spaces)
net/compat.c:592:57:expected struct compat_group_req [noderef] *gr32
net/compat.c:592:57:got void *
net/compat.c:613:65: warning: cast removes address space of expression
net/compat.c:613:65: warning: incorrect type in initializer (different address 
spaces)
net/compat.c:613:65:expected struct compat_group_source_req [noderef] 
*gsr32
net/compat.c:613:65:got void *
net/compat.c:634:60: warning: cast removes address space of expression
net/compat.c:634:60: warning: incorrect type in initializer (different address 
spaces)
net/compat.c:634:60:expected struct compat_group_filter [noderef] 
*gf32
net/compat.c:634:60:got void *
net/compat.c:672:52: warning: cast removes address space of expression
net/compat.c:672:52: warning: incorrect type in initializer (different address 
spaces)
net/compat.c:672:52:expected struct compat_group_filter [noderef] 
*gf32
net/compat.c:672:52:got void *

Signed-off-by: Ben Dooks 
---
 net/compat.c | 8 
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/net/compat.c b/net/compat.c
index 3d348198004f..8c8c57d814af 100644
--- a/net/compat.c
+++ b/net/compat.c
@@ -589,7 +589,7 @@ int compat_mc_setsockopt(struct sock *sock, int level, int 
optname,
case MCAST_JOIN_GROUP:
case MCAST_LEAVE_GROUP:
{
-   struct compat_group_req __user *gr32 = (void *)optval;
+   struct compat_group_req __user *gr32 = (void __user *)optval;
struct group_req __user *kgr =
compat_alloc_user_space(sizeof(struct group_req));
u32 interface;
@@ -610,7 +610,7 @@ int compat_mc_setsockopt(struct sock *sock, int level, int 
optname,
case MCAST_BLOCK_SOURCE:
case MCAST_UNBLOCK_SOURCE:
{
-   struct compat_group_source_req __user *gsr32 = (void *)optval;
+   struct compat_group_source_req __user *gsr32 = (void __user 
*)optval;
struct group_source_req __user *kgsr = compat_alloc_user_space(
sizeof(struct group_source_req));
u32 interface;
@@ -631,7 +631,7 @@ int compat_mc_setsockopt(struct sock *sock, int level, int 
optname,
}
case MCAST_MSFILTER:
{
-   struct compat_group_filter __user *gf32 = (void *)optval;
+   struct compat_group_filter __user *gf32 = (void __user *)optval;
struct group_filter __user *kgf;
u32 interface, fmode, numsrc;
 
@@ -669,7 +669,7 @@ int compat_mc_getsockopt(struct sock *sock, int level, int 
optname,
char __user *optval, int __user *optlen,
int (*getsockopt)(struct sock *, int, int, char __user *, int __user *))
 {
-   struct compat_group_filter __user *gf32 = (void *)optval;
+   struct compat_group_filter __user *gf32 = (void __user *)optval;
struct group_filter __user *kgf;
int __user  *koptlen;
u32 interface, fmode, numsrc;
-- 
2.20.1



[PATCH] net: cdc_ncm: use tasklet_init() for tasklet_struct init

2018-10-11 Thread Ben Dooks
The tasklet initialisation would be better done by tasklet_init()
instead of assuming all the fields are in an ok state by default.

This does not fix any actual know bug.

Signed-off-by: Ben Dooks 
---
 drivers/net/usb/cdc_ncm.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/drivers/net/usb/cdc_ncm.c b/drivers/net/usb/cdc_ncm.c
index 0d722b326e1b..863f3548a439 100644
--- a/drivers/net/usb/cdc_ncm.c
+++ b/drivers/net/usb/cdc_ncm.c
@@ -784,8 +784,7 @@ int cdc_ncm_bind_common(struct usbnet *dev, struct 
usb_interface *intf, u8 data_
 
hrtimer_init(&ctx->tx_timer, CLOCK_MONOTONIC, HRTIMER_MODE_REL);
ctx->tx_timer.function = &cdc_ncm_tx_timer_cb;
-   ctx->bh.data = (unsigned long)dev;
-   ctx->bh.func = cdc_ncm_txpath_bh;
+   tasklet_init(&ctx->bh, cdc_ncm_txpath_bh, (unsigned long)dev);
atomic_set(&ctx->stop, 0);
spin_lock_init(&ctx->mtx);
 
-- 
2.19.1



Re: net: stmmac: Meson GXBB: attempting to execute userspace memory

2016-11-26 Thread Ben Dooks



On 2016-11-26 07:53, Heinrich Schuchardt wrote:

For Odroid C2 I have compiled kernel
4.9.0-rc6-next-20161124-1-gbf7e142
with one additional patch
https://github.com/xypron/kernel-odroid-c2/blob/master/patch/0001-stmmac-RTL8211F-Meson-GXBB-TX-throughput-problems.patch

I repeatedly see faults like the one below:

[ 2557.400796] Unhandled fault: synchronous external abort (0x9210)
at 0x40001e8ee4b0
[ 2557.952413] CPU: 0 PID: 22837 Comm: cc1 Tainted: G  D
4.9.0-rc6-next-20161124-1-gbf7e142 #1
[ 2557.962062] Hardware name: Hardkernel ODROID-C2 (DT)
[ 2557.966980] task: 80006ddb7080 task.stack: 80006dd9c000
[ 2557.972846] PC is at 0x6a0d98
[ 2557.975776] LR is at 0x6a0e54
[ 2557.978709] pc : [<006a0d98>] lr : [<006a0e54>]
pstate: 8000
[ 2557.986040] sp : f3ee5f80
[ 2557.989318] x29: f3ee5f80 x28: 4b3f1240
[ 2557.994578] x27: 012a7000 x26: 4b3f1288
[ 2557.999840] x25: 00f58f88 x24: 4b3f1240
[ 2558.005101] x23:  x22: 0001
[ 2558.010362] x21: 0001 x20: 4b3f1250
[ 2558.015623] x19: 0054 x18: 0001
[ 2558.020885] x17: 48acaa10 x16: 01285050
[ 2558.026146] x15: 4ad96dc8 x14: 001f
[ 2558.031407] x13: 4b3f1270 x12: 4b3f1258
[ 2558.036668] x11: 01347000 x10: 0661
[ 2558.041930] x9 : 0005 x8 : 0003
[ 2558.047191] x7 : 4b3f1240 x6 : 20020033
[ 2558.052452] x5 : 4b402020 x4 : 4b3e1aa0
[ 2558.057713] x3 : 000c x2 : 0020
[ 2558.062974] x1 : 00f45000 x0 : 0065
[ 2558.068235]
[ 2558.069712] Internal error: Attempting to execute userspace memory:
860f [#7] PREEMPT SMP
[ 2558.078155] Modules linked in: meson_rng rng_core meson_gxbb_wdt
ip_tables x_tables ipv6 dwmac_generic realtek dwmac_meson8b
stmmac_platform stmmac
[ 2558.091267] CPU: 0 PID: 22837 Comm: cc1 Tainted: G  D
4.9.0-rc6-next-20161124-1-gbf7e142 #1
[ 2558.100925] Hardware name: Hardkernel ODROID-C2 (DT)
[ 2558.105841] task: 80006ddb7080 task.stack: 80006dd9c000
[ 2558.111706] PC is at 0x6a0e54
[ 2558.114638] LR is at 0x6a0e54
[ 2558.117571] pc : [<006a0e54>] lr : [<006a0e54>]
pstate: 63c5
[ 2558.124902] sp : 80006dd9fec0
[ 2558.128179] x29:  x28: 80006ddb7080
[ 2558.133441] x27: 012a7000 x26: 4b3f1288
[ 2558.138702] x25: 00f58f88 x24: 4b3f1240
[ 2558.143963] x23: 8000 x22: 006a0d98
[ 2558.149225] x21:  x20: 80006e223000
[ 2558.154486] x19:  x18: 0010
[ 2558.159747] x17: 48acaa10 x16: 01285050
[ 2558.165008] x15: 88e91f07 x14: 0006
[ 2558.170270] x13: 08e91f15 x12: 000f
[ 2558.175531] x11: 0002 x10: 02ea
[ 2558.180792] x9 : 80006dd9fb40 x8 : 00010a8b
[ 2558.186053] x7 :  x6 : 020e
[ 2558.191315] x5 : 020f020e x4 : 
[ 2558.196576] x3 :  x2 : 020f
[ 2558.201837] x1 : 80006ddb7080 x0 : 
[ 2558.207098]
[ 2558.208565] Process cc1 (pid: 22837, stack limit = 
0x80006dd9c000)

[ 2558.215035] Stack: (0x80006dd9fec0 to 0x80006dda)
[ 2558.220728] fec0: 0065 00f45000 0020
000c
[ 2558.228490] fee0: 4b3e1aa0 4b402020 20020033
4b3f1240
[ 2558.236253] ff00: 0003 0005 0661
01347000
[ 2558.244015] ff20: 4b3f1258 4b3f1270 001f
4ad96dc8
[ 2558.251778] ff40: 01285050 48acaa10 0001
0054
[ 2558.259540] ff60: 4b3f1250 0001 0001

[ 2558.267303] ff80: 4b3f1240 00f58f88 4b3f1288
012a7000
[ 2558.275065] ffa0: 4b3f1240 f3ee5f80 006a0e54
f3ee5f80
[ 2558.282828] ffc0: 006a0d98 8000 0003

[ 2558.290590] ffe0:   

[ 2558.298351] Call trace:
[ 2558.300769] Exception stack(0x80006dd9fcf0 to 
0x80006dd9fe20)

[ 2558.307149] fce0:   
0001
[ 2558.314913] fd00: 80006dd9fec0 006a0e54 800073acf500
0004
[ 2558.322675] fd20:  08dbbc18 80006ddb7080
6dd9fdd0
[ 2558.330438] fd40: 80006dd9fd90 080ca878 80006dd9fe40
80006ddb7080
[ 2558.338200] fd60: 0004 03c0 80006dd9fe40
4b3f1240
[ 2558.345963] fd80: 00f58f88 4b3f1288 
80006ddb7080
[ 2558.353725] fda0: 020f 

[PATCH] [V3] net: ipconfig: avoid warning by making ic_addrservaddr static

2016-06-10 Thread Ben Dooks
The symbol ic_addrservaddr is not static, but has no declaration
to match so make it static to fix the following warning:

net/ipv4/ipconfig.c:130:8: warning: symbol 'ic_addrservaddr' was not declared. 
Should it be static?

Signed-off-by: Ben Dooks 
---
V3: fix the title from V2
V2: make ic_addrservaddr static instead of adding to header
---
Cc: "David S. Miller" 
Cc: Alexey Kuznetsov 
Cc: James Morris 
Cc: Hideaki YOSHIFUJI 
Cc: Patrick McHardy 
Cc: netdev@vger.kernel.org
---
 net/ipv4/ipconfig.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/net/ipv4/ipconfig.c b/net/ipv4/ipconfig.c
index 2ed9dd2..eccf9fd 100644
--- a/net/ipv4/ipconfig.c
+++ b/net/ipv4/ipconfig.c
@@ -127,7 +127,7 @@ __be32 ic_myaddr = NONE;/* My IP address */
 static __be32 ic_netmask = NONE;   /* Netmask for local subnet */
 __be32 ic_gateway = NONE;  /* Gateway IP address */
 
-__be32 ic_addrservaddr = NONE; /* IP Address of the IP addresses'server */
+static __be32 ic_addrservaddr = NONE;  /* IP Address of the IP 
addresses'server */
 
 __be32 ic_servaddr = NONE; /* Boot server IP address */
 
-- 
2.8.1



Re: [PATCH] [V2] net: ipconfig: add declaration for ic_addrservaddr

2016-06-10 Thread Ben Dooks
On 09/06/16 21:35, David Miller wrote:
> From: Ben Dooks 
> Date: Thu,  9 Jun 2016 18:54:37 +0100
> 
>> The symbol ic_addrservaddr is not static, but has no declaration
>> to match so make it static to fix the following warning:
>>
>> net/ipv4/ipconfig.c:130:8: warning: symbol 'ic_addrservaddr' was not 
>> declared. Should it be static?
>>
>> Signed-off-by: Ben Dooks 
> 
> Your Subject line needs to be updated, you're not ading a declaration
> any more.

OOPS. Will fix and re-send thanks.

-- 
Ben Dooks   http://www.codethink.co.uk/
Senior Engineer Codethink - Providing Genius


[PATCH] [V2] net: ipconfig: add declaration for ic_addrservaddr

2016-06-09 Thread Ben Dooks
The symbol ic_addrservaddr is not static, but has no declaration
to match so make it static to fix the following warning:

net/ipv4/ipconfig.c:130:8: warning: symbol 'ic_addrservaddr' was not declared. 
Should it be static?

Signed-off-by: Ben Dooks 
---
V2: make ic_addrservaddr static instead of adding to header
---
Cc: "David S. Miller" 
Cc: Alexey Kuznetsov 
Cc: James Morris 
Cc: Hideaki YOSHIFUJI 
Cc: Patrick McHardy 
Cc: netdev@vger.kernel.org
---
 net/ipv4/ipconfig.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/net/ipv4/ipconfig.c b/net/ipv4/ipconfig.c
index 2ed9dd2..eccf9fd 100644
--- a/net/ipv4/ipconfig.c
+++ b/net/ipv4/ipconfig.c
@@ -127,7 +127,7 @@ __be32 ic_myaddr = NONE;/* My IP address */
 static __be32 ic_netmask = NONE;   /* Netmask for local subnet */
 __be32 ic_gateway = NONE;  /* Gateway IP address */
 
-__be32 ic_addrservaddr = NONE; /* IP Address of the IP addresses'server */
+static __be32 ic_addrservaddr = NONE;  /* IP Address of the IP 
addresses'server */
 
 __be32 ic_servaddr = NONE; /* Boot server IP address */
 
-- 
2.8.1



[PATCH] [V2] net: diag: add missing declarations

2016-06-09 Thread Ben Dooks
The functions inet_diag_msg_common_fill and inet_diag_msg_attrs_fill
seem to have been missed from the include/linux/inet_diag.h header
file. Add them to fix the following warnings:

net/ipv4/inet_diag.c:69:6: warning: symbol 'inet_diag_msg_common_fill' was not 
declared. Should it be static?
net/ipv4/inet_diag.c:108:5: warning: symbol 'inet_diag_msg_attrs_fill' was not 
declared. Should it be static?

Signed-off-by: Ben Dooks 
---
V2: remove duplicates from net/sctp/sctp_diag.c
---
Cc: "David S. Miller" 
Cc: netdev@vger.kernel.org
Cc: linux-ker...@vger.kernel.org
---
 include/linux/inet_diag.h | 6 ++
 net/sctp/sctp_diag.c  | 6 --
 2 files changed, 6 insertions(+), 6 deletions(-)

diff --git a/include/linux/inet_diag.h b/include/linux/inet_diag.h
index 7c27fa1..feb04ea 100644
--- a/include/linux/inet_diag.h
+++ b/include/linux/inet_diag.h
@@ -52,6 +52,12 @@ struct sock *inet_diag_find_one_icsk(struct net *net,
 
 int inet_diag_bc_sk(const struct nlattr *_bc, struct sock *sk);
 
+void inet_diag_msg_common_fill(struct inet_diag_msg *r, struct sock *sk);
+
+int inet_diag_msg_attrs_fill(struct sock *sk, struct sk_buff *skb,
+struct inet_diag_msg *r, int ext,
+struct user_namespace *user_ns);
+
 extern int  inet_diag_register(const struct inet_diag_handler *handler);
 extern void inet_diag_unregister(const struct inet_diag_handler *handler);
 #endif /* _INET_DIAG_H_ */
diff --git a/net/sctp/sctp_diag.c b/net/sctp/sctp_diag.c
index 1ce724b..f69edcf 100644
--- a/net/sctp/sctp_diag.c
+++ b/net/sctp/sctp_diag.c
@@ -3,12 +3,6 @@
 #include 
 #include 
 
-extern void inet_diag_msg_common_fill(struct inet_diag_msg *r,
- struct sock *sk);
-extern int inet_diag_msg_attrs_fill(struct sock *sk, struct sk_buff *skb,
-   struct inet_diag_msg *r, int ext,
-   struct user_namespace *user_ns);
-
 static void sctp_diag_get_info(struct sock *sk, struct inet_diag_msg *r,
   void *info);
 
-- 
2.8.1



Re: [PATCH] net: diag: add missing declarations

2016-06-09 Thread Ben Dooks
On 09/06/16 15:10, Eric Dumazet wrote:
> On Thu, 2016-06-09 at 12:17 +0100, Ben Dooks wrote:
>> The functions inet_diag_msg_common_fill and inet_diag_msg_attrs_fill
>> seem to have been missed from the include/linux/inet_diag.h header
>> file. Add them to fix the following warnings:
>>
>> net/ipv4/inet_diag.c:69:6: warning: symbol 'inet_diag_msg_common_fill' was 
>> not declared. Should it be static?
>> net/ipv4/inet_diag.c:108:5: warning: symbol 'inet_diag_msg_attrs_fill' was 
>> not declared. Should it be static?
>>
>> Signed-off-by: Ben Dooks 
>> ---
>> Cc: "David S. Miller" 
>> Cc: netdev@vger.kernel.org
>> Cc: linux-ker...@vger.kernel.org
>> ---
>>  include/linux/inet_diag.h | 6 ++
>>  1 file changed, 6 insertions(+)
>>
>> diff --git a/include/linux/inet_diag.h b/include/linux/inet_diag.h
>> index 7c27fa1..feb04ea 100644
>> --- a/include/linux/inet_diag.h
>> +++ b/include/linux/inet_diag.h
>> @@ -52,6 +52,12 @@ struct sock *inet_diag_find_one_icsk(struct net *net,
>>  
>>  int inet_diag_bc_sk(const struct nlattr *_bc, struct sock *sk);
>>  
>> +void inet_diag_msg_common_fill(struct inet_diag_msg *r, struct sock *sk);
>> +
>> +int inet_diag_msg_attrs_fill(struct sock *sk, struct sk_buff *skb,
>> + struct inet_diag_msg *r, int ext,
>> + struct user_namespace *user_ns);
>> +
>>  extern int  inet_diag_register(const struct inet_diag_handler *handler);
>>  extern void inet_diag_unregister(const struct inet_diag_handler *handler);
>>  #endif /* _INET_DIAG_H_ */
> 
> Please send a v2, deleting them from net/sctp/sctp_diag.c

Ah, didn't spot those. Will send a second version thanks.

-- 
Ben Dooks   http://www.codethink.co.uk/
Senior Engineer Codethink - Providing Genius


Re: [PATCH] net: dsa: mv88e6xxx: make unexported functions static

2016-06-09 Thread Ben Dooks
On 09/06/16 13:47, Vivien Didelot wrote:
> Hi Ben,
> 
> Vivien Didelot  writes:
> 
>> Most of them are fixed or being handled in net-next.
>>
>> I don't know if net should diverge or if it can live with these
>> warnings...
> 
> In fact I have a series in net-next fixing a few checkpatch.pl issue. If
> you don't mind I can rebase your fix and integrate the missing static.

Ah, didn't check net-next. You are welcome to rebase.

-- 
Ben Dooks   http://www.codethink.co.uk/
Senior Engineer Codethink - Providing Genius


Re: [PATCH] net: ipconfgi: add declaration for ic_addrservaddr

2016-06-09 Thread Ben Dooks
On 09/06/16 12:35, Daniel Borkmann wrote:
> On 06/09/2016 01:07 PM, Ben Dooks wrote:
>> The symbol ic_addrservaddr is not static, but has no declaration
>> to match. Since the similar variables are all exported, add this
>> one to the header file as well.
>>
>> This fixes the following warning:
>>
>> net/ipv4/ipconfig.c:130:8: warning: symbol 'ic_addrservaddr' was not
>> declared. Should it be static?
>>
>> Signed-off-by: Ben Dooks 
> 
> Well, how about making it actually static if it's only used
> from ipconfig.c ?

The only reason is that I thought someone might want to
use it in the future. I have no particular insight though.

-- 
Ben Dooks   http://www.codethink.co.uk/
Senior Engineer Codethink - Providing Genius


[PATCH] net: diag: add missing declarations

2016-06-09 Thread Ben Dooks
The functions inet_diag_msg_common_fill and inet_diag_msg_attrs_fill
seem to have been missed from the include/linux/inet_diag.h header
file. Add them to fix the following warnings:

net/ipv4/inet_diag.c:69:6: warning: symbol 'inet_diag_msg_common_fill' was not 
declared. Should it be static?
net/ipv4/inet_diag.c:108:5: warning: symbol 'inet_diag_msg_attrs_fill' was not 
declared. Should it be static?

Signed-off-by: Ben Dooks 
---
Cc: "David S. Miller" 
Cc: netdev@vger.kernel.org
Cc: linux-ker...@vger.kernel.org
---
 include/linux/inet_diag.h | 6 ++
 1 file changed, 6 insertions(+)

diff --git a/include/linux/inet_diag.h b/include/linux/inet_diag.h
index 7c27fa1..feb04ea 100644
--- a/include/linux/inet_diag.h
+++ b/include/linux/inet_diag.h
@@ -52,6 +52,12 @@ struct sock *inet_diag_find_one_icsk(struct net *net,
 
 int inet_diag_bc_sk(const struct nlattr *_bc, struct sock *sk);
 
+void inet_diag_msg_common_fill(struct inet_diag_msg *r, struct sock *sk);
+
+int inet_diag_msg_attrs_fill(struct sock *sk, struct sk_buff *skb,
+struct inet_diag_msg *r, int ext,
+struct user_namespace *user_ns);
+
 extern int  inet_diag_register(const struct inet_diag_handler *handler);
 extern void inet_diag_unregister(const struct inet_diag_handler *handler);
 #endif /* _INET_DIAG_H_ */
-- 
2.8.1



[PATCH] net: ipconfgi: add declaration for ic_addrservaddr

2016-06-09 Thread Ben Dooks
The symbol ic_addrservaddr is not static, but has no declaration
to match. Since the similar variables are all exported, add this
one to the header file as well.

This fixes the following warning:

net/ipv4/ipconfig.c:130:8: warning: symbol 'ic_addrservaddr' was not declared. 
Should it be static?

Signed-off-by: Ben Dooks 
---
Cc: "David S. Miller" 
Cc: Alexey Kuznetsov 
Cc: James Morris 
Cc: Hideaki YOSHIFUJI 
Cc: Patrick McHardy 
Cc: netdev@vger.kernel.org
---
 include/net/ipconfig.h | 1 +
 1 file changed, 1 insertion(+)

diff --git a/include/net/ipconfig.h b/include/net/ipconfig.h
index c74cc1b..e5f4d6e 100644
--- a/include/net/ipconfig.h
+++ b/include/net/ipconfig.h
@@ -13,6 +13,7 @@ extern __be32 ic_myaddr;  /* My IP address */
 extern __be32 ic_gateway;  /* Gateway IP address */
 
 extern __be32 ic_servaddr; /* Boot server IP address */
+extern __be32 ic_addrservaddr; /* IP Address of the IP 
addresses'server */
 
 extern __be32 root_server_addr;/* Address of NFS server */
 extern u8 root_server_path[];  /* Path to mount as root */
-- 
2.8.1



[PATCH] net: dsa: mv88e6xxx: make unexported functions static

2016-06-09 Thread Ben Dooks
The driver has a number of functions that are not exported or
declared elsewhere, so make them static to avoid the following
warnings from sparse:

drivers/net/dsa/mv88e6xxx.c:113:5: warning: symbol 'mv88e6xxx_reg_read' was not 
declared. Should it be static?
drivers/net/dsa/mv88e6xxx.c:167:5: warning: symbol 'mv88e6xxx_reg_write' was 
not declared. Should it be static?
drivers/net/dsa/mv88e6xxx.c:231:5: warning: symbol 'mv88e6xxx_set_addr' was not 
declared. Should it be static?
drivers/net/dsa/mv88e6xxx.c:367:6: warning: symbol 'mv88e6xxx_ppu_state_init' 
was not declared. Should it be static?
drivers/net/dsa/mv88e6xxx.c:3157:5: warning: symbol 'mv88e6xxx_phy_page_read' 
was not declared. Should it be static?
drivers/net/dsa/mv88e6xxx.c:3169:5: warning: symbol 'mv88e6xxx_phy_page_write' 
was not declared. Should it be static?
drivers/net/dsa/mv88e6xxx.c:3583:26: warning: symbol 'mv88e6xxx_switch_driver' 
was not declared. Should it be static?
drivers/net/dsa/mv88e6xxx.c:3621:5: warning: symbol 'mv88e6xxx_probe' was not 
declared. Should it be static?

Signed-off-by: Ben Dooks 
---
Cc: Vivien Didelot 
Cc: Andrew Lunn 
Cc: Lennert Buytenhek 
Cc: "David S. Miller" 
Cc: netdev@vger.kernel.org
---
 drivers/net/dsa/mv88e6xxx.c | 21 +++--
 1 file changed, 11 insertions(+), 10 deletions(-)

diff --git a/drivers/net/dsa/mv88e6xxx.c b/drivers/net/dsa/mv88e6xxx.c
index ba9dfc9..2cebde8 100644
--- a/drivers/net/dsa/mv88e6xxx.c
+++ b/drivers/net/dsa/mv88e6xxx.c
@@ -110,7 +110,7 @@ static int _mv88e6xxx_reg_read(struct mv88e6xxx_priv_state 
*ps,
return ret;
 }
 
-int mv88e6xxx_reg_read(struct mv88e6xxx_priv_state *ps, int addr, int reg)
+static int mv88e6xxx_reg_read(struct mv88e6xxx_priv_state *ps, int addr, int 
reg)
 {
int ret;
 
@@ -164,8 +164,8 @@ static int _mv88e6xxx_reg_write(struct mv88e6xxx_priv_state 
*ps, int addr,
return __mv88e6xxx_reg_write(ps->bus, ps->sw_addr, addr, reg, val);
 }
 
-int mv88e6xxx_reg_write(struct mv88e6xxx_priv_state *ps, int addr,
-   int reg, u16 val)
+static int mv88e6xxx_reg_write(struct mv88e6xxx_priv_state *ps, int addr,
+  int reg, u16 val)
 {
int ret;
 
@@ -228,7 +228,7 @@ static int mv88e6xxx_set_addr_indirect(struct dsa_switch 
*ds, u8 *addr)
return 0;
 }
 
-int mv88e6xxx_set_addr(struct dsa_switch *ds, u8 *addr)
+static int mv88e6xxx_set_addr(struct dsa_switch *ds, u8 *addr)
 {
struct mv88e6xxx_priv_state *ps = ds_to_priv(ds);
 
@@ -364,7 +364,7 @@ static void mv88e6xxx_ppu_access_put(struct 
mv88e6xxx_priv_state *ps)
mutex_unlock(&ps->ppu_mutex);
 }
 
-void mv88e6xxx_ppu_state_init(struct mv88e6xxx_priv_state *ps)
+static void mv88e6xxx_ppu_state_init(struct mv88e6xxx_priv_state *ps)
 {
mutex_init(&ps->ppu_mutex);
INIT_WORK(&ps->ppu_work, mv88e6xxx_ppu_reenable_work);
@@ -3154,7 +3154,8 @@ unlock:
return err;
 }
 
-int mv88e6xxx_phy_page_read(struct dsa_switch *ds, int port, int page, int reg)
+static int mv88e6xxx_phy_page_read(struct dsa_switch *ds,
+  int port, int page, int reg)
 {
struct mv88e6xxx_priv_state *ps = ds_to_priv(ds);
int ret;
@@ -3166,8 +3167,8 @@ int mv88e6xxx_phy_page_read(struct dsa_switch *ds, int 
port, int page, int reg)
return ret;
 }
 
-int mv88e6xxx_phy_page_write(struct dsa_switch *ds, int port, int page,
-int reg, int val)
+static int mv88e6xxx_phy_page_write(struct dsa_switch *ds, int port, int page,
+   int reg, int val)
 {
struct mv88e6xxx_priv_state *ps = ds_to_priv(ds);
int ret;
@@ -3580,7 +3581,7 @@ static const char *mv88e6xxx_drv_probe(struct device 
*dsa_dev,
return name;
 }
 
-struct dsa_switch_driver mv88e6xxx_switch_driver = {
+static struct dsa_switch_driver mv88e6xxx_switch_driver = {
.tag_protocol   = DSA_TAG_PROTO_EDSA,
.probe  = mv88e6xxx_drv_probe,
.setup  = mv88e6xxx_setup,
@@ -3618,7 +3619,7 @@ struct dsa_switch_driver mv88e6xxx_switch_driver = {
.port_fdb_dump  = mv88e6xxx_port_fdb_dump,
 };
 
-int mv88e6xxx_probe(struct mdio_device *mdiodev)
+static int mv88e6xxx_probe(struct mdio_device *mdiodev)
 {
struct device *dev = &mdiodev->dev;
struct device_node *np = dev->of_node;
-- 
2.8.1



[PATCH] stmmac: fix parameter to dwmac4_set_umac_addr()

2016-06-08 Thread Ben Dooks
The dwmac4_set_umac_addr() takes a struct mac_device_info as
the first parameter, but is being passed a ioaddr instead from
dwmac4_set_filter(). Fix the warning/bug by changing the first
parameter.

drivers/net/ethernet/stmicro/stmmac/dwmac4_core.c:159:46: warning: incorrect 
type in argument 1 (different address spaces)
drivers/net/ethernet/stmicro/stmmac/dwmac4_core.c:159:46:expected struct 
mac_device_info *hw
drivers/net/ethernet/stmicro/stmmac/dwmac4_core.c:159:46:got void [noderef] 
*ioaddr

Note, only compile tested this as do not have any
hardware with it in.

Signed-off-by: Ben Dooks 
---
Cc: Giuseppe Cavallaro 
Cc: Alexandre Torgue 
Cc: netdev@vger.kernel.org
---
 drivers/net/ethernet/stmicro/stmmac/dwmac4_core.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/net/ethernet/stmicro/stmmac/dwmac4_core.c 
b/drivers/net/ethernet/stmicro/stmmac/dwmac4_core.c
index 4f7283d..44da877 100644
--- a/drivers/net/ethernet/stmicro/stmmac/dwmac4_core.c
+++ b/drivers/net/ethernet/stmicro/stmmac/dwmac4_core.c
@@ -156,7 +156,7 @@ static void dwmac4_set_filter(struct mac_device_info *hw,
struct netdev_hw_addr *ha;
 
netdev_for_each_uc_addr(ha, dev) {
-   dwmac4_set_umac_addr(ioaddr, ha->addr, reg);
+   dwmac4_set_umac_addr(hw, ha->addr, reg);
reg++;
}
}
-- 
2.8.1



[PATCH] net-sysfs: fix missing

2016-06-07 Thread Ben Dooks
The of_find_net_device_by_node() function is defined in
 but not included in the .c file that
implements it. Fix the following warning by including the
header:

net/core/net-sysfs.c:1494:19: warning: symbol 'of_find_net_device_by_node' was 
not declared. Should it be static?

Signed-off-by: Ben Dooks 
---
Cc: "David S. Miller" 
Cc: netdev@vger.kernel.org
---
 net/core/net-sysfs.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/net/core/net-sysfs.c b/net/core/net-sysfs.c
index 2b3f76f..7a0b616 100644
--- a/net/core/net-sysfs.c
+++ b/net/core/net-sysfs.c
@@ -24,6 +24,7 @@
 #include 
 #include 
 #include 
+#include 
 
 #include "net-sysfs.h"
 
-- 
2.8.1



Re: [git patches] net driver updates

2008-02-12 Thread Ben Dooks
On Mon, Feb 11, 2008 at 12:05:16PM -0500, Jeff Garzik wrote:
> Mostly fixes, a few cleanups (generally assisting fixes), and an
> exception for PS3 wireless because it had been posted, reviewed and
> acked for a while, just not committed.

Thanks, good to get the DM9000 changes moving.
 
> Please pull from 'upstream-davem' branch of
> master.kernel.org:/pub/scm/linux/kernel/git/jgarzik/netdev-2.6.git 
> upstream-davem
> 

> Ben Dooks (24):
>   DM9000: Fix endian-ness of data accesses.
>   DM9000: Add platform data to specify external phy

These two where meant to be from Laurent Pinchart, they do have
the correct signed-off lines in for him and start with "Patch from:". Is
there any chance of fixing the authour attribution now?

-- 
Ben ([EMAIL PROTECTED], http://www.fluff.org/)

  'a smiley only costs 4 bytes'
--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH 07/24 for-2.6.25] DM9000: Add initial ethtool support

2008-02-06 Thread Ben Dooks
On Wed, Feb 06, 2008 at 10:52:54PM +0100, Francois Romieu wrote:
> Ben Dooks <[EMAIL PROTECTED]> :
> [...]
> > The next patch in the series changes the locking.
> 
> Do you mean patch #08 ?

Sorry, looked at the wrong patch, it is #11 which changes the locking
for address register accesses.
-- 
Ben ([EMAIL PROTECTED], http://www.fluff.org/)

  'a smiley only costs 4 bytes'
--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH 07/24 for-2.6.25] DM9000: Add initial ethtool support

2008-02-06 Thread Ben Dooks
On Tue, Feb 05, 2008 at 11:50:45PM +0100, Francois Romieu wrote:
> Ben Dooks <[EMAIL PROTECTED]> :
> > Add support for ethtool operations for the DM9000.
> > 
> > Signed-off-by: Ben Dooks <[EMAIL PROTECTED]>
> > 
> > Index: linux-2.6.24-quilt3/drivers/net/dm9000.c
> > ===
> > --- linux-2.6.24-quilt3.orig/drivers/net/dm9000.c
> > +++ linux-2.6.24-quilt3/drivers/net/dm9000.c
> [...]
> > +static int dm9000_get_settings(struct net_device *dev, struct ethtool_cmd 
> > *cmd)
> > +{
> > +   board_info_t *dm = to_dm9000_board(dev);
> > +   unsigned long flags;
> > +
> > +   spin_lock_irqsave(&dm->lock, flags);
> > +   mii_ethtool_gset(&dm->mii, cmd);
> 
> drivers/net/mii.c::mii_ethtool_gset
> [...]
> advert = mii->mdio_read(dev, mii->phy_id, MII_ADVERTISE);
> 
> drivers/net/dm9000.c::dm9000_probe
> [...]
> db->mii.mdio_read= dm9000_phy_read;
> 
> drivers/net/dm9000.c::dm9000_phy_read
> [...]
> board_info_t *db = (board_info_t *) dev->priv;
> unsigned long flags;
> unsigned int reg_save;
> int ret;
> 
> spin_lock_irqsave(&db->lock,flags);
> 
> -> deadlock

The next patch in the series changes the locking.

-- 
Ben ([EMAIL PROTECTED], http://www.fluff.org/)

  'a smiley only costs 4 bytes'
--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH 00/24 for-2.6.25] DM9000 updates for 2.6.25

2008-02-04 Thread Ben Dooks
On Mon, Feb 04, 2008 at 04:19:40PM -0800, Andrew Morton wrote:
> On Tue, 05 Feb 2008 00:01:59 +
> Ben Dooks <[EMAIL PROTECTED]> wrote:
> 
> > Subject: [PATCH 00/24 for-2.6.25] DM9000 updates for 2.6.25
> 
> Holy cow.
> 
> > This patch set is a series of updates for the DM9000
> > driver, to tidy-up some of the source, stop the accesses
> > to the PHY and EEPROM sitting and spinning with locks
> > held, and to add ethtool support.
> 
> Jeff, the immediate issue is that the driver doesn't compile on mips.  I
> have the below lameo fix for it, but it appears to be wrong.  Or at least
> suboptimal.
> 
> So if you're unprepared to chew on this lot (and 24 patches two weeks into the
> merge window is one hell of a chew) then we do need to get that
> regression fixed, at least.

To be fair, jeff has already acked most of these patches, this set is
a repost hopefully without the offending patches.
 
> 
> 
> From: Andrew Morton <[EMAIL PROTECTED]>
> 
> mips:
> 
> drivers/net/dm9000.c: In function `dm9000_open':
> drivers/net/dm9000.c:627: error: `IRQT_RISING' undeclared (first use in this 
> function)
> drivers/net/dm9000.c:627: error: (Each undeclared identifier is reported only 
> once
> drivers/net/dm9000.c:627: error: for each function it appears in.)
> 
> Cc: Daniel Mack <[EMAIL PROTECTED]>
> Cc: Russell King <[EMAIL PROTECTED]>
> Signed-off-by: Andrew Morton <[EMAIL PROTECTED]>
> ---
> 
>  drivers/net/dm9000.c |4 +++-
>  1 file changed, 3 insertions(+), 1 deletion(-)
> 
> diff -puN 
> drivers/net/dm9000.c~drivers-net-dm9000c-vague-probably-wrong-build-fix 
> drivers/net/dm9000.c
> --- a/drivers/net/dm9000.c~drivers-net-dm9000c-vague-probably-wrong-build-fix
> +++ a/drivers/net/dm9000.c
> @@ -113,8 +113,10 @@
>  #define writesw  outsw
>  #define writesl  outsl
>  #define DM9000_IRQ_FLAGS (IRQF_SHARED | IRQF_TRIGGER_HIGH)
> -#else
> +#elif defined(ARM)
>  #define DM9000_IRQ_FLAGS (IRQF_SHARED | IRQT_RISING)
> +#else
> +#define DM9000_IRQ_FLAGS (IRQF_SHARED)
>  #endif
>  
>  /*
> _
> 
> --
> To unsubscribe from this list: send the line "unsubscribe netdev" in
> the body of a message to [EMAIL PROTECTED]
> More majordomo info at  http://vger.kernel.org/majordomo-info.html

-- 
Ben ([EMAIL PROTECTED], http://www.fluff.org/)

  'a smiley only costs 4 bytes'
--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH 02/24 for-2.6.25] DM9000: Add platform data to specify external phy

2008-02-04 Thread Ben Dooks
This should have been:

Patch from: Laurent Pinchart <[EMAIL PROTECTED]>

This patch adds a flag to the DM9000 platform data which, when set,
configures the device to use an external PHY.

Signed-off-by: Laurent Pinchart <[EMAIL PROTECTED]>
Signed-off-by: Ben Dooks <[EMAIL PROTECTED]>

> Index: linux-2.6.24-git5-dm9k/drivers/net/dm9000.c
> ===
> --- linux-2.6.24-git5-dm9k.orig/drivers/net/dm9000.c
> +++ linux-2.6.24-git5-dm9k/drivers/net/dm9000.c
> @@ -137,6 +137,7 @@ typedef struct board_info {
>   u16 dbug_cnt;
>   u8 io_mode; /* 0:word, 2:byte */
>   u8 phy_addr;
> + unsigned int flags;
>  
>   void (*inblk)(void __iomem *port, void *data, int length);
>   void (*outblk)(void __iomem *port, void *data, int length);
> @@ -525,6 +526,8 @@ dm9000_probe(struct platform_device *pde
>  
>   if (pdata->dumpblk != NULL)
>   db->dumpblk = pdata->dumpblk;
> +
> + db->flags = pdata->flags;
>   }
>  
>   dm9000_reset(db);
> @@ -665,6 +668,9 @@ dm9000_init_dm9000(struct net_device *de
>   iow(db, DM9000_GPCR, GPCR_GEP_CNTL);/* Let GPIO0 output */
>   iow(db, DM9000_GPR, 0); /* Enable PHY */
>  
> + if (db->flags & DM9000_PLATF_EXT_PHY)
> + iow(db, DM9000_NCR, NCR_EXT_PHY);
> +
>   /* Program operating register */
>   iow(db, DM9000_TCR, 0); /* TX Polling clear */
>   iow(db, DM9000_BPTR, 0x3f); /* Less 3Kb, 200us */
> Index: linux-2.6.24-git5-dm9k/include/linux/dm9000.h
> ===
> --- linux-2.6.24-git5-dm9k.orig/include/linux/dm9000.h
> +++ linux-2.6.24-git5-dm9k/include/linux/dm9000.h
> @@ -19,6 +19,7 @@
>  #define DM9000_PLATF_8BITONLY(0x0001)
>  #define DM9000_PLATF_16BITONLY   (0x0002)
>  #define DM9000_PLATF_32BITONLY   (0x0004)
> +#define DM9000_PLATF_EXT_PHY (0x0008)
>  
>  /* platfrom data for platfrom device structure's platfrom_data field */
>  
> 
> -- 
> Ben ([EMAIL PROTECTED], http://www.fluff.org/)
> 
>   'a smiley only costs 4 bytes'
> --
> To unsubscribe from this list: send the line "unsubscribe netdev" in
> the body of a message to [EMAIL PROTECTED]
> More majordomo info at  http://vger.kernel.org/majordomo-info.html

-- 
Ben ([EMAIL PROTECTED], http://www.fluff.org/)

  'a smiley only costs 4 bytes'
--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH 01/24 for-2.6.25] DM9000: Fix endian-ness of data accesses.

2008-02-04 Thread Ben Dooks
On Tue, Feb 05, 2008 at 12:02:00AM +, Ben Dooks wrote:

This should have been:
Patch From: Laurent Pinchart <[EMAIL PROTECTED]>

This patch splits the receive status in 8bit wide fields and convert the
packet length from little endian to CPU byte order.

Signed-off-by: Laurent Pinchart <[EMAIL PROTECTED]>
Signed-off-by: Ben Dooks <[EMAIL PROTECTED]>

> Index: linux-2.6.24-git5-dm9k/drivers/net/dm9000.c
> ===
> --- linux-2.6.24-git5-dm9k.orig/drivers/net/dm9000.c
> +++ linux-2.6.24-git5-dm9k/drivers/net/dm9000.c
> @@ -867,7 +867,8 @@ dm9000_timer(unsigned long data)
>  }
>  
>  struct dm9000_rxhdr {
> - u16 RxStatus;
> + u8  RxPktReady;
> + u8  RxStatus;
>   u16 RxLen;
>  } __attribute__((__packed__));
>  
> @@ -908,7 +909,7 @@ dm9000_rx(struct net_device *dev)
>  
>   (db->inblk)(db->io_data, &rxhdr, sizeof(rxhdr));
>  
> - RxLen = rxhdr.RxLen;
> + RxLen = le16_to_cpu(rxhdr.RxLen);
>  
>   /* Packet Status check */
>   if (RxLen < 0x40) {
> @@ -920,17 +921,17 @@ dm9000_rx(struct net_device *dev)
>   PRINTK1("RST: RX Len:%x\n", RxLen);
>   }
>  
> - if (rxhdr.RxStatus & 0xbf00) {
> + if (rxhdr.RxStatus & 0xbf) {
>   GoodPacket = false;
> - if (rxhdr.RxStatus & 0x100) {
> + if (rxhdr.RxStatus & 0x01) {
>   PRINTK1("fifo error\n");
>   dev->stats.rx_fifo_errors++;
>   }
> - if (rxhdr.RxStatus & 0x200) {
> + if (rxhdr.RxStatus & 0x02) {
>   PRINTK1("crc error\n");
>   dev->stats.rx_crc_errors++;
>   }
> - if (rxhdr.RxStatus & 0x8000) {
> + if (rxhdr.RxStatus & 0x80) {
>   PRINTK1("length error\n");
>   dev->stats.rx_length_errors++;
>   }
> 
> -- 
> Ben ([EMAIL PROTECTED], http://www.fluff.org/)
> 
>   'a smiley only costs 4 bytes'
> --
> To unsubscribe from this list: send the line "unsubscribe netdev" in
> the body of a message to [EMAIL PROTECTED]
> More majordomo info at  http://vger.kernel.org/majordomo-info.html

-- 
Ben ([EMAIL PROTECTED], http://www.fluff.org/)

  'a smiley only costs 4 bytes'
--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 10/24 for-2.6.25] DM9000: Remove barely used SROM array read.

2008-02-04 Thread Ben Dooks
The srom array in the board data is only being used in the device probe
routines. The probe also only uses the first 6 bytes of an array
we spend 512ms reading 128 bytes from. Change to reading the
MAC area directly to the MAC address structure.

As a side product, we rename the read_srom_word to dm9000_read_eeprom
to bring it into line with the rest of the driver. No change is made
to the delay in this function, which will be dealt with in a later
patch.

Signed-off-by: Ben Dooks <[EMAIL PROTECTED]>


Index: linux-2.6.24-quilt3/drivers/net/dm9000.c
===
--- linux-2.6.24-quilt3.orig/drivers/net/dm9000.c
+++ linux-2.6.24-quilt3/drivers/net/dm9000.c
@@ -132,7 +132,6 @@ typedef struct board_info {
struct resource *data_req;
struct resource *irq_res;
 
-   unsigned char srom[128];
spinlock_t lock;
 
struct mii_if_info mii;
@@ -166,7 +165,8 @@ static irqreturn_t dm9000_interrupt(int,
 static int dm9000_phy_read(struct net_device *dev, int phyaddr_unsused, int 
reg);
 static void dm9000_phy_write(struct net_device *dev, int phyaddr_unused, int 
reg,
   int value);
-static u16 read_srom_word(board_info_t *, int);
+
+static void dm9000_read_eeprom(board_info_t *, int addr, unsigned char *to);
 static void dm9000_rx(struct net_device *);
 static void dm9000_hash_table(struct net_device *);
 
@@ -630,13 +630,9 @@ dm9000_probe(struct platform_device *pde
db->mii.mdio_read= dm9000_phy_read;
db->mii.mdio_write   = dm9000_phy_write;
 
-   /* Read SROM content */
-   for (i = 0; i < 64; i++)
-   ((u16 *) db->srom)[i] = read_srom_word(db, i);
-
-   /* Set Node Address */
-   for (i = 0; i < 6; i++)
-   ndev->dev_addr[i] = db->srom[i];
+   /* try reading the node address from the attached EEPROM */
+   for (i = 0; i < 6; i += 2)
+   dm9000_read_eeprom(db, i / 2, ndev->dev_addr+i);
 
if (!is_valid_ether_addr(ndev->dev_addr)) {
/* try reading from mac */
@@ -1001,17 +997,19 @@ dm9000_rx(struct net_device *dev)
 }
 
 /*
- *  Read a word data from SROM
+ *  Read a word data from EEPROM
  */
-static u16
-read_srom_word(board_info_t * db, int offset)
+static void
+dm9000_read_eeprom(board_info_t * db, int offset, unsigned char *to)
 {
iow(db, DM9000_EPAR, offset);
iow(db, DM9000_EPCR, EPCR_ERPRR);
mdelay(8);  /* according to the datasheet 200us should be 
enough,
   but it doesn't work */
iow(db, DM9000_EPCR, 0x0);
-   return (ior(db, DM9000_EPDRL) + (ior(db, DM9000_EPDRH) << 8));
+
+   to[0] = ior(db, DM9000_EPDRL);
+   to[1] = ior(db, DM9000_EPDRH);
 }
 
 #ifdef DM9000_PROGRAM_EEPROM

-- 
Ben ([EMAIL PROTECTED], http://www.fluff.org/)

  'a smiley only costs 4 bytes'
--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 24/24 for-2.6.25] DM9000: Show the MAC address source after printing MAC

2008-02-04 Thread Ben Dooks
Show whether the MAC address was read from the EEPROM or
the onboard PAR registers.

Signed-off-by: Ben Dooks <[EMAIL PROTECTED]>

Index: linux-2.6.24-quilt3/drivers/net/dm9000.c
===
--- linux-2.6.24-quilt3.orig/drivers/net/dm9000.c
+++ linux-2.6.24-quilt3/drivers/net/dm9000.c
@@ -509,6 +509,7 @@ dm9000_probe(struct platform_device *pde
struct dm9000_plat_data *pdata = pdev->dev.platform_data;
struct board_info *db;  /* Point a board information structure */
struct net_device *ndev;
+   const unsigned char *mac_src;
unsigned long base;
int ret = 0;
int iosize;
@@ -687,13 +688,16 @@ dm9000_probe(struct platform_device *pde
db->mii.mdio_read= dm9000_phy_read;
db->mii.mdio_write   = dm9000_phy_write;
 
+   mac_src = "eeprom";
+
/* try reading the node address from the attached EEPROM */
for (i = 0; i < 6; i += 2)
dm9000_read_eeprom(db, i / 2, ndev->dev_addr+i);
 
if (!is_valid_ether_addr(ndev->dev_addr)) {
/* try reading from mac */
-
+   
+   mac_src = "chip";
for (i = 0; i < 6; i++)
ndev->dev_addr[i] = ior(db, i+DM9000_PAR);
}
@@ -707,9 +711,9 @@ dm9000_probe(struct platform_device *pde
 
if (ret == 0) {
DECLARE_MAC_BUF(mac);
-   printk("%s: dm9000 at %p,%p IRQ %d MAC: %s\n",
+   printk("%s: dm9000 at %p,%p IRQ %d MAC: %s (%s)\n",
   ndev->name,  db->io_addr, db->io_data, ndev->irq,
-  print_mac(mac, ndev->dev_addr));
+  print_mac(mac, ndev->dev_addr), mac_src);
}
return 0;
 

-- 
Ben ([EMAIL PROTECTED], http://www.fluff.org/)

  'a smiley only costs 4 bytes'
--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 18/24 for-2.6.25] DM9000: Fix delays used by EEPROM read and write

2008-02-04 Thread Ben Dooks
The code was using a delay of 8ms, when it should have been
using the EEPROM status flag from the device to indicate the
EEPROM transaction had finished.

Signed-off-by: Ben Dooks <[EMAIL PROTECTED]>

Index: linux-2.6.24-quilt3/drivers/net/dm9000.c
===
--- linux-2.6.24-quilt3.orig/drivers/net/dm9000.c
+++ linux-2.6.24-quilt3/drivers/net/dm9000.c
@@ -1051,6 +1051,50 @@ dm9000_rx(struct net_device *dev)
} while (rxbyte == DM9000_PKT_RDY);
 }
 
+static unsigned int
+dm9000_read_locked(board_info_t *db, int reg)
+{
+   unsigned long flags;
+   unsigned int ret;
+
+   spin_lock_irqsave(&db->lock, flags);
+   ret = ior(db, reg);
+   spin_unlock_irqrestore(&db->lock, flags);
+
+   return ret;
+}
+
+static int dm9000_wait_eeprom(board_info_t *db)
+{
+   unsigned int status;
+   int timeout = 8;/* wait max 8msec */
+
+   /* The DM9000 data sheets say we should be able to
+* poll the ERRE bit in EPCR to wait for the EEPROM
+* operation. From testing several chips, this bit
+* does not seem to work. 
+*
+* We attempt to use the bit, but fall back to the
+* timeout (which is why we do not return an error
+* on expiry) to say that the EEPROM operation has
+* completed.
+*/
+
+   while (1) {
+   status = dm9000_read_locked(db, DM9000_EPCR);
+
+   if ((status & EPCR_ERRE) == 0)
+   break;
+
+   if (timeout-- < 0) {
+   dev_dbg(db->dev, "timeout waiting EEPROM\n");
+   break;
+   }
+   }
+
+   return 0;
+}
+
 /*
  *  Read a word data from EEPROM
  */
@@ -1068,8 +1112,10 @@ dm9000_read_eeprom(board_info_t *db, int
 
spin_unlock_irqrestore(&db->lock, flags);
 
-   mdelay(8);  /* according to the datasheet 200us should be 
enough,
-  but it doesn't work */
+   dm9000_wait_eeprom(db);
+
+   /* delay for at-least 150uS */
+   msleep(1);
 
spin_lock_irqsave(&db->lock, flags);
 
@@ -1100,7 +1146,9 @@ dm9000_write_eeprom(board_info_t *db, in
iow(db, DM9000_EPCR, EPCR_WEP | EPCR_ERPRW);
spin_unlock_irqrestore(&db->lock, flags);
 
-   mdelay(8);  /* same shit */
+   dm9000_wait_eeprom(db);
+
+   mdelay(1);  /* wait at least 150uS to clear */
 
spin_lock_irqsave(&db->lock, flags);
iow(db, DM9000_EPCR, 0);

-- 
Ben ([EMAIL PROTECTED], http://www.fluff.org/)

  'a smiley only costs 4 bytes'
--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 02/24 for-2.6.25] DM9000: Add platform data to specify external phy Patch from: Laurent Pinchart

2008-02-04 Thread Ben Dooks
This patch adds a flag to the DM9000 platform data which, when set,
configures the device to use an external PHY.

Signed-off-by: Laurent Pinchart <[EMAIL PROTECTED]>
Signed-off-by: Ben Dooks <[EMAIL PROTECTED]>

Index: linux-2.6.24-git5-dm9k/drivers/net/dm9000.c
===
--- linux-2.6.24-git5-dm9k.orig/drivers/net/dm9000.c
+++ linux-2.6.24-git5-dm9k/drivers/net/dm9000.c
@@ -137,6 +137,7 @@ typedef struct board_info {
u16 dbug_cnt;
u8 io_mode; /* 0:word, 2:byte */
u8 phy_addr;
+   unsigned int flags;
 
void (*inblk)(void __iomem *port, void *data, int length);
void (*outblk)(void __iomem *port, void *data, int length);
@@ -525,6 +526,8 @@ dm9000_probe(struct platform_device *pde
 
if (pdata->dumpblk != NULL)
db->dumpblk = pdata->dumpblk;
+
+   db->flags = pdata->flags;
}
 
dm9000_reset(db);
@@ -665,6 +668,9 @@ dm9000_init_dm9000(struct net_device *de
iow(db, DM9000_GPCR, GPCR_GEP_CNTL);/* Let GPIO0 output */
iow(db, DM9000_GPR, 0); /* Enable PHY */
 
+   if (db->flags & DM9000_PLATF_EXT_PHY)
+   iow(db, DM9000_NCR, NCR_EXT_PHY);
+
/* Program operating register */
iow(db, DM9000_TCR, 0); /* TX Polling clear */
iow(db, DM9000_BPTR, 0x3f); /* Less 3Kb, 200us */
Index: linux-2.6.24-git5-dm9k/include/linux/dm9000.h
===
--- linux-2.6.24-git5-dm9k.orig/include/linux/dm9000.h
+++ linux-2.6.24-git5-dm9k/include/linux/dm9000.h
@@ -19,6 +19,7 @@
 #define DM9000_PLATF_8BITONLY  (0x0001)
 #define DM9000_PLATF_16BITONLY (0x0002)
 #define DM9000_PLATF_32BITONLY (0x0004)
+#define DM9000_PLATF_EXT_PHY   (0x0008)
 
 /* platfrom data for platfrom device structure's platfrom_data field */
 

-- 
Ben ([EMAIL PROTECTED], http://www.fluff.org/)

  'a smiley only costs 4 bytes'
--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 20/24 for-2.6.25] DM9000: Remove redudant use of "& 0xff"

2008-02-04 Thread Ben Dooks
The writing of the data should implicitly truncate
the data to 8bits, so do not bother with the ands
in the code.

Signed-off-by: Ben Dooks <[EMAIL PROTECTED]>

Index: linux-2.6.24-quilt3/drivers/net/dm9000.c
===
--- linux-2.6.24-quilt3.orig/drivers/net/dm9000.c
+++ linux-2.6.24-quilt3/drivers/net/dm9000.c
@@ -817,8 +817,8 @@ dm9000_start_xmit(struct sk_buff *skb, s
/* TX control: First packet immediately send, second packet queue */
if (db->tx_pkt_cnt == 1) {
/* Set TX length to DM9000 */
-   iow(db, DM9000_TXPLL, skb->len & 0xff);
-   iow(db, DM9000_TXPLH, (skb->len >> 8) & 0xff);
+   iow(db, DM9000_TXPLL, skb->len);
+   iow(db, DM9000_TXPLH, skb->len >> 8);
 
/* Issue TX polling command */
iow(db, DM9000_TCR, TCR_TXREQ); /* Cleared after TX complete */
@@ -893,8 +893,8 @@ dm9000_tx_done(struct net_device *dev, b
 
/* Queue packet check & send */
if (db->tx_pkt_cnt > 0) {
-   iow(db, DM9000_TXPLL, db->queue_pkt_len & 0xff);
-   iow(db, DM9000_TXPLH, (db->queue_pkt_len >> 8) & 0xff);
+   iow(db, DM9000_TXPLL, db->queue_pkt_len);
+   iow(db, DM9000_TXPLH, db->queue_pkt_len >> 8);
iow(db, DM9000_TCR, TCR_TXREQ);
dev->trans_start = jiffies;
}
@@ -1278,8 +1278,8 @@ dm9000_phy_write(struct net_device *dev,
iow(db, DM9000_EPAR, DM9000_PHY | reg);
 
/* Fill the written data into REG_0D & REG_0E */
-   iow(db, DM9000_EPDRL, (value & 0xff));
-   iow(db, DM9000_EPDRH, ((value >> 8) & 0xff));
+   iow(db, DM9000_EPDRL, value);
+   iow(db, DM9000_EPDRH, value >> 8);
 
iow(db, DM9000_EPCR, 0xa);  /* Issue phyxcer write command */
 

-- 
Ben ([EMAIL PROTECTED], http://www.fluff.org/)

  'a smiley only costs 4 bytes'
--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 19/24 for-2.6.25] DM9000: Remove cal_CRC() and use ether_crc_le instead

2008-02-04 Thread Ben Dooks
Remove the cal_CRC as this is basically wrappering the
ether_crc_le function, and is only being used by the
multicast hash table functions.

Signed-off-by: Ben Dooks <[EMAIL PROTECTED]>

Index: linux-2.6.24-quilt3/drivers/net/dm9000.c
===
--- linux-2.6.24-quilt3.orig/drivers/net/dm9000.c
+++ linux-2.6.24-quilt3/drivers/net/dm9000.c
@@ -1158,24 +1158,6 @@ dm9000_write_eeprom(board_info_t *db, in
 }
 
 /*
- *  Calculate the CRC valude of the Rx packet
- *  flag = 1 : return the reverse CRC (for the received packet CRC)
- * 0 : return the normal CRC (for Hash Table index)
- */
-
-static unsigned long
-cal_CRC(unsigned char *Data, unsigned int Len, u8 flag)
-{
-
-   u32 crc = ether_crc_le(Len, Data);
-
-   if (flag)
-   return ~crc;
-
-   return crc;
-}
-
-/*
  *  Set DM9000 multicast address
  */
 static void
@@ -1184,15 +1166,16 @@ dm9000_hash_table(struct net_device *dev
board_info_t *db = (board_info_t *) dev->priv;
struct dev_mc_list *mcptr = dev->mc_list;
int mc_cnt = dev->mc_count;
+   int i, oft;
u32 hash_val;
-   u16 i, oft, hash_table[4];
+   u16 hash_table[4];
unsigned long flags;
 
dm9000_dbg(db, 1, "entering %s\n", __func__);
 
-   spin_lock_irqsave(&db->lock,flags);
+   spin_lock_irqsave(&db->lock, flags);
 
-   for (i = 0, oft = 0x10; i < 6; i++, oft++)
+   for (i = 0, oft = DM9000_PAR; i < 6; i++, oft++)
iow(db, oft, dev->dev_addr[i]);
 
/* Clear Hash Table */
@@ -1204,17 +1187,17 @@ dm9000_hash_table(struct net_device *dev
 
/* the multicast address in Hash Table : 64 bits */
for (i = 0; i < mc_cnt; i++, mcptr = mcptr->next) {
-   hash_val = cal_CRC((char *) mcptr->dmi_addr, 6, 0) & 0x3f;
+   hash_val = ether_crc_le(6, mcptr->dmi_addr) & 0x3f;
hash_table[hash_val / 16] |= (u16) 1 << (hash_val % 16);
}
 
/* Write the hash table to MAC MD table */
-   for (i = 0, oft = 0x16; i < 4; i++) {
-   iow(db, oft++, hash_table[i] & 0xff);
-   iow(db, oft++, (hash_table[i] >> 8) & 0xff);
+   for (i = 0, oft = DM9000_MAR; i < 4; i++) {
+   iow(db, oft++, hash_table[i]);
+   iow(db, oft++, hash_table[i] >> 8);
}
 
-   spin_unlock_irqrestore(&db->lock,flags);
+   spin_unlock_irqrestore(&db->lock, flags);
 }
 
 

-- 
Ben ([EMAIL PROTECTED], http://www.fluff.org/)

  'a smiley only costs 4 bytes'
--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 06/24 for-2.6.25] DM9000: Remove old timer based poll routines

2008-02-04 Thread Ben Dooks
Remove the timer based MII phy polling, as this is
currently broken with the new EEPROM code that now
uses mutexes to protect the phy access.

This will need to be replaced in the future by some
form of mutex safe mechanism for reading the MII
phy status.

The replacement has not been done here as changing
this patch, which is early in the sequence has quite
a knock-on effect. Once this series is merged, then
a new presentation of an patch to poll the MII link
status can be added.

Signed-off-by: Ben Dooks <[EMAIL PROTECTED]>

Index: linux-2.6.24-quilt2/drivers/net/dm9000.c
===
--- linux-2.6.24-quilt2.orig/drivers/net/dm9000.c
+++ linux-2.6.24-quilt2/drivers/net/dm9000.c
@@ -81,8 +81,6 @@
 #define CARDNAME "dm9000"
 #define PFX CARDNAME ": "
 
-#define DM9000_TIMER_WUT  jiffies+(HZ*2)   /* timer wakeup time : 2 second 
*/
-
 #ifdef CONFIG_BLACKFIN
 #define readsb insb
 #define readsw insw
@@ -131,7 +129,6 @@ typedef struct board_info {
struct resource *data_req;
struct resource *irq_res;
 
-   struct timer_list timer;
unsigned char srom[128];
spinlock_t lock;
 
@@ -154,8 +151,6 @@ static int dm9000_open(struct net_device
 static int dm9000_start_xmit(struct sk_buff *, struct net_device *);
 static int dm9000_stop(struct net_device *);
 
-
-static void dm9000_timer(unsigned long);
 static void dm9000_init_dm9000(struct net_device *);
 
 static irqreturn_t dm9000_interrupt(int, void *);
@@ -638,13 +633,6 @@ dm9000_open(struct net_device *dev)
/* Init driver variable */
db->dbug_cnt = 0;
 
-   /* set and active a timer process */
-   init_timer(&db->timer);
-   db->timer.expires  = DM9000_TIMER_WUT;
-   db->timer.data = (unsigned long) dev;
-   db->timer.function = &dm9000_timer;
-   add_timer(&db->timer);
-
mii_check_media(&db->mii, netif_msg_link(db), 1);
netif_start_queue(dev);
 
@@ -766,9 +754,6 @@ dm9000_stop(struct net_device *ndev)
 
dm9000_dbg(db, 1, "entering %s\n", __func__);
 
-   /* deleted timer */
-   del_timer(&db->timer);
-
netif_stop_queue(ndev);
netif_carrier_off(ndev);
 
@@ -849,25 +834,6 @@ dm9000_interrupt(int irq, void *dev_id)
return IRQ_HANDLED;
 }
 
-/*
- *  A periodic timer routine
- *  Dynamic media sense, allocated Rx buffer...
- */
-static void
-dm9000_timer(unsigned long data)
-{
-   struct net_device *dev = (struct net_device *) data;
-   board_info_t *db = (board_info_t *) dev->priv;
-
-   dm9000_dbg(db, 3, "entering %s\n", __func__);
-
-   mii_check_media(&db->mii, netif_msg_link(db), 0);
-
-   /* Set timer again */
-   db->timer.expires = DM9000_TIMER_WUT;
-   add_timer(&db->timer);
-}
-
 struct dm9000_rxhdr {
u8  RxPktReady;
u8  RxStatus;

-- 
Ben ([EMAIL PROTECTED], http://www.fluff.org/)

  'a smiley only costs 4 bytes'
--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 07/24 for-2.6.25] DM9000: Add initial ethtool support

2008-02-04 Thread Ben Dooks
Add support for ethtool operations for the DM9000.

Signed-off-by: Ben Dooks <[EMAIL PROTECTED]>

Index: linux-2.6.24-quilt3/drivers/net/dm9000.c
===
--- linux-2.6.24-quilt3.orig/drivers/net/dm9000.c
+++ linux-2.6.24-quilt3/drivers/net/dm9000.c
@@ -63,6 +63,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -80,6 +81,7 @@
 
 #define CARDNAME "dm9000"
 #define PFX CARDNAME ": "
+#define DRV_VERSION"1.30"
 
 #ifdef CONFIG_BLACKFIN
 #define readsb insb
@@ -145,6 +147,11 @@ typedef struct board_info {
}   \
 } while (0)
 
+static inline board_info_t *to_dm9000_board(struct net_device *dev)
+{
+   return dev->priv;
+}
+
 /* function declaration - */
 static int dm9000_probe(struct platform_device *);
 static int dm9000_open(struct net_device *);
@@ -342,6 +349,64 @@ static void dm9000_poll_controller(struc
 }
 #endif
 
+/* ethtool ops */
+
+static void dm9000_get_drvinfo(struct net_device *dev,
+  struct ethtool_drvinfo *info)
+{
+   board_info_t *dm = to_dm9000_board(dev);
+
+   strcpy(info->driver, CARDNAME);
+   strcpy(info->version, DRV_VERSION);
+   strcpy(info->bus_info, to_platform_device(dm->dev)->name);
+}
+
+static int dm9000_get_settings(struct net_device *dev, struct ethtool_cmd *cmd)
+{
+   board_info_t *dm = to_dm9000_board(dev);
+   unsigned long flags;
+
+   spin_lock_irqsave(&dm->lock, flags);
+   mii_ethtool_gset(&dm->mii, cmd);
+   spin_lock_irqsave(&dm->lock, flags);
+
+   return 0;
+}
+
+static int dm9000_set_settings(struct net_device *dev, struct ethtool_cmd *cmd)
+{
+   board_info_t *dm = to_dm9000_board(dev);
+   unsigned long flags;
+   int rc;
+
+   spin_lock_irqsave(&dm->lock, flags);
+   rc = mii_ethtool_sset(&dm->mii, cmd);
+   spin_lock_irqsave(&dm->lock, flags);
+
+   return rc;
+}
+
+static int dm9000_nway_reset(struct net_device *dev)
+{
+   board_info_t *dm = to_dm9000_board(dev);
+   return mii_nway_restart(&dm->mii);
+}
+
+static u32 dm9000_get_link(struct net_device *dev)
+{
+   board_info_t *dm = to_dm9000_board(dev);
+   return mii_link_ok(&dm->mii);
+}
+
+static const struct ethtool_ops dm9000_ethtool_ops = {
+   .get_drvinfo= dm9000_get_drvinfo,
+   .get_settings   = dm9000_get_settings,
+   .set_settings   = dm9000_set_settings,
+   .nway_reset = dm9000_nway_reset,
+   .get_link   = dm9000_get_link,
+};
+
+
 /* dm9000_release_board
  *
  * release a board, and any mapped resources
@@ -546,6 +611,8 @@ dm9000_probe(struct platform_device *pde
ndev->watchdog_timeo = msecs_to_jiffies(watchdog);
ndev->stop   = &dm9000_stop;
ndev->set_multicast_list = &dm9000_hash_table;
+   ndev->ethtool_ops= &dm9000_ethtool_ops;
+
 #ifdef CONFIG_NET_POLL_CONTROLLER
ndev->poll_controller= &dm9000_poll_controller;
 #endif
@@ -1170,7 +1237,7 @@ static struct platform_driver dm9000_dri
 static int __init
 dm9000_init(void)
 {
-   printk(KERN_INFO "%s Ethernet Driver\n", CARDNAME);
+   printk(KERN_INFO "%s Ethernet Driver, V%s\n", CARDNAME, DRV_VERSION);
 
return platform_driver_register(&dm9000_driver);/* search board 
and register */
 }

-- 
Ben ([EMAIL PROTECTED], http://www.fluff.org/)

  'a smiley only costs 4 bytes'
--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 23/24 for-2.6.25] DM9000: Update retry count whilst identifying chip

2008-02-04 Thread Ben Dooks
Reading the ID register does not always return the correct ID
from the device, so we retry several times to see if we get
a correct value.

These failures seem to be excaserbated by the speed of the
access to the chip (possibly time between issuing the address
and then the data cycle).

Signed-off-by: Ben Dooks <[EMAIL PROTECTED]>

Index: linux-2.6.24-quilt3/drivers/net/dm9000.c
===
--- linux-2.6.24-quilt3.orig/drivers/net/dm9000.c
+++ linux-2.6.24-quilt3/drivers/net/dm9000.c
@@ -643,7 +643,7 @@ dm9000_probe(struct platform_device *pde
dm9000_reset(db);
 
/* try two times, DM9000 sometimes gets the first read wrong */
-   for (i = 0; i < 2; i++) {
+   for (i = 0; i < 8; i++) {
id_val  = ior(db, DM9000_VIDL);
id_val |= (u32)ior(db, DM9000_VIDH) << 8;
id_val |= (u32)ior(db, DM9000_PIDL) << 16;

-- 
Ben ([EMAIL PROTECTED], http://www.fluff.org/)

  'a smiley only costs 4 bytes'
--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 08/24 for-2.6.25] DM9000: Do not sleep with spinlock and IRQs held

2008-02-04 Thread Ben Dooks
The phy read and write routines call udelay() with the board
lock held, and with the posibility of IRQs being disabled. Since
these delays can be up to 500usec, and are only required as we
have to save the chip's address register. 

To improve the behaviour, hold the lock whilst we are writing
and then restore the state before the delay and then repeat
the process once the delay has happened.

Signed-off-by: Ben Dooks <[EMAIL PROTECTED]>

Index: linux-2.6.24-quilt3/drivers/net/dm9000.c
===
--- linux-2.6.24-quilt3.orig/drivers/net/dm9000.c
+++ linux-2.6.24-quilt3/drivers/net/dm9000.c
@@ -1130,7 +1130,15 @@ dm9000_phy_read(struct net_device *dev, 
iow(db, DM9000_EPAR, DM9000_PHY | reg);
 
iow(db, DM9000_EPCR, 0xc);  /* Issue phyxcer read command */
+
+   writeb(reg_save, db->io_addr);
+   spin_unlock_irqrestore(&db->lock,flags);
+
udelay(100);/* Wait read complete */
+
+   spin_lock_irqsave(&db->lock,flags);
+   reg_save = readb(db->io_addr);
+
iow(db, DM9000_EPCR, 0x0);  /* Clear phyxcer read command */
 
/* The read data keeps on REG_0D & REG_0E */
@@ -1138,7 +1146,6 @@ dm9000_phy_read(struct net_device *dev, 
 
/* restore the previous address */
writeb(reg_save, db->io_addr);
-
spin_unlock_irqrestore(&db->lock,flags);
 
return ret;
@@ -1167,7 +1174,15 @@ dm9000_phy_write(struct net_device *dev,
iow(db, DM9000_EPDRH, ((value >> 8) & 0xff));
 
iow(db, DM9000_EPCR, 0xa);  /* Issue phyxcer write command */
+
+   writeb(reg_save, db->io_addr);
+   spin_unlock_irqrestore(&db->lock,flags);
+
udelay(500);/* Wait write complete */
+
+   spin_lock_irqsave(&db->lock,flags);
+   reg_save = readb(db->io_addr);
+
iow(db, DM9000_EPCR, 0x0);  /* Clear phyxcer write command */
 
/* restore the previous address */

-- 
Ben ([EMAIL PROTECTED], http://www.fluff.org/)

  'a smiley only costs 4 bytes'
--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 05/24 for-2.6.25] DM9000: Pass IRQ flags via platform resources

2008-02-04 Thread Ben Dooks
Use the flags in the IRQ resource to specify the type of
IRQ being requested, so that systems which do not have
level-based interrupts, or change the interrupt in some
other way can specify this without making an #ifdef mess
in the driver.

This is specifically designed to undo the change in commit
4e4fc05a2b6e7bd2e0facd96e0c18dceb34d9349 which hardwires the
type for everyone but blackfin to IRQT_RISING, which breaks
all a number of Simtec boards which use (and setup in the
bootloader) active low IRQs.

Note, although there where originally objections due to
the use of IORESOURCE_IRQ and IRQT_ flags not sharing the
same definition, at least  notes
these are the same.

Signed-off-by: Ben Dooks <[EMAIL PROTECTED]>
CC: Daniel Mack <[EMAIL PROTECTED]>
CC: Bryan Wu <[EMAIL PROTECTED]>
CC: Alex Landau <[EMAIL PROTECTED]>

Index: linux-2.6.24-quilt2/drivers/net/dm9000.c
===
--- linux-2.6.24-quilt2.orig/drivers/net/dm9000.c
+++ linux-2.6.24-quilt2/drivers/net/dm9000.c
@@ -90,9 +90,9 @@
 #define writesboutsb
 #define writeswoutsw
 #define writesloutsl
-#define DM9000_IRQ_FLAGS   (IRQF_SHARED | IRQF_TRIGGER_HIGH)
+#define DEFAULT_TRIGGER IRQF_TRIGGER_HIGH
 #else
-#define DM9000_IRQ_FLAGS   (IRQF_SHARED | IRQT_RISING)
+#define DEFAULT_TRIGGER (0)
 #endif
 
 /*
@@ -614,10 +614,21 @@ static int
 dm9000_open(struct net_device *dev)
 {
board_info_t *db = (board_info_t *) dev->priv;
+   unsigned long irqflags = db->irq_res->flags & IRQF_TRIGGER_MASK;
 
dev_dbg(db->dev, "entering %s\n", __func__);
 
-   if (request_irq(dev->irq, &dm9000_interrupt, DM9000_IRQ_FLAGS, 
dev->name, dev))
+   /* If there is no IRQ type specified, default to something that
+* may work, and tell the user that this is a problem */
+
+   if (irqflags == IRQF_TRIGGER_NONE) {
+   dev_warn(db->dev, "WARNING: no IRQ resource flags set.\n");
+   irqflags = DEFAULT_TRIGGER;
+   }
+   
+   irqflags |= IRQF_SHARED;
+
+   if (request_irq(dev->irq, &dm9000_interrupt, irqflags, dev->name, dev))
return -EAGAIN;
 
/* Initialize DM9000 board */

-- 
Ben ([EMAIL PROTECTED], http://www.fluff.org/)

  'a smiley only costs 4 bytes'
--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 11/24 for-2.6.25] DM9000: Add mutex to protect access

2008-02-04 Thread Ben Dooks
Add a mutex to serialise access to the chip functions from
entries such as the ethtool and the MII code. This should
reduce the amount of time the spinlock is held to protect
the address register. 

Signed-off-by: Ben Dooks <[EMAIL PROTECTED]>

Index: linux-2.6.24-quilt3/drivers/net/dm9000.c
===
--- linux-2.6.24-quilt3.orig/drivers/net/dm9000.c
+++ linux-2.6.24-quilt3/drivers/net/dm9000.c
@@ -102,6 +102,24 @@ static int watchdog = 5000;
 module_param(watchdog, int, 0400);
 MODULE_PARM_DESC(watchdog, "transmit timeout in milliseconds");
 
+/* DM9000 register address locking.
+ *
+ * The DM9000 uses an address register to control where data written
+ * to the data register goes. This means that the address register
+ * must be preserved over interrupts or similar calls.
+ *
+ * During interrupt and other critical calls, a spinlock is used to
+ * protect the system, but the calls themselves save the address
+ * in the address register in case they are interrupting another
+ * access to the device.
+ *
+ * For general accesses a lock is provided so that calls which are
+ * allowed to sleep are serialised so that the address register does
+ * not need to be saved. This lock also serves to serialise access
+ * to the EEPROM and PHY access registers which are shared between
+ * these two devices.
+ */
+
 /* Structure/enum declaration --- */
 typedef struct board_info {
 
@@ -132,6 +150,8 @@ typedef struct board_info {
struct resource *data_req;
struct resource *irq_res;
 
+   struct mutex addr_lock; /* phy and eeprom access lock */
+
spinlock_t lock;
 
struct mii_if_info mii;
@@ -365,26 +385,16 @@ static void dm9000_get_drvinfo(struct ne
 static int dm9000_get_settings(struct net_device *dev, struct ethtool_cmd *cmd)
 {
board_info_t *dm = to_dm9000_board(dev);
-   unsigned long flags;
 
-   spin_lock_irqsave(&dm->lock, flags);
mii_ethtool_gset(&dm->mii, cmd);
-   spin_lock_irqsave(&dm->lock, flags);
-
return 0;
 }
 
 static int dm9000_set_settings(struct net_device *dev, struct ethtool_cmd *cmd)
 {
board_info_t *dm = to_dm9000_board(dev);
-   unsigned long flags;
-   int rc;
-
-   spin_lock_irqsave(&dm->lock, flags);
-   rc = mii_ethtool_sset(&dm->mii, cmd);
-   spin_lock_irqsave(&dm->lock, flags);
 
-   return rc;
+   return mii_ethtool_sset(&dm->mii, cmd);
 }
 
 static int dm9000_nway_reset(struct net_device *dev)
@@ -475,6 +485,7 @@ dm9000_probe(struct platform_device *pde
db->dev = &pdev->dev;
 
spin_lock_init(&db->lock);
+   mutex_init(&db->addr_lock);
 
if (pdev->num_resources < 2) {
ret = -ENODEV;
@@ -1000,8 +1011,10 @@ dm9000_rx(struct net_device *dev)
  *  Read a word data from EEPROM
  */
 static void
-dm9000_read_eeprom(board_info_t * db, int offset, unsigned char *to)
+dm9000_read_eeprom(board_info_t *db, int offset, unsigned char *to)
 {
+   mutex_lock(&db->addr_lock);
+
iow(db, DM9000_EPAR, offset);
iow(db, DM9000_EPCR, EPCR_ERPRR);
mdelay(8);  /* according to the datasheet 200us should be 
enough,
@@ -1010,6 +1023,8 @@ dm9000_read_eeprom(board_info_t * db, in
 
to[0] = ior(db, DM9000_EPDRL);
to[1] = ior(db, DM9000_EPDRH);
+
+   mutex_unlock(&db->addr_lock);
 }
 
 #ifdef DM9000_PROGRAM_EEPROM
@@ -1019,12 +1034,16 @@ dm9000_read_eeprom(board_info_t * db, in
 static void
 write_srom_word(board_info_t * db, int offset, u16 val)
 {
+   mutex_lock(&db->addr_lock);
+
iow(db, DM9000_EPAR, offset);
iow(db, DM9000_EPDRH, ((val >> 8) & 0xff));
iow(db, DM9000_EPDRL, (val & 0xff));
iow(db, DM9000_EPCR, EPCR_WEP | EPCR_ERPRW);
mdelay(8);  /* same shit */
iow(db, DM9000_EPCR, 0);
+
+   mutex_unlock(&db->addr_lock);
 }
 
 /*
@@ -1132,6 +1151,8 @@ dm9000_phy_read(struct net_device *dev, 
unsigned int reg_save;
int ret;
 
+   mutex_lock(&db->addr_lock);
+
spin_lock_irqsave(&db->lock,flags);
 
/* Save previous register address */
@@ -1159,6 +1180,7 @@ dm9000_phy_read(struct net_device *dev, 
writeb(reg_save, db->io_addr);
spin_unlock_irqrestore(&db->lock,flags);
 
+   mutex_unlock(&db->addr_lock);
return ret;
 }
 
@@ -1172,6 +1194,8 @@ dm9000_phy_write(struct net_device *dev,
unsigned long flags;
unsigned long reg_save;
 
+   mutex_lock(&db->addr_lock);
+
spin_lock_irqsave(&db->lock,flags);
 
/* Save previous register address */
@@ -1187,7 +1211,7 @@ dm9000_phy_write(struct net_device *dev,
iow(db, DM9000_EPCR, 0xa);  /* Issue phyxcer writ

[PATCH 09/24 for-2.6.25] DM9000: Use msleep() instead of udelay()

2008-02-04 Thread Ben Dooks
We can use sleeping functions when reading and writing the
PHY registers, so let us sleep instead of busy waiting for
the PHY.

Note, this also fixes a bug reading the PHY where only 100uS
was being used instead of 150uS

Signed-off-by: Ben Dooks <[EMAIL PROTECTED]>

Index: linux-2.6.24-quilt3/drivers/net/dm9000.c
===
--- linux-2.6.24-quilt3.orig/drivers/net/dm9000.c
+++ linux-2.6.24-quilt3/drivers/net/dm9000.c
@@ -116,6 +116,7 @@ typedef struct board_info {
u8 io_mode; /* 0:word, 2:byte */
u8 phy_addr;
unsigned int flags;
+   unsigned int in_suspend :1;
 
int debug_level;
 
@@ -,6 +1112,18 @@ dm9000_hash_table(struct net_device *dev
 
 
 /*
+ * Sleep, either by using msleep() or if we are suspending, then
+ * use mdelay() to sleep.
+ */
+static void dm9000_msleep(board_info_t *db, unsigned int ms)
+{
+   if (db->in_suspend)
+   mdelay(ms);
+   else
+   msleep(ms);
+}
+
+/*
  *   Read a word from phyxcer
  */
 static int
@@ -1134,7 +1147,7 @@ dm9000_phy_read(struct net_device *dev, 
writeb(reg_save, db->io_addr);
spin_unlock_irqrestore(&db->lock,flags);
 
-   udelay(100);/* Wait read complete */
+   dm9000_msleep(db, 1);   /* Wait read complete */
 
spin_lock_irqsave(&db->lock,flags);
reg_save = readb(db->io_addr);
@@ -1178,7 +1191,7 @@ dm9000_phy_write(struct net_device *dev,
writeb(reg_save, db->io_addr);
spin_unlock_irqrestore(&db->lock,flags);
 
-   udelay(500);/* Wait write complete */
+   dm9000_msleep(db, 1);   /* Wait write complete */
 
spin_lock_irqsave(&db->lock,flags);
reg_save = readb(db->io_addr);
@@ -1195,8 +1208,12 @@ static int
 dm9000_drv_suspend(struct platform_device *dev, pm_message_t state)
 {
struct net_device *ndev = platform_get_drvdata(dev);
+   board_info_t *db;
 
if (ndev) {
+   db = (board_info_t *) ndev->priv;
+   db->in_suspend = 1;
+
if (netif_running(ndev)) {
netif_device_detach(ndev);
dm9000_shutdown(ndev);
@@ -1219,6 +1236,8 @@ dm9000_drv_resume(struct platform_device
 
netif_device_attach(ndev);
}
+
+   db->in_suspend = 0;
}
return 0;
 }

-- 
Ben ([EMAIL PROTECTED], http://www.fluff.org/)

  'a smiley only costs 4 bytes'
--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 17/24 for-2.6.25] DM9000: Use netif_msg to enable debugging options

2008-02-04 Thread Ben Dooks
Use the netif_msg_*() macros to enable the debugging based
on the board's msg_enable field. The output still goes via
the dev_dbg() macros, so will be tagged and output as 
appropriate.

Signed-off-by: Ben Dooks <[EMAIL PROTECTED]>

Index: linux-2.6.24-quilt3/drivers/net/dm9000.c
===
--- linux-2.6.24-quilt3.orig/drivers/net/dm9000.c
+++ linux-2.6.24-quilt3/drivers/net/dm9000.c
@@ -714,7 +714,8 @@ dm9000_open(struct net_device *dev)
board_info_t *db = (board_info_t *) dev->priv;
unsigned long irqflags = db->irq_res->flags & IRQF_TRIGGER_MASK;
 
-   dev_dbg(db->dev, "entering %s\n", __func__);
+   if (netif_msg_ifup(db))
+   dev_dbg(db->dev, "enabling %s\n", dev->name);
 
/* If there is no IRQ type specified, default to something that
 * may work, and tell the user that this is a problem */
@@ -858,7 +859,8 @@ dm9000_stop(struct net_device *ndev)
 {
board_info_t *db = (board_info_t *) ndev->priv;
 
-   dm9000_dbg(db, 1, "entering %s\n", __func__);
+   if (netif_msg_ifdown(db))
+   dev_dbg(db->dev, "shutting down %s\n", ndev->name);
 
netif_stop_queue(ndev);
netif_carrier_off(ndev);
@@ -886,6 +888,9 @@ dm9000_tx_done(struct net_device *dev, b
db->tx_pkt_cnt--;
dev->stats.tx_packets++;
 
+   if (netif_msg_tx_done(db))
+   dev_dbg(db->dev, "tx done, NSR %02x\n", tx_status);
+
/* Queue packet check & send */
if (db->tx_pkt_cnt > 0) {
iow(db, DM9000_TXPLL, db->queue_pkt_len & 0xff);
@@ -921,6 +926,9 @@ dm9000_interrupt(int irq, void *dev_id)
int_status = ior(db, DM9000_ISR);   /* Got ISR */
iow(db, DM9000_ISR, int_status);/* Clear ISR status */
 
+   if (netif_msg_intr(db))
+   dev_dbg(db->dev, "interrupt status %02x\n", int_status);
+
/* Received the coming packet */
if (int_status & ISR_PRS)
dm9000_rx(dev);
@@ -985,10 +993,15 @@ dm9000_rx(struct net_device *dev)
 
RxLen = le16_to_cpu(rxhdr.RxLen);
 
+   if (netif_msg_rx_status(db))
+   dev_dbg(db->dev, "RX: status %02x, length %04x\n",
+   rxhdr.RxStatus, RxLen);
+
/* Packet Status check */
if (RxLen < 0x40) {
GoodPacket = false;
-   dev_dbg(db->dev, "Bad Packet received (runt)\n");
+   if (netif_msg_rx_err(db))
+   dev_dbg(db->dev, "RX: Bad Packet (runt)\n");
}
 
if (RxLen > DM9000_PKT_MAX) {
@@ -998,15 +1011,18 @@ dm9000_rx(struct net_device *dev)
if (rxhdr.RxStatus & 0xbf) {
GoodPacket = false;
if (rxhdr.RxStatus & 0x01) {
-   dev_dbg(db->dev, "fifo error\n");
+   if (netif_msg_rx_err(db))
+   dev_dbg(db->dev, "fifo error\n");
dev->stats.rx_fifo_errors++;
}
if (rxhdr.RxStatus & 0x02) {
-   dev_dbg(db->dev, "crc error\n");
+   if (netif_msg_rx_err(db))
+   dev_dbg(db->dev, "crc error\n");
dev->stats.rx_crc_errors++;
}
if (rxhdr.RxStatus & 0x80) {
-   dev_dbg(db->dev, "length error\n");
+   if (netif_msg_rx_err(db))
+   dev_dbg(db->dev, "length error\n");
dev->stats.rx_length_errors++;
}
}

-- 
Ben ([EMAIL PROTECTED], http://www.fluff.org/)

  'a smiley only costs 4 bytes'
--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 22/24 for-2.6.25] DM9000: Add support for MII ioctl() calls

2008-02-04 Thread Ben Dooks
Add entry to handle the MII ioctl() calls via the
generic_mii_ioctl call.

Signed-off-by: Ben Dooks <[EMAIL PROTECTED]>

Index: linux-2.6.24-quilt3/drivers/net/dm9000.c
===
--- linux-2.6.24-quilt3.orig/drivers/net/dm9000.c
+++ linux-2.6.24-quilt3/drivers/net/dm9000.c
@@ -142,6 +142,7 @@ static int dm9000_probe(struct platform_
 static int dm9000_open(struct net_device *);
 static int dm9000_start_xmit(struct sk_buff *, struct net_device *);
 static int dm9000_stop(struct net_device *);
+static int dm9000_ioctl(struct net_device *dev, struct ifreq *req, int cmd);
 
 static void dm9000_init_dm9000(struct net_device *);
 
@@ -332,6 +333,16 @@ static void dm9000_poll_controller(struc
 }
 #endif
 
+static int dm9000_ioctl(struct net_device *dev, struct ifreq *req, int cmd)
+{
+   board_info_t *dm = to_dm9000_board(dev);
+
+   if (!netif_running(dev))
+   return -EINVAL;
+
+   return generic_mii_ioctl(&dm->mii, if_mii(req), cmd, NULL);
+}
+
 /* ethtool ops */
 
 static void dm9000_get_drvinfo(struct net_device *dev,
@@ -661,6 +672,7 @@ dm9000_probe(struct platform_device *pde
ndev->stop   = &dm9000_stop;
ndev->set_multicast_list = &dm9000_hash_table;
ndev->ethtool_ops= &dm9000_ethtool_ops;
+   ndev->do_ioctl   = &dm9000_ioctl;
 
 #ifdef CONFIG_NET_POLL_CONTROLLER
ndev->poll_controller= &dm9000_poll_controller;

-- 
Ben ([EMAIL PROTECTED], http://www.fluff.org/)

  'a smiley only costs 4 bytes'
--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 04/24 for-2.6.25] DM9000 update debugging macros to use debug level

2008-02-04 Thread Ben Dooks
Change the debug macros to use the compiler to elide any
unnecessary debug level, and to allow device configurable
debug control.

Signed-off-by: Ben Dooks <[EMAIL PROTECTED]>

Index: linux-2.6.24-git5-dm9k/drivers/net/Kconfig
===
--- linux-2.6.24-git5-dm9k.orig/drivers/net/Kconfig
+++ linux-2.6.24-git5-dm9k/drivers/net/Kconfig
@@ -912,6 +912,14 @@ config DM9000
  To compile this driver as a module, choose M here.  The module
  will be called dm9000.
 
+config DM9000_DEBUGLEVEL
+   int "DM9000 maximum debug level"
+   depends on DM9000
+   default 4
+   help
+ The maximum level of debugging code compiled into the DM9000
+ driver.
+
 config SMC911X
tristate "SMSC LAN911[5678] support"
select CRC32
Index: linux-2.6.24-git5-dm9k/drivers/net/dm9000.c
===
--- linux-2.6.24-git5-dm9k.orig/drivers/net/dm9000.c
+++ linux-2.6.24-git5-dm9k/drivers/net/dm9000.c
@@ -83,28 +83,6 @@
 
 #define DM9000_TIMER_WUT  jiffies+(HZ*2)   /* timer wakeup time : 2 second 
*/
 
-#define DM9000_DEBUG 0
-
-#if DM9000_DEBUG > 2
-#define PRINTK3(args...)  printk(CARDNAME ": " args)
-#else
-#define PRINTK3(args...)  do { } while(0)
-#endif
-
-#if DM9000_DEBUG > 1
-#define PRINTK2(args...)  printk(CARDNAME ": " args)
-#else
-#define PRINTK2(args...)  do { } while(0)
-#endif
-
-#if DM9000_DEBUG > 0
-#define PRINTK1(args...)  printk(CARDNAME ": " args)
-#define PRINTK(args...)   printk(CARDNAME ": " args)
-#else
-#define PRINTK1(args...)  do { } while(0)
-#define PRINTK(args...)   printk(KERN_DEBUG args)
-#endif
-
 #ifdef CONFIG_BLACKFIN
 #define readsb insb
 #define readsw insw
@@ -139,6 +117,8 @@ typedef struct board_info {
u8 phy_addr;
unsigned int flags;
 
+   int debug_level;
+
void (*inblk)(void __iomem *port, void *data, int length);
void (*outblk)(void __iomem *port, void *data, int length);
void (*dumpblk)(void __iomem *port, int length);
@@ -159,6 +139,15 @@ typedef struct board_info {
u32 msg_enable;
 } board_info_t;
 
+/* debug code */
+
+#define dm9000_dbg(db, lev, msg...) do {   \
+   if ((lev) < CONFIG_DM9000_DEBUGLEVEL && \
+   (lev) < db->debug_level) {  \
+   dev_dbg(db->dev, msg);  \
+   }   \
+} while (0)
+
 /* function declaration - */
 static int dm9000_probe(struct platform_device *);
 static int dm9000_open(struct net_device *);
@@ -659,7 +648,7 @@ dm9000_init_dm9000(struct net_device *de
 {
board_info_t *db = (board_info_t *) dev->priv;
 
-   PRINTK1("entering %s\n",__FUNCTION__);
+   dm9000_dbg(db, 1, "entering %s\n", __func__);
 
/* I/O mode */
db->io_mode = ior(db, DM9000_ISR) >> 6; /* ISR bit7:6 keeps I/O mode */
@@ -705,7 +694,7 @@ dm9000_start_xmit(struct sk_buff *skb, s
unsigned long flags;
board_info_t *db = (board_info_t *) dev->priv;
 
-   PRINTK3("dm9000_start_xmit\n");
+   dm9000_dbg(db, 3, "%s:\n", __func__);
 
if (db->tx_pkt_cnt > 1)
return 1;
@@ -764,7 +753,7 @@ dm9000_stop(struct net_device *ndev)
 {
board_info_t *db = (board_info_t *) ndev->priv;
 
-   PRINTK1("entering %s\n",__FUNCTION__);
+   dm9000_dbg(db, 1, "entering %s\n", __func__);
 
/* deleted timer */
del_timer(&db->timer);
@@ -810,19 +799,14 @@ static irqreturn_t
 dm9000_interrupt(int irq, void *dev_id)
 {
struct net_device *dev = dev_id;
-   board_info_t *db;
+   board_info_t *db = (board_info_t *) dev->priv;
int int_status;
u8 reg_save;
 
-   PRINTK3("entering %s\n",__FUNCTION__);
-
-   if (!dev) {
-   PRINTK1("dm9000_interrupt() without DEVICE arg\n");
-   return IRQ_HANDLED;
-   }
+   dm9000_dbg(db, 3, "entering %s\n", __func__);
 
/* A real interrupt coming */
-   db = (board_info_t *) dev->priv;
+
spin_lock(&db->lock);
 
/* Save previous register address */
@@ -864,7 +848,7 @@ dm9000_timer(unsigned long data)
struct net_device *dev = (struct net_device *) data;
board_info_t *db = (board_info_t *) dev->priv;
 
-   PRINTK3("dm9000_timer()\n");
+   dm9000_dbg(db, 3, "entering %s\n", __func__);
 
mii_check_media(&db->mii, netif_msg_link(db), 0);
 
@@ -1049,7 +1033,7 @@ dm9000_hash_table(struct net_device *dev
u16 i, oft, hash_table[4];
unsigned long flags;
 
-   PRINTK2("dm9000_hash_table()\n");
+   dm9000

[PATCH 21/24 for-2.6.25] DM9000: Add platform flag for no attached EEPROM

2008-02-04 Thread Ben Dooks
Allow the platform data to specify to the DM9000 driver
that there is no posibility of an attached EEPROM on the
device, so default all reads to 0xff and ignore any
write operations.

Signed-off-by: Ben Dooks <[EMAIL PROTECTED]>

Index: linux-2.6.24-quilt3/drivers/net/dm9000.c
===
--- linux-2.6.24-quilt3.orig/drivers/net/dm9000.c
+++ linux-2.6.24-quilt3/drivers/net/dm9000.c
@@ -405,6 +405,9 @@ static int dm9000_get_eeprom(struct net_
if ((len & 1) != 0 || (offset & 1) != 0)
return -EINVAL;
 
+   if (dm->flags & DM9000_PLATF_NO_EEPROM)
+   return -ENOENT;
+
ee->magic = DM_EEPROM_MAGIC;
 
for (i = 0; i < len; i += 2)
@@ -426,6 +429,9 @@ static int dm9000_set_eeprom(struct net_
if ((len & 1) != 0 || (offset & 1) != 0)
return -EINVAL;
 
+   if (dm->flags & DM9000_PLATF_NO_EEPROM)
+   return -ENOENT;
+
if (ee->magic != DM_EEPROM_MAGIC)
return -EINVAL;
 
@@ -1103,6 +1109,12 @@ dm9000_read_eeprom(board_info_t *db, int
 {
unsigned long flags;
 
+   if (db->flags & DM9000_PLATF_NO_EEPROM) {
+   to[0] = 0xff;
+   to[1] = 0xff;
+   return;
+   }
+
mutex_lock(&db->addr_lock);
 
spin_lock_irqsave(&db->lock, flags);
@@ -1137,6 +1149,9 @@ dm9000_write_eeprom(board_info_t *db, in
 {
unsigned long flags;
 
+   if (db->flags & DM9000_PLATF_NO_EEPROM)
+   return;
+
mutex_lock(&db->addr_lock);
 
spin_lock_irqsave(&db->lock, flags);
Index: linux-2.6.24-quilt3/include/linux/dm9000.h
===
--- linux-2.6.24-quilt3.orig/include/linux/dm9000.h
+++ linux-2.6.24-quilt3/include/linux/dm9000.h
@@ -20,6 +20,7 @@
 #define DM9000_PLATF_16BITONLY (0x0002)
 #define DM9000_PLATF_32BITONLY (0x0004)
 #define DM9000_PLATF_EXT_PHY   (0x0008)
+#define DM9000_PLATF_NO_EEPROM (0x0010)
 
 /* platfrom data for platfrom device structure's platfrom_data field */
 

-- 
Ben ([EMAIL PROTECTED], http://www.fluff.org/)

  'a smiley only costs 4 bytes'
--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 00/24 for-2.6.25] DM9000 updates for 2.6.25

2008-02-04 Thread Ben Dooks
This patch set is a series of updates for the DM9000
driver, to tidy-up some of the source, stop the accesses
to the PHY and EEPROM sitting and spinning with locks
held, and to add ethtool support.

This set includes a pair of patches from Laurent Pinchart
for addition platform-data based configuration, please
apply these from this if you can attribute these correctly
to Laurent, otherwise ask Laurent to resubmit. I have
signed-off-by both these patches, but would be equally
happy acking them.

The only missing item in this series is to replace the
old timer based polling code. This series has been sitting
long enough on my own trees, and having MII link status
reports is not a driver-threatening bug.

Hopefully this series meets up to everyone's approval and
can be applied whilst the current merge window is upon us.

-- 
Ben
--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 13/24 for-2.6.25] DM9000: Add ethtool control of msg_enable value

2008-02-04 Thread Ben Dooks
Allow the msg_enable value to be read and written by
the ethtool interface.

Signed-off-by: Ben Dooks <[EMAIL PROTECTED]>

Index: linux-2.6.24-quilt3/drivers/net/dm9000.c
===
--- linux-2.6.24-quilt3.orig/drivers/net/dm9000.c
+++ linux-2.6.24-quilt3/drivers/net/dm9000.c
@@ -383,6 +383,20 @@ static void dm9000_get_drvinfo(struct ne
strcpy(info->bus_info, to_platform_device(dm->dev)->name);
 }
 
+static u32 dm9000_get_msglevel(struct net_device *dev)
+{
+   board_info_t *dm = to_dm9000_board(dev);
+
+   return dm->msg_enable;
+}
+
+static void dm9000_set_msglevel(struct net_device *dev, u32 value)
+{
+   board_info_t *dm = to_dm9000_board(dev);
+
+   dm->msg_enable = value;
+}
+
 static int dm9000_get_settings(struct net_device *dev, struct ethtool_cmd *cmd)
 {
board_info_t *dm = to_dm9000_board(dev);
@@ -464,6 +478,8 @@ static const struct ethtool_ops dm9000_e
.get_drvinfo= dm9000_get_drvinfo,
.get_settings   = dm9000_get_settings,
.set_settings   = dm9000_set_settings,
+   .get_msglevel   = dm9000_get_msglevel,
+   .set_msglevel   = dm9000_set_msglevel,
.nway_reset = dm9000_nway_reset,
.get_link   = dm9000_get_link,
.get_eeprom_len = dm9000_get_eeprom_len,

-- 
Ben ([EMAIL PROTECTED], http://www.fluff.org/)

  'a smiley only costs 4 bytes'
--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 16/24 for-2.6.25] DM9000: Remove unnecessary changelog in header comment

2008-02-04 Thread Ben Dooks
We have a perfectly good version control system, so we do not
need to duplicate change comments in the header for this code.

Signed-off-by: Ben Dooks <[EMAIL PROTECTED]>

Index: linux-2.6.24-quilt3/drivers/net/dm9000.c
===
--- linux-2.6.24-quilt3.orig/drivers/net/dm9000.c
+++ linux-2.6.24-quilt3/drivers/net/dm9000.c
@@ -1,7 +1,5 @@
 /*
- *   dm9000.c: Version 1.2 03/18/2003
- *
- * A Davicom DM9000 ISA NIC fast Ethernet driver for Linux.
+ *  Davicom DM9000 Fast Ethernet driver for Linux.
  * Copyright (C) 1997  Sten Wang
  *
  * This program is free software; you can redistribute it and/or
@@ -14,44 +12,11 @@
  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  * GNU General Public License for more details.
  *
- *   (C)Copyright 1997-1998 DAVICOM Semiconductor,Inc. All Rights Reserved.
- *
- * V0.11   06/20/2001  REG_0A bit3=1, default enable BP with DA match
- * 06/22/2001  Support DM9801 progrmming
- * E3: R25 = ((R24 + NF) & 0x00ff) | 0xf000
- * E4: R25 = ((R24 + NF) & 0x00ff) | 0xc200
- * R17 = (R17 & 0xfff0) | NF + 3
- * E5: R25 = ((R24 + NF - 3) & 0x00ff) | 0xc200
- * R17 = (R17 & 0xfff0) | NF
- *
- * v1.00   modify by simon 2001.9.5
- * change for kernel 2.4.x
- *
- * v1.1   11/09/2001   fix force mode bug
- *
- * v1.2   03/18/2003   Weilun Huang <[EMAIL PROTECTED]>:
- * Fixed phy reset.
- * Added tx/rx 32 bit mode.
- * Cleaned up for kernel merge.
- *
- *03/03/2004Sascha Hauer <[EMAIL PROTECTED]>
- *  Port to 2.6 kernel
- *
- *   24-Sep-2004   Ben Dooks <[EMAIL PROTECTED]>
- * Cleanup of code to remove ifdefs
- * Allowed platform device data to influence access width
- * Reformatting areas of code
- *
- *17-Mar-2005   Sascha Hauer <[EMAIL PROTECTED]>
- *  * removed 2.4 style module parameters
- *  * removed removed unused stat counter and fixed
- *net_device_stats
- *  * introduced tx_timeout function
- *  * reworked locking
+ * (C) Copyright 1997-1998 DAVICOM Semiconductor,Inc. All Rights Reserved.
  *
- *   01-Jul-2005   Ben Dooks <[EMAIL PROTECTED]>
- * * fixed spinlock call without pointer
- * * ensure spinlock is initialised
+ * Additional updates, Copyright:
+ * Ben Dooks <[EMAIL PROTECTED]>
+ * Sascha Hauer <[EMAIL PROTECTED]>
  */
 
 #include 

-- 
Ben ([EMAIL PROTECTED], http://www.fluff.org/)

  'a smiley only costs 4 bytes'
--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 12/24 for-2.6.25] DM9000: Add ethtool support for reading and writing EEPROM

2008-02-04 Thread Ben Dooks
Add ethtool support to access the configuration EEPROM
connected to the DM9000.

Signed-off-by: Ben Dooks <[EMAIL PROTECTED]>

Index: linux-2.6.24-quilt3/drivers/net/dm9000.c
===
--- linux-2.6.24-quilt3.orig/drivers/net/dm9000.c
+++ linux-2.6.24-quilt3/drivers/net/dm9000.c
@@ -186,7 +186,8 @@ static int dm9000_phy_read(struct net_de
 static void dm9000_phy_write(struct net_device *dev, int phyaddr_unused, int 
reg,
   int value);
 
-static void dm9000_read_eeprom(board_info_t *, int addr, unsigned char *to);
+static void dm9000_read_eeprom(board_info_t *, int addr, u8 *to);
+static void dm9000_write_eeprom(board_info_t *, int addr, u8 *dp);
 static void dm9000_rx(struct net_device *);
 static void dm9000_hash_table(struct net_device *);
 
@@ -409,12 +410,65 @@ static u32 dm9000_get_link(struct net_de
return mii_link_ok(&dm->mii);
 }
 
+#define DM_EEPROM_MAGIC(0x444D394B)
+
+static int dm9000_get_eeprom_len(struct net_device *dev)
+{
+   return 128;
+}
+
+static int dm9000_get_eeprom(struct net_device *dev,
+struct ethtool_eeprom *ee, u8 *data)
+{
+   board_info_t *dm = to_dm9000_board(dev);
+   int offset = ee->offset;
+   int len = ee->len;
+   int i;
+
+   /* EEPROM access is aligned to two bytes */
+
+   if ((len & 1) != 0 || (offset & 1) != 0)
+   return -EINVAL;
+
+   ee->magic = DM_EEPROM_MAGIC;
+
+   for (i = 0; i < len; i += 2)
+   dm9000_read_eeprom(dm, (offset + i) / 2, data + i);
+
+   return 0;
+}
+
+static int dm9000_set_eeprom(struct net_device *dev,
+struct ethtool_eeprom *ee, u8 *data)
+{
+   board_info_t *dm = to_dm9000_board(dev);
+   int offset = ee->offset;
+   int len = ee->len;
+   int i;
+
+   /* EEPROM access is aligned to two bytes */
+
+   if ((len & 1) != 0 || (offset & 1) != 0)
+   return -EINVAL;
+
+   if (ee->magic != DM_EEPROM_MAGIC)
+   return -EINVAL;
+
+   for (i = 0; i < len; i += 2)
+   dm9000_write_eeprom(dm, (offset + i) / 2, data + i);
+
+   return 0;
+}
+
 static const struct ethtool_ops dm9000_ethtool_ops = {
.get_drvinfo= dm9000_get_drvinfo,
.get_settings   = dm9000_get_settings,
.set_settings   = dm9000_set_settings,
.nway_reset = dm9000_nway_reset,
.get_link   = dm9000_get_link,
+   .get_eeprom_len = dm9000_get_eeprom_len,
+   .get_eeprom = dm9000_get_eeprom,
+   .set_eeprom = dm9000_set_eeprom,
 };
 
 
@@ -1011,7 +1065,7 @@ dm9000_rx(struct net_device *dev)
  *  Read a word data from EEPROM
  */
 static void
-dm9000_read_eeprom(board_info_t *db, int offset, unsigned char *to)
+dm9000_read_eeprom(board_info_t *db, int offset, u8 *to)
 {
mutex_lock(&db->addr_lock);
 
@@ -1027,18 +1081,17 @@ dm9000_read_eeprom(board_info_t *db, int
mutex_unlock(&db->addr_lock);
 }
 
-#ifdef DM9000_PROGRAM_EEPROM
 /*
  * Write a word data to SROM
  */
 static void
-write_srom_word(board_info_t * db, int offset, u16 val)
+dm9000_write_eeprom(board_info_t *db, int offset, u8 *data)
 {
mutex_lock(&db->addr_lock);
 
iow(db, DM9000_EPAR, offset);
-   iow(db, DM9000_EPDRH, ((val >> 8) & 0xff));
-   iow(db, DM9000_EPDRL, (val & 0xff));
+   iow(db, DM9000_EPDRH, data[1]);
+   iow(db, DM9000_EPDRL, data[0]);
iow(db, DM9000_EPCR, EPCR_WEP | EPCR_ERPRW);
mdelay(8);  /* same shit */
iow(db, DM9000_EPCR, 0);
@@ -1046,6 +1099,7 @@ write_srom_word(board_info_t * db, int o
mutex_unlock(&db->addr_lock);
 }
 
+#ifdef DM9000_PROGRAM_EEPROM
 /*
  * Only for development:
  * Here we write static data to the eeprom in case

-- 
Ben ([EMAIL PROTECTED], http://www.fluff.org/)

  'a smiley only costs 4 bytes'
--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 15/24 for-2.6.25] DM9000: Ensure spinlock held whilst accessing EEPROM registers

2008-02-04 Thread Ben Dooks
Ensure we hold the spinlock whilst the registers and being
modified even though we hold the overall lock. This should
protect against an interrupt happening whilst we are using
the device.

Signed-off-by: Ben Dooks <[EMAIL PROTECTED]>

Index: linux-2.6.24-quilt3/drivers/net/dm9000.c
===
--- linux-2.6.24-quilt3.orig/drivers/net/dm9000.c
+++ linux-2.6.24-quilt3/drivers/net/dm9000.c
@@ -1076,17 +1076,29 @@ dm9000_rx(struct net_device *dev)
 static void
 dm9000_read_eeprom(board_info_t *db, int offset, u8 *to)
 {
+   unsigned long flags;
+
mutex_lock(&db->addr_lock);
 
+   spin_lock_irqsave(&db->lock, flags);
+
iow(db, DM9000_EPAR, offset);
iow(db, DM9000_EPCR, EPCR_ERPRR);
+
+   spin_unlock_irqrestore(&db->lock, flags);
+
mdelay(8);  /* according to the datasheet 200us should be 
enough,
   but it doesn't work */
+
+   spin_lock_irqsave(&db->lock, flags);
+
iow(db, DM9000_EPCR, 0x0);
 
to[0] = ior(db, DM9000_EPDRL);
to[1] = ior(db, DM9000_EPDRH);
 
+   spin_unlock_irqrestore(&db->lock, flags);
+
mutex_unlock(&db->addr_lock);
 }
 
@@ -1096,14 +1108,22 @@ dm9000_read_eeprom(board_info_t *db, int
 static void
 dm9000_write_eeprom(board_info_t *db, int offset, u8 *data)
 {
+   unsigned long flags;
+
mutex_lock(&db->addr_lock);
 
+   spin_lock_irqsave(&db->lock, flags);
iow(db, DM9000_EPAR, offset);
iow(db, DM9000_EPDRH, data[1]);
iow(db, DM9000_EPDRL, data[0]);
iow(db, DM9000_EPCR, EPCR_WEP | EPCR_ERPRW);
+   spin_unlock_irqrestore(&db->lock, flags);
+
mdelay(8);  /* same shit */
+
+   spin_lock_irqsave(&db->lock, flags);
iow(db, DM9000_EPCR, 0);
+   spin_unlock_irqrestore(&db->lock, flags);
 
mutex_unlock(&db->addr_lock);
 }

-- 
Ben ([EMAIL PROTECTED], http://www.fluff.org/)

  'a smiley only costs 4 bytes'
--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 01/24 for-2.6.25] DM9000: Fix endian-ness of data accesses. Patch from: Laurent Pinchart

2008-02-04 Thread Ben Dooks
This patch splits the receive status in 8bit wide fields and convert the
packet length from little endian to CPU byte order.

Signed-off-by: Laurent Pinchart <[EMAIL PROTECTED]>
Signed-off-by: Ben Dooks <[EMAIL PROTECTED]>

Index: linux-2.6.24-git5-dm9k/drivers/net/dm9000.c
===
--- linux-2.6.24-git5-dm9k.orig/drivers/net/dm9000.c
+++ linux-2.6.24-git5-dm9k/drivers/net/dm9000.c
@@ -867,7 +867,8 @@ dm9000_timer(unsigned long data)
 }
 
 struct dm9000_rxhdr {
-   u16 RxStatus;
+   u8  RxPktReady;
+   u8  RxStatus;
u16 RxLen;
 } __attribute__((__packed__));
 
@@ -908,7 +909,7 @@ dm9000_rx(struct net_device *dev)
 
(db->inblk)(db->io_data, &rxhdr, sizeof(rxhdr));
 
-   RxLen = rxhdr.RxLen;
+   RxLen = le16_to_cpu(rxhdr.RxLen);
 
/* Packet Status check */
if (RxLen < 0x40) {
@@ -920,17 +921,17 @@ dm9000_rx(struct net_device *dev)
PRINTK1("RST: RX Len:%x\n", RxLen);
}
 
-   if (rxhdr.RxStatus & 0xbf00) {
+   if (rxhdr.RxStatus & 0xbf) {
GoodPacket = false;
-   if (rxhdr.RxStatus & 0x100) {
+   if (rxhdr.RxStatus & 0x01) {
PRINTK1("fifo error\n");
dev->stats.rx_fifo_errors++;
}
-   if (rxhdr.RxStatus & 0x200) {
+   if (rxhdr.RxStatus & 0x02) {
PRINTK1("crc error\n");
dev->stats.rx_crc_errors++;
}
-   if (rxhdr.RxStatus & 0x8000) {
+   if (rxhdr.RxStatus & 0x80) {
PRINTK1("length error\n");
dev->stats.rx_length_errors++;
}

-- 
Ben ([EMAIL PROTECTED], http://www.fluff.org/)

  'a smiley only costs 4 bytes'
--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 14/24 for-2.6.25] DM9000: Remove EEPROM initialisation code.

2008-02-04 Thread Ben Dooks
Remove the old hack to program an initial EEPROM setting
into the DM9000 as we now have ethtool support for reading
and writing the EEPROM.

Signed-off-by: Ben Dooks <[EMAIL PROTECTED]>

Index: linux-2.6.24-quilt3/drivers/net/dm9000.c
===
--- linux-2.6.24-quilt3.orig/drivers/net/dm9000.c
+++ linux-2.6.24-quilt3/drivers/net/dm9000.c
@@ -191,10 +191,6 @@ static void dm9000_write_eeprom(board_in
 static void dm9000_rx(struct net_device *);
 static void dm9000_hash_table(struct net_device *);
 
-//#define DM9000_PROGRAM_EEPROM
-#ifdef DM9000_PROGRAM_EEPROM
-static void program_eeprom(board_info_t * db);
-#endif
 /* DM9000 network board routine  */
 
 static void
@@ -699,9 +695,6 @@ dm9000_probe(struct platform_device *pde
ndev->poll_controller= &dm9000_poll_controller;
 #endif
 
-#ifdef DM9000_PROGRAM_EEPROM
-   program_eeprom(db);
-#endif
db->msg_enable   = NETIF_MSG_LINK;
db->mii.phy_id_mask  = 0x1f;
db->mii.reg_num_mask = 0x1f;
@@ -1115,28 +1108,6 @@ dm9000_write_eeprom(board_info_t *db, in
mutex_unlock(&db->addr_lock);
 }
 
-#ifdef DM9000_PROGRAM_EEPROM
-/*
- * Only for development:
- * Here we write static data to the eeprom in case
- * we don't have valid content on a new board
- */
-static void
-program_eeprom(board_info_t * db)
-{
-   u16 eeprom[] = { 0x0c00, 0x007f, 0x1300,/* MAC Address */
-   0x, /* Autoload: accept nothing */
-   0x0a46, 0x9000, /* Vendor / Product ID */
-   0x, /* pin control */
-   0x,
-   };  /* Wake-up mode control */
-   int i;
-   for (i = 0; i < 8; i++)
-   write_srom_word(db, i, eeprom[i]);
-}
-#endif
-
-
 /*
  *  Calculate the CRC valude of the Rx packet
  *  flag = 1 : return the reverse CRC (for the received packet CRC)

-- 
Ben ([EMAIL PROTECTED], http://www.fluff.org/)

  'a smiley only costs 4 bytes'
--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 03/24 for-2.6.25] DM9000 use dev_xxx() instead of printk for output.

2008-02-04 Thread Ben Dooks
Move to using dev_dbg() and friends for the output of
information to the user.

Signed-off-by: Ben Dooks <[EMAIL PROTECTED]>

Index: linux-2.6.24-git5-dm9k/drivers/net/dm9000.c
===
--- linux-2.6.24-git5-dm9k.orig/drivers/net/dm9000.c
+++ linux-2.6.24-git5-dm9k/drivers/net/dm9000.c
@@ -143,6 +143,8 @@ typedef struct board_info {
void (*outblk)(void __iomem *port, void *data, int length);
void (*dumpblk)(void __iomem *port, int length);
 
+   struct device   *dev;/* parent device */
+
struct resource *addr_res;   /* resources found */
struct resource *data_res;
struct resource *addr_req;   /* resources requested */
@@ -185,7 +187,8 @@ static void program_eeprom(board_info_t 
 static void
 dm9000_reset(board_info_t * db)
 {
-   PRINTK1("dm9000x: resetting\n");
+   dev_dbg(db->dev, "resetting device\n");
+
/* RESET device */
writeb(DM9000_NCR, db->io_addr);
udelay(200);
@@ -301,14 +304,10 @@ static void dm9000_set_io(struct board_i
db->inblk   = dm9000_inblk_8bit;
break;
 
-   case 2:
-   db->dumpblk = dm9000_dumpblk_16bit;
-   db->outblk  = dm9000_outblk_16bit;
-   db->inblk   = dm9000_inblk_16bit;
-   break;
 
case 3:
-   printk(KERN_ERR PFX ": 3 byte IO, falling back to 16bit\n");
+   dev_dbg(db->dev, ": 3 byte IO, falling back to 16bit\n");
+   case 2:
db->dumpblk = dm9000_dumpblk_16bit;
db->outblk  = dm9000_outblk_16bit;
db->inblk   = dm9000_inblk_16bit;
@@ -411,18 +410,20 @@ dm9000_probe(struct platform_device *pde
/* Init network device */
ndev = alloc_etherdev(sizeof (struct board_info));
if (!ndev) {
-   printk("%s: could not allocate device.\n", CARDNAME);
+   dev_err(&pdev->dev, "could not allocate device.\n");
return -ENOMEM;
}
 
SET_NETDEV_DEV(ndev, &pdev->dev);
 
-   PRINTK2("dm9000_probe()");
+   dev_dbg(&pdev->dev, "dm9000_probe()");
 
/* setup board info structure */
db = (struct board_info *) ndev->priv;
memset(db, 0, sizeof (*db));
 
+   db->dev = &pdev->dev;
+
spin_lock_init(&db->lock);
 
if (pdev->num_resources < 2) {
@@ -451,7 +452,7 @@ dm9000_probe(struct platform_device *pde
 
if (db->addr_res == NULL || db->data_res == NULL ||
db->irq_res == NULL) {
-   printk(KERN_ERR PFX "insufficient resources\n");
+   dev_err(db->dev, "insufficient resources\n");
ret = -ENOENT;
goto out;
}
@@ -461,7 +462,7 @@ dm9000_probe(struct platform_device *pde
  pdev->name);
 
if (db->addr_req == NULL) {
-   printk(KERN_ERR PFX "cannot claim address reg area\n");
+   dev_err(db->dev, "cannot claim address reg area\n");
ret = -EIO;
goto out;
}
@@ -469,7 +470,7 @@ dm9000_probe(struct platform_device *pde
db->io_addr = ioremap(db->addr_res->start, i);
 
if (db->io_addr == NULL) {
-   printk(KERN_ERR "failed to ioremap address reg\n");
+   dev_err(db->dev, "failed to ioremap address reg\n");
ret = -EINVAL;
goto out;
}
@@ -479,7 +480,7 @@ dm9000_probe(struct platform_device *pde
  pdev->name);
 
if (db->data_req == NULL) {
-   printk(KERN_ERR PFX "cannot claim data reg area\n");
+   dev_err(db->dev, "cannot claim data reg area\n");
ret = -EIO;
goto out;
}
@@ -487,7 +488,7 @@ dm9000_probe(struct platform_device *pde
db->io_data = ioremap(db->data_res->start, iosize);
 
if (db->io_data == NULL) {
-   printk(KERN_ERR "failed to ioremap data reg\n");
+   dev_err(db->dev,"failed to ioremap data reg\n");
ret = -EINVAL;
goto out;
}
@@ -541,11 +542,11 @@ dm9000_probe(struct platform_device *pde
 
if (id_val == DM9000_ID)
break;
-   printk("%s: read wrong id 0x%0

NET: AX88796 use dev_dbg() instead of printk()

2008-01-31 Thread Ben Dooks
Change to using dev_dbg() and the other dev_xxx()
macros instead of printk, and update to use the
print_mac() helper.

Signed-off-by: Ben Dooks <[EMAIL PROTECTED]>

Index: linux-2.6.24-quilt1/drivers/net/ax88796.c
===
--- linux-2.6.24-quilt1.orig/drivers/net/ax88796.c
+++ linux-2.6.24-quilt1/drivers/net/ax88796.c
@@ -137,11 +137,12 @@ static int ax_initial_check(struct net_d
 static void ax_reset_8390(struct net_device *dev)
 {
struct ei_device *ei_local = netdev_priv(dev);
+   struct ax_device  *ax = to_ax_dev(dev);
unsigned long reset_start_time = jiffies;
void __iomem *addr = (void __iomem *)dev->base_addr;
 
if (ei_debug > 1)
-   printk(KERN_DEBUG "resetting the 8390 t=%ld...", jiffies);
+   dev_dbg(&ax->dev->dev, "resetting the 8390 t=%ld\n", jiffies);
 
ei_outb(ei_inb(addr + NE_RESET), addr + NE_RESET);
 
@@ -151,7 +152,7 @@ static void ax_reset_8390(struct net_dev
/* This check _should_not_ be necessary, omit eventually. */
while ((ei_inb(addr + EN0_ISR) & ENISR_RESET) == 0) {
if (jiffies - reset_start_time > 2*HZ/100) {
-   printk(KERN_WARNING "%s: %s did not complete.\n",
+   dev_warn(&ax->dev->dev, "%s: %s did not complete.\n",
   __FUNCTION__, dev->name);
break;
}
@@ -165,13 +166,15 @@ static void ax_get_8390_hdr(struct net_d
int ring_page)
 {
struct ei_device *ei_local = netdev_priv(dev);
+   struct ax_device  *ax = to_ax_dev(dev);
void __iomem *nic_base = ei_local->mem;
 
/* This *shouldn't* happen. If it does, it's the last thing you'll see 
*/
if (ei_status.dmaing) {
-   printk(KERN_EMERG "%s: DMAing conflict in %s 
[DMAstat:%d][irqlock:%d].\n",
+   dev_err(&ax->dev->dev, "%s: DMAing conflict in %s "
+   "[DMAstat:%d][irqlock:%d].\n",
dev->name, __FUNCTION__,
-  ei_status.dmaing, ei_status.irqlock);
+   ei_status.dmaing, ei_status.irqlock);
return;
}
 
@@ -204,13 +207,16 @@ static void ax_block_input(struct net_de
   struct sk_buff *skb, int ring_offset)
 {
struct ei_device *ei_local = netdev_priv(dev);
+   struct ax_device  *ax = to_ax_dev(dev);
void __iomem *nic_base = ei_local->mem;
char *buf = skb->data;
 
if (ei_status.dmaing) {
-   printk(KERN_EMERG "%s: DMAing conflict in ax_block_input "
+   dev_err(&ax->dev->dev,
+   "%s: DMAing conflict in %s "
"[DMAstat:%d][irqlock:%d].\n",
-   dev->name, ei_status.dmaing, ei_status.irqlock);
+   dev->name, __FUNCTION__,
+   ei_status.dmaing, ei_status.irqlock);
return;
}
 
@@ -239,6 +245,7 @@ static void ax_block_output(struct net_d
const unsigned char *buf, const int start_page)
 {
struct ei_device *ei_local = netdev_priv(dev);
+   struct ax_device  *ax = to_ax_dev(dev);
void __iomem *nic_base = ei_local->mem;
unsigned long dma_start;
 
@@ -251,7 +258,7 @@ static void ax_block_output(struct net_d
 
/* This *shouldn't* happen. If it does, it's the last thing you'll see 
*/
if (ei_status.dmaing) {
-   printk(KERN_EMERG "%s: DMAing conflict in %s."
+   dev_err(&ax->dev->dev, "%s: DMAing conflict in %s."
"[DMAstat:%d][irqlock:%d]\n",
dev->name, __FUNCTION__,
   ei_status.dmaing, ei_status.irqlock);
@@ -281,7 +288,8 @@ static void ax_block_output(struct net_d
 
while ((ei_inb(nic_base + EN0_ISR) & ENISR_RDC) == 0) {
if (jiffies - dma_start > 2*HZ/100) {   /* 20ms */
-   printk(KERN_WARNING "%s: timeout waiting for Tx 
RDC.\n", dev->name);
+   dev_warn(&ax->dev->dev,
+"%s: timeout waiting for Tx RDC.\n", 
dev->name);
ax_reset_8390(dev);
ax_NS8390_init(dev,1);
break;
@@ -424,10 +432,11 @@ static void
 ax_phy_write(struct net_device *dev, int phy_addr, int reg, int value)
 {
struct ei_device *ei = (struct ei_device *) netdev_priv(dev);
+   struct ax_device  *ax = to_ax_dev(dev);
unsigned long flags;
 
-   printk(KERN_DEBUG "%s: 

Re: [PATCH] dm9000 - fix spinlock issue, updated

2007-12-22 Thread Ben Dooks
On Wed, Nov 21, 2007 at 04:47:53PM +0300, dmitry pervushin wrote:
> The patch below fixes the problem with dm9000_timeout function: it calls
> dm9000_init under the spin_lock db->lock, which was going to be acquired
> again in dm9000_hash_table. From the other hand, dm9000_hash_table has
> to be called with db->lock held
> 
> Signed-off-by: dmitry pervushin <[EMAIL PROTECTED]>
Acked-by: Ben Dooks <[EMAIL PROTECTED]>
> Index: linux/drivers/net/dm9000.c
> ===
> --- linux.orig/drivers/net/dm9000.c
> +++ linux/drivers/net/dm9000.c
> @@ -173,6 +173,7 @@ static void dm9000_phy_write(struct net_
>  static u16 read_srom_word(board_info_t *, int);
>  static void dm9000_rx(struct net_device *);
>  static void dm9000_hash_table(struct net_device *);
> +static void dm9000_set_multicast(struct net_device *dev);
>  
>  //#define DM9000_PROGRAM_EEPROM
>  #ifdef DM9000_PROGRAM_EEPROM
> @@ -556,7 +557,7 @@ dm9000_probe(struct platform_device *pde
>   ndev->tx_timeout = &dm9000_timeout;
>   ndev->watchdog_timeo = msecs_to_jiffies(watchdog);
>   ndev->stop   = &dm9000_stop;
> - ndev->set_multicast_list = &dm9000_hash_table;
> + ndev->set_multicast_list = &dm9000_set_multicast;
>  #ifdef CONFIG_NET_POLL_CONTROLLER
>   ndev->poll_controller= &dm9000_poll_controller;
>  #endif
> @@ -620,6 +621,7 @@ static int
>  dm9000_open(struct net_device *dev)
>  {
>   board_info_t *db = (board_info_t *) dev->priv;
> + unsigned long flags;
>  
>   PRINTK2("entering dm9000_open\n");
>  
> @@ -627,8 +629,10 @@ dm9000_open(struct net_device *dev)
>   return -EAGAIN;
>  
>   /* Initialize DM9000 board */
> + spin_lock_irqsave(&db->lock, flags);
>   dm9000_reset(db);
>   dm9000_init_dm9000(dev);
> + spin_unlock_irqrestore(&db->lock, flags);
>  
>   /* Init driver variable */
>   db->dbug_cnt = 0;
> @@ -1030,6 +1034,18 @@ cal_CRC(unsigned char *Data, unsigned in
>  /*
>   *  Set DM9000 multicast address
>   */
> +
> +static void
> +dm9000_set_multicast(struct net_device *dev)
> +{
> + board_info_t *db = (board_info_t *) dev->priv;
> + unsigned long flags;
> +
> + spin_lock_irqsave(&db->lock,flags);
> + dm9000_hash_table(dev);
> + spin_unlock_irqrestore(&db->lock, flags);
> +}
> +
>  static void
>  dm9000_hash_table(struct net_device *dev)
>  {
> @@ -1038,12 +1054,9 @@ dm9000_hash_table(struct net_device *dev
>   int mc_cnt = dev->mc_count;
>   u32 hash_val;
>   u16 i, oft, hash_table[4];
> - unsigned long flags;
>  
>   PRINTK2("dm9000_hash_table()\n");
>  
> - spin_lock_irqsave(&db->lock,flags);
> -
>   for (i = 0, oft = 0x10; i < 6; i++, oft++)
>   iow(db, oft, dev->dev_addr[i]);
>  
> @@ -1065,8 +1078,6 @@ dm9000_hash_table(struct net_device *dev
>   iow(db, oft++, hash_table[i] & 0xff);
>   iow(db, oft++, (hash_table[i] >> 8) & 0xff);
>   }
> -
> - spin_unlock_irqrestore(&db->lock,flags);
>  }
>  
>  
> @@ -1155,12 +1166,15 @@ dm9000_drv_resume(struct platform_device
>  {
>   struct net_device *ndev = platform_get_drvdata(dev);
>   board_info_t *db = (board_info_t *) ndev->priv;
> + unsigned long flags;
>  
>   if (ndev) {
>  
>   if (netif_running(ndev)) {
> + spin_lock_irqsave(&db->lock, flags);
>   dm9000_reset(db);
>   dm9000_init_dm9000(ndev);
> + spin_unlock_irqrestore(&db->lock, flags);
>  
>   netif_device_attach(ndev);
>   }
> 
> 
> -
> To unsubscribe from this list: send the line "unsubscribe netdev" in
> the body of a message to [EMAIL PROTECTED]
> More majordomo info at  http://vger.kernel.org/majordomo-info.html

-- 
Ben ([EMAIL PROTECTED], http://www.fluff.org/)

  'a smiley only costs 4 bytes'
--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: DM9000_IRQ_FLAGS

2007-12-20 Thread Ben Dooks
On Wed, Dec 12, 2007 at 02:41:53PM +0100, Daniel Mack wrote:
> Hi Remy,
> 
> On Tue, Dec 11, 2007 at 09:31:03PM +0100, Remy Bohmer wrote:
> > This controller is also used on many other boards, like the e.g. Atmel
> > AT91sam9261-ek board. On that board on both the rising _and_ falling
> > edge an interrupt is generated.
> 
> However, request_irq() is called with IRQF_SHARED only, so neither
> IRQT_RISING nor IRQT_FALLING is set and the value defaults to
> IRQT_NOEDGE. How can you get IRQs?
> 
> > I can test tomorrow if this patch leaves this board in tact, but
> > should the board-specific code not add this flag if it is required ?
> > By modifying this driver you will interfere the behavior of other
> > boards, and I do not know if there any level triggered types used.
> 
> Actually, the best way to go is to let the platform resources flags 
> decide about that with something like
> 
>   resource->flags = IORESOURCE_IRQ | IRQT_RISING;
> 
> but the dm9000 does not care about them at all. Changing that would also
> imply modifications to all board support code.

I did have a go at trying to get people to pass the information this
way, but it seem to be ignored last time I sent it. I can dig out the
code that converts resource->flags to IRQT_ flags.

-- 
Ben ([EMAIL PROTECTED], http://www.fluff.org/)

  'a smiley only costs 4 bytes'
--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: DM9000_IRQ_FLAGS

2007-12-20 Thread Ben Dooks
On Tue, Dec 11, 2007 at 08:18:23PM +0100, Daniel Mack wrote:
> Hi,
> 
> on Toradex' Colibri, a PXA270 based board with a DM9000 ethernet
> controller, this driver won't work due to unsuitable DM9000_IRQ_FLAGS.
> If I understood the code behind request_irq() correctly, it's not
> recommended to register an IRQ without any of the IRQT_* flags set.
> 
> Is there any concerns about applying the patch below?

Yes, that will possibly break all systems using level-triggered
interrupts.

Probably the best solution is to pass the data via the platform
information being fed to the device.

-- 
Ben ([EMAIL PROTECTED], http://www.fluff.org/)

  'a smiley only costs 4 bytes'
--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [patch 06/22] NET: DM9000: Use kthread to probe MII status when device open

2007-12-07 Thread Ben Dooks
On Fri, Nov 23, 2007 at 08:38:51PM -0500, Jeff Garzik wrote:
> seems like a delayed workqueue would be most appropriate for this.

I like the fact that the use of kthread shows the user how much
cpu time is being used by the execution of monitoring the phy. How
badly do people object to using a kthread?

-- 
Ben ([EMAIL PROTECTED], http://www.fluff.org/)

  'a smiley only costs 4 bytes'
--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [patch 22/22] NET: DM9000: Show the MAC address source after printing MAC

2007-12-07 Thread Ben Dooks
On Fri, Nov 23, 2007 at 08:43:04PM -0500, Jeff Garzik wrote:
> ACK patches 16-22

Is reposting here ok to get these queued for the next kernel
release, or are there people to CC: for this?

-- 
Ben ([EMAIL PROTECTED], http://www.fluff.org/)

  'a smiley only costs 4 bytes'
--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [patch 07/22] NET: DM9000: Use msleep() instead of udelay()

2007-12-07 Thread Ben Dooks
On Fri, Nov 23, 2007 at 08:39:45PM -0500, Jeff Garzik wrote:
> are you sure you cannot sleep during suspend?

Yes. This is not the first driver that has had this problem,
see the sm501 as another example.

-- 
Ben ([EMAIL PROTECTED], http://www.fluff.org/)

  'a smiley only costs 4 bytes'
--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [patch 00/22] DM9000 updates for 2.6.25

2007-11-20 Thread Ben Dooks
On Mon, Nov 19, 2007 at 08:39:10PM +, Ben Dooks wrote:
> This is my current proposed patch series to the DM9000
> driver for both general cleanups, support for ethtool
> and to make the code better.

Apologies, it seems that when I updated it to 2.6.24-rc3
it turns out I applied it without first upgrading the
underlying kernel source to that version. I will post
a new series to the list once i've fixed up all the
changes.

-- 
Ben ([EMAIL PROTECTED], http://www.fluff.org/)

  'a smiley only costs 4 bytes'
-
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH] dm9000: fix spinlock issue and introduce platform_init callback

2007-11-20 Thread Ben Dooks
On Tue, Nov 20, 2007 at 05:59:49PM +0300, dmitry pervushin wrote:
> 
> On ???, 2007-11-20 at 14:51 +0000, Ben Dooks wrote:
> > On Tue, Nov 20, 2007 at 05:43:42PM +0300, dmitry pervushin wrote:
> > > Hey all,
> > > 
> > > The patch below is intended to fix two problems:
> > > - trying to acquire spinlock twice on timeout condition
> > 
> > I'll have a look into this, although I think we may be better of
> > not dropping the spinlock and simply moving it out of
> > dm9000_init_dm9000() and ensure all callers of this function
> > hold the lock already.

> actually, dm9000_hash_table holds this spin lock. Well, I'll try to rework 
> this

I think that dropping and re-aquiring the lock is creating the
possibility that something else could happen in this sequence
of events.

> > > - create callback than can be used by platform code to initialize the
> > > chip
> > 
> > Hi, what purpose is the callback for? and if it takes a platform
> > device why is the prototype for 'void *' ?
> to initialize the chip. My target board has to configure GPIO/CPLD
> registers properly to activate dm9000. I do not want to move this
> initialization to common code -- the GPIO lines might be shared and I'd
> like to configure them only if it is needed.

Aha, could the comment in the header file be expanded to say
something like "Callback for machine or board dependant initialisation,
such as enabling the routing of control signals to the DM9000" to signify
what is meant to be happening here.
 
> > This should have also been two seperate patches as there are two
> > different issues.

Just as an further explanation, the spinlock fix is ideal to push
now, whereas the callback patch is probably 2.6.25 material.

> > > Signed-off-by: dmitry pervushin <[EMAIL PROTECTED]>
> > > Index: linux/drivers/net/dm9000.c
> > > ===
> > > --- linux.orig/drivers/net/dm9000.c
> > > +++ linux/drivers/net/dm9000.c
> > > @@ -335,8 +335,11 @@ static void dm9000_timeout(struct net_de
> > >  
> > >   netif_stop_queue(dev);
> > >   dm9000_reset(db);
> > > + spin_unlock_irqrestore(&db->lock,flags);
> > > +
> > >   dm9000_init_dm9000(dev);
> > >   /* We can accept TX packets again */
> > > + spin_lock_irqsave(&db->lock,flags);
> > >   dev->trans_start = jiffies;
> > >   netif_wake_queue(dev);
> > >  
> > > @@ -526,6 +529,8 @@ dm9000_probe(struct platform_device *pde
> > >   db->dumpblk = pdata->dumpblk;
> > >   }
> > >  
> > > + if (pdata && pdata->platform_init)
> > > + pdata->platform_init(pdev);
> > >   dm9000_reset(db);
> > >  
> > >   /* try two times, DM9000 sometimes gets the first read wrong */
> > > @@ -1155,10 +1160,13 @@ dm9000_drv_resume(struct platform_device
> > >  {
> > >   struct net_device *ndev = platform_get_drvdata(dev);
> > >   board_info_t *db = (board_info_t *) ndev->priv;
> > > + struct dm9000_plat_data *pdata = dev->dev.platform_data;
> > >  
> > >   if (ndev) {
> > >  
> > >   if (netif_running(ndev)) {
> > > + if (pdata && pdata->platform_init)
> > > + pdata->platform_init(dev);
> > >   dm9000_reset(db);
> > >   dm9000_init_dm9000(ndev);
> > >  
> > > Index: linux/include/linux/dm9000.h
> > > ===
> > > --- linux.orig/include/linux/dm9000.h
> > > +++ linux/include/linux/dm9000.h
> > > @@ -30,6 +30,9 @@ struct dm9000_plat_data {
> > >   void(*inblk)(void __iomem *reg, void *data, int len);
> > >   void(*outblk)(void __iomem *reg, void *data, int len);
> > >   void(*dumpblk)(void __iomem *reg, int len);
> > > +
> > > + /* platform init, if any */
> > > + void(*platform_init)(void *);
> > >  };
> > >  
> > >  #endif /* __DM9000_PLATFORM_DATA */
> > > 
> > > 
> > > -
> > > To unsubscribe from this list: send the line "unsubscribe netdev" in
> > > the body of a message to [EMAIL PROTECTED]
> > > More majordomo info at  http://vger.kernel.org/majordomo-info.html
> > 
> 
> -
> To unsubscribe from this list: send the line "unsubscribe netdev" in
> the body of a message to [EMAIL PROTECTED]
> More majordomo info at  http://vger.kernel.org/majordomo-info.html

-- 
Ben ([EMAIL PROTECTED], http://www.fluff.org/)

  'a smiley only costs 4 bytes'
-
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH] dm9000: fix spinlock issue and introduce platform_init callback

2007-11-20 Thread Ben Dooks
On Tue, Nov 20, 2007 at 05:43:42PM +0300, dmitry pervushin wrote:
> Hey all,
> 
> The patch below is intended to fix two problems:
> - trying to acquire spinlock twice on timeout condition

I'll have a look into this, although I think we may be better of
not dropping the spinlock and simply moving it out of
dm9000_init_dm9000() and ensure all callers of this function
hold the lock already.

> - create callback than can be used by platform code to initialize the
> chip

Hi, what purpose is the callback for? and if it takes a platform
device why is the prototype for 'void *' ?

This should have also been two seperate patches as there are two
different issues.
 
> Signed-off-by: dmitry pervushin <[EMAIL PROTECTED]>
> Index: linux/drivers/net/dm9000.c
> ===
> --- linux.orig/drivers/net/dm9000.c
> +++ linux/drivers/net/dm9000.c
> @@ -335,8 +335,11 @@ static void dm9000_timeout(struct net_de
>  
>   netif_stop_queue(dev);
>   dm9000_reset(db);
> + spin_unlock_irqrestore(&db->lock,flags);
> +
>   dm9000_init_dm9000(dev);
>   /* We can accept TX packets again */
> + spin_lock_irqsave(&db->lock,flags);
>   dev->trans_start = jiffies;
>   netif_wake_queue(dev);
>  
> @@ -526,6 +529,8 @@ dm9000_probe(struct platform_device *pde
>   db->dumpblk = pdata->dumpblk;
>   }
>  
> + if (pdata && pdata->platform_init)
> + pdata->platform_init(pdev);
>   dm9000_reset(db);
>  
>   /* try two times, DM9000 sometimes gets the first read wrong */
> @@ -1155,10 +1160,13 @@ dm9000_drv_resume(struct platform_device
>  {
>   struct net_device *ndev = platform_get_drvdata(dev);
>   board_info_t *db = (board_info_t *) ndev->priv;
> + struct dm9000_plat_data *pdata = dev->dev.platform_data;
>  
>   if (ndev) {
>  
>   if (netif_running(ndev)) {
> + if (pdata && pdata->platform_init)
> + pdata->platform_init(dev);
>   dm9000_reset(db);
>   dm9000_init_dm9000(ndev);
>  
> Index: linux/include/linux/dm9000.h
> ===
> --- linux.orig/include/linux/dm9000.h
> +++ linux/include/linux/dm9000.h
> @@ -30,6 +30,9 @@ struct dm9000_plat_data {
>   void(*inblk)(void __iomem *reg, void *data, int len);
>   void(*outblk)(void __iomem *reg, void *data, int len);
>   void(*dumpblk)(void __iomem *reg, int len);
> +
> + /* platform init, if any */
> + void(*platform_init)(void *);
>  };
>  
>  #endif /* __DM9000_PLATFORM_DATA */
> 
> 
> -
> To unsubscribe from this list: send the line "unsubscribe netdev" in
> the body of a message to [EMAIL PROTECTED]
> More majordomo info at  http://vger.kernel.org/majordomo-info.html

-- 
Ben ([EMAIL PROTECTED], http://www.fluff.org/)

  'a smiley only costs 4 bytes'
-
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [patch 00/22] DM9000 updates for 2.6.25

2007-11-20 Thread Ben Dooks
On Mon, Nov 19, 2007 at 03:04:31PM -0800, Stephen Hemminger wrote:
> On Mon, 19 Nov 2007 20:39:10 +
> Ben Dooks <[EMAIL PROTECTED]> wrote:
> 
> > This is my current proposed patch series to the DM9000
> > driver for both general cleanups, support for ethtool
> > and to make the code better.
> > 
> 
> You could also change all instances of dev->priv with netdev_priv(dev).

Ok, will add that to the patch set.

-- 
Ben ([EMAIL PROTECTED], http://www.fluff.org/)

  'a smiley only costs 4 bytes'
-
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [patch 06/22] NET: DM9000: Use kthread to probe MII status when device open

2007-11-20 Thread Ben Dooks
On Tue, Nov 20, 2007 at 07:46:27AM +, Christoph Hellwig wrote:
> > +static void dm9000_start_thread(struct net_device *dev)
> > +{
> > +   board_info_t *db = (board_info_t *) dev->priv;
> > +
> > +   /* Create a thread to keep track of the state of the phy
> > +* as we do not get an interrupt when the PHY state changes.
> > +*
> > +* Note, we do not abort the open if we fail to create the
> > +* thread, as this is mainly to ensure the user is kept up to
> > +* date with the device's state. PHY accesses will still work
> > +* via the MII read and write methods.
> > +*/
> > +
> > +   db->thread = kthread_create(dm9000_mii_thread, db, dev->name);
> > +   if (IS_ERR(db->thread)) {
> > +   dev_err(db->dev, "failed to create MII thread\n");
> > +   db->thread = NULL;
> > +   } else
> > +   wake_up_process(db->thread);
> > +}
> > +
> >  /*
> >   *  Open the interface.
> >   *  The interface is opened whenever "ifconfig" actives it.
> > @@ -704,12 +724,7 @@ dm9000_open(struct net_device *dev)
> > /* Init driver variable */
> > db->dbug_cnt = 0;
> >  
> > -   /* set and active a timer process */
> > -   init_timer(&db->timer);
> > -   db->timer.expires  = DM9000_TIMER_WUT;
> > -   db->timer.data = (unsigned long) dev;
> > -   db->timer.function = &dm9000_timer;
> > -   add_timer(&db->timer);
> > +   dm9000_start_thread(dev);
> 
> Please don't just ignore the error.  Just inline the content of
> dm9000_start_thread into the caller and use proper goto-based
> unwinding.

The error is not important, I would be happy with adding an
error print in there, but not having the MII system print
an message if the link status changes is not an driver threatening
error.

-- 
Ben ([EMAIL PROTECTED], http://www.fluff.org/)

  'a smiley only costs 4 bytes'
-
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[patch 12/22] NET: DM9000: Remove EEPROM initialisation code.

2007-11-19 Thread Ben Dooks
Remove the old hack to program an initial EEPROM setting
into the DM9000 as we now have ethtool support for reading
and writing the EEPROM.

Signed-off-by: Ben Dooks <[EMAIL PROTECTED]>

Index: linux-2.6.23-quilt3/drivers/net/dm9000.c
===
--- linux-2.6.23-quilt3.orig/drivers/net/dm9000.c
+++ linux-2.6.23-quilt3/drivers/net/dm9000.c
@@ -196,10 +196,6 @@ static void dm9000_write_eeprom(board_in
 static void dm9000_rx(struct net_device *);
 static void dm9000_hash_table(struct net_device *);
 
-//#define DM9000_PROGRAM_EEPROM
-#ifdef DM9000_PROGRAM_EEPROM
-static void program_eeprom(board_info_t * db);
-#endif
 /* DM9000 network board routine  */
 
 static void
@@ -707,9 +703,6 @@ dm9000_probe(struct platform_device *pde
ndev->poll_controller= &dm9000_poll_controller;
 #endif
 
-#ifdef DM9000_PROGRAM_EEPROM
-   program_eeprom(db);
-#endif
db->msg_enable   = NETIF_MSG_LINK;
db->mii.phy_id_mask  = 0x1f;
db->mii.reg_num_mask = 0x1f;
@@ -1178,28 +1171,6 @@ dm9000_write_eeprom(board_info_t *db, in
mutex_unlock(&db->addr_lock);
 }
 
-#ifdef DM9000_PROGRAM_EEPROM
-/*
- * Only for development:
- * Here we write static data to the eeprom in case
- * we don't have valid content on a new board
- */
-static void
-program_eeprom(board_info_t * db)
-{
-   u16 eeprom[] = { 0x0c00, 0x007f, 0x1300,/* MAC Address */
-   0x, /* Autoload: accept nothing */
-   0x0a46, 0x9000, /* Vendor / Product ID */
-   0x, /* pin control */
-   0x,
-   };  /* Wake-up mode control */
-   int i;
-   for (i = 0; i < 8; i++)
-   write_srom_word(db, i, eeprom[i]);
-}
-#endif
-
-
 /*
  *  Calculate the CRC valude of the Rx packet
  *  flag = 1 : return the reverse CRC (for the received packet CRC)

-- 
Ben ([EMAIL PROTECTED], http://www.fluff.org/)

  'a smiley only costs 4 bytes'
-
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[patch 07/22] NET: DM9000: Use msleep() instead of udelay()

2007-11-19 Thread Ben Dooks
We can use sleeping functions when reading and writing the
PHY registers, so let us sleep instead of busy waiting for
the PHY.

Note, this also fixes a bug reading the PHY where only 100uS
was being used instead of 150uS

Signed-off-by: Ben Dooks <[EMAIL PROTECTED]>

Index: linux-2.6.23-quilt3/drivers/net/dm9000.c
===
--- linux-2.6.23-quilt3.orig/drivers/net/dm9000.c
+++ linux-2.6.23-quilt3/drivers/net/dm9000.c
@@ -114,6 +114,7 @@ typedef struct board_info {
u8 io_mode; /* 0:word, 2:byte */
u8 phy_addr;
unsigned int flags;
+   unsigned int in_suspend :1;
 
int debug_level;
 
@@ -1174,6 +1175,18 @@ dm9000_hash_table(struct net_device *dev
 
 
 /*
+ * Sleep, either by using msleep() or if we are suspending, then
+ * use mdelay() to sleep.
+ */
+static void dm9000_msleep(board_info_t *db, unsigned int ms)
+{
+   if (db->in_suspend)
+   mdelay(ms);
+   else
+   msleep(ms);
+}
+
+/*
  *   Read a word from phyxcer
  */
 static int
@@ -1197,7 +1210,7 @@ dm9000_phy_read(struct net_device *dev, 
writeb(reg_save, db->io_addr);
spin_unlock_irqrestore(&db->lock,flags);
 
-   udelay(100);/* Wait read complete */
+   dm9000_msleep(db, 1);   /* Wait read complete */
 
spin_lock_irqsave(&db->lock,flags);
reg_save = readb(db->io_addr);
@@ -1241,7 +1254,7 @@ dm9000_phy_write(struct net_device *dev,
writeb(reg_save, db->io_addr);
spin_unlock_irqrestore(&db->lock,flags);
 
-   udelay(500);/* Wait write complete */
+   dm9000_msleep(db, 1);   /* Wait write complete */
 
spin_lock_irqsave(&db->lock,flags);
reg_save = readb(db->io_addr);
@@ -1258,8 +1271,12 @@ static int
 dm9000_drv_suspend(struct platform_device *dev, pm_message_t state)
 {
struct net_device *ndev = platform_get_drvdata(dev);
+   board_info_t *db;
 
if (ndev) {
+   db = (board_info_t *) ndev->priv;
+   db->in_suspend = 1;
+
if (netif_running(ndev)) {
netif_device_detach(ndev);
dm9000_shutdown(ndev);
@@ -1282,6 +1299,8 @@ dm9000_drv_resume(struct platform_device
 
netif_device_attach(ndev);
}
+
+   db->in_suspend = 0;
}
return 0;
 }

-- 
Ben ([EMAIL PROTECTED], http://www.fluff.org/)

  'a smiley only costs 4 bytes'
-
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[patch 14/22] NET: DM9000: Remove unnecessary changelog in header comment

2007-11-19 Thread Ben Dooks
We have a perfectly good version control system, so we do not
need to duplicate change comments in the header for this code.

Signed-off-by: Ben Dooks <[EMAIL PROTECTED]>

Index: linux-2.6.23-quilt2/drivers/net/dm9000.c
===
--- linux-2.6.23-quilt2.orig/drivers/net/dm9000.c
+++ linux-2.6.23-quilt2/drivers/net/dm9000.c
@@ -1,7 +1,5 @@
 /*
- *   dm9000.c: Version 1.2 03/18/2003
- *
- * A Davicom DM9000 ISA NIC fast Ethernet driver for Linux.
+ *  Davicom DM9000 Fast Ethernet driver for Linux.
  * Copyright (C) 1997  Sten Wang
  *
  * This program is free software; you can redistribute it and/or
@@ -14,44 +12,11 @@
  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  * GNU General Public License for more details.
  *
- *   (C)Copyright 1997-1998 DAVICOM Semiconductor,Inc. All Rights Reserved.
- *
- * V0.11   06/20/2001  REG_0A bit3=1, default enable BP with DA match
- * 06/22/2001  Support DM9801 progrmming
- * E3: R25 = ((R24 + NF) & 0x00ff) | 0xf000
- * E4: R25 = ((R24 + NF) & 0x00ff) | 0xc200
- * R17 = (R17 & 0xfff0) | NF + 3
- * E5: R25 = ((R24 + NF - 3) & 0x00ff) | 0xc200
- * R17 = (R17 & 0xfff0) | NF
- *
- * v1.00   modify by simon 2001.9.5
- * change for kernel 2.4.x
- *
- * v1.1   11/09/2001   fix force mode bug
- *
- * v1.2   03/18/2003   Weilun Huang <[EMAIL PROTECTED]>:
- * Fixed phy reset.
- * Added tx/rx 32 bit mode.
- * Cleaned up for kernel merge.
- *
- *03/03/2004Sascha Hauer <[EMAIL PROTECTED]>
- *  Port to 2.6 kernel
- *
- *   24-Sep-2004   Ben Dooks <[EMAIL PROTECTED]>
- * Cleanup of code to remove ifdefs
- * Allowed platform device data to influence access width
- * Reformatting areas of code
- *
- *17-Mar-2005   Sascha Hauer <[EMAIL PROTECTED]>
- *  * removed 2.4 style module parameters
- *  * removed removed unused stat counter and fixed
- *net_device_stats
- *  * introduced tx_timeout function
- *  * reworked locking
+ * (C) Copyright 1997-1998 DAVICOM Semiconductor,Inc. All Rights Reserved.
  *
- *   01-Jul-2005   Ben Dooks <[EMAIL PROTECTED]>
- * * fixed spinlock call without pointer
- * * ensure spinlock is initialised
+ * Additional updates, Copyright:
+ * Ben Dooks <[EMAIL PROTECTED]>
+ * Sascha Hauer <[EMAIL PROTECTED]>
  */
 
 #include 

-- 
Ben ([EMAIL PROTECTED], http://www.fluff.org/)

  'a smiley only costs 4 bytes'
-
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[patch 01/22] NET: DM9000 use dev_xxx() instead of printk for output.

2007-11-19 Thread Ben Dooks
Move to using dev_dbg() and friends for the output of
information to the user.

Signed-off-by: Ben Dooks <[EMAIL PROTECTED]>

Index: linux-2.6.22-quilt4/drivers/net/dm9000.c
===
--- linux-2.6.22-quilt4.orig/drivers/net/dm9000.c
+++ linux-2.6.22-quilt4/drivers/net/dm9000.c
@@ -142,6 +142,8 @@ typedef struct board_info {
void (*outblk)(void __iomem *port, void *data, int length);
void (*dumpblk)(void __iomem *port, int length);
 
+   struct device   *dev;/* parent device */
+
struct resource *addr_res;   /* resources found */
struct resource *data_res;
struct resource *addr_req;   /* resources requested */
@@ -187,7 +189,8 @@ static void program_eeprom(board_info_t 
 static void
 dm9000_reset(board_info_t * db)
 {
-   PRINTK1("dm9000x: resetting\n");
+   dev_dbg(db->dev, "resetting device\n");
+
/* RESET device */
writeb(DM9000_NCR, db->io_addr);
udelay(200);
@@ -303,14 +306,10 @@ static void dm9000_set_io(struct board_i
db->inblk   = dm9000_inblk_8bit;
break;
 
-   case 2:
-   db->dumpblk = dm9000_dumpblk_16bit;
-   db->outblk  = dm9000_outblk_16bit;
-   db->inblk   = dm9000_inblk_16bit;
-   break;
 
case 3:
-   printk(KERN_ERR PFX ": 3 byte IO, falling back to 16bit\n");
+   dev_dbg(db->dev, ": 3 byte IO, falling back to 16bit\n");
+   case 2:
db->dumpblk = dm9000_dumpblk_16bit;
db->outblk  = dm9000_outblk_16bit;
db->inblk   = dm9000_inblk_16bit;
@@ -413,19 +412,21 @@ dm9000_probe(struct platform_device *pde
/* Init network device */
ndev = alloc_etherdev(sizeof (struct board_info));
if (!ndev) {
-   printk("%s: could not allocate device.\n", CARDNAME);
+   dev_err(&pdev->dev, "could not allocate device.\n");
return -ENOMEM;
}
 
SET_MODULE_OWNER(ndev);
SET_NETDEV_DEV(ndev, &pdev->dev);
 
-   PRINTK2("dm9000_probe()");
+   dev_dbg(&pdev->dev, "probing device\n");
 
/* setup board info structure */
db = (struct board_info *) ndev->priv;
memset(db, 0, sizeof (*db));
 
+   db->dev = &pdev->dev;
+
spin_lock_init(&db->lock);
 
if (pdev->num_resources < 2) {
@@ -454,7 +455,7 @@ dm9000_probe(struct platform_device *pde
 
if (db->addr_res == NULL || db->data_res == NULL ||
db->irq_res == NULL) {
-   printk(KERN_ERR PFX "insufficient resources\n");
+   dev_err(db->dev, "insufficient resources\n");
ret = -ENOENT;
goto out;
}
@@ -464,7 +465,7 @@ dm9000_probe(struct platform_device *pde
  pdev->name);
 
if (db->addr_req == NULL) {
-   printk(KERN_ERR PFX "cannot claim address reg area\n");
+   dev_err(db->dev, "cannot claim address reg area\n");
ret = -EIO;
goto out;
}
@@ -472,7 +473,7 @@ dm9000_probe(struct platform_device *pde
db->io_addr = ioremap(db->addr_res->start, i);
 
if (db->io_addr == NULL) {
-   printk(KERN_ERR "failed to ioremap address reg\n");
+   dev_err(db->dev, "failed to ioremap address reg\n");
ret = -EINVAL;
goto out;
}
@@ -482,7 +483,7 @@ dm9000_probe(struct platform_device *pde
  pdev->name);
 
if (db->data_req == NULL) {
-   printk(KERN_ERR PFX "cannot claim data reg area\n");
+   dev_err(db->dev, "cannot claim data reg area\n");
ret = -EIO;
goto out;
}
@@ -490,7 +491,7 @@ dm9000_probe(struct platform_device *pde
db->io_data = ioremap(db->data_res->start, iosize);
 
if (db->io_data == NULL) {
-   printk(KERN_ERR "failed to ioremap data reg\n");
+   dev_err(db->dev,"failed to ioremap data reg\n");
ret = -EINVAL;
goto out;
}
@@ -544,11 +545,11 @@ dm9000_probe(struct platform_device *pde
 
if (id_val == DM9000_ID)
break;
-   printk(&

[patch 10/22] NET: DM9000: Add ethtool support for reading and writing EEPROM

2007-11-19 Thread Ben Dooks
Add ethtool support to access the configuration EEPROM
connected to the DM9000.

Signed-off-by: Ben Dooks <[EMAIL PROTECTED]>

Index: linux-2.6.23-quilt3/drivers/net/dm9000.c
===
--- linux-2.6.23-quilt3.orig/drivers/net/dm9000.c
+++ linux-2.6.23-quilt3/drivers/net/dm9000.c
@@ -191,7 +191,8 @@ static int dm9000_phy_read(struct net_de
 static void dm9000_phy_write(struct net_device *dev, int phyaddr_unused, int 
reg,
   int value);
 
-static void dm9000_read_eeprom(board_info_t *, int addr, unsigned char *to);
+static void dm9000_read_eeprom(board_info_t *, int addr, u8 *to);
+static void dm9000_write_eeprom(board_info_t *, int addr, u8 *dp);
 static void dm9000_rx(struct net_device *);
 static void dm9000_hash_table(struct net_device *);
 
@@ -414,12 +415,65 @@ static u32 dm9000_get_link(struct net_de
return mii_link_ok(&dm->mii);
 }
 
+#define DM_EEPROM_MAGIC(0x444D394B)
+
+static int dm9000_get_eeprom_len(struct net_device *dev)
+{
+   return 128;
+}
+
+static int dm9000_get_eeprom(struct net_device *dev,
+struct ethtool_eeprom *ee, u8 *data)
+{
+   board_info_t *dm = to_dm9000_board(dev);
+   int offset = ee->offset;
+   int len = ee->len;
+   int i;
+
+   /* EEPROM access is aligned to two bytes */
+
+   if ((len & 1) != 0 || (offset & 1) != 0)
+   return -EINVAL;
+
+   ee->magic = DM_EEPROM_MAGIC;
+
+   for (i = 0; i < len; i += 2)
+   dm9000_read_eeprom(dm, (offset + i) / 2, data + i);
+
+   return 0;
+}
+
+static int dm9000_set_eeprom(struct net_device *dev,
+struct ethtool_eeprom *ee, u8 *data)
+{
+   board_info_t *dm = to_dm9000_board(dev);
+   int offset = ee->offset;
+   int len = ee->len;
+   int i;
+
+   /* EEPROM access is aligned to two bytes */
+
+   if ((len & 1) != 0 || (offset & 1) != 0)
+   return -EINVAL;
+
+   if (ee->magic != DM_EEPROM_MAGIC)
+   return -EINVAL;
+
+   for (i = 0; i < len; i += 2)
+   dm9000_write_eeprom(dm, (offset + i) / 2, data + i);
+
+   return 0;
+}
+
 static const struct ethtool_ops dm9000_ethtool_ops = {
.get_drvinfo= dm9000_get_drvinfo,
.get_settings   = dm9000_get_settings,
.set_settings   = dm9000_set_settings,
.nway_reset = dm9000_nway_reset,
.get_link   = dm9000_get_link,
+   .get_eeprom_len = dm9000_get_eeprom_len,
+   .get_eeprom = dm9000_get_eeprom,
+   .set_eeprom = dm9000_set_eeprom,
 };
 
 
@@ -1074,7 +1128,7 @@ dm9000_rx(struct net_device *dev)
  *  Read a word data from EEPROM
  */
 static void
-dm9000_read_eeprom(board_info_t *db, int offset, unsigned char *to)
+dm9000_read_eeprom(board_info_t *db, int offset, u8 *to)
 {
mutex_lock(&db->addr_lock);
 
@@ -1090,18 +1144,17 @@ dm9000_read_eeprom(board_info_t *db, int
mutex_unlock(&db->addr_lock);
 }
 
-#ifdef DM9000_PROGRAM_EEPROM
 /*
  * Write a word data to SROM
  */
 static void
-write_srom_word(board_info_t * db, int offset, u16 val)
+dm9000_write_eeprom(board_info_t *db, int offset, u8 *data)
 {
mutex_lock(&db->addr_lock);
 
iow(db, DM9000_EPAR, offset);
-   iow(db, DM9000_EPDRH, ((val >> 8) & 0xff));
-   iow(db, DM9000_EPDRL, (val & 0xff));
+   iow(db, DM9000_EPDRH, data[1]);
+   iow(db, DM9000_EPDRL, data[0]);
iow(db, DM9000_EPCR, EPCR_WEP | EPCR_ERPRW);
mdelay(8);  /* same shit */
iow(db, DM9000_EPCR, 0);
@@ -1109,6 +1162,7 @@ write_srom_word(board_info_t * db, int o
mutex_unlock(&db->addr_lock);
 }
 
+#ifdef DM9000_PROGRAM_EEPROM
 /*
  * Only for development:
  * Here we write static data to the eeprom in case

-- 
Ben ([EMAIL PROTECTED], http://www.fluff.org/)

  'a smiley only costs 4 bytes'
-
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[patch 03/22] NET: DM9000: Pass IRQ flags via platform data

2007-11-19 Thread Ben Dooks
Use the platform data to pass modifications to the flags
passed to request_irq() to alter the behaviour of the IRQ.

This can be used to specify IRQ type for the platform the
DM9000 is connected to.

Signed-off-by: Ben Dooks <[EMAIL PROTECTED]>

Index: linux-2.6.22-quilt6/drivers/net/dm9000.c
===
--- linux-2.6.22-quilt6.orig/drivers/net/dm9000.c   2007-08-20 
18:26:22.0 +0100
+++ linux-2.6.22-quilt6/drivers/net/dm9000.c2007-08-20 18:37:54.0 
+0100
@@ -89,9 +89,6 @@
 #define writesboutsb
 #define writeswoutsw
 #define writesloutsl
-#define DM9000_IRQ_FLAGS   (IRQF_SHARED | IRQF_TRIGGER_HIGH)
-#else
-#define DM9000_IRQ_FLAGS   IRQF_SHARED
 #endif
 
 /*
@@ -124,6 +121,8 @@ typedef struct board_info {
 
struct device   *dev;/* parent device */
 
+   struct dm9000_plat_data *platdata;
+
struct resource *addr_res;   /* resources found */
struct resource *data_res;
struct resource *addr_req;   /* resources requested */
@@ -496,9 +495,11 @@ dm9000_probe(struct platform_device *pde
 
/* check to see if anything is being over-ridden */
if (pdata != NULL) {
+   db->platdata = pdata;
+
/* check to see if the driver wants to over-ride the
 * default IO width */
-
+ 
if (pdata->flags & DM9000_PLATF_8BITONLY)
dm9000_set_io(db, 1);
 
@@ -619,10 +620,14 @@ static int
 dm9000_open(struct net_device *dev)
 {
board_info_t *db = (board_info_t *) dev->priv;
+   unsigned long irqflags = IRQF_SHARED;
 
dev_dbg(db->dev, "entering %s\n", __func__);
 
-   if (request_irq(dev->irq, &dm9000_interrupt, DM9000_IRQ_FLAGS, 
dev->name, dev))
+   if (db->platdata)
+   irqflags |= db->platdata->irqflags;
+
+   if (request_irq(dev->irq, &dm9000_interrupt, irqflags, dev->name, dev))
return -EAGAIN;
 
/* Initialize DM9000 board */
Index: linux-2.6.22-quilt6/include/linux/dm9000.h
===
--- linux-2.6.22-quilt6.orig/include/linux/dm9000.h 2007-08-20 
18:19:04.0 +0100
+++ linux-2.6.22-quilt6/include/linux/dm9000.h  2007-08-20 18:28:37.0 
+0100
@@ -25,6 +25,7 @@
 
 struct dm9000_plat_data {
unsigned intflags;
+   unsigned long   irqflags;   /* to pass to request_irq() */
 
/* allow replacement IO routines */
 

-- 
Ben ([EMAIL PROTECTED], http://www.fluff.org/)

  'a smiley only costs 4 bytes'
-
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[patch 16/22] NET: DM9000: Fix delays used by EEPROM read and write

2007-11-19 Thread Ben Dooks
The code was using a delay of 8ms, when it should have been
using the EEPROM status flag from the device to indicate the
EEPROM transaction had finished.

Signed-off-by: Ben Dooks <[EMAIL PROTECTED]>

Index: linux-2.6.23-quilt3/drivers/net/dm9000.c
===
--- linux-2.6.23-quilt3.orig/drivers/net/dm9000.c
+++ linux-2.6.23-quilt3/drivers/net/dm9000.c
@@ -1114,6 +1114,50 @@ dm9000_rx(struct net_device *dev)
} while (rxbyte == DM9000_PKT_RDY);
 }
 
+static unsigned int
+dm9000_read_locked(board_info_t *db, int reg)
+{
+   unsigned long flags;
+   unsigned int ret;
+
+   spin_lock_irqsave(&db->lock, flags);
+   ret = ior(db, reg);
+   spin_unlock_irqrestore(&db->lock, flags);
+
+   return ret;
+}
+
+static int dm9000_wait_eeprom(board_info_t *db)
+{
+   unsigned int status;
+   int timeout = 8;/* wait max 8msec */
+
+   /* The DM9000 data sheets say we should be able to
+* poll the ERRE bit in EPCR to wait for the EEPROM
+* operation. From testing several chips, this bit
+* does not seem to work. 
+*
+* We attempt to use the bit, but fall back to the
+* timeout (which is why we do not return an error
+* on expiry) to say that the EEPROM operation has
+* completed.
+*/
+
+   while (1) {
+   status = dm9000_read_locked(db, DM9000_EPCR);
+
+   if ((status & EPCR_ERRE) == 0)
+   break;
+
+   if (timeout-- < 0) {
+   dev_dbg(db->dev, "timeout waiting EEPROM\n");
+   break;
+   }
+   }
+
+   return 0;
+}
+
 /*
  *  Read a word data from EEPROM
  */
@@ -1131,8 +1175,10 @@ dm9000_read_eeprom(board_info_t *db, int
 
spin_unlock_irqrestore(&db->lock, flags);
 
-   mdelay(8);  /* according to the datasheet 200us should be 
enough,
-  but it doesn't work */
+   dm9000_wait_eeprom(db);
+
+   /* delay for at-least 150uS */
+   msleep(1);
 
spin_lock_irqsave(&db->lock, flags);
 
@@ -1163,7 +1209,9 @@ dm9000_write_eeprom(board_info_t *db, in
iow(db, DM9000_EPCR, EPCR_WEP | EPCR_ERPRW);
spin_unlock_irqrestore(&db->lock, flags);
 
-   mdelay(8);  /* same shit */
+   dm9000_wait_eeprom(db);
+
+   mdelay(1);  /* wait at least 150uS to clear */
 
spin_lock_irqsave(&db->lock, flags);
iow(db, DM9000_EPCR, 0);

-- 
Ben ([EMAIL PROTECTED], http://www.fluff.org/)

  'a smiley only costs 4 bytes'
-
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[patch 02/22] NET: DM9000 update debugging macros to use debug level

2007-11-19 Thread Ben Dooks
Change the debug macros to use the compiler to elide any
unnecessary debug level, and to allow device configurable
debug control.

Signed-off-by: Ben Dooks <[EMAIL PROTECTED]>

Index: linux-2.6.23-quilt1/drivers/net/Kconfig
===
--- linux-2.6.23-quilt1.orig/drivers/net/Kconfig
+++ linux-2.6.23-quilt1/drivers/net/Kconfig
@@ -940,6 +940,14 @@ config DM9000
  .  The module will be
  called dm9000.
 
+config DM9000_DEBUGLEVEL
+   int "DM9000 maximum debug level"
+   depends on DM9000
+   default 4
+   help
+ The maximum level of debugging code compiled into the DM9000
+ driver.
+
 config SMC911X
tristate "SMSC LAN911[5678] support"
select CRC32
Index: linux-2.6.23-quilt1/drivers/net/dm9000.c
===
--- linux-2.6.23-quilt1.orig/drivers/net/dm9000.c
+++ linux-2.6.23-quilt1/drivers/net/dm9000.c
@@ -82,28 +82,6 @@
 
 #define DM9000_TIMER_WUT  jiffies+(HZ*2)   /* timer wakeup time : 2 second 
*/
 
-#define DM9000_DEBUG 0
-
-#if DM9000_DEBUG > 2
-#define PRINTK3(args...)  printk(CARDNAME ": " args)
-#else
-#define PRINTK3(args...)  do { } while(0)
-#endif
-
-#if DM9000_DEBUG > 1
-#define PRINTK2(args...)  printk(CARDNAME ": " args)
-#else
-#define PRINTK2(args...)  do { } while(0)
-#endif
-
-#if DM9000_DEBUG > 0
-#define PRINTK1(args...)  printk(CARDNAME ": " args)
-#define PRINTK(args...)   printk(CARDNAME ": " args)
-#else
-#define PRINTK1(args...)  do { } while(0)
-#define PRINTK(args...)   printk(KERN_DEBUG args)
-#endif
-
 #ifdef CONFIG_BLACKFIN
 #define readsb insb
 #define readsw insw
@@ -138,6 +116,8 @@ typedef struct board_info {
u8 phy_addr;
unsigned int flags;
 
+   int debug_level;
+
void (*inblk)(void __iomem *port, void *data, int length);
void (*outblk)(void __iomem *port, void *data, int length);
void (*dumpblk)(void __iomem *port, int length);
@@ -159,6 +139,15 @@ typedef struct board_info {
u32 msg_enable;
 } board_info_t;
 
+/* debug code */
+
+#define dm9000_dbg(db, lev, msg...) do {   \
+   if ((lev) < CONFIG_DM9000_DEBUGLEVEL && \
+   (lev) < db->debug_level) {  \
+   dev_dbg(db->dev, msg);  \
+   }   \
+} while (0)
+
 /* function declaration - */
 static int dm9000_probe(struct platform_device *);
 static int dm9000_open(struct net_device *);
@@ -664,7 +653,7 @@ dm9000_init_dm9000(struct net_device *de
 {
board_info_t *db = (board_info_t *) dev->priv;
 
-   PRINTK1("entering %s\n",__FUNCTION__);
+   dm9000_dbg(db, 1, "entering %s\n", __func__);
 
/* I/O mode */
db->io_mode = ior(db, DM9000_ISR) >> 6; /* ISR bit7:6 keeps I/O mode */
@@ -710,7 +699,7 @@ dm9000_start_xmit(struct sk_buff *skb, s
unsigned long flags;
board_info_t *db = (board_info_t *) dev->priv;
 
-   PRINTK3("dm9000_start_xmit\n");
+   dm9000_dbg(db, 3, "%s:\n", __func__);
 
if (db->tx_pkt_cnt > 1)
return 1;
@@ -769,7 +758,7 @@ dm9000_stop(struct net_device *ndev)
 {
board_info_t *db = (board_info_t *) ndev->priv;
 
-   PRINTK1("entering %s\n",__FUNCTION__);
+   dm9000_dbg(db, 1, "entering %s\n", __func__);
 
/* deleted timer */
del_timer(&db->timer);
@@ -815,19 +804,14 @@ static irqreturn_t
 dm9000_interrupt(int irq, void *dev_id)
 {
struct net_device *dev = dev_id;
-   board_info_t *db;
+   board_info_t *db = (board_info_t *) dev->priv;
int int_status;
u8 reg_save;
 
-   PRINTK3("entering %s\n",__FUNCTION__);
-
-   if (!dev) {
-   PRINTK1("dm9000_interrupt() without DEVICE arg\n");
-   return IRQ_HANDLED;
-   }
+   dm9000_dbg(db, 3, "entering %s\n", __func__);
 
/* A real interrupt coming */
-   db = (board_info_t *) dev->priv;
+
spin_lock(&db->lock);
 
/* Save previous register address */
@@ -880,7 +864,7 @@ dm9000_timer(unsigned long data)
struct net_device *dev = (struct net_device *) data;
board_info_t *db = (board_info_t *) dev->priv;
 
-   PRINTK3("dm9000_timer()\n");
+   dm9000_dbg(db, 3, "entering %s\n", __func__);
 
mii_check_media(&db->mii, netif_msg_link(db), 0);
 
@@ -1065,7 +1049,7 @@ dm9000_hash_table(struct net_device *dev
u16 i, oft, hash_table[4];
unsigned long flags;
 
-   PRINTK2("dm9000_hash_table()\n");
+   dm9000_dbg(db, 1, "entering %s\n", __func__);
 
spin

[patch 08/22] NET: DM9000: Remove barely used SROM array read.

2007-11-19 Thread Ben Dooks
The srom array in the board data is only being used in the device probe
routines. The probe also only uses the first 6 bytes of an array
we spend 512ms reading 128 bytes from. Change to reading the
MAC area directly to the MAC address structure.

As a side product, we rename the read_srom_word to dm9000_read_eeprom
to bring it into line with the rest of the driver. No change is made
to the delay in this function, which will be dealt with in a later
patch.

Signed-off-by: Ben Dooks <[EMAIL PROTECTED]>


Index: linux-2.6.23-quilt5/drivers/net/dm9000.c
===
--- linux-2.6.23-quilt5.orig/drivers/net/dm9000.c
+++ linux-2.6.23-quilt5/drivers/net/dm9000.c
@@ -134,7 +134,6 @@ typedef struct board_info {
 
struct task_struct *thread;
struct net_device_stats stats;
-   unsigned char srom[128];
spinlock_t lock;
 
struct mii_if_info mii;
@@ -171,7 +170,8 @@ static irqreturn_t dm9000_interrupt(int,
 static int dm9000_phy_read(struct net_device *dev, int phyaddr_unsused, int 
reg);
 static void dm9000_phy_write(struct net_device *dev, int phyaddr_unused, int 
reg,
   int value);
-static u16 read_srom_word(board_info_t *, int);
+
+static void dm9000_read_eeprom(board_info_t *, int addr, unsigned char *to);
 static void dm9000_rx(struct net_device *);
 static void dm9000_hash_table(struct net_device *);
 
@@ -638,13 +638,9 @@ dm9000_probe(struct platform_device *pde
db->mii.mdio_read= dm9000_phy_read;
db->mii.mdio_write   = dm9000_phy_write;
 
-   /* Read SROM content */
-   for (i = 0; i < 64; i++)
-   ((u16 *) db->srom)[i] = read_srom_word(db, i);
-
-   /* Set Node Address */
-   for (i = 0; i < 6; i++)
-   ndev->dev_addr[i] = db->srom[i];
+   /* try reading the node address from the attached EEPROM */
+   for (i = 0; i < 6; i += 2)
+   dm9000_read_eeprom(db, i / 2, ndev->dev_addr+i);
 
if (!is_valid_ether_addr(ndev->dev_addr)) {
/* try reading from mac */
@@ -1064,17 +1060,19 @@ dm9000_rx(struct net_device *dev)
 }
 
 /*
- *  Read a word data from SROM
+ *  Read a word data from EEPROM
  */
-static u16
-read_srom_word(board_info_t * db, int offset)
+static void
+dm9000_read_eeprom(board_info_t * db, int offset, unsigned char *to)
 {
iow(db, DM9000_EPAR, offset);
iow(db, DM9000_EPCR, EPCR_ERPRR);
mdelay(8);  /* according to the datasheet 200us should be 
enough,
   but it doesn't work */
iow(db, DM9000_EPCR, 0x0);
-   return (ior(db, DM9000_EPDRL) + (ior(db, DM9000_EPDRH) << 8));
+
+   to[0] = ior(db, DM9000_EPDRL);
+   to[1] = ior(db, DM9000_EPDRH);
 }
 
 #ifdef DM9000_PROGRAM_EEPROM

-- 
Ben ([EMAIL PROTECTED], http://www.fluff.org/)

  'a smiley only costs 4 bytes'
-
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[patch 15/22] NET: DM9000: Use netif_msg to enable debugging options

2007-11-19 Thread Ben Dooks
Use the netif_msg_*() macros to enable the debugging based
on the board's msg_enable field. The output still goes via
the dev_dbg() macros, so will be tagged and output as 
appropriate.

Signed-off-by: Ben Dooks <[EMAIL PROTECTED]>

Index: linux-2.6.23-quilt4/drivers/net/dm9000.c
===
--- linux-2.6.23-quilt4.orig/drivers/net/dm9000.c
+++ linux-2.6.23-quilt4/drivers/net/dm9000.c
@@ -745,7 +745,8 @@ dm9000_open(struct net_device *dev)
board_info_t *db = (board_info_t *) dev->priv;
unsigned long irqflags = IRQF_SHARED;
 
-   dev_dbg(db->dev, "entering %s\n", __func__);
+   if (netif_msg_ifup(db))
+   dev_dbg(db->dev, "enabling %s\n", dev->name);
 
if (db->platdata)
irqflags |= db->platdata->irqflags;
@@ -881,7 +882,8 @@ dm9000_stop(struct net_device *ndev)
 {
board_info_t *db = (board_info_t *) ndev->priv;
 
-   dm9000_dbg(db, 1, "entering %s\n", __func__);
+   if (netif_msg_ifdown(db))
+   dev_dbg(db->dev, "shutting down %s\n", ndev->name);
 
/* deleted timer */
kthread_stop(db->thread);
@@ -912,6 +914,9 @@ dm9000_tx_done(struct net_device *dev, b
db->tx_pkt_cnt--;
db->stats.tx_packets++;
 
+   if (netif_msg_tx_done(db))
+   dev_dbg(db->dev, "tx done, NSR %02x\n", tx_status);
+
/* Queue packet check & send */
if (db->tx_pkt_cnt > 0) {
iow(db, DM9000_TXPLL, db->queue_pkt_len & 0xff);
@@ -947,6 +952,9 @@ dm9000_interrupt(int irq, void *dev_id)
int_status = ior(db, DM9000_ISR);   /* Got ISR */
iow(db, DM9000_ISR, int_status);/* Clear ISR status */
 
+   if (netif_msg_intr(db))
+   dev_dbg(db->dev, "interrupt status %02x\n", int_status);
+
/* Received the coming packet */
if (int_status & ISR_PRS)
dm9000_rx(dev);
@@ -1048,10 +1056,15 @@ dm9000_rx(struct net_device *dev)
 
RxLen = le16_to_cpu(rxhdr.RxLen);
 
+   if (netif_msg_rx_status(db))
+   dev_dbg(db->dev, "RX: status %02x, length %04x\n",
+   rxhdr.RxStatus, RxLen);
+
/* Packet Status check */
if (RxLen < 0x40) {
GoodPacket = false;
-   dev_dbg(db->dev, "Bad Packet received (runt)\n");
+   if (netif_msg_rx_err(db))
+   dev_dbg(db->dev, "RX: Bad Packet (runt)\n");
}
 
if (RxLen > DM9000_PKT_MAX) {
@@ -1061,15 +1074,18 @@ dm9000_rx(struct net_device *dev)
if (rxhdr.RxStatus & 0xbf) {
GoodPacket = false;
if (rxhdr.RxStatus & 0x01) {
-   dev_dbg(db->dev, "fifo error\n");
+   if (netif_msg_rx_err(db))
+   dev_dbg(db->dev, "fifo error\n");
db->stats.rx_fifo_errors++;
}
if (rxhdr.RxStatus & 0x02) {
-   dev_dbg(db->dev, "crc error\n");
+   if (netif_msg_rx_err(db))
+   dev_dbg(db->dev, "crc error\n");
db->stats.rx_crc_errors++;
}
if (rxhdr.RxStatus & 0x80) {
-   dev_dbg(db->dev, "length error\n");
+   if (netif_msg_rx_err(db))
+   dev_dbg(db->dev, "length error\n");
db->stats.rx_length_errors++;
}
}

-- 
Ben ([EMAIL PROTECTED], http://www.fluff.org/)

  'a smiley only costs 4 bytes'
-
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[patch 05/22] NET: DM9000: Do not sleep with spinlock and IRQs held

2007-11-19 Thread Ben Dooks
The phy read and write routines call udelay() with the board
lock held, and with the posibility of IRQs being disabled. Since
these delays can be up to 500usec, and are only required as we
have to save the chip's address register. 

To improve the behaviour, hold the lock whilst we are writing
and then restore the state before the delay and then repeat
the process once the delay has happened.

Signed-off-by: Ben Dooks <[EMAIL PROTECTED]>

Index: linux-2.6.23-quilt3/drivers/net/dm9000.c
===
--- linux-2.6.23-quilt3.orig/drivers/net/dm9000.c
+++ linux-2.6.23-quilt3/drivers/net/dm9000.c
@@ -1171,7 +1171,15 @@ dm9000_phy_read(struct net_device *dev, 
iow(db, DM9000_EPAR, DM9000_PHY | reg);
 
iow(db, DM9000_EPCR, 0xc);  /* Issue phyxcer read command */
+
+   writeb(reg_save, db->io_addr);
+   spin_unlock_irqrestore(&db->lock,flags);
+
udelay(100);/* Wait read complete */
+
+   spin_lock_irqsave(&db->lock,flags);
+   reg_save = readb(db->io_addr);
+
iow(db, DM9000_EPCR, 0x0);  /* Clear phyxcer read command */
 
/* The read data keeps on REG_0D & REG_0E */
@@ -1179,7 +1187,6 @@ dm9000_phy_read(struct net_device *dev, 
 
/* restore the previous address */
writeb(reg_save, db->io_addr);
-
spin_unlock_irqrestore(&db->lock,flags);
 
return ret;
@@ -1208,7 +1215,15 @@ dm9000_phy_write(struct net_device *dev,
iow(db, DM9000_EPDRH, ((value >> 8) & 0xff));
 
iow(db, DM9000_EPCR, 0xa);  /* Issue phyxcer write command */
+
+   writeb(reg_save, db->io_addr);
+   spin_unlock_irqrestore(&db->lock,flags);
+
udelay(500);/* Wait write complete */
+
+   spin_lock_irqsave(&db->lock,flags);
+   reg_save = readb(db->io_addr);
+
iow(db, DM9000_EPCR, 0x0);  /* Clear phyxcer write command */
 
/* restore the previous address */

-- 
Ben ([EMAIL PROTECTED], http://www.fluff.org/)

  'a smiley only costs 4 bytes'
-
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[patch 00/22] DM9000 updates for 2.6.25

2007-11-19 Thread Ben Dooks
This is my current proposed patch series to the DM9000
driver for both general cleanups, support for ethtool
and to make the code better.

-- 
Ben ([EMAIL PROTECTED], http://www.fluff.org/)

  'a smiley only costs 4 bytes'
-
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[patch 19/22] NET: DM9000: Add platform flag for no attached EEPROM

2007-11-19 Thread Ben Dooks
Allow the platform data to specify to the DM9000 driver
that there is no posibility of an attached EEPROM on the
device, so default all reads to 0xff and ignore any
write operations.

Signed-off-by: Ben Dooks <[EMAIL PROTECTED]>

Index: linux-2.6.23-quilt3/drivers/net/dm9000.c
===
--- linux-2.6.23-quilt3.orig/drivers/net/dm9000.c
+++ linux-2.6.23-quilt3/drivers/net/dm9000.c
@@ -410,6 +410,9 @@ static int dm9000_get_eeprom(struct net_
if ((len & 1) != 0 || (offset & 1) != 0)
return -EINVAL;
 
+   if (dm->flags & DM9000_PLATF_NO_EEPROM)
+   return -ENOENT;
+
ee->magic = DM_EEPROM_MAGIC;
 
for (i = 0; i < len; i += 2)
@@ -431,6 +434,9 @@ static int dm9000_set_eeprom(struct net_
if ((len & 1) != 0 || (offset & 1) != 0)
return -EINVAL;
 
+   if (dm->flags & DM9000_PLATF_NO_EEPROM)
+   return -ENOENT;
+
if (ee->magic != DM_EEPROM_MAGIC)
return -EINVAL;
 
@@ -1166,6 +1172,12 @@ dm9000_read_eeprom(board_info_t *db, int
 {
unsigned long flags;
 
+   if (db->flags & DM9000_PLATF_NO_EEPROM) {
+   to[0] = 0xff;
+   to[1] = 0xff;
+   return;
+   }
+
mutex_lock(&db->addr_lock);
 
spin_lock_irqsave(&db->lock, flags);
@@ -1200,6 +1212,9 @@ dm9000_write_eeprom(board_info_t *db, in
 {
unsigned long flags;
 
+   if (db->flags & DM9000_PLATF_NO_EEPROM)
+   return;
+
mutex_lock(&db->addr_lock);
 
spin_lock_irqsave(&db->lock, flags);
Index: linux-2.6.23-quilt3/include/linux/dm9000.h
===
--- linux-2.6.23-quilt3.orig/include/linux/dm9000.h
+++ linux-2.6.23-quilt3/include/linux/dm9000.h
@@ -20,6 +20,7 @@
 #define DM9000_PLATF_16BITONLY (0x0002)
 #define DM9000_PLATF_32BITONLY (0x0004)
 #define DM9000_PLATF_EXT_PHY   (0x0008)
+#define DM9000_PLATF_NO_EEPROM (0x0010)
 
 /* platfrom data for platfrom device structure's platfrom_data field */
 

-- 
Ben ([EMAIL PROTECTED], http://www.fluff.org/)

  'a smiley only costs 4 bytes'
-
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[patch 13/22] NET: DM9000: Ensure spinlock held whilst accessing EEPROM registers

2007-11-19 Thread Ben Dooks
Ensure we hold the spinlock whilst the registers and being
modified even though we hold the overall lock. This should
protect against an interrupt happening whilst we are using
the device.

Signed-off-by: Ben Dooks <[EMAIL PROTECTED]>

Index: linux-2.6.23-quilt3/drivers/net/dm9000.c
===
--- linux-2.6.23-quilt3.orig/drivers/net/dm9000.c
+++ linux-2.6.23-quilt3/drivers/net/dm9000.c
@@ -1139,17 +1139,29 @@ dm9000_rx(struct net_device *dev)
 static void
 dm9000_read_eeprom(board_info_t *db, int offset, u8 *to)
 {
+   unsigned long flags;
+
mutex_lock(&db->addr_lock);
 
+   spin_lock_irqsave(&db->lock, flags);
+
iow(db, DM9000_EPAR, offset);
iow(db, DM9000_EPCR, EPCR_ERPRR);
+
+   spin_unlock_irqrestore(&db->lock, flags);
+
mdelay(8);  /* according to the datasheet 200us should be 
enough,
   but it doesn't work */
+
+   spin_lock_irqsave(&db->lock, flags);
+
iow(db, DM9000_EPCR, 0x0);
 
to[0] = ior(db, DM9000_EPDRL);
to[1] = ior(db, DM9000_EPDRH);
 
+   spin_unlock_irqrestore(&db->lock, flags);
+
mutex_unlock(&db->addr_lock);
 }
 
@@ -1159,14 +1171,22 @@ dm9000_read_eeprom(board_info_t *db, int
 static void
 dm9000_write_eeprom(board_info_t *db, int offset, u8 *data)
 {
+   unsigned long flags;
+
mutex_lock(&db->addr_lock);
 
+   spin_lock_irqsave(&db->lock, flags);
iow(db, DM9000_EPAR, offset);
iow(db, DM9000_EPDRH, data[1]);
iow(db, DM9000_EPDRL, data[0]);
iow(db, DM9000_EPCR, EPCR_WEP | EPCR_ERPRW);
+   spin_unlock_irqrestore(&db->lock, flags);
+
mdelay(8);  /* same shit */
+
+   spin_lock_irqsave(&db->lock, flags);
iow(db, DM9000_EPCR, 0);
+   spin_unlock_irqrestore(&db->lock, flags);
 
mutex_unlock(&db->addr_lock);
 }

-- 
Ben ([EMAIL PROTECTED], http://www.fluff.org/)

  'a smiley only costs 4 bytes'
-
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[patch 20/22] NET: DM9000: Add support for MII ioctl() calls

2007-11-19 Thread Ben Dooks
Add entry to handle the MII ioctl() calls via the
generic_mii_ioctl call.

Signed-off-by: Ben Dooks <[EMAIL PROTECTED]>

Index: linux-2.6.23-quilt3/drivers/net/dm9000.c
===
--- linux-2.6.23-quilt3.orig/drivers/net/dm9000.c
+++ linux-2.6.23-quilt3/drivers/net/dm9000.c
@@ -148,6 +148,8 @@ static int dm9000_mii_thread(void *data)
 
 static void dm9000_init_dm9000(struct net_device *);
 
+static int dm9000_ioctl(struct net_device *dev, struct ifreq *req, int cmd);
+
 static struct net_device_stats *dm9000_get_stats(struct net_device *);
 
 static irqreturn_t dm9000_interrupt(int, void *);
@@ -337,6 +339,16 @@ static void dm9000_poll_controller(struc
 }
 #endif
 
+static int dm9000_ioctl(struct net_device *dev, struct ifreq *req, int cmd)
+{
+   board_info_t *dm = to_dm9000_board(dev);
+
+   if (!netif_running(dev))
+   return -EINVAL;
+
+   return generic_mii_ioctl(&dm->mii, if_mii(req), cmd, NULL);
+}
+
 /* ethtool ops */
 
 static void dm9000_get_drvinfo(struct net_device *dev,
@@ -669,6 +681,7 @@ dm9000_probe(struct platform_device *pde
ndev->get_stats  = &dm9000_get_stats;
ndev->set_multicast_list = &dm9000_hash_table;
ndev->ethtool_ops= &dm9000_ethtool_ops;
+   ndev->do_ioctl   = &dm9000_ioctl;
 
 #ifdef CONFIG_NET_POLL_CONTROLLER
ndev->poll_controller= &dm9000_poll_controller;

-- 
Ben ([EMAIL PROTECTED], http://www.fluff.org/)

  'a smiley only costs 4 bytes'
-
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[patch 09/22] NET: DM9000: Add mutex to protect access

2007-11-19 Thread Ben Dooks
Add a mutex to serialise access to the chip functions from
entries such as the ethtool and the MII code. This should
reduce the amount of time the spinlock is held to protect
the address register. 

Signed-off-by: Ben Dooks <[EMAIL PROTECTED]>

Index: linux-2.6.23-quilt3/drivers/net/dm9000.c
===
--- linux-2.6.23-quilt3.orig/drivers/net/dm9000.c
+++ linux-2.6.23-quilt3/drivers/net/dm9000.c
@@ -100,6 +100,24 @@ static int watchdog = 5000;
 module_param(watchdog, int, 0400);
 MODULE_PARM_DESC(watchdog, "transmit timeout in milliseconds");
 
+/* DM9000 register address locking.
+ *
+ * The DM9000 uses an address register to control where data written
+ * to the data register goes. This means that the address register
+ * must be preserved over interrupts or similar calls.
+ *
+ * During interrupt and other critical calls, a spinlock is used to
+ * protect the system, but the calls themselves save the address
+ * in the address register in case they are interrupting another
+ * access to the device.
+ *
+ * For general accesses a lock is provided so that calls which are
+ * allowed to sleep are serialised so that the address register does
+ * not need to be saved. This lock also serves to serialise access
+ * to the EEPROM and PHY access registers which are shared between
+ * these two devices.
+ */
+
 /* Structure/enum declaration --- */
 typedef struct board_info {
 
@@ -132,6 +150,8 @@ typedef struct board_info {
struct resource *data_req;
struct resource *irq_res;
 
+   struct mutexaddr_lock;  /* phy and eeprom access lock */
+
struct task_struct *thread;
struct net_device_stats stats;
spinlock_t lock;
@@ -370,26 +390,16 @@ static void dm9000_get_drvinfo(struct ne
 static int dm9000_get_settings(struct net_device *dev, struct ethtool_cmd *cmd)
 {
board_info_t *dm = to_dm9000_board(dev);
-   unsigned long flags;
 
-   spin_lock_irqsave(&dm->lock, flags);
mii_ethtool_gset(&dm->mii, cmd);
-   spin_lock_irqsave(&dm->lock, flags);
-
return 0;
 }
 
 static int dm9000_set_settings(struct net_device *dev, struct ethtool_cmd *cmd)
 {
board_info_t *dm = to_dm9000_board(dev);
-   unsigned long flags;
-   int rc;
-
-   spin_lock_irqsave(&dm->lock, flags);
-   rc = mii_ethtool_sset(&dm->mii, cmd);
-   spin_lock_irqsave(&dm->lock, flags);
 
-   return rc;
+   return mii_ethtool_sset(&dm->mii, cmd);
 }
 
 static int dm9000_nway_reset(struct net_device *dev)
@@ -481,6 +491,7 @@ dm9000_probe(struct platform_device *pde
db->dev = &pdev->dev;
 
spin_lock_init(&db->lock);
+   mutex_init(&db->addr_lock);
 
if (pdev->num_resources < 2) {
ret = -ENODEV;
@@ -1063,8 +1074,10 @@ dm9000_rx(struct net_device *dev)
  *  Read a word data from EEPROM
  */
 static void
-dm9000_read_eeprom(board_info_t * db, int offset, unsigned char *to)
+dm9000_read_eeprom(board_info_t *db, int offset, unsigned char *to)
 {
+   mutex_lock(&db->addr_lock);
+
iow(db, DM9000_EPAR, offset);
iow(db, DM9000_EPCR, EPCR_ERPRR);
mdelay(8);  /* according to the datasheet 200us should be 
enough,
@@ -1073,6 +1086,8 @@ dm9000_read_eeprom(board_info_t * db, in
 
to[0] = ior(db, DM9000_EPDRL);
to[1] = ior(db, DM9000_EPDRH);
+
+   mutex_unlock(&db->addr_lock);
 }
 
 #ifdef DM9000_PROGRAM_EEPROM
@@ -1082,12 +1097,16 @@ dm9000_read_eeprom(board_info_t * db, in
 static void
 write_srom_word(board_info_t * db, int offset, u16 val)
 {
+   mutex_lock(&db->addr_lock);
+
iow(db, DM9000_EPAR, offset);
iow(db, DM9000_EPDRH, ((val >> 8) & 0xff));
iow(db, DM9000_EPDRL, (val & 0xff));
iow(db, DM9000_EPCR, EPCR_WEP | EPCR_ERPRW);
mdelay(8);  /* same shit */
iow(db, DM9000_EPCR, 0);
+
+   mutex_unlock(&db->addr_lock);
 }
 
 /*
@@ -1195,6 +1214,8 @@ dm9000_phy_read(struct net_device *dev, 
unsigned int reg_save;
int ret;
 
+   mutex_lock(&db->addr_lock);
+
spin_lock_irqsave(&db->lock,flags);
 
/* Save previous register address */
@@ -1222,6 +1243,7 @@ dm9000_phy_read(struct net_device *dev, 
writeb(reg_save, db->io_addr);
spin_unlock_irqrestore(&db->lock,flags);
 
+   mutex_unlock(&db->addr_lock);
return ret;
 }
 
@@ -1235,6 +1257,8 @@ dm9000_phy_write(struct net_device *dev,
unsigned long flags;
unsigned long reg_save;
 
+   mutex_lock(&db->addr_lock);
+
spin_lock_irqsave(&db->lock,flags);
 
/* Save previous register address */
@@ -1250,7 +1274,7 @@ dm9000_phy_write(struct net_device *dev,
iow(db, DM9000_EPCR, 

[patch 06/22] NET: DM9000: Use kthread to probe MII status when device open

2007-11-19 Thread Ben Dooks
When the device is open, we have to probe the PHY's MII status
periodically as there is no status change interrupt. As the 
phy code is going to change to using calls which might sleep
we move to using a kthread instead of a timer.

Signed-off-by: Ben Dooks <[EMAIL PROTECTED]>

Index: linux-2.6.23-quilt3/drivers/net/dm9000.c
===
--- linux-2.6.23-quilt3.orig/drivers/net/dm9000.c
+++ linux-2.6.23-quilt3/drivers/net/dm9000.c
@@ -66,6 +66,8 @@
 #include 
 #include 
 #include 
+#include 
+#include 
 #include 
 
 #include 
@@ -82,8 +84,6 @@
 #define PFX CARDNAME ": "
 #define DRV_VERSION"1.30"
 
-#define DM9000_TIMER_WUT  jiffies+(HZ*2)   /* timer wakeup time : 2 second 
*/
-
 #ifdef CONFIG_BLACKFIN
 #define readsb insb
 #define readsw insw
@@ -131,7 +131,7 @@ typedef struct board_info {
struct resource *data_req;
struct resource *irq_res;
 
-   struct timer_list timer;
+   struct task_struct *thread;
struct net_device_stats stats;
unsigned char srom[128];
spinlock_t lock;
@@ -159,9 +159,8 @@ static int dm9000_probe(struct platform_
 static int dm9000_open(struct net_device *);
 static int dm9000_start_xmit(struct sk_buff *, struct net_device *);
 static int dm9000_stop(struct net_device *);
+static int dm9000_mii_thread(void *data);
 
-
-static void dm9000_timer(unsigned long);
 static void dm9000_init_dm9000(struct net_device *);
 
 static struct net_device_stats *dm9000_get_stats(struct net_device *);
@@ -679,6 +678,27 @@ dm9000_probe(struct platform_device *pde
return ret;
 }
 
+static void dm9000_start_thread(struct net_device *dev)
+{
+   board_info_t *db = (board_info_t *) dev->priv;
+
+   /* Create a thread to keep track of the state of the phy
+* as we do not get an interrupt when the PHY state changes.
+*
+* Note, we do not abort the open if we fail to create the
+* thread, as this is mainly to ensure the user is kept up to
+* date with the device's state. PHY accesses will still work
+* via the MII read and write methods.
+*/
+
+   db->thread = kthread_create(dm9000_mii_thread, db, dev->name);
+   if (IS_ERR(db->thread)) {
+   dev_err(db->dev, "failed to create MII thread\n");
+   db->thread = NULL;
+   } else
+   wake_up_process(db->thread);
+}
+
 /*
  *  Open the interface.
  *  The interface is opened whenever "ifconfig" actives it.
@@ -704,12 +724,7 @@ dm9000_open(struct net_device *dev)
/* Init driver variable */
db->dbug_cnt = 0;
 
-   /* set and active a timer process */
-   init_timer(&db->timer);
-   db->timer.expires  = DM9000_TIMER_WUT;
-   db->timer.data = (unsigned long) dev;
-   db->timer.function = &dm9000_timer;
-   add_timer(&db->timer);
+   dm9000_start_thread(dev);
 
mii_check_media(&db->mii, netif_msg_link(db), 1);
netif_start_queue(dev);
@@ -833,7 +848,7 @@ dm9000_stop(struct net_device *ndev)
dm9000_dbg(db, 1, "entering %s\n", __func__);
 
/* deleted timer */
-   del_timer(&db->timer);
+   kthread_stop(db->thread);
 
netif_stop_queue(ndev);
netif_carrier_off(ndev);
@@ -925,24 +940,31 @@ dm9000_get_stats(struct net_device *dev)
return &db->stats;
 }
 
+#define DM9000_MII_POLLFREQ(2000)
 
-/*
- *  A periodic timer routine
- *  Dynamic media sense, allocated Rx buffer...
- */
-static void
-dm9000_timer(unsigned long data)
+static int
+dm9000_mii_thread(void *pw)
 {
-   struct net_device *dev = (struct net_device *) data;
-   board_info_t *db = (board_info_t *) dev->priv;
+   board_info_t *db = pw;
+   unsigned long next = jiffies + msecs_to_jiffies(DM9000_MII_POLLFREQ);
 
dm9000_dbg(db, 3, "entering %s\n", __func__);
 
-   mii_check_media(&db->mii, netif_msg_link(db), 0);
+   while (!kthread_should_stop()) {
+   set_current_state(TASK_INTERRUPTIBLE);
+   try_to_freeze();
+
+   if (time_after(jiffies, next)) {
+   mii_check_media(&db->mii, netif_msg_link(db), 0);
+   next = jiffies;
+   next += msecs_to_jiffies(DM9000_MII_POLLFREQ);
+   }
+
+   msleep_interruptible(DM9000_MII_POLLFREQ);
+   }
 
-   /* Set timer again */
-   db->timer.expires = DM9000_TIMER_WUT;
-   add_timer(&db->timer);
+   dm9000_dbg(db, 3, "leaving %s\n", __func__);
+   return 0;
 }
 
 struct dm9000_rxhdr {

-- 
Ben ([EMAIL PROTECTED], http://www.fluff.org/)

  'a smiley only costs 4 bytes'
-
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[patch 22/22] NET: DM9000: Show the MAC address source after printing MAC

2007-11-19 Thread Ben Dooks
Show whether the MAC address was read from the EEPROM or
the onboard PAR registers.

Signed-off-by: Ben Dooks <[EMAIL PROTECTED]>

Index: linux-2.6.23-quilt5/drivers/net/dm9000.c
===
--- linux-2.6.23-quilt5.orig/drivers/net/dm9000.c
+++ linux-2.6.23-quilt5/drivers/net/dm9000.c
@@ -515,6 +515,7 @@ dm9000_probe(struct platform_device *pde
struct dm9000_plat_data *pdata = pdev->dev.platform_data;
struct board_info *db;  /* Point a board information structure */
struct net_device *ndev;
+   const unsigned char *mac_src;
unsigned long base;
int ret = 0;
int iosize;
@@ -696,13 +697,16 @@ dm9000_probe(struct platform_device *pde
db->mii.mdio_read= dm9000_phy_read;
db->mii.mdio_write   = dm9000_phy_write;
 
+   mac_src = "eeprom";
+
/* try reading the node address from the attached EEPROM */
for (i = 0; i < 6; i += 2)
dm9000_read_eeprom(db, i / 2, ndev->dev_addr+i);
 
if (!is_valid_ether_addr(ndev->dev_addr)) {
/* try reading from mac */
-
+   
+   mac_src = "chip";
for (i = 0; i < 6; i++)
ndev->dev_addr[i] = ior(db, i+DM9000_PAR);
}
@@ -719,7 +723,7 @@ dm9000_probe(struct platform_device *pde
   ndev->name,  db->io_addr, db->io_data, ndev->irq);
for (i = 0; i < 5; i++)
printk("%02x:", ndev->dev_addr[i]);
-   printk("%02x\n", ndev->dev_addr[5]);
+   printk("%02x (%s)\n", ndev->dev_addr[5], mac_src);
}
return 0;
 

-- 
Ben ([EMAIL PROTECTED], http://www.fluff.org/)

  'a smiley only costs 4 bytes'
-
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[patch 18/22] NET: DM9000: Remove redudant use of "& 0xff"

2007-11-19 Thread Ben Dooks
The writing of the data should implicitly truncate
the data to 8bits, so do not bother with the ands
in the code.

Signed-off-by: Ben Dooks <[EMAIL PROTECTED]>

Index: linux-2.6.23-quilt3/drivers/net/dm9000.c
===
--- linux-2.6.23-quilt3.orig/drivers/net/dm9000.c
+++ linux-2.6.23-quilt3/drivers/net/dm9000.c
@@ -840,8 +840,8 @@ dm9000_start_xmit(struct sk_buff *skb, s
/* TX control: First packet immediately send, second packet queue */
if (db->tx_pkt_cnt == 1) {
/* Set TX length to DM9000 */
-   iow(db, DM9000_TXPLL, skb->len & 0xff);
-   iow(db, DM9000_TXPLH, (skb->len >> 8) & 0xff);
+   iow(db, DM9000_TXPLL, skb->len);
+   iow(db, DM9000_TXPLH, skb->len >> 8);
 
/* Issue TX polling command */
iow(db, DM9000_TCR, TCR_TXREQ); /* Cleared after TX complete */
@@ -919,8 +919,8 @@ dm9000_tx_done(struct net_device *dev, b
 
/* Queue packet check & send */
if (db->tx_pkt_cnt > 0) {
-   iow(db, DM9000_TXPLL, db->queue_pkt_len & 0xff);
-   iow(db, DM9000_TXPLH, (db->queue_pkt_len >> 8) & 0xff);
+   iow(db, DM9000_TXPLL, db->queue_pkt_len);
+   iow(db, DM9000_TXPLH, db->queue_pkt_len >> 8);
iow(db, DM9000_TCR, TCR_TXREQ);
dev->trans_start = jiffies;
}
@@ -1341,8 +1341,8 @@ dm9000_phy_write(struct net_device *dev,
iow(db, DM9000_EPAR, DM9000_PHY | reg);
 
/* Fill the written data into REG_0D & REG_0E */
-   iow(db, DM9000_EPDRL, (value & 0xff));
-   iow(db, DM9000_EPDRH, ((value >> 8) & 0xff));
+   iow(db, DM9000_EPDRL, value);
+   iow(db, DM9000_EPDRH, value >> 8);
 
iow(db, DM9000_EPCR, 0xa);  /* Issue phyxcer write command */
 

-- 
Ben ([EMAIL PROTECTED], http://www.fluff.org/)

  'a smiley only costs 4 bytes'
-
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[patch 11/22] NET: DM9000: Add ethtool control of msg_enable value

2007-11-19 Thread Ben Dooks
Allow the msg_enable value to be read and written by
the ethtool interface.

Signed-off-by: Ben Dooks <[EMAIL PROTECTED]>

Index: linux-2.6.23-quilt3/drivers/net/dm9000.c
===
--- linux-2.6.23-quilt3.orig/drivers/net/dm9000.c
+++ linux-2.6.23-quilt3/drivers/net/dm9000.c
@@ -388,6 +388,20 @@ static void dm9000_get_drvinfo(struct ne
strcpy(info->bus_info, to_platform_device(dm->dev)->name);
 }
 
+static u32 dm9000_get_msglevel(struct net_device *dev)
+{
+   board_info_t *dm = to_dm9000_board(dev);
+
+   return dm->msg_enable;
+}
+
+static void dm9000_set_msglevel(struct net_device *dev, u32 value)
+{
+   board_info_t *dm = to_dm9000_board(dev);
+
+   dm->msg_enable = value;
+}
+
 static int dm9000_get_settings(struct net_device *dev, struct ethtool_cmd *cmd)
 {
board_info_t *dm = to_dm9000_board(dev);
@@ -469,6 +483,8 @@ static const struct ethtool_ops dm9000_e
.get_drvinfo= dm9000_get_drvinfo,
.get_settings   = dm9000_get_settings,
.set_settings   = dm9000_set_settings,
+   .get_msglevel   = dm9000_get_msglevel,
+   .set_msglevel   = dm9000_set_msglevel,
.nway_reset = dm9000_nway_reset,
.get_link   = dm9000_get_link,
.get_eeprom_len = dm9000_get_eeprom_len,

-- 
Ben ([EMAIL PROTECTED], http://www.fluff.org/)

  'a smiley only costs 4 bytes'
-
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[patch 04/22] NET: DM9000: Add initial ethtool support

2007-11-19 Thread Ben Dooks
Add support for ethtool operations for the DM9000.

Signed-off-by: Ben Dooks <[EMAIL PROTECTED]>

Index: linux-2.6.23-quilt3/drivers/net/dm9000.c
===
--- linux-2.6.23-quilt3.orig/drivers/net/dm9000.c
+++ linux-2.6.23-quilt3/drivers/net/dm9000.c
@@ -63,6 +63,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -79,6 +80,7 @@
 
 #define CARDNAME "dm9000"
 #define PFX CARDNAME ": "
+#define DRV_VERSION"1.30"
 
 #define DM9000_TIMER_WUT  jiffies+(HZ*2)   /* timer wakeup time : 2 second 
*/
 
@@ -147,6 +149,11 @@ typedef struct board_info {
}   \
 } while (0)
 
+static inline board_info_t *to_dm9000_board(struct net_device *dev)
+{
+   return dev->priv;
+}
+
 /* function declaration - */
 static int dm9000_probe(struct platform_device *);
 static int dm9000_open(struct net_device *);
@@ -348,6 +355,64 @@ static void dm9000_poll_controller(struc
 }
 #endif
 
+/* ethtool ops */
+
+static void dm9000_get_drvinfo(struct net_device *dev,
+  struct ethtool_drvinfo *info)
+{
+   board_info_t *dm = to_dm9000_board(dev);
+
+   strcpy(info->driver, CARDNAME);
+   strcpy(info->version, DRV_VERSION);
+   strcpy(info->bus_info, to_platform_device(dm->dev)->name);
+}
+
+static int dm9000_get_settings(struct net_device *dev, struct ethtool_cmd *cmd)
+{
+   board_info_t *dm = to_dm9000_board(dev);
+   unsigned long flags;
+
+   spin_lock_irqsave(&dm->lock, flags);
+   mii_ethtool_gset(&dm->mii, cmd);
+   spin_lock_irqsave(&dm->lock, flags);
+
+   return 0;
+}
+
+static int dm9000_set_settings(struct net_device *dev, struct ethtool_cmd *cmd)
+{
+   board_info_t *dm = to_dm9000_board(dev);
+   unsigned long flags;
+   int rc;
+
+   spin_lock_irqsave(&dm->lock, flags);
+   rc = mii_ethtool_sset(&dm->mii, cmd);
+   spin_lock_irqsave(&dm->lock, flags);
+
+   return rc;
+}
+
+static int dm9000_nway_reset(struct net_device *dev)
+{
+   board_info_t *dm = to_dm9000_board(dev);
+   return mii_nway_restart(&dm->mii);
+}
+
+static u32 dm9000_get_link(struct net_device *dev)
+{
+   board_info_t *dm = to_dm9000_board(dev);
+   return mii_link_ok(&dm->mii);
+}
+
+static const struct ethtool_ops dm9000_ethtool_ops = {
+   .get_drvinfo= dm9000_get_drvinfo,
+   .get_settings   = dm9000_get_settings,
+   .set_settings   = dm9000_set_settings,
+   .nway_reset = dm9000_nway_reset,
+   .get_link   = dm9000_get_link,
+};
+
+
 /* dm9000_release_board
  *
  * release a board, and any mapped resources
@@ -555,6 +620,8 @@ dm9000_probe(struct platform_device *pde
ndev->stop   = &dm9000_stop;
ndev->get_stats  = &dm9000_get_stats;
ndev->set_multicast_list = &dm9000_hash_table;
+   ndev->ethtool_ops= &dm9000_ethtool_ops;
+
 #ifdef CONFIG_NET_POLL_CONTROLLER
ndev->poll_controller= &dm9000_poll_controller;
 #endif
@@ -1211,7 +1278,7 @@ static struct platform_driver dm9000_dri
 static int __init
 dm9000_init(void)
 {
-   printk(KERN_INFO "%s Ethernet Driver\n", CARDNAME);
+   printk(KERN_INFO "%s Ethernet Driver, V%s\n", CARDNAME, DRV_VERSION);
 
return platform_driver_register(&dm9000_driver);/* search board 
and register */
 }

-- 
Ben ([EMAIL PROTECTED], http://www.fluff.org/)

  'a smiley only costs 4 bytes'
-
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[patch 21/22] NET: DM9000: Update retry count whilst identifying chip

2007-11-19 Thread Ben Dooks
Reading the ID register does not always return the correct ID
from the device, so we retry several times to see if we get
a correct value.

These failures seem to be excaserbated by the speed of the
access to the chip (possibly time between issuing the address
and then the data cycle).

Signed-off-by: Ben Dooks <[EMAIL PROTECTED]>

Index: linux-2.6.23-quilt3/drivers/net/dm9000.c
===
--- linux-2.6.23-quilt3.orig/drivers/net/dm9000.c
+++ linux-2.6.23-quilt3/drivers/net/dm9000.c
@@ -652,7 +652,7 @@ dm9000_probe(struct platform_device *pde
dm9000_reset(db);
 
/* try two times, DM9000 sometimes gets the first read wrong */
-   for (i = 0; i < 2; i++) {
+   for (i = 0; i < 8; i++) {
id_val  = ior(db, DM9000_VIDL);
id_val |= (u32)ior(db, DM9000_VIDH) << 8;
id_val |= (u32)ior(db, DM9000_PIDL) << 16;

-- 
Ben ([EMAIL PROTECTED], http://www.fluff.org/)

  'a smiley only costs 4 bytes'
-
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[patch 17/22] NET: DM9000: Remove cal_CRC() and use ether_crc_le instead

2007-11-19 Thread Ben Dooks
Remove the cal_CRC as this is basically wrappering the
ether_crc_le function, and is only being used by the
multicast hash table functions.

Signed-off-by: Ben Dooks <[EMAIL PROTECTED]>

Index: linux-2.6.23-quilt3/drivers/net/dm9000.c
===
--- linux-2.6.23-quilt3.orig/drivers/net/dm9000.c
+++ linux-2.6.23-quilt3/drivers/net/dm9000.c
@@ -1221,24 +1221,6 @@ dm9000_write_eeprom(board_info_t *db, in
 }
 
 /*
- *  Calculate the CRC valude of the Rx packet
- *  flag = 1 : return the reverse CRC (for the received packet CRC)
- * 0 : return the normal CRC (for Hash Table index)
- */
-
-static unsigned long
-cal_CRC(unsigned char *Data, unsigned int Len, u8 flag)
-{
-
-   u32 crc = ether_crc_le(Len, Data);
-
-   if (flag)
-   return ~crc;
-
-   return crc;
-}
-
-/*
  *  Set DM9000 multicast address
  */
 static void
@@ -1247,15 +1229,16 @@ dm9000_hash_table(struct net_device *dev
board_info_t *db = (board_info_t *) dev->priv;
struct dev_mc_list *mcptr = dev->mc_list;
int mc_cnt = dev->mc_count;
+   int i, oft;
u32 hash_val;
-   u16 i, oft, hash_table[4];
+   u16 hash_table[4];
unsigned long flags;
 
dm9000_dbg(db, 1, "entering %s\n", __func__);
 
-   spin_lock_irqsave(&db->lock,flags);
+   spin_lock_irqsave(&db->lock, flags);
 
-   for (i = 0, oft = 0x10; i < 6; i++, oft++)
+   for (i = 0, oft = DM9000_PAR; i < 6; i++, oft++)
iow(db, oft, dev->dev_addr[i]);
 
/* Clear Hash Table */
@@ -1267,17 +1250,17 @@ dm9000_hash_table(struct net_device *dev
 
/* the multicast address in Hash Table : 64 bits */
for (i = 0; i < mc_cnt; i++, mcptr = mcptr->next) {
-   hash_val = cal_CRC((char *) mcptr->dmi_addr, 6, 0) & 0x3f;
+   hash_val = ether_crc_le(6, mcptr->dmi_addr) & 0x3f;
hash_table[hash_val / 16] |= (u16) 1 << (hash_val % 16);
}
 
/* Write the hash table to MAC MD table */
-   for (i = 0, oft = 0x16; i < 4; i++) {
-   iow(db, oft++, hash_table[i] & 0xff);
-   iow(db, oft++, (hash_table[i] >> 8) & 0xff);
+   for (i = 0, oft = DM9000_MAR; i < 4; i++) {
+   iow(db, oft++, hash_table[i]);
+   iow(db, oft++, hash_table[i] >> 8);
}
 
-   spin_unlock_irqrestore(&db->lock,flags);
+   spin_unlock_irqrestore(&db->lock, flags);
 }
 
 

-- 
Ben ([EMAIL PROTECTED], http://www.fluff.org/)

  'a smiley only costs 4 bytes'
-
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [BUG] New Kernel Bugs

2007-11-15 Thread Ben Dooks
On Tue, Nov 13, 2007 at 10:34:37PM +, Russell King wrote:
> On Tue, Nov 13, 2007 at 06:25:16PM +, Alan Cox wrote:
> > > Given the wide range of ARM platforms today, it is utterly idiotic to
> > > expect a single person to be able to provide responses for all ARM bugs.
> > > I for one wish I'd never *VOLUNTEERED* to be a part of the kernel
> > > bugzilla, and really *WISH* I could pull out of that function.
> > 
> > You can. Perhaps that bugzilla needs to point to some kind of
> > [EMAIL PROTECTED] list for the various ARM platform
> > maintainers ?
> 
> That might work - though it would be hard to get all the platform
> maintainers to be signed up to yet another mailing list, I'm sure
> sufficient would do.

As long as it would just be bug reports, I'm sure that most of us
could be persuaded to subscribe. Adding another list for general
discussions is probably not going to be read, the current list
provides more than enough to keep us busy.

-- 
Ben

Q:  What's a light-year?
A:  One-third less calories than a regular year.

-
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [RFC] dependencies for platform drivers (was Re: ax88796: add superh to kconfig dependencies)

2007-11-09 Thread Ben Dooks
On Thu, Nov 08, 2007 at 08:18:54AM +, Al Viro wrote:
> On Thu, Nov 08, 2007 at 04:31:05PM +0900, Magnus Damm wrote:
> >  config AX88796
> > tristate "ASIX AX88796 NE2000 clone support"
> > -   depends on ARM || MIPS
> > +   depends on ARM || MIPS || SUPERH
> 
> You know, that really sucks more and more.  How about doing the following:
>   a) making it depend on PLAT_HAS_AX88796
>   b) adding selects for all subarchitectures that have the corresponding
> platform device
> and setting that as a uniform policy for platform drivers?  For things like
> SM501 we would do
> config MFD_SM501
>   depends on PCI || PLAT_HAS_SM501
> etc.

The PLAT_HAS_xxx method is nice, and I would like it applied to other places
in the kernel (see libata arugment below), and would have acked
this patch if it hadn't already been applied by Jeff.

The only reservation is that this doesn't show up the posibilty
of having the driver in the menuconfig, but anyone adding new
board support (should) be bright enough to look through the
Kconfig scripts before deciding they need to write an entirely
new driver.

I would note you may want to do PLAT_HAS_NET_AX88796 as there is
entirely a posibility of confusing this with the simple parallel
port driver which a board may not have support for.

> Seriously, folks, we are getting shitloads of platform drivers with no
> dependencies whatsoever, needed on a handful of targets and occasionally
> failing to build on unrelated architectures.  Moreover, having a list
> of architectures in dependencies for each of those suckers is a PITA
> from the conflict POV.  Not to mention platform drivers that fall into
> the mainline kernel with not a single platform device for them, etc.

There is a general problem with chicken-vs-egg here, how do you submit
support for a machine's platform device without the platform device
being there (and vice-versa) with seperate maintainers for network
and machine support?

One of my colleagues has passed along comments you made about a pair
of the simtec drivers (simtec-i2c and simtec-ide) which have been
added, but have no current users as patches have been stalled either
in submission process, or awaiting for an resolution. In the case
of simtec-ide, I would like to replace it with platform-ata, but
the libata maintainers seem wholy un-interested in
PLAT_HAS_PLATFORM_ATA or similar.

-- 
Ben ([EMAIL PROTECTED], http://www.fluff.org/)

  'a smiley only costs 4 bytes'
-
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [RFC] dependencies for platform drivers (was Re: ax88796: add superh to kconfig dependencies)

2007-11-09 Thread Ben Dooks
On Fri, Nov 09, 2007 at 06:40:23PM +0900, Paul Mundt wrote:
> On Fri, Nov 09, 2007 at 09:26:52AM +, Ralf Baechle wrote:
> > If writesb() is not an official API then maybe the answer should have been
> > to either add that API to other architectures or fix the driver.
> > 
> > I guess this incident means I need to go through all Kconfig* files to
> > see what bogus architecture dependencies on MIPS or !MIPS exist ...
> > 
> While writesb() isn't an official API, the iowriteX_rep() interfaces
> theoretically are. Tidying up the driver for iomap is probably a better
> option.

If anyone else isn't interested in doing this, and there are
no objections to having it done, then I would be willing to
look at moving to the iowrite interfaces.

The only other way would be to add an 8/16bit configuration
to drop the use of writesb, as I belive most people connect
these devices in 16bit mode.

-- 
Ben ([EMAIL PROTECTED], http://www.fluff.org/)

  'a smiley only costs 4 bytes'
-
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH] DM9000: fix interface hang under load

2007-08-23 Thread Ben Dooks
On Tue, Aug 21, 2007 at 01:33:42AM +0200, Florian Westphal wrote:
> When transferring data at full speed, the DM9000 network interface
> sometimes stops sending/receiving data. Worse, ksoftirqd consumes
> 100% cpu and the net tx watchdog never triggers.

A newline here would have helped readability.

> Fix by spin_lock_irqsave() in dm9000_start_xmit() to prevent the
> interrupt handler from interfering.

I personally have not come across this during any of our testing,
but it is possible that an ARM9 has slightly different interrupt
behaviour to the PXAs.

Changing to use spin_lock_irqsave() is probably a much safer
way of stopping this happening than trying to disable the
interrupts comming from the chip, and spin_lock_irqsave() is
not exactly expensive. This will also stop dm9000_start_xmit from
being interrupted by the watchdog.

I will update my local DM9000 patch set for after the 2.6.23 release.

> Signed-off-by: Florian Westphal <[EMAIL PROTECTED]>
Acked-by: Ben Dooks <[EMAIL PROTECTED]>
> ---
>  Actually the comments ('Disable all interrupts, iow(db, DM9000_IMR, IMR_PAR) 
> etc)
>  give the impression that the interrupt handler cannot run during 
> dm9000_start_xmit(),
>  however this isn't correct (perhaps the chipset has some weird timing 
> issues?).
>  The interface lockup usually occurs between 30 and 360 seconds after 
> starting transmitting
>  data (netcat /dev/zero) at full speed; with this patch applied I haven't 
> been able
>  to reproduce hangs yet (ran for > 2h).
>  FTR: This is a dm9000 on XScale-PXA255 rev 6 (ARMv5TE)/Compulab CM-x255, i.e.
>  a module not supported by the vanilla kernel. Tested on (patched) 2.6.18.
> 
>  dm9000.c |   25 +++--
>  1 file changed, 7 insertions(+), 18 deletions(-)
> 
> diff --git a/drivers/net/dm9000.c b/drivers/net/dm9000.c
> index c3de81b..738aa59 100644
> --- a/drivers/net/dm9000.c
> +++ b/drivers/net/dm9000.c
> @@ -700,6 +700,7 @@ dm9000_init_dm9000(struct net_device *dev)
>  static int
>  dm9000_start_xmit(struct sk_buff *skb, struct net_device *dev)
>  {
> + unsigned long flags;
>   board_info_t *db = (board_info_t *) dev->priv;
>  
>   PRINTK3("dm9000_start_xmit\n");
> @@ -707,10 +708,7 @@ dm9000_start_xmit(struct sk_buff *skb, struct net_device 
> *dev)
>   if (db->tx_pkt_cnt > 1)
>   return 1;
>  
> - netif_stop_queue(dev);
> -
> - /* Disable all interrupts */
> - iow(db, DM9000_IMR, IMR_PAR);
> + spin_lock_irqsave(&db->lock, flags);
>  
>   /* Move data to DM9000 TX RAM */
>   writeb(DM9000_MWCMD, db->io_addr);
> @@ -718,12 +716,9 @@ dm9000_start_xmit(struct sk_buff *skb, struct net_device 
> *dev)
>   (db->outblk)(db->io_data, skb->data, skb->len);
>   db->stats.tx_bytes += skb->len;
>  
> + db->tx_pkt_cnt++;
>   /* TX control: First packet immediately send, second packet queue */
> - if (db->tx_pkt_cnt == 0) {
> -
> - /* First Packet */
> - db->tx_pkt_cnt++;
> -
> + if (db->tx_pkt_cnt == 1) {
>   /* Set TX length to DM9000 */
>   iow(db, DM9000_TXPLL, skb->len & 0xff);
>   iow(db, DM9000_TXPLH, (skb->len >> 8) & 0xff);
> @@ -732,23 +727,17 @@ dm9000_start_xmit(struct sk_buff *skb, struct 
> net_device *dev)
>   iow(db, DM9000_TCR, TCR_TXREQ); /* Cleared after TX complete */
>  
>   dev->trans_start = jiffies; /* save the time stamp */
> -
>   } else {
>   /* Second packet */
> - db->tx_pkt_cnt++;
>   db->queue_pkt_len = skb->len;
> + netif_stop_queue(dev);
>   }
>  
> + spin_unlock_irqrestore(&db->lock, flags);
> +
>   /* free this SKB */
>   dev_kfree_skb(skb);
>  
> - /* Re-enable resource check */
> - if (db->tx_pkt_cnt == 1)
> - netif_wake_queue(dev);
> -
> - /* Re-enable interrupt */
> - iow(db, DM9000_IMR, IMR_PAR | IMR_PTM | IMR_PRM);
> -
>   return 0;
>  }

If I read this correctly, you've moved the netif_{stop,start}_queue()
calls so that the queue is only stopped if we have loaded 2 packets
into the chip instead of stopping and starting each time.
  
> -
> To unsubscribe from this list: send the line "unsubscribe netdev" in
> the body of a message to [EMAIL PROTECTED]
> More majordomo info at  http://vger.kernel.org/majordomo-info.html

-- 
Ben ([EMAIL PROTECTED], http://www.fluff.org/)

  'a smiley only costs 4 bytes'
-
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH 2/2] [DM9000] External PHY support

2007-08-16 Thread Ben Dooks
On Thu, Aug 16, 2007 at 10:16:08AM +0200, Laurent Pinchart wrote:
> This patch adds a flag to the DM9000 platform data which, when set,
> configures the device to use an external PHY.
> 
> Signed-off-by: Laurent Pinchart <[EMAIL PROTECTED]>
Acked-by: Ben Dooks <[EMAIL PROTECTED]>
> ---
>  drivers/net/dm9000.c   |6 ++
>  include/linux/dm9000.h |1 +
>  2 files changed, 7 insertions(+), 0 deletions(-)
> 
> diff --git a/drivers/net/dm9000.c b/drivers/net/dm9000.c
> index a424810..a86984e 100644
> --- a/drivers/net/dm9000.c
> +++ b/drivers/net/dm9000.c
> @@ -136,6 +136,7 @@ typedef struct board_info {
>   u16 dbug_cnt;
>   u8 io_mode; /* 0:word, 2:byte */
>   u8 phy_addr;
> + unsigned int flags;
>  
>   void (*inblk)(void __iomem *port, void *data, int length);
>   void (*outblk)(void __iomem *port, void *data, int length);
> @@ -528,6 +529,8 @@ dm9000_probe(struct platform_device *pdev)
>  
>   if (pdata->dumpblk != NULL)
>   db->dumpblk = pdata->dumpblk;
> +
> + db->flags = pdata->flags;
>   }
>  
>   dm9000_reset(db);
> @@ -670,6 +673,9 @@ dm9000_init_dm9000(struct net_device *dev)
>   iow(db, DM9000_GPCR, GPCR_GEP_CNTL);/* Let GPIO0 output */
>   iow(db, DM9000_GPR, 0); /* Enable PHY */
>  
> + if (db->flags & DM9000_PLATF_EXT_PHY)
> + iow(db, DM9000_NCR, NCR_EXT_PHY);
> +
>   /* Program operating register */
>   iow(db, DM9000_TCR, 0); /* TX Polling clear */
>   iow(db, DM9000_BPTR, 0x3f); /* Less 3Kb, 200us */
> diff --git a/include/linux/dm9000.h b/include/linux/dm9000.h
> index 0008e2a..ea530fd 100644
> --- a/include/linux/dm9000.h
> +++ b/include/linux/dm9000.h
> @@ -19,6 +19,7 @@
>  #define DM9000_PLATF_8BITONLY(0x0001)
>  #define DM9000_PLATF_16BITONLY   (0x0002)
>  #define DM9000_PLATF_32BITONLY   (0x0004)
> +#define DM9000_PLATF_EXT_PHY (0x0008)
>  
>  /* platfrom data for platfrom device structure's platfrom_data field */
>  
> -- 
> 1.5.0
> 
> -- 
> Laurent Pinchart
> CSE Semaphore Belgium
> 
> Chauss?e de Bruxelles, 732A
> B-1410 Waterloo
> Belgium
> 
> T +32 (2) 387 42 59
> F +32 (2) 387 42 75
> -
> To unsubscribe from this list: send the line "unsubscribe netdev" in
> the body of a message to [EMAIL PROTECTED]
> More majordomo info at  http://vger.kernel.org/majordomo-info.html

-- 
Ben ([EMAIL PROTECTED], http://www.fluff.org/)

  'a smiley only costs 4 bytes'
-
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH 1/2] [DM9000] Added support for big-endian hosts

2007-08-16 Thread Ben Dooks
On Thu, Aug 16, 2007 at 10:15:35AM +0200, Laurent Pinchart wrote:
> This patch splits the receive status in 8bit wide fields and convert the
> packet length from little endian to CPU byte order.
> 
> Signed-off-by: Laurent Pinchart <[EMAIL PROTECTED]>
Acked-by: Ben Dooks <[EMAIL PROTECTED]>
> ---
>  drivers/net/dm9000.c |   13 +++--
>  1 files changed, 7 insertions(+), 6 deletions(-)
> 
> diff --git a/drivers/net/dm9000.c b/drivers/net/dm9000.c
> index c3de81b..a424810 100644
> --- a/drivers/net/dm9000.c
> +++ b/drivers/net/dm9000.c
> @@ -894,7 +894,8 @@ dm9000_timer(unsigned long data)
>  }
>  
>  struct dm9000_rxhdr {
> - u16 RxStatus;
> + u8  RxPktReady;
> + u8  RxStatus;
>   u16 RxLen;
>  } __attribute__((__packed__));
>  
> @@ -935,7 +936,7 @@ dm9000_rx(struct net_device *dev)
>  
>   (db->inblk)(db->io_data, &rxhdr, sizeof(rxhdr));
>  
> - RxLen = rxhdr.RxLen;
> + RxLen = le16_to_cpu(rxhdr.RxLen);
>  
>   /* Packet Status check */
>   if (RxLen < 0x40) {
> @@ -947,17 +948,17 @@ dm9000_rx(struct net_device *dev)
>   PRINTK1("RST: RX Len:%x\n", RxLen);
>   }
>  
> - if (rxhdr.RxStatus & 0xbf00) {
> + if (rxhdr.RxStatus & 0xbf) {
>   GoodPacket = false;
> - if (rxhdr.RxStatus & 0x100) {
> + if (rxhdr.RxStatus & 0x01) {
>   PRINTK1("fifo error\n");
>   db->stats.rx_fifo_errors++;
>   }
> - if (rxhdr.RxStatus & 0x200) {
> + if (rxhdr.RxStatus & 0x02) {
>   PRINTK1("crc error\n");
>   db->stats.rx_crc_errors++;
>   }
> - if (rxhdr.RxStatus & 0x8000) {
> + if (rxhdr.RxStatus & 0x80) {
>   PRINTK1("length error\n");
>   db->stats.rx_length_errors++;
>   }
> -- 
> 1.5.0
> 
> -- 
> Laurent Pinchart
> CSE Semaphore Belgium
> 
> Chauss?e de Bruxelles, 732A
> B-1410 Waterloo
> Belgium
> 
> T +32 (2) 387 42 59
> F +32 (2) 387 42 75
> -
> To unsubscribe from this list: send the line "unsubscribe netdev" in
> the body of a message to [EMAIL PROTECTED]
> More majordomo info at  http://vger.kernel.org/majordomo-info.html

-- 
Ben ([EMAIL PROTECTED], http://www.fluff.org/)

  'a smiley only costs 4 bytes'
-
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH] [DM9000] Add support for big-endian hosts

2007-08-14 Thread Ben Dooks
On Tue, Aug 14, 2007 at 01:22:32PM +0200, Laurent Pinchart wrote:
> This patch splits the receive status in 8bit wide fields and convert the
> packet length from little endian to CPU byte order.

Which version of the the kernel was this against, it applies with
fuzz to 2.6.23-rc3:

$ patch -p1 < ~/dm9000-fix-endianness.patch 
patching file drivers/net/dm9000.c
Hunk #1 succeeded at 894 (offset 15 lines).
Hunk #2 succeeded at 936 (offset 15 lines).
Hunk #3 succeeded at 948 (offset 15 lines).

> Signed-off-by: Laurent Pinchart <[EMAIL PROTECTED]>
> ---
>  drivers/net/dm9000.c |   13 +++--
>  1 files changed, 7 insertions(+), 6 deletions(-)
> 
> diff --git a/drivers/net/dm9000.c b/drivers/net/dm9000.c
> index 264fa0e..ee578d9 100644
> --- a/drivers/net/dm9000.c
> +++ b/drivers/net/dm9000.c
> @@ -879,7 +879,8 @@ dm9000_timer(unsigned long data)
>  }
>  
>  struct dm9000_rxhdr {
> - u16 RxStatus;
> + u8  RxPktReady;
> + u8  RxStatus;
>   u16 RxLen;
>  } __attribute__((__packed__));
>  
> @@ -920,7 +921,7 @@ dm9000_rx(struct net_device *dev)
>  
>   (db->inblk)(db->io_data, &rxhdr, sizeof(rxhdr));
>  
> - RxLen = rxhdr.RxLen;
> + RxLen = le16_to_cpu(rxhdr.RxLen);
>  
>   /* Packet Status check */
>   if (RxLen < 0x40) {
> @@ -932,17 +933,17 @@ dm9000_rx(struct net_device *dev)
>   PRINTK1("RST: RX Len:%x\n", RxLen);
>   }
>  
> - if (rxhdr.RxStatus & 0xbf00) {
> + if (rxhdr.RxStatus & 0xbf) {
>   GoodPacket = false;
> - if (rxhdr.RxStatus & 0x100) {
> + if (rxhdr.RxStatus & 0x01) {
>   PRINTK1("fifo error\n");
>   db->stats.rx_fifo_errors++;
>   }
> - if (rxhdr.RxStatus & 0x200) {
> + if (rxhdr.RxStatus & 0x02) {
>   PRINTK1("crc error\n");
>   db->stats.rx_crc_errors++;
>   }
> - if (rxhdr.RxStatus & 0x8000) {
> + if (rxhdr.RxStatus & 0x80) {
>   PRINTK1("length error\n");
>   db->stats.rx_length_errors++;
>   }
> -- 
> 1.5.0


-- 
Ben ([EMAIL PROTECTED], http://www.fluff.org/)

  'a smiley only costs 4 bytes'
-
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH] [DM9000] External PHY support

2007-08-14 Thread Ben Dooks
On Tue, Aug 14, 2007 at 01:29:35PM +0200, Laurent Pinchart wrote:
> This patch adds a flag to the DM9000 platform data which, when set,
> configures the device to use an external PHY.

This patch applies with fuzz:

$ patch -p1 < ~/dm9000-external-phy.patch   
patching file drivers/net/dm9000.c
Hunk #1 succeeded at 136 (offset 12 lines).
Hunk #2 succeeded at 529 (offset 15 lines).
Hunk #3 succeeded at 673 (offset 15 lines).
patching file include/linux/dm9000.h

> Signed-off-by: Laurent Pinchart <[EMAIL PROTECTED]>
> ---
>  drivers/net/dm9000.c   |6 ++
>  include/linux/dm9000.h |1 +
>  2 files changed, 7 insertions(+), 0 deletions(-)
> 
> diff --git a/drivers/net/dm9000.c b/drivers/net/dm9000.c
> index ee578d9..820f0d3 100644
> --- a/drivers/net/dm9000.c
> +++ b/drivers/net/dm9000.c
> @@ -124,6 +124,7 @@ typedef struct board_info {
>   u16 dbug_cnt;
>   u8 io_mode; /* 0:word, 2:byte */
>   u8 phy_addr;
> + unsigned int flags;
>  
>   void (*inblk)(void __iomem *port, void *data, int length);
>   void (*outblk)(void __iomem *port, void *data, int length);
> @@ -513,6 +514,8 @@ dm9000_probe(struct platform_device *pdev)
>  
>   if (pdata->dumpblk != NULL)
>   db->dumpblk = pdata->dumpblk;
> +
> + db->flags = pdata->flags;
>   }
>  
>   dm9000_reset(db);
> @@ -655,6 +658,9 @@ dm9000_init_dm9000(struct net_device *dev)
>   iow(db, DM9000_GPCR, GPCR_GEP_CNTL);/* Let GPIO0 output */
>   iow(db, DM9000_GPR, 0); /* Enable PHY */
>  
> + if (db->flags & DM9000_PLATF_EXT_PHY)
> + iow(db, DM9000_NCR, NCR_EXT_PHY);
> +
>   /* Program operating register */
>   iow(db, DM9000_TCR, 0); /* TX Polling clear */
>   iow(db, DM9000_BPTR, 0x3f); /* Less 3Kb, 200us */
> diff --git a/include/linux/dm9000.h b/include/linux/dm9000.h
> index 0008e2a..ea530fd 100644
> --- a/include/linux/dm9000.h
> +++ b/include/linux/dm9000.h
> @@ -19,6 +19,7 @@
>  #define DM9000_PLATF_8BITONLY(0x0001)
>  #define DM9000_PLATF_16BITONLY   (0x0002)
>  #define DM9000_PLATF_32BITONLY   (0x0004)
> +#define DM9000_PLATF_EXT_PHY (0x0008)
>  
>  /* platfrom data for platfrom device structure's platfrom_data field */

-- 
Ben ([EMAIL PROTECTED], http://www.fluff.org/)

  'a smiley only costs 4 bytes'
-
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: Davicom Ethernet (onboard) with many Tx timeouts...

2007-08-14 Thread Ben Dooks
On Wed, Jan 03, 2007 at 10:33:08PM -0200, D?niel Fraga wrote:
> Linux 2.6.19 (but this problem occurs with previous kernels too)
> gcc 4.1.1
> pentium 3
> Module dmfe.ko
> 
> dmfe: Davicom DM9xxx net driver, version 1.36.4 (2002-01-17)

hmm, dmfe does not cover the dm9000, a little missleading?

-- 
Ben ([EMAIL PROTECTED], http://www.fluff.org/)

  'a smiley only costs 4 bytes'
-
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: dm9000: add set_mac_address()

2007-08-14 Thread Ben Dooks
On Sun, Aug 12, 2007 at 07:08:52PM -0400, Jeff Garzik wrote:
> set_mac_address should not write to the SROM, as Michael noted.
> 
> The proper operations are:
> 
> probe time:
>   read MAC address from SROM
> 
> dev open (interface up):
>   write dev->dev_addr[] to RX filter (or identity) registers
> 
> EEPROM update support is available separately, via an ethtool sub-ioctl.

This sounds sensible, I am working on adding ethtool support
and should have a patch available in the next day or so.

-- 
Ben ([EMAIL PROTECTED], http://www.fluff.org/)

  'a smiley only costs 4 bytes'
-
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


ethtool locking

2007-07-11 Thread Ben Dooks
I am currently upgrading the DM9000 network driver to support
ethtool for items such as controlling the MII interface and
have the following question about locking with the ethtool
interface:

Most devices use an overall spinlock when changing the settings
such as in the 8139too.c driver:

static int rtl8139_set_settings(struct net_device *dev, struct ethtool_cmd *cmd)
{
struct rtl8139_private *np = netdev_priv(dev);
int rc;
spin_lock_irq(&np->lock);
rc = mii_ethtool_sset(&np->mii, cmd);
spin_unlock_irq(&np->lock);
return rc;
}

In the case of the DM9000, the phy read and write code
already has a spinlock in for hardware access.

Do I need any more locking for the MII calls other than
what is provided by the lower layer (IE, do these calls
need locking against anything else?)

-- 
Ben ([EMAIL PROTECTED], http://www.fluff.org/)

  'a smiley only costs 4 bytes'
-
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH] AX88796 network driver

2007-07-03 Thread Ben Dooks
Support for the Asix AX88796 network controller, an
NE2000 compatible 10/100 ethernet device with internal
PHY.

The driver supports PHY settings via either ioctl() or
the ethtool driver ops. 

Signed-off-by: Ben Dooks <[EMAIL PROTECTED]>

Index: linux-2.6.21-quilt4/drivers/net/8390.h
===
--- linux-2.6.21-quilt4.orig/drivers/net/8390.h 2007-04-26 04:08:32.0 
+0100
+++ linux-2.6.21-quilt4/drivers/net/8390.h  2007-06-04 15:46:35.0 
+0100
@@ -73,6 +73,9 @@ struct ei_device {
u32 *reg_offset;/* Register mapping table */
spinlock_t page_lock;   /* Page register locks */
unsigned long priv; /* Private field to store bus IDs etc. 
*/
+#ifdef AX88796_PLATFORM
+   unsigned char rxcr_base;/* default value for RXCR */
+#endif
 };
 
 /* The maximum number of 8390 interrupt service routines called per IRQ. */
@@ -86,11 +89,19 @@ struct ei_device {
 /* Some generic ethernet register configurations. */
 #define E8390_TX_IRQ_MASK  0xa /* For register EN0_ISR */
 #define E8390_RX_IRQ_MASK  0x5
+
+#ifdef AX88796_PLATFORM
+#define E8390_RXCONFIG (ei_status.rxcr_base | 0x04)
+#define E8390_RXOFF(ei_status.rxcr_base | 0x20)
+#else
 #define E8390_RXCONFIG 0x4 /* EN0_RXCR: broadcasts, no 
multicast,errors */
 #define E8390_RXOFF0x20/* EN0_RXCR: Accept no packets */
+#endif
+
 #define E8390_TXCONFIG 0x00/* EN0_TXCR: Normal transmit mode */
 #define E8390_TXOFF0x02/* EN0_TXCR: Transmitter off */
 
+
 /*  Register accessed at EN_CMD, the 8390 base addr.  */
 #define E8390_STOP 0x01/* Stop and reset the chip */
 #define E8390_START0x02/* Start the chip, clear reset */
Index: linux-2.6.21-quilt4/drivers/net/Makefile
===
--- linux-2.6.21-quilt4.orig/drivers/net/Makefile   2007-04-26 
04:08:32.0 +0100
+++ linux-2.6.21-quilt4/drivers/net/Makefile2007-06-04 15:46:35.0 
+0100
@@ -107,6 +107,7 @@ obj-$(CONFIG_NET_SB1250_MAC) += sb1250-m
 obj-$(CONFIG_B44) += b44.o
 obj-$(CONFIG_FORCEDETH) += forcedeth.o
 obj-$(CONFIG_NE_H8300) += ne-h8300.o
+obj-$(CONFIG_AX88796) += ax88796.o
 
 obj-$(CONFIG_TSI108_ETH) += tsi108_eth.o
 obj-$(CONFIG_MV643XX_ETH) += mv643xx_eth.o
Index: linux-2.6.21-quilt4/drivers/net/ax88796.c
===
--- /dev/null   1970-01-01 00:00:00.0 +
+++ linux-2.6.21-quilt4/drivers/net/ax88796.c   2007-06-04 15:51:04.0 
+0100
@@ -0,0 +1,952 @@
+/* drivers/net/ax88796.c
+ *
+ * Copyright 2005,2007 Simtec Electronics
+ *     Ben Dooks <[EMAIL PROTECTED]>
+ *
+ * Asix AX88796 10/100 Ethernet controller support
+ * Based on ne.c, by Donald Becker, et-al.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+*/
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#include 
+
+#include 
+#include 
+
+static int phy_debug = 0;
+
+/* Rename the lib8390.c functions to show that they are in this driver */
+#define __ei_open   ax_ei_open
+#define __ei_close  ax_ei_close
+#define __ei_poll  ax_ei_poll
+#define __ei_tx_timeout ax_ei_tx_timeout
+#define __ei_interrupt  ax_ei_interrupt
+#define alloc_ei_netdev ax__alloc_ei_netdev
+#define __NS8390_init   ax_NS8390_init
+
+/* force unsigned long back to 'void __iomem *' */
+#define ax_convert_addr(_a) ((void __force __iomem *)(_a))
+
+#define ei_inb(_a) readb(ax_convert_addr(_a))
+#define ei_outb(_v, _a) writeb(_v, ax_convert_addr(_a))
+
+#define ei_inb_p(_a)   ei_inb(_a)
+#define ei_outb_p(_v, _a) ei_outb(_v, _a)
+
+/* define EI_SHIFT() to take into account our register offsets */
+#define EI_SHIFT(x) (ei_local->reg_offset[(x)])
+
+/* Ensure we have our RCR base value */
+#define AX88796_PLATFORM
+
+static unsigned char version[] = "ax88796.c: Copyright 2005,2007 Simtec 
Electronics\n";
+
+#include "lib8390.c"
+
+#define DRV_NAME "ax88796"
+#define DRV_VERSION "1.00"
+
+/* from ne.c */
+#define NE_CMD EI_SHIFT(0x00)
+#define NE_RESET   EI_SHIFT(0x1f)
+#define NE_DATAPORTEI_SHIFT(0x10)
+
+#define NE1SM_START_PG 0x20/* First page of TX buffer */
+#define NE1SM_STOP_PG  0x40/* Last page +1 of RX ring */
+#define NESM_START_PG  0x40/* First page of TX buffer */
+#define NESM_STOP_PG   0x80/* Last page +1 of RX ring */
+
+/* device private data */
+
+struct ax_device {
+   struct timer_listmii_timer;
+   spinlock_t   mii_lock;
+   struct mii_if_info   mii;
+
+   u32  

Re: [info] What's in netdev-2.6.git?

2007-07-02 Thread Ben Dooks
On Mon, Jul 02, 2007 at 11:08:26AM -0400, Jeff Garzik wrote:
> 
> This is what is currently queued for 2.6.23.  There are a few patches
> in my mbox not yet applied to the git tree, but this is most of them.

I sent driver support for the AX88796 a few weeks ago with no feedback,
should I re-send this CC: you?
 
-- 
Ben ([EMAIL PROTECTED], http://www.fluff.org/)

  'a smiley only costs 4 bytes'
-
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Feedback on AX88796 driver

2007-05-28 Thread Ben Dooks
I posted [1] an driver for the Asix AX88796 network controller
a while back, and have had no feedback. Is this driver suitable
for submission for the next kernel window, or is there anything
that needs to be done for it?

If it is, then is jgarzik the right person to send this patch
to, or is there somewhere else to submit?

[1] http://lwn.net/Articles/234308/

-- 
Ben
-
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH] ASIX AX88796 10/100 network driver

2007-05-11 Thread Ben Dooks
This patch adds support for the ASIX AX88796
10/100 network controller. This device is an
NE2000 compatible chip, with a 10/100 phy.

The driver attaches via the platform bus,
and takes platform data specified in the
 include file to allow the
chip to be configured. It fully supports
devices where the address bus is not an 1:1
map.

Control of the phy is provided via an ethtool
or ioctl interface.

To properly configure the chip, the driver
patches 8390.h to add a default rcr to the
ei_device structure (dependant on the
presence of AX88796_PLATFORM)

The driver has been tested on an Simtec BAST
and several Simtec development boards. 

Signed-off-by: Ben Dooks <[EMAIL PROTECTED]>

diff -urNp linux-2.6.21-git14/drivers/net/8390.h 
linux-2.6.21-git14-ax88796/drivers/net/8390.h
--- linux-2.6.21-git14/drivers/net/8390.h   2007-05-10 13:41:19.0 
+0100
+++ linux-2.6.21-git14-ax88796/drivers/net/8390.h   2007-05-11 
12:16:24.0 +0100
@@ -73,6 +73,9 @@ struct ei_device {
u32 *reg_offset;/* Register mapping table */
spinlock_t page_lock;   /* Page register locks */
unsigned long priv; /* Private field to store bus IDs etc. 
*/
+#ifdef AX88796_PLATFORM
+   unsigned char rxcr_base;/* default value for RXCR */
+#endif
 };
 
 /* The maximum number of 8390 interrupt service routines called per IRQ. */
@@ -86,11 +89,19 @@ struct ei_device {
 /* Some generic ethernet register configurations. */
 #define E8390_TX_IRQ_MASK  0xa /* For register EN0_ISR */
 #define E8390_RX_IRQ_MASK  0x5
+
+#ifdef AX88796_PLATFORM
+#define E8390_RXCONFIG (ei_status.rxcr_base | 0x04)
+#define E8390_RXOFF(ei_status.rxcr_base | 0x20)
+#else
 #define E8390_RXCONFIG 0x4 /* EN0_RXCR: broadcasts, no 
multicast,errors */
 #define E8390_RXOFF0x20/* EN0_RXCR: Accept no packets */
+#endif
+
 #define E8390_TXCONFIG 0x00/* EN0_TXCR: Normal transmit mode */
 #define E8390_TXOFF0x02/* EN0_TXCR: Transmitter off */
 
+
 /*  Register accessed at EN_CMD, the 8390 base addr.  */
 #define E8390_STOP 0x01/* Stop and reset the chip */
 #define E8390_START0x02/* Start the chip, clear reset */
diff -urNp linux-2.6.21-git14/drivers/net/ax88796.c 
linux-2.6.21-git14-ax88796/drivers/net/ax88796.c
--- linux-2.6.21-git14/drivers/net/ax88796.c1970-01-01 01:00:00.0 
+0100
+++ linux-2.6.21-git14-ax88796/drivers/net/ax88796.c2007-05-11 
12:16:48.0 +0100
@@ -0,0 +1,952 @@
+/* drivers/net/ax88796.c
+ *
+ * Copyright 2005,2007 Simtec Electronics
+ *     Ben Dooks <[EMAIL PROTECTED]>
+ *
+ * Asix AX88796 10/100 Ethernet controller support
+ * Based on ne.c, by Donald Becker, et-al.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+*/
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#include 
+
+#include 
+#include 
+
+static int phy_debug = 0;
+
+/* Rename the lib8390.c functions to show that they are in this driver */
+#define __ei_open   ax_ei_open
+#define __ei_close  ax_ei_close
+#define __ei_poll  ax_ei_poll
+#define __ei_tx_timeout ax_ei_tx_timeout
+#define __ei_interrupt  ax_ei_interrupt
+#define alloc_ei_netdev ax__alloc_ei_netdev
+#define __NS8390_init   ax_NS8390_init
+
+/* force unsigned long back to 'void __iomem *' */
+#define ax_convert_addr(_a) ((void __force __iomem *)(_a))
+
+#define ei_inb(_a) readb(ax_convert_addr(_a))
+#define ei_outb(_v, _a) writeb(_v, ax_convert_addr(_a))
+
+#define ei_inb_p(_a)   ei_inb(_a)
+#define ei_outb_p(_v, _a) ei_outb(_v, _a)
+
+/* define EI_SHIFT() to take into account our register offsets */
+#define EI_SHIFT(x) (ei_local->reg_offset[(x)])
+
+/* Ensure we have our RCR base value */
+#define AX88796_PLATFORM
+
+static unsigned char version[] = "ax88796.c: Copyright 2005,2007 Simtec 
Electronics\n";
+
+#include "lib8390.c"
+
+#define DRV_NAME "ax88796"
+#define DRV_VERSION "1.00"
+
+/* from ne.c */
+#define NE_CMD EI_SHIFT(0x00)
+#define NE_RESET   EI_SHIFT(0x1f)
+#define NE_DATAPORTEI_SHIFT(0x10)
+
+#define NE1SM_START_PG 0x20/* First page of TX buffer */
+#define NE1SM_STOP_PG  0x40/* Last page +1 of RX ring */
+#define NESM_START_PG  0x40/* First page of TX buffer */
+#define NESM_STOP_PG   0x80/* Last page +1 of RX ring */
+
+/* device private data */
+
+struct ax_device {
+   struct timer_listmii_timer;
+   spinlock_t   mii_lock;
+   struct mii_if_info   mii;
+
+   u32  msg_enable;
+   void __iomem*map2;
+   struct platform_device  *dev;
+   struct resource   

  1   2   >