Commit 9489a062 authored by Linus Torvalds's avatar Linus Torvalds
parents edeb280e 399dc43b
...@@ -2,6 +2,7 @@ ...@@ -2,6 +2,7 @@
#include <linux/module.h> #include <linux/module.h>
#include <linux/init.h> #include <linux/init.h>
#include <linux/proc_fs.h> #include <linux/proc_fs.h>
#include <linux/seq_file.h>
#include <linux/string.h> #include <linux/string.h>
#include <linux/jiffies.h> #include <linux/jiffies.h>
#include <linux/timer.h> #include <linux/timer.h>
...@@ -45,21 +46,22 @@ static void led_blink(unsigned long timeout) ...@@ -45,21 +46,22 @@ static void led_blink(unsigned long timeout)
add_timer(&led_blink_timer); add_timer(&led_blink_timer);
} }
static int led_read_proc(char *buf, char **start, off_t offset, int count, static int led_proc_show(struct seq_file *m, void *v)
int *eof, void *data)
{ {
int len = 0;
if (get_auxio() & AUXIO_LED) if (get_auxio() & AUXIO_LED)
len = sprintf(buf, "on\n"); seq_puts(m, "on\n");
else else
len = sprintf(buf, "off\n"); seq_puts(m, "off\n");
return 0;
}
return len; static int led_proc_open(struct inode *inode, struct file *file)
{
return single_open(file, led_proc_show, NULL);
} }
static int led_write_proc(struct file *file, const char __user *buffer, static ssize_t led_proc_write(struct file *file, const char __user *buffer,
unsigned long count, void *data) size_t count, loff_t *ppos)
{ {
char *buf = NULL; char *buf = NULL;
...@@ -103,6 +105,15 @@ static int led_write_proc(struct file *file, const char __user *buffer, ...@@ -103,6 +105,15 @@ static int led_write_proc(struct file *file, const char __user *buffer,
return count; return count;
} }
static const struct file_operations led_proc_fops = {
.owner = THIS_MODULE,
.open = led_proc_open,
.read = seq_read,
.llseek = seq_lseek,
.release = single_release,
.write = led_proc_write,
};
static struct proc_dir_entry *led; static struct proc_dir_entry *led;
#define LED_VERSION "0.1" #define LED_VERSION "0.1"
...@@ -112,12 +123,9 @@ static int __init led_init(void) ...@@ -112,12 +123,9 @@ static int __init led_init(void)
init_timer(&led_blink_timer); init_timer(&led_blink_timer);
led_blink_timer.function = led_blink; led_blink_timer.function = led_blink;
led = create_proc_entry("led", 0, NULL); led = proc_create("led", 0, NULL, &led_proc_fops);
if (!led) if (!led)
return -ENOMEM; return -ENOMEM;
led->read_proc = led_read_proc; /* reader function */
led->write_proc = led_write_proc; /* writer function */
led->owner = THIS_MODULE; led->owner = THIS_MODULE;
printk(KERN_INFO printk(KERN_INFO
......
...@@ -24,7 +24,8 @@ static inline u8 _inb(unsigned long addr) ...@@ -24,7 +24,8 @@ static inline u8 _inb(unsigned long addr)
__asm__ __volatile__("lduba\t[%1] %2, %0\t/* pci_inb */" __asm__ __volatile__("lduba\t[%1] %2, %0\t/* pci_inb */"
: "=r" (ret) : "=r" (ret)
: "r" (addr), "i" (ASI_PHYS_BYPASS_EC_E_L)); : "r" (addr), "i" (ASI_PHYS_BYPASS_EC_E_L)
: "memory");
return ret; return ret;
} }
...@@ -35,7 +36,8 @@ static inline u16 _inw(unsigned long addr) ...@@ -35,7 +36,8 @@ static inline u16 _inw(unsigned long addr)
__asm__ __volatile__("lduha\t[%1] %2, %0\t/* pci_inw */" __asm__ __volatile__("lduha\t[%1] %2, %0\t/* pci_inw */"
: "=r" (ret) : "=r" (ret)
: "r" (addr), "i" (ASI_PHYS_BYPASS_EC_E_L)); : "r" (addr), "i" (ASI_PHYS_BYPASS_EC_E_L)
: "memory");
return ret; return ret;
} }
...@@ -46,7 +48,8 @@ static inline u32 _inl(unsigned long addr) ...@@ -46,7 +48,8 @@ static inline u32 _inl(unsigned long addr)
__asm__ __volatile__("lduwa\t[%1] %2, %0\t/* pci_inl */" __asm__ __volatile__("lduwa\t[%1] %2, %0\t/* pci_inl */"
: "=r" (ret) : "=r" (ret)
: "r" (addr), "i" (ASI_PHYS_BYPASS_EC_E_L)); : "r" (addr), "i" (ASI_PHYS_BYPASS_EC_E_L)
: "memory");
return ret; return ret;
} }
...@@ -55,21 +58,24 @@ static inline void _outb(u8 b, unsigned long addr) ...@@ -55,21 +58,24 @@ static inline void _outb(u8 b, unsigned long addr)
{ {
__asm__ __volatile__("stba\t%r0, [%1] %2\t/* pci_outb */" __asm__ __volatile__("stba\t%r0, [%1] %2\t/* pci_outb */"
: /* no outputs */ : /* no outputs */
: "Jr" (b), "r" (addr), "i" (ASI_PHYS_BYPASS_EC_E_L)); : "Jr" (b), "r" (addr), "i" (ASI_PHYS_BYPASS_EC_E_L)
: "memory");
} }
static inline void _outw(u16 w, unsigned long addr) static inline void _outw(u16 w, unsigned long addr)
{ {
__asm__ __volatile__("stha\t%r0, [%1] %2\t/* pci_outw */" __asm__ __volatile__("stha\t%r0, [%1] %2\t/* pci_outw */"
: /* no outputs */ : /* no outputs */
: "Jr" (w), "r" (addr), "i" (ASI_PHYS_BYPASS_EC_E_L)); : "Jr" (w), "r" (addr), "i" (ASI_PHYS_BYPASS_EC_E_L)
: "memory");
} }
static inline void _outl(u32 l, unsigned long addr) static inline void _outl(u32 l, unsigned long addr)
{ {
__asm__ __volatile__("stwa\t%r0, [%1] %2\t/* pci_outl */" __asm__ __volatile__("stwa\t%r0, [%1] %2\t/* pci_outl */"
: /* no outputs */ : /* no outputs */
: "Jr" (l), "r" (addr), "i" (ASI_PHYS_BYPASS_EC_E_L)); : "Jr" (l), "r" (addr), "i" (ASI_PHYS_BYPASS_EC_E_L)
: "memory");
} }
#define inb(__addr) (_inb((unsigned long)(__addr))) #define inb(__addr) (_inb((unsigned long)(__addr)))
...@@ -128,7 +134,8 @@ static inline u8 _readb(const volatile void __iomem *addr) ...@@ -128,7 +134,8 @@ static inline u8 _readb(const volatile void __iomem *addr)
__asm__ __volatile__("lduba\t[%1] %2, %0\t/* pci_readb */" __asm__ __volatile__("lduba\t[%1] %2, %0\t/* pci_readb */"
: "=r" (ret) : "=r" (ret)
: "r" (addr), "i" (ASI_PHYS_BYPASS_EC_E_L)); : "r" (addr), "i" (ASI_PHYS_BYPASS_EC_E_L)
: "memory");
return ret; return ret;
} }
...@@ -137,7 +144,8 @@ static inline u16 _readw(const volatile void __iomem *addr) ...@@ -137,7 +144,8 @@ static inline u16 _readw(const volatile void __iomem *addr)
__asm__ __volatile__("lduha\t[%1] %2, %0\t/* pci_readw */" __asm__ __volatile__("lduha\t[%1] %2, %0\t/* pci_readw */"
: "=r" (ret) : "=r" (ret)
: "r" (addr), "i" (ASI_PHYS_BYPASS_EC_E_L)); : "r" (addr), "i" (ASI_PHYS_BYPASS_EC_E_L)
: "memory");
return ret; return ret;
} }
...@@ -147,7 +155,8 @@ static inline u32 _readl(const volatile void __iomem *addr) ...@@ -147,7 +155,8 @@ static inline u32 _readl(const volatile void __iomem *addr)
__asm__ __volatile__("lduwa\t[%1] %2, %0\t/* pci_readl */" __asm__ __volatile__("lduwa\t[%1] %2, %0\t/* pci_readl */"
: "=r" (ret) : "=r" (ret)
: "r" (addr), "i" (ASI_PHYS_BYPASS_EC_E_L)); : "r" (addr), "i" (ASI_PHYS_BYPASS_EC_E_L)
: "memory");
return ret; return ret;
} }
...@@ -157,7 +166,8 @@ static inline u64 _readq(const volatile void __iomem *addr) ...@@ -157,7 +166,8 @@ static inline u64 _readq(const volatile void __iomem *addr)
__asm__ __volatile__("ldxa\t[%1] %2, %0\t/* pci_readq */" __asm__ __volatile__("ldxa\t[%1] %2, %0\t/* pci_readq */"
: "=r" (ret) : "=r" (ret)
: "r" (addr), "i" (ASI_PHYS_BYPASS_EC_E_L)); : "r" (addr), "i" (ASI_PHYS_BYPASS_EC_E_L)
: "memory");
return ret; return ret;
} }
...@@ -166,28 +176,32 @@ static inline void _writeb(u8 b, volatile void __iomem *addr) ...@@ -166,28 +176,32 @@ static inline void _writeb(u8 b, volatile void __iomem *addr)
{ {
__asm__ __volatile__("stba\t%r0, [%1] %2\t/* pci_writeb */" __asm__ __volatile__("stba\t%r0, [%1] %2\t/* pci_writeb */"
: /* no outputs */ : /* no outputs */
: "Jr" (b), "r" (addr), "i" (ASI_PHYS_BYPASS_EC_E_L)); : "Jr" (b), "r" (addr), "i" (ASI_PHYS_BYPASS_EC_E_L)
: "memory");
} }
static inline void _writew(u16 w, volatile void __iomem *addr) static inline void _writew(u16 w, volatile void __iomem *addr)
{ {
__asm__ __volatile__("stha\t%r0, [%1] %2\t/* pci_writew */" __asm__ __volatile__("stha\t%r0, [%1] %2\t/* pci_writew */"
: /* no outputs */ : /* no outputs */
: "Jr" (w), "r" (addr), "i" (ASI_PHYS_BYPASS_EC_E_L)); : "Jr" (w), "r" (addr), "i" (ASI_PHYS_BYPASS_EC_E_L)
: "memory");
} }
static inline void _writel(u32 l, volatile void __iomem *addr) static inline void _writel(u32 l, volatile void __iomem *addr)
{ {
__asm__ __volatile__("stwa\t%r0, [%1] %2\t/* pci_writel */" __asm__ __volatile__("stwa\t%r0, [%1] %2\t/* pci_writel */"
: /* no outputs */ : /* no outputs */
: "Jr" (l), "r" (addr), "i" (ASI_PHYS_BYPASS_EC_E_L)); : "Jr" (l), "r" (addr), "i" (ASI_PHYS_BYPASS_EC_E_L)
: "memory");
} }
static inline void _writeq(u64 q, volatile void __iomem *addr) static inline void _writeq(u64 q, volatile void __iomem *addr)
{ {
__asm__ __volatile__("stxa\t%r0, [%1] %2\t/* pci_writeq */" __asm__ __volatile__("stxa\t%r0, [%1] %2\t/* pci_writeq */"
: /* no outputs */ : /* no outputs */
: "Jr" (q), "r" (addr), "i" (ASI_PHYS_BYPASS_EC_E_L)); : "Jr" (q), "r" (addr), "i" (ASI_PHYS_BYPASS_EC_E_L)
: "memory");
} }
#define readb(__addr) _readb(__addr) #define readb(__addr) _readb(__addr)
...@@ -299,7 +313,8 @@ static inline u8 _sbus_readb(const volatile void __iomem *addr) ...@@ -299,7 +313,8 @@ static inline u8 _sbus_readb(const volatile void __iomem *addr)
__asm__ __volatile__("lduba\t[%1] %2, %0\t/* sbus_readb */" __asm__ __volatile__("lduba\t[%1] %2, %0\t/* sbus_readb */"
: "=r" (ret) : "=r" (ret)
: "r" (addr), "i" (ASI_PHYS_BYPASS_EC_E)); : "r" (addr), "i" (ASI_PHYS_BYPASS_EC_E)
: "memory");
return ret; return ret;
} }
...@@ -310,7 +325,8 @@ static inline u16 _sbus_readw(const volatile void __iomem *addr) ...@@ -310,7 +325,8 @@ static inline u16 _sbus_readw(const volatile void __iomem *addr)
__asm__ __volatile__("lduha\t[%1] %2, %0\t/* sbus_readw */" __asm__ __volatile__("lduha\t[%1] %2, %0\t/* sbus_readw */"
: "=r" (ret) : "=r" (ret)
: "r" (addr), "i" (ASI_PHYS_BYPASS_EC_E)); : "r" (addr), "i" (ASI_PHYS_BYPASS_EC_E)
: "memory");
return ret; return ret;
} }
...@@ -321,7 +337,8 @@ static inline u32 _sbus_readl(const volatile void __iomem *addr) ...@@ -321,7 +337,8 @@ static inline u32 _sbus_readl(const volatile void __iomem *addr)
__asm__ __volatile__("lduwa\t[%1] %2, %0\t/* sbus_readl */" __asm__ __volatile__("lduwa\t[%1] %2, %0\t/* sbus_readl */"
: "=r" (ret) : "=r" (ret)
: "r" (addr), "i" (ASI_PHYS_BYPASS_EC_E)); : "r" (addr), "i" (ASI_PHYS_BYPASS_EC_E)
: "memory");
return ret; return ret;
} }
...@@ -332,7 +349,8 @@ static inline u64 _sbus_readq(const volatile void __iomem *addr) ...@@ -332,7 +349,8 @@ static inline u64 _sbus_readq(const volatile void __iomem *addr)
__asm__ __volatile__("ldxa\t[%1] %2, %0\t/* sbus_readq */" __asm__ __volatile__("ldxa\t[%1] %2, %0\t/* sbus_readq */"
: "=r" (ret) : "=r" (ret)
: "r" (addr), "i" (ASI_PHYS_BYPASS_EC_E)); : "r" (addr), "i" (ASI_PHYS_BYPASS_EC_E)
: "memory");
return ret; return ret;
} }
...@@ -341,28 +359,32 @@ static inline void _sbus_writeb(u8 b, volatile void __iomem *addr) ...@@ -341,28 +359,32 @@ static inline void _sbus_writeb(u8 b, volatile void __iomem *addr)
{ {
__asm__ __volatile__("stba\t%r0, [%1] %2\t/* sbus_writeb */" __asm__ __volatile__("stba\t%r0, [%1] %2\t/* sbus_writeb */"
: /* no outputs */ : /* no outputs */
: "Jr" (b), "r" (addr), "i" (ASI_PHYS_BYPASS_EC_E)); : "Jr" (b), "r" (addr), "i" (ASI_PHYS_BYPASS_EC_E)
: "memory");
} }
static inline void _sbus_writew(u16 w, volatile void __iomem *addr) static inline void _sbus_writew(u16 w, volatile void __iomem *addr)
{ {
__asm__ __volatile__("stha\t%r0, [%1] %2\t/* sbus_writew */" __asm__ __volatile__("stha\t%r0, [%1] %2\t/* sbus_writew */"
: /* no outputs */ : /* no outputs */
: "Jr" (w), "r" (addr), "i" (ASI_PHYS_BYPASS_EC_E)); : "Jr" (w), "r" (addr), "i" (ASI_PHYS_BYPASS_EC_E)
: "memory");
} }
static inline void _sbus_writel(u32 l, volatile void __iomem *addr) static inline void _sbus_writel(u32 l, volatile void __iomem *addr)
{ {
__asm__ __volatile__("stwa\t%r0, [%1] %2\t/* sbus_writel */" __asm__ __volatile__("stwa\t%r0, [%1] %2\t/* sbus_writel */"
: /* no outputs */ : /* no outputs */
: "Jr" (l), "r" (addr), "i" (ASI_PHYS_BYPASS_EC_E)); : "Jr" (l), "r" (addr), "i" (ASI_PHYS_BYPASS_EC_E)
: "memory");
} }
static inline void _sbus_writeq(u64 l, volatile void __iomem *addr) static inline void _sbus_writeq(u64 l, volatile void __iomem *addr)
{ {
__asm__ __volatile__("stxa\t%r0, [%1] %2\t/* sbus_writeq */" __asm__ __volatile__("stxa\t%r0, [%1] %2\t/* sbus_writeq */"
: /* no outputs */ : /* no outputs */
: "Jr" (l), "r" (addr), "i" (ASI_PHYS_BYPASS_EC_E)); : "Jr" (l), "r" (addr), "i" (ASI_PHYS_BYPASS_EC_E)
: "memory");
} }
#define sbus_readb(__addr) _sbus_readb(__addr) #define sbus_readb(__addr) _sbus_readb(__addr)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment