Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 8de53481 authored by Boris Brezillon's avatar Boris Brezillon
Browse files

Merge branch 'mtd-nand-trigger' of...

Merge branch 'mtd-nand-trigger' of git://git.kernel.org/pub/scm/linux/kernel/git/j.anaszewski/linux-leds into nand/next

Pull leds-trigger changes from Jacek Anaszewski.
Create a generic mtd led-trigger to replace the exisitng nand led-trigger
implementation.

* 'mtd-nand-trigger' of git://git.kernel.org/pub/scm/linux/kernel/git/j.anaszewski/linux-leds:
  mtd: Hook I/O activity to the MTD LED trigger
  mtd: nand: Remove the "nand-disk" LED trigger
  leds: trigger: Introduce a MTD (NAND/NOR) trigger
  mtd: Uninline mtd_write_oob and move it to mtdcore.c
  leds: trigger: Introduce a kernel panic LED trigger
parents 4217ff35 fea728c0
Loading
Loading
Loading
Loading
+15 −0
Original line number Diff line number Diff line
@@ -41,6 +41,14 @@ config LEDS_TRIGGER_IDE_DISK
	  This allows LEDs to be controlled by IDE disk activity.
	  If unsure, say Y.

config LEDS_TRIGGER_MTD
	bool "LED MTD (NAND/NOR) Trigger"
	depends on MTD
	depends on LEDS_TRIGGERS
	help
	  This allows LEDs to be controlled by MTD activity.
	  If unsure, say N.

config LEDS_TRIGGER_HEARTBEAT
	tristate "LED Heartbeat Trigger"
	depends on LEDS_TRIGGERS
@@ -108,4 +116,11 @@ config LEDS_TRIGGER_CAMERA
	  This enables direct flash/torch on/off by the driver, kernel space.
	  If unsure, say Y.

config LEDS_TRIGGER_PANIC
	bool "LED Panic Trigger"
	depends on LEDS_TRIGGERS
	help
	  This allows LEDs to be configured to blink on a kernel panic.
	  If unsure, say Y.

endif # LEDS_TRIGGERS
+2 −0
Original line number Diff line number Diff line
obj-$(CONFIG_LEDS_TRIGGER_TIMER)	+= ledtrig-timer.o
obj-$(CONFIG_LEDS_TRIGGER_ONESHOT)	+= ledtrig-oneshot.o
obj-$(CONFIG_LEDS_TRIGGER_IDE_DISK)	+= ledtrig-ide-disk.o
obj-$(CONFIG_LEDS_TRIGGER_MTD)		+= ledtrig-mtd.o
obj-$(CONFIG_LEDS_TRIGGER_HEARTBEAT)	+= ledtrig-heartbeat.o
obj-$(CONFIG_LEDS_TRIGGER_BACKLIGHT)	+= ledtrig-backlight.o
obj-$(CONFIG_LEDS_TRIGGER_GPIO)		+= ledtrig-gpio.o
@@ -8,3 +9,4 @@ obj-$(CONFIG_LEDS_TRIGGER_CPU) += ledtrig-cpu.o
obj-$(CONFIG_LEDS_TRIGGER_DEFAULT_ON)	+= ledtrig-default-on.o
obj-$(CONFIG_LEDS_TRIGGER_TRANSIENT)	+= ledtrig-transient.o
obj-$(CONFIG_LEDS_TRIGGER_CAMERA)	+= ledtrig-camera.o
obj-$(CONFIG_LEDS_TRIGGER_PANIC)	+= ledtrig-panic.o
+45 −0
Original line number Diff line number Diff line
/*
 * LED MTD trigger
 *
 * Copyright 2016 Ezequiel Garcia <ezequiel@vanguardiasur.com.ar>
 *
 * Based on LED IDE-Disk Activity Trigger
 *
 * Copyright 2006 Openedhand Ltd.
 *
 * Author: Richard Purdie <rpurdie@openedhand.com>
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License version 2 as
 * published by the Free Software Foundation.
 *
 */

#include <linux/kernel.h>
#include <linux/init.h>
#include <linux/leds.h>

#define BLINK_DELAY 30

DEFINE_LED_TRIGGER(ledtrig_mtd);
DEFINE_LED_TRIGGER(ledtrig_nand);

void ledtrig_mtd_activity(void)
{
	unsigned long blink_delay = BLINK_DELAY;

	led_trigger_blink_oneshot(ledtrig_mtd,
				  &blink_delay, &blink_delay, 0);
	led_trigger_blink_oneshot(ledtrig_nand,
				  &blink_delay, &blink_delay, 0);
}
EXPORT_SYMBOL(ledtrig_mtd_activity);

static int __init ledtrig_mtd_init(void)
{
	led_trigger_register_simple("mtd", &ledtrig_mtd);
	led_trigger_register_simple("nand-disk", &ledtrig_nand);

	return 0;
}
device_initcall(ledtrig_mtd_init);
+30 −0
Original line number Diff line number Diff line
/*
 * Kernel Panic LED Trigger
 *
 * Copyright 2016 Ezequiel Garcia <ezequiel@vanguardiasur.com.ar>
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License version 2 as
 * published by the Free Software Foundation.
 *
 */

#include <linux/kernel.h>
#include <linux/init.h>
#include <linux/leds.h>

static struct led_trigger *trigger;

static long led_panic_blink(int state)
{
	led_trigger_event(trigger, state ? LED_FULL : LED_OFF);
	return 0;
}

static int __init ledtrig_panic_init(void)
{
	led_trigger_register_simple("panic", &trigger);
	panic_blink = led_panic_blink;
	return 0;
}
device_initcall(ledtrig_panic_init);
+19 −0
Original line number Diff line number Diff line
@@ -40,6 +40,7 @@
#include <linux/slab.h>
#include <linux/reboot.h>
#include <linux/kconfig.h>
#include <linux/leds.h>

#include <linux/mtd/mtd.h>
#include <linux/mtd/partitions.h>
@@ -862,6 +863,7 @@ int mtd_erase(struct mtd_info *mtd, struct erase_info *instr)
		mtd_erase_callback(instr);
		return 0;
	}
	ledtrig_mtd_activity();
	return mtd->_erase(mtd, instr);
}
EXPORT_SYMBOL_GPL(mtd_erase);
@@ -925,6 +927,7 @@ int mtd_read(struct mtd_info *mtd, loff_t from, size_t len, size_t *retlen,
	if (!len)
		return 0;

	ledtrig_mtd_activity();
	/*
	 * In the absence of an error, drivers return a non-negative integer
	 * representing the maximum number of bitflips that were corrected on
@@ -949,6 +952,7 @@ int mtd_write(struct mtd_info *mtd, loff_t to, size_t len, size_t *retlen,
		return -EROFS;
	if (!len)
		return 0;
	ledtrig_mtd_activity();
	return mtd->_write(mtd, to, len, retlen, buf);
}
EXPORT_SYMBOL_GPL(mtd_write);
@@ -982,6 +986,8 @@ int mtd_read_oob(struct mtd_info *mtd, loff_t from, struct mtd_oob_ops *ops)
	ops->retlen = ops->oobretlen = 0;
	if (!mtd->_read_oob)
		return -EOPNOTSUPP;

	ledtrig_mtd_activity();
	/*
	 * In cases where ops->datbuf != NULL, mtd->_read_oob() has semantics
	 * similar to mtd->_read(), returning a non-negative integer
@@ -997,6 +1003,19 @@ int mtd_read_oob(struct mtd_info *mtd, loff_t from, struct mtd_oob_ops *ops)
}
EXPORT_SYMBOL_GPL(mtd_read_oob);

int mtd_write_oob(struct mtd_info *mtd, loff_t to,
				struct mtd_oob_ops *ops)
{
	ops->retlen = ops->oobretlen = 0;
	if (!mtd->_write_oob)
		return -EOPNOTSUPP;
	if (!(mtd->flags & MTD_WRITEABLE))
		return -EROFS;
	ledtrig_mtd_activity();
	return mtd->_write_oob(mtd, to, ops);
}
EXPORT_SYMBOL_GPL(mtd_write_oob);

/*
 * Method to access the protection register area, present in some flash
 * devices. The user data is one time programmable but the factory data is read
Loading