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

Re: Hard Drive light



According to Benjamin Herrenschmidt, on Mon, 24 Jan 2005 09:19:13 +1100, 
>
>> 
>> Hi ben, 
>> 
>> Did you have time to have a look at that ? As far as I can see, I actually attached to
>the> only struct device in the hwif. So it might be what you wanted.
>
>No, sorry I've been a bit too busy. Please, re-send me your latest
>patch.
>

No need to be sorry, this is in no way a first priority matter :)
There it is.

Cedric
--- pmac.c.old	2004-12-05 23:58:25.000000000 +1100
+++ pmac.c	2005-01-23 21:20:08.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>
@@ -372,6 +377,15 @@
 
 #ifdef CONFIG_BLK_DEV_IDE_PMAC_BLINK
 
+MODULE_AUTHOR("Paul Mackerras & Ben. Herrenschmidt");
+MODULE_DESCRIPTION("Support for IDE interfaces on PowerMacs");
+MODULE_LICENSE("GPL");
+
+static int blinking_led = 1;
+module_param_named(noblink,blinking_led, invbool, 0666);
+MODULE_PARM_DESC(noblink,"Enable/Disable blinking led [Default: enabled]");
+
+
 /* Set to 50ms minimum led-on time (also used to limit frequency
  * of requests sent to the PMU
  */
@@ -382,8 +396,7 @@
 static unsigned long pmu_blink_stoptime;
 static int pmu_blink_ledstate;
 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 +426,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,8 +443,28 @@
 	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 initialized (blink %s)\n",
+			blinking_led?"enabled":"disabled");
+	return count;
+}
+
+static DEVICE_ATTR (blinking_led, S_IRUGO | S_IWUSR, 
+		show_blinkingled_activity, set_blinkingled_activity);
+
 static int
-pmu_hd_blink_init(void)
+pmu_hd_blink_init(struct device * dev)
 {
 	struct device_node *dt;
 	const char *model;
@@ -458,6 +493,11 @@
 	init_timer(&pmu_blink_timer);
 	pmu_blink_timer.function = pmu_hd_blink_timeout;
 
+	device_create_file (dev, &dev_attr_blinking_led);
+	
+	printk(KERN_INFO "pmac blinking led initialized (blink %s)\n",
+			blinking_led?"enabled":"disabled");
+
 	return 1;
 }
 
@@ -1229,13 +1269,6 @@
 		hwif->selectproc = pmac_ide_selectproc;
 	hwif->speedproc = pmac_ide_tune_chipset;
 
-#ifdef CONFIG_BLK_DEV_IDE_PMAC_BLINK
-	pmu_ide_blink_enabled = pmu_hd_blink_init();
-
-	if (pmu_ide_blink_enabled)
-		hwif->led_act = pmu_hd_kick_blink;
-#endif
-
 	printk(KERN_INFO "ide%d: Found Apple %s controller, bus ID %d%s, irq %d\n",
 	       hwif->index, model_name[pmif->kind], pmif->aapl_bus_id,
 	       pmif->mediabay ? " (mediabay)" : "", hwif->irq);
@@ -1253,6 +1286,13 @@
 
 	/* We probe the hwif now */
 	probe_hwif_init(hwif);
+#ifdef CONFIG_BLK_DEV_IDE_PMAC_BLINK
+	pmu_ide_blink_enabled = pmu_hd_blink_init(hwif->gendev.parent);
+
+	if (pmu_ide_blink_enabled)
+		hwif->led_act = pmu_hd_kick_blink;
+#endif
+
 
 	/* The code IDE code will have set hwif->present if we have devices attached,
 	 * if we don't, the discard the interface except if we are on a media bay slot
@@ -1342,6 +1382,7 @@
 #endif /* CONFIG_BLK_DEV_IDEDMA_PMAC */
 	dev_set_drvdata(&mdev->ofdev.dev, hwif);
 
+	printk(KERN_INFO "pmac: using macio interface");
 	rc = pmac_ide_setup_device(pmif, hwif);
 	if (rc != 0) {
 		/* The inteface is released to the common IDE layer */
@@ -1454,6 +1495,7 @@
 
 	pci_set_drvdata(pdev, hwif);
 
+	printk(KERN_INFO "pmac: using PCI interface");
 	rc = pmac_ide_setup_device(pmif, hwif);
 	if (rc != 0) {
 		/* The inteface is released to the common IDE layer */

Reply to: