According to Jesus Climent, on Mon, 6 Dec 2004 01:44:17 +0100, >On Mon, Dec 06, 2004 at 12:28:24AM +1100, Cedric Pradalier wrote: >> >> I attach a very small patch doing that. This a patch only for >> drivers/ide/ppc/pmac.c >> file, with respect to a pure kernel 2.6.9 from kernel.org >> >> It adds an entry in /sys/devices/ide-pmac/blinking_led >> echo 1 > /sys/devices/ide-pmac/blinking_led >> activates the led >> >> echo 0 > /sys/devices/ide-pmac/blinking_led >> disactivates it >> >> It starts disactivated. > >Can it be configurable? > >I would like to see it from the very start of the kernel run. >
Actually, it is not possible to activate it at the very start. You have to wait the ide-pmac initialisation, that is one or two seconds after boot ;o) In this version of the patch, if your boot your kernel with the argument blinking_led (append="blinking_led" in yaboot.conf), the led blinks. The /sys interface stays the same. I've used a more standard way of managing boolean... ;o) -- Cedric Pradalier
--- pmac.c.orig 2004-12-06 00:27:50.000000000 +1100 +++ pmac.c 2004-12-07 00:03:44.000000000 +1100 @@ -35,6 +35,11 @@ #include <linux/adb.h> #include <linux/pmu.h> +#ifdef CONFIG_BLK_DEV_IDE_PMAC_BLINK +#include <linux/device.h> +#include <asm/of_device.h> +#endif + #include <asm/prom.h> #include <asm/io.h> #include <asm/dbdma.h> @@ -381,9 +386,9 @@ static spinlock_t pmu_blink_lock; static unsigned long pmu_blink_stoptime; static int pmu_blink_ledstate; +static int blinking_led = 0; static struct timer_list pmu_blink_timer; -static int pmu_ide_blink_enabled; - +static int pmu_ide_blink_enabled = 0; static void pmu_hd_blink_timeout(unsigned long data) @@ -413,6 +418,8 @@ pmu_hd_kick_blink(void *data, int rw) { unsigned long flags; + if (!blinking_led) + return; pmu_blink_stoptime = jiffies + PMU_HD_BLINK_TIME; wmb(); @@ -428,9 +435,32 @@ spin_unlock_irqrestore(&pmu_blink_lock, flags); } +static ssize_t show_blinkingled_activity(struct device *dev, char *buf)\ +{ + return sprintf(buf, "%c\n", blinking_led?'1':'0'); +} + +static ssize_t set_blinkingled_activity(struct device *dev, + const char *buf, size_t count) +{ + int blink; + if (sscanf (buf, "%d", &blink) != 1) + return -EINVAL; + blinking_led = (blink != 0); + printk (KERN_INFO "pmac blinking led has been %sactivated\n", + blinking_led?"":"dis"); + return count; +} + +static DEVICE_ATTR (blinking_led, S_IRUGO | S_IWUSR, + show_blinkingled_activity, set_blinkingled_activity); + static int pmu_hd_blink_init(void) { + extern char saved_command_line[]; + struct device_node *np; + static struct of_device *of_hd_dev; struct device_node *dt; const char *model; @@ -458,6 +488,16 @@ init_timer(&pmu_blink_timer); pmu_blink_timer.function = pmu_hd_blink_timeout; + np = of_find_node_by_name (NULL, "disk"); + if (!np) return 1; + of_hd_dev = of_platform_device_create (np, "ide-pmac"); + if (!of_hd_dev) return 1; + device_create_file (&of_hd_dev->dev, &dev_attr_blinking_led); + + blinking_led = (strstr(saved_command_line,"blinking_led") != NULL); + printk(KERN_INFO "pmac blinking led initialized (blink %sactivated)\n", + blinking_led?"":"dis"); + return 1; }