lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20210809033217.1113444-3-arequipeno@gmail.com>
Date:   Sun,  8 Aug 2021 22:32:09 -0500
From:   Ian Pilcher <arequipeno@...il.com>
To:     linux-block@...r.kernel.org, linux-leds@...r.kernel.org
Cc:     axboe@...nel.dk, pavel@....cz, linux-kernel@...r.kernel.org,
        kernelnewbies@...nelnewbies.org
Subject: [RFC PATCH v2 02/10] block: Add file (blk-ledtrig.c) for block device LED trigger implementation

Define data structure for all associated LEDs

Add list of associated LEDs and list search helper

Add trigger mutex - must be held when accessing trigger/LED or device/LED
associations

Signed-off-by: Ian Pilcher <arequipeno@...il.com>
---
 block/blk-ledtrig.c | 48 +++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 48 insertions(+)
 create mode 100644 block/blk-ledtrig.c

diff --git a/block/blk-ledtrig.c b/block/blk-ledtrig.c
new file mode 100644
index 000000000000..c5ad57ed9c3b
--- /dev/null
+++ b/block/blk-ledtrig.c
@@ -0,0 +1,48 @@
+// SPDX-License-Identifier: GPL-2.0-only
+
+/*
+ *	Block device LED triggers
+ *
+ *	Copyright 2021 Ian Pilcher <arequipeno@...il.com>
+ */
+
+#include <linux/leds.h>
+#include <linux/mutex.h>
+
+/*
+ *
+ *	Trigger mutex and LED list
+ *
+ */
+
+// Must hold when doing anything with LED/trigger/block device
+// associations
+static DEFINE_MUTEX(blk_ledtrig_mutex);
+
+static LIST_HEAD(blk_ledtrig_leds);
+
+// Every LED associated with the blkdev trigger gets one of these
+struct blk_ledtrig_led {
+	struct kobject		*dir;		// block_devices subdirectory
+	struct led_classdev	*led;
+	unsigned int		blink_on;
+	unsigned int		blink_off;
+	struct list_head	leds_list_node;
+	struct list_head	dev_list;
+};
+
+// Caller must hold blk_ledtrig_mutex
+static struct blk_ledtrig_led *blk_ledtrig_find(const char *const led_name,
+						const size_t name_len)
+{
+	struct blk_ledtrig_led *bd_led;
+
+	list_for_each_entry(bd_led, &blk_ledtrig_leds, leds_list_node) {
+		if (strlen(bd_led->led->name) != name_len)
+			continue;
+		if (memcmp(bd_led->led->name, led_name, name_len) == 0)
+			return bd_led;
+	}
+
+	return NULL;
+}
-- 
2.31.1

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ