Skip to content

Commit

Permalink
Merge master.kernel.org:/pub/scm/linux/kernel/git/davem/sparc-2.6
Browse files Browse the repository at this point in the history
  • Loading branch information
Linus Torvalds committed Nov 8, 2005
2 parents e3d8b77 + dd3e2dc commit d27ba47
Show file tree
Hide file tree
Showing 32 changed files with 673 additions and 1,569 deletions.
2 changes: 0 additions & 2 deletions Documentation/ioctl-number.txt
Original file line number Diff line number Diff line change
Expand Up @@ -130,8 +130,6 @@ Code Seq# Include File Comments
<mailto:zapman@interlan.net>
'i' 00-3F linux/i2o.h
'j' 00-3F linux/joystick.h
'k' all asm-sparc/kbio.h
asm-sparc64/kbio.h
'l' 00-3F linux/tcfs_fs.h transparent cryptographic file system
<http://mikonos.dia.unisa.it/tcfs>
'l' 40-7F linux/udf_fs_i.h in development:
Expand Down
8 changes: 8 additions & 0 deletions arch/sparc/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -201,6 +201,14 @@ config SUN_OPENPROMFS
Only choose N if you know in advance that you will not need to modify
OpenPROM settings on the running system.

config SPARC_LED
tristate "Sun4m LED driver"
help
This driver toggles the front-panel LED on sun4m systems
in a user-specifyable manner. It's state can be probed
by reading /proc/led and it's blinking mode can be changed
via writes to /proc/led

source "fs/Kconfig.binfmt"

config SUNOS_EMUL
Expand Down
1 change: 1 addition & 0 deletions arch/sparc/kernel/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ obj-$(CONFIG_SUN_AUXIO) += auxio.o
obj-$(CONFIG_PCI) += ebus.o
obj-$(CONFIG_SUN_PM) += apc.o pmc.o
obj-$(CONFIG_MODULES) += module.o sparc_ksyms.o
obj-$(CONFIG_SPARC_LED) += led.o

ifdef CONFIG_SUNOS_EMUL
obj-y += sys_sunos.o sunos_ioctl.o
Expand Down
139 changes: 139 additions & 0 deletions arch/sparc/kernel/led.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,139 @@
#include <linux/kernel.h>
#include <linux/module.h>
#include <linux/init.h>
#include <linux/proc_fs.h>
#include <linux/string.h>

#include <asm/auxio.h>

#define LED_MAX_LENGTH 8 /* maximum chars written to proc file */

static inline void led_toggle(void)
{
unsigned char val = get_auxio();
unsigned char on, off;

if (val & AUXIO_LED) {
on = 0;
off = AUXIO_LED;
} else {
on = AUXIO_LED;
off = 0;
}

set_auxio(on, off);
}

static struct timer_list led_blink_timer;

static void led_blink(unsigned long timeout)
{
led_toggle();

/* reschedule */
if (!timeout) { /* blink according to load */
led_blink_timer.expires = jiffies +
((1 + (avenrun[0] >> FSHIFT)) * HZ);
led_blink_timer.data = 0;
} else { /* blink at user specified interval */
led_blink_timer.expires = jiffies + (timeout * HZ);
led_blink_timer.data = timeout;
}
add_timer(&led_blink_timer);
}

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

if (get_auxio() & AUXIO_LED)
len = sprintf(buf, "on\n");
else
len = sprintf(buf, "off\n");

return len;
}

static int led_write_proc(struct file *file, const char *buffer,
unsigned long count, void *data)
{
char *buf = NULL;

if (count > LED_MAX_LENGTH)
count = LED_MAX_LENGTH;

buf = kmalloc(sizeof(char) * (count + 1), GFP_KERNEL);
if (!buf)
return -ENOMEM;

if (copy_from_user(buf, buffer, count)) {
kfree(buf);
return -EFAULT;
}

buf[count] = '\0';

/* work around \n when echo'ing into proc */
if (buf[count - 1] == '\n')
buf[count - 1] = '\0';

/* before we change anything we want to stop any running timers,
* otherwise calls such as on will have no persistent effect
*/
del_timer_sync(&led_blink_timer);

if (!strcmp(buf, "on")) {
auxio_set_led(AUXIO_LED_ON);
} else if (!strcmp(buf, "toggle")) {
led_toggle();
} else if ((*buf > '0') && (*buf <= '9')) {
led_blink(simple_strtoul(buf, NULL, 10));
} else if (!strcmp(buf, "load")) {
led_blink(0);
} else {
auxio_set_led(AUXIO_LED_OFF);
}

kfree(buf);

return count;
}

static struct proc_dir_entry *led;

#define LED_VERSION "0.1"

static int __init led_init(void)
{
init_timer(&led_blink_timer);
led_blink_timer.function = led_blink;

led = create_proc_entry("led", 0, NULL);
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
"led: version %s, Lars Kotthoff <metalhead@metalhead.ws>\n",
LED_VERSION);

return 0;
}

static void __exit led_exit(void)
{
remove_proc_entry("led", NULL);
del_timer_sync(&led_blink_timer);
}

module_init(led_init);
module_exit(led_exit);

MODULE_AUTHOR("Lars Kotthoff <metalhead@metalhead.ws>");
MODULE_DESCRIPTION("Provides control of the front LED on SPARC systems.");
MODULE_LICENSE("GPL");
MODULE_VERSION(LED_VERSION);
1 change: 0 additions & 1 deletion arch/sparc/kernel/sunos_ioctl.c
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@
#include <linux/smp_lock.h>
#include <linux/syscalls.h>
#include <linux/file.h>
#include <asm/kbio.h>

#if 0
extern char sunkbd_type;
Expand Down
Loading

0 comments on commit d27ba47

Please sign in to comment.