[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

[Patch #3] Re: Hard Drive light



According to David Pye, on Mon, 6 Dec 2004 20:46:15 +0000, 
>On Monday 06 December 2004 13:31, Cedric Pradalier wrote:
>+       printk (KERN_INFO "pmac blinking led has been %sactivated\n", 
>+                       blinking_led?"":"dis");
>
>You never get an easy life around here ;)
>
>I think that should be "de", not "dis"  :)
>
>Though would "%s", blinking_led?"enabled":"disabled" sound better?
>
[...]

You're right. So this is a version with the strings updated. 
Please excuse my english...

Cheers,

-- 
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 %sabled\n", 
+			blinking_led?"en":"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 %sabled)\n",
+			blinking_led?"en":"dis");
+
 	return 1;
 }
 

Reply to: