6 #include <linux/module.h>
7 #include <linux/kernel.h>
9 #include <linux/errno.h>
10 #include <linux/atmdev.h>
11 #include <linux/sonet.h>
15 #include <linux/capability.h>
18 #include <linux/slab.h>
19 #include <asm/param.h>
20 #include <asm/uaccess.h>
27 #define DPRINTK(format,args...) printk(KERN_DEBUG format,##args)
29 #define DPRINTK(format,args...)
43 #define PRIV(dev) ((struct idt77105_priv *) dev->phy_data)
45 #define PUT(val,reg) dev->ops->phy_put(dev,val,IDT77105_##reg)
46 #define GET(reg) dev->ops->phy_get(dev,IDT77105_##reg)
48 static void idt77105_stats_timer_func(
unsigned long);
49 static void idt77105_restart_timer_func(
unsigned long);
52 static DEFINE_TIMER(stats_timer, idt77105_stats_timer_func, 0, 0);
53 static DEFINE_TIMER(restart_timer, idt77105_restart_timer_func, 0, 0);
54 static int start_timer = 1;
83 static void idt77105_stats_timer_func(
unsigned long dummy)
89 DPRINTK(
"IDT77105 gathering statistics\n");
90 for (walk = idt77105_all; walk; walk = walk->
next) {
112 static void idt77105_restart_timer_func(
unsigned long dummy)
118 DPRINTK(
"IDT77105 checking for cable re-insertion\n");
119 for (walk = idt77105_all; walk; walk = walk->
next) {
150 spin_unlock_irqrestore(&idt77105_priv_lock, flags);
158 static int set_loopback(
struct atm_dev *dev,
int mode)
188 static int idt77105_ioctl(
struct atm_dev *dev,
unsigned int cmd,
void __user *arg)
198 return set_loopback(dev,(
int)(
unsigned long) arg);
200 return put_user(
PRIV(dev)->loop_mode,(
int __user *)arg) ?
204 (
int __user *) arg) ? -
EFAULT : 0;
212 static void idt77105_int(
struct atm_dev *dev)
218 DPRINTK(
"IDT77105 generated an interrupt, istat=%02x\n", (
unsigned)istat);
222 if (istat & IDT77105_ISTAT_GOODSIG) {
260 static int idt77105_start(
struct atm_dev *dev)
268 PRIV(dev)->next = idt77105_all;
269 idt77105_all =
PRIV(dev);
270 spin_unlock_irqrestore(&idt77105_priv_lock, flags);
275 GET(ISTAT) & IDT77105_ISTAT_GOODSIG ?
302 idt77105_stats_timer_func(0);
311 stats_timer.function = idt77105_stats_timer_func;
316 restart_timer.function = idt77105_restart_timer_func;
319 spin_unlock_irqrestore(&idt77105_priv_lock, flags);
324 static int idt77105_stop(
struct atm_dev *dev)
334 for (prev =
NULL, walk = idt77105_all ;
336 prev = walk, walk = walk->
next) {
337 if (walk->dev == dev) {
339 prev->
next = walk->next;
341 idt77105_all = walk->
next;
353 static const struct atmphy_ops idt77105_ops = {
354 .start = idt77105_start,
355 .ioctl = idt77105_ioctl,
356 .interrupt = idt77105_int,
357 .stop = idt77105_stop,
363 dev->
phy = &idt77105_ops;
369 static void __exit idt77105_exit(
void)