public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Richard Purdie <rpurdie@rpsys.net>
To: kogiidena@eggplant.ddo.jp
Cc: linux-kernel@vger.kernel.org, lethal@linux-sh.org
Subject: Re: [PATCH 1/2] leds:arch/sh/boards/landisk LEDs supports
Date: Tue, 08 May 2007 13:54:48 +0100	[thread overview]
Message-ID: <1178628889.6061.33.camel@localhost.localdomain> (raw)
In-Reply-To: <1743.192.168.1.10.1178627210.squirrel@eggplant.ddo.jp>

> On Tue, 2007-05-08 at 21:26 +0900, kogiidena wrote:
> To:Richard-san
> CC:all
> 
> LED driver of I-O DATA LANDISK and USL-5P
> Please apply following patch
> 
> Signed-off-by: kogiidena <kogiidena@eggplant.ddo.jp>
> 
[...]
> +/* HDD-access-LED setting at landisk status LED */
> +static void landisk_disk_trig_activate(struct led_classdev *led_cdev)
> +{
> +        unsigned long flags;
> +        spin_lock_irqsave(&landisk_led_lock, flags);
> +        ctrl_outb((ctrl_inb(PA_LED) & ~0x0c) | 0x04, PA_LED);
> +        spin_unlock_irqrestore(&landisk_led_lock, flags);
> +}
> +
> +static void landisk_disk_trig_deactivate(struct led_classdev *led_cdev)
> +{
> +        unsigned long flags;
> +        spin_lock_irqsave(&landisk_led_lock, flags);
> +        ctrl_outb((ctrl_inb(PA_LED) & ~0x0c) | 0x0c, PA_LED);
> +        spin_unlock_irqrestore(&landisk_led_lock, flags);
> +}
> +
> +static struct led_trigger landisk_disk_led_trigger = {
> +        .name = "disk",
> +        .activate = landisk_disk_trig_activate,
> +        .deactivate = landisk_disk_trig_deactivate,
> +};

You can't do this since the trigger will appear for all LEDs and it only
applies to a single LED. There has been previous discussion of LED
specific triggers and we'll need that support before you can make
something like this work. Nobody has sent me a patch for that yet and I
haven't had time to write one...

+static int __init landisk_led_init(void)
> +{
> +        u8 orig, test;
> +
> +        orig = ctrl_inb(PA_LED);
> +        ctrl_outb(0x40, PA_LED);
> +
> +        test = ctrl_inb(PA_LED);
> +        ctrl_outb(orig, PA_LED);
> +
> +        landisk_arch = (test == 0x40);
> +
> +        if (landisk_arch == 0) {
> +                /* arch == landisk */
> +                ctrl_outb(orig | 0x07, PA_LED);
> +                landisk_leds[1].default_trigger = "disk";
> +                led_trigger_register(&landisk_disk_led_trigger);
> +        } else {
> +                /* arch == usl-5p */
> +                ctrl_outb(orig | 0x03, PA_LED);
> +        }
> +        return platform_driver_register(&landisk_led_driver);

Broken error handling - you should check the return code of
led_trigger_register().

> +static void __exit landisk_led_exit(void)
> +{
> +        if (landisk_arch == 0)
> +                led_trigger_unregister(&landisk_disk_led_trigger);
> +        return platform_driver_unregister(&landisk_led_driver);
> +}

void functions don't return.

Other than those issues, it looks ok.

Richard



  reply	other threads:[~2007-05-08 12:55 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-05-08 12:26 [PATCH 1/2] leds:arch/sh/boards/landisk LEDs supports kogiidena
2007-05-08 12:54 ` Richard Purdie [this message]
2007-05-09 14:26   ` kogiidena
2007-05-09 15:13     ` Richard Purdie
2007-05-09 16:03       ` Anton Vorontsov
2007-05-10 11:52         ` kogiidena
2007-05-10 14:04           ` Paul Mundt
2007-05-11 15:03             ` kogiidena
2007-05-12  4:01               ` kogiidena
2007-05-13 23:16         ` Richard Purdie
2007-05-14 19:56           ` Anton Vorontsov
2007-05-14 20:12           ` Anton Vorontsov
2007-05-14 20:33             ` Richard Purdie
2007-05-14 21:13               ` Anton Vorontsov
2007-05-09 21:48       ` kogiidena

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1178628889.6061.33.camel@localhost.localdomain \
    --to=rpurdie@rpsys.net \
    --cc=kogiidena@eggplant.ddo.jp \
    --cc=lethal@linux-sh.org \
    --cc=linux-kernel@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox