Skip to content

Commit

Permalink
mmc: add led trigger
Browse files Browse the repository at this point in the history
Add a led trigger for each host controller that indicates if there
is a request active on the controller.

Signed-off-by: Pierre Ossman <drzeus@drzeus.cx>
  • Loading branch information
Pierre Ossman committed Sep 24, 2007
1 parent 15a0580 commit af8350c
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 0 deletions.
5 changes: 5 additions & 0 deletions drivers/mmc/core/core.c
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
#include <linux/delay.h>
#include <linux/pagemap.h>
#include <linux/err.h>
#include <linux/leds.h>
#include <asm/scatterlist.h>
#include <linux/scatterlist.h>

Expand Down Expand Up @@ -92,6 +93,8 @@ void mmc_request_done(struct mmc_host *host, struct mmc_request *mrq)
cmd->error = 0;
host->ops->request(host, mrq);
} else {
led_trigger_event(host->led, LED_OFF);

pr_debug("%s: req done (CMD%u): %d: %08x %08x %08x %08x\n",
mmc_hostname(host), cmd->opcode, err,
cmd->resp[0], cmd->resp[1],
Expand Down Expand Up @@ -146,6 +149,8 @@ mmc_start_request(struct mmc_host *host, struct mmc_request *mrq)

WARN_ON(!host->claimed);

led_trigger_event(host->led, LED_FULL);

mrq->cmd->error = 0;
mrq->cmd->mrq = mrq;
if (mrq->data) {
Expand Down
5 changes: 5 additions & 0 deletions drivers/mmc/core/host.c
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
#include <linux/err.h>
#include <linux/idr.h>
#include <linux/pagemap.h>
#include <linux/leds.h>

#include <linux/mmc/host.h>

Expand Down Expand Up @@ -115,6 +116,8 @@ int mmc_add_host(struct mmc_host *host)
snprintf(host->class_dev.bus_id, BUS_ID_SIZE,
"mmc%d", host->index);

led_trigger_register_simple(host->class_dev.bus_id, &host->led);

err = device_add(&host->class_dev);
if (err)
return err;
Expand All @@ -140,6 +143,8 @@ void mmc_remove_host(struct mmc_host *host)

device_del(&host->class_dev);

led_trigger_unregister(host->led);

spin_lock(&mmc_host_lock);
idr_remove(&mmc_host_idr, host->index);
spin_unlock(&mmc_host_lock);
Expand Down
6 changes: 6 additions & 0 deletions include/linux/mmc/host.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@
#ifndef LINUX_MMC_HOST_H
#define LINUX_MMC_HOST_H

#include <linux/leds.h>

#include <linux/mmc/core.h>

struct mmc_ios {
Expand Down Expand Up @@ -133,6 +135,10 @@ struct mmc_host {
struct task_struct *sdio_irq_thread;
atomic_t sdio_irq_thread_abort;

#ifdef CONFIG_LEDS_TRIGGERS
struct led_trigger *led; /* activity led */
#endif

unsigned long private[0] ____cacheline_aligned;
};

Expand Down

0 comments on commit af8350c

Please sign in to comment.