According to Benjamin Herrenschmidt, on Mon, 20 Dec 2004 07:59:49 +0100, 
>
>> You mean in /sys/bus/macio/drivers/ide-pmac ?
>
>That's the driver entry, but the devices themselves have entries as
>well, I'd rather put a per-device switch in them (either through the
>actual device path, either PCI or macio, or the ide interface proper).
>
>> The main reason is that I could not find how to add my sysfs in this 
>> directory since it
>is> not created in the ide-pmac.c file (still a lot to learn :)). So I 
>convinced myself
>that a> platform device was not so irrelevant.
>
>It's totally irrelevant actually  :)

Ok I believe you. It is now attached to the macio device
/sys/bus/macio/devices/0.0001f000\:ata-4/blinking_led
Is this what you suggested?

I chose macio since I had the struct device pointer easily accessible in pmac.c.

>> Other thing strange to me is that I have to use the saved command line to 
>> know if there
>> is a boot time argument. According to the comments around MODULE_PARM, a 
>> module
>parameter> should be enough. I tried that, but the boot parameter never had 
>any influence
>on the > parameter.
>
>You must have typed it wrong ... One problem with ide-pmac though is
>that the module name is confusing since the file name itself is just
>"pmac". I'm not too familiar with the module params thing tho, it may be
>possible to "override" the module name.

I don't think so. Module parameters do not depend of the module name (as far as 
I
understand from the doc). What I guess is that ide-pmac module is initialized 
too early to
have correct boot parameters. For instance, I tried to had a dummy module_init 
function,
and it is called much later than ide_pmac_setup_device (where blinking is 
initialized).
Anybody can confirm or infirm this guess ?

Furthermore I've looked at the way framebuffers manage boot params, and these 
module seems
to be parsing the comand line themselves too. 

-- 
Cedric Pradalier
--- pmac.c.old  2004-12-05 23:58:25.000000000 +1100
+++ pmac.c      2004-12-20 21:40:43.976967000 +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,30 @@
        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)
+pmu_hd_blink_init(struct device * dev)
 {
+       extern char saved_command_line[];
        struct device_node *dt;
        const char *model;
 
@@ -458,6 +486,12 @@
        init_timer(&pmu_blink_timer);
        pmu_blink_timer.function = pmu_hd_blink_timeout;
 
+       device_create_file (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;
 }
 
@@ -1230,7 +1264,7 @@
        hwif->speedproc = pmac_ide_tune_chipset;
 
 #ifdef CONFIG_BLK_DEV_IDE_PMAC_BLINK
-       pmu_ide_blink_enabled = pmu_hd_blink_init();
+       pmu_ide_blink_enabled = pmu_hd_blink_init(&(pmif->mdev->ofdev.dev));
 
        if (pmu_ide_blink_enabled)
                hwif->led_act = pmu_hd_kick_blink;

Reply via email to