Skip to content

Commit

Permalink
Merge git://git.kernel.org/pub/scm/linux/kernel/git/davem/sparc-2.6
Browse files Browse the repository at this point in the history
* git://git.kernel.org/pub/scm/linux/kernel/git/davem/sparc-2.6:
  sparc: switch /proc/led to seq_file
  sparc64: IO accessors fix
  • Loading branch information
Linus Torvalds committed Jun 5, 2008
2 parents edeb280 + 399dc43 commit 9489a06
Show file tree
Hide file tree
Showing 2 changed files with 65 additions and 35 deletions.
34 changes: 21 additions & 13 deletions arch/sparc/kernel/led.c
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
#include <linux/module.h>
#include <linux/init.h>
#include <linux/proc_fs.h>
#include <linux/seq_file.h>
#include <linux/string.h>
#include <linux/jiffies.h>
#include <linux/timer.h>
Expand Down Expand Up @@ -45,21 +46,22 @@ static void led_blink(unsigned long timeout)
add_timer(&led_blink_timer);
}

static int led_read_proc(char *buf, char **start, off_t offset, int count,
int *eof, void *data)
static int led_proc_show(struct seq_file *m, void *v)
{
int len = 0;

if (get_auxio() & AUXIO_LED)
len = sprintf(buf, "on\n");
seq_puts(m, "on\n");
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,
unsigned long count, void *data)
static ssize_t led_proc_write(struct file *file, const char __user *buffer,
size_t count, loff_t *ppos)
{
char *buf = NULL;

Expand Down Expand Up @@ -103,6 +105,15 @@ static int led_write_proc(struct file *file, const char __user *buffer,
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;

#define LED_VERSION "0.1"
Expand All @@ -112,12 +123,9 @@ static int __init led_init(void)
init_timer(&led_blink_timer);
led_blink_timer.function = led_blink;

led = create_proc_entry("led", 0, NULL);
led = proc_create("led", 0, NULL, &led_proc_fops);
if (!led)
return -ENOMEM;

led->read_proc = led_read_proc; /* reader function */
led->write_proc = led_write_proc; /* writer function */
led->owner = THIS_MODULE;

printk(KERN_INFO
Expand Down
66 changes: 44 additions & 22 deletions include/asm-sparc64/io.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,8 @@ static inline u8 _inb(unsigned long addr)

__asm__ __volatile__("lduba\t[%1] %2, %0\t/* pci_inb */"
: "=r" (ret)
: "r" (addr), "i" (ASI_PHYS_BYPASS_EC_E_L));
: "r" (addr), "i" (ASI_PHYS_BYPASS_EC_E_L)
: "memory");

return ret;
}
Expand All @@ -35,7 +36,8 @@ static inline u16 _inw(unsigned long addr)

__asm__ __volatile__("lduha\t[%1] %2, %0\t/* pci_inw */"
: "=r" (ret)
: "r" (addr), "i" (ASI_PHYS_BYPASS_EC_E_L));
: "r" (addr), "i" (ASI_PHYS_BYPASS_EC_E_L)
: "memory");

return ret;
}
Expand All @@ -46,7 +48,8 @@ static inline u32 _inl(unsigned long addr)

__asm__ __volatile__("lduwa\t[%1] %2, %0\t/* pci_inl */"
: "=r" (ret)
: "r" (addr), "i" (ASI_PHYS_BYPASS_EC_E_L));
: "r" (addr), "i" (ASI_PHYS_BYPASS_EC_E_L)
: "memory");

return ret;
}
Expand All @@ -55,21 +58,24 @@ static inline void _outb(u8 b, unsigned long addr)
{
__asm__ __volatile__("stba\t%r0, [%1] %2\t/* pci_outb */"
: /* 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)
{
__asm__ __volatile__("stha\t%r0, [%1] %2\t/* pci_outw */"
: /* 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)
{
__asm__ __volatile__("stwa\t%r0, [%1] %2\t/* pci_outl */"
: /* 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)))
Expand Down Expand Up @@ -128,7 +134,8 @@ static inline u8 _readb(const volatile void __iomem *addr)

__asm__ __volatile__("lduba\t[%1] %2, %0\t/* pci_readb */"
: "=r" (ret)
: "r" (addr), "i" (ASI_PHYS_BYPASS_EC_E_L));
: "r" (addr), "i" (ASI_PHYS_BYPASS_EC_E_L)
: "memory");
return ret;
}

Expand All @@ -137,7 +144,8 @@ static inline u16 _readw(const volatile void __iomem *addr)

__asm__ __volatile__("lduha\t[%1] %2, %0\t/* pci_readw */"
: "=r" (ret)
: "r" (addr), "i" (ASI_PHYS_BYPASS_EC_E_L));
: "r" (addr), "i" (ASI_PHYS_BYPASS_EC_E_L)
: "memory");

return ret;
}
Expand All @@ -147,7 +155,8 @@ static inline u32 _readl(const volatile void __iomem *addr)

__asm__ __volatile__("lduwa\t[%1] %2, %0\t/* pci_readl */"
: "=r" (ret)
: "r" (addr), "i" (ASI_PHYS_BYPASS_EC_E_L));
: "r" (addr), "i" (ASI_PHYS_BYPASS_EC_E_L)
: "memory");

return ret;
}
Expand All @@ -157,7 +166,8 @@ static inline u64 _readq(const volatile void __iomem *addr)

__asm__ __volatile__("ldxa\t[%1] %2, %0\t/* pci_readq */"
: "=r" (ret)
: "r" (addr), "i" (ASI_PHYS_BYPASS_EC_E_L));
: "r" (addr), "i" (ASI_PHYS_BYPASS_EC_E_L)
: "memory");

return ret;
}
Expand All @@ -166,28 +176,32 @@ static inline void _writeb(u8 b, volatile void __iomem *addr)
{
__asm__ __volatile__("stba\t%r0, [%1] %2\t/* pci_writeb */"
: /* 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)
{
__asm__ __volatile__("stha\t%r0, [%1] %2\t/* pci_writew */"
: /* 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)
{
__asm__ __volatile__("stwa\t%r0, [%1] %2\t/* pci_writel */"
: /* 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)
{
__asm__ __volatile__("stxa\t%r0, [%1] %2\t/* pci_writeq */"
: /* 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)
Expand Down Expand Up @@ -299,7 +313,8 @@ static inline u8 _sbus_readb(const volatile void __iomem *addr)

__asm__ __volatile__("lduba\t[%1] %2, %0\t/* sbus_readb */"
: "=r" (ret)
: "r" (addr), "i" (ASI_PHYS_BYPASS_EC_E));
: "r" (addr), "i" (ASI_PHYS_BYPASS_EC_E)
: "memory");

return ret;
}
Expand All @@ -310,7 +325,8 @@ static inline u16 _sbus_readw(const volatile void __iomem *addr)

__asm__ __volatile__("lduha\t[%1] %2, %0\t/* sbus_readw */"
: "=r" (ret)
: "r" (addr), "i" (ASI_PHYS_BYPASS_EC_E));
: "r" (addr), "i" (ASI_PHYS_BYPASS_EC_E)
: "memory");

return ret;
}
Expand All @@ -321,7 +337,8 @@ static inline u32 _sbus_readl(const volatile void __iomem *addr)

__asm__ __volatile__("lduwa\t[%1] %2, %0\t/* sbus_readl */"
: "=r" (ret)
: "r" (addr), "i" (ASI_PHYS_BYPASS_EC_E));
: "r" (addr), "i" (ASI_PHYS_BYPASS_EC_E)
: "memory");

return ret;
}
Expand All @@ -332,7 +349,8 @@ static inline u64 _sbus_readq(const volatile void __iomem *addr)

__asm__ __volatile__("ldxa\t[%1] %2, %0\t/* sbus_readq */"
: "=r" (ret)
: "r" (addr), "i" (ASI_PHYS_BYPASS_EC_E));
: "r" (addr), "i" (ASI_PHYS_BYPASS_EC_E)
: "memory");

return ret;
}
Expand All @@ -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 */"
: /* 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)
{
__asm__ __volatile__("stha\t%r0, [%1] %2\t/* sbus_writew */"
: /* 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)
{
__asm__ __volatile__("stwa\t%r0, [%1] %2\t/* sbus_writel */"
: /* 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)
{
__asm__ __volatile__("stxa\t%r0, [%1] %2\t/* sbus_writeq */"
: /* 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)
Expand Down

0 comments on commit 9489a06

Please sign in to comment.