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]
Date:	Sat, 26 Nov 2011 18:31:03 +0100
From:	Alessandro Rubini <rubini@...dd.com>
To:	linux-iio@...r.kernel.org, greg@...ah.com,
	linux-kernel@...r.kernel.org
Cc:	federico.vaga@...il.com, dcobas@...n.ch, siglesia@...n.ch,
	manohar.vanga@...n.ch
Subject: [RFC PATCH 5/7] drivers/zio: add the zio-zero device driver

From: Federico Vaga <federico.vaga@...il.com>

zio-zero is a demonstration driver that generates /dev/zero-like data.
I can be used to test the default trigger and the default buffer.
The files match commit 7d37663 in git://ohwr.org/misc/zio.git .

Signed-off-by: Federico Vaga <federico.vaga@...il.com>
Signed-off-by: Alessandro Rubini <rubini@...dd.com>
Acked-by: Juan David Gonzalez Cobas <dcobas@...n.ch>
Acked-by: Samuel Iglesias Gonsalvez <siglesia@...n.ch>
Acked-by: Manohar Vanga <manohar.vanga@...n.ch>
---
 drivers/zio/drivers/Makefile   |    1 +
 drivers/zio/drivers/zio-zero.c |   87 ++++++++++++++++++++++++++++++++++++++++
 2 files changed, 88 insertions(+), 0 deletions(-)
 create mode 100644 drivers/zio/drivers/Makefile
 create mode 100644 drivers/zio/drivers/zio-zero.c

diff --git a/drivers/zio/drivers/Makefile b/drivers/zio/drivers/Makefile
new file mode 100644
index 0000000..d59387b
--- /dev/null
+++ b/drivers/zio/drivers/Makefile
@@ -0,0 +1 @@
+obj-$(CONFIG_ZIO) += zio-zero.o
diff --git a/drivers/zio/drivers/zio-zero.c b/drivers/zio/drivers/zio-zero.c
new file mode 100644
index 0000000..f803e09
--- /dev/null
+++ b/drivers/zio/drivers/zio-zero.c
@@ -0,0 +1,87 @@
+/* Federico Vaga for CERN, 2011, GNU GPLv2 or later */
+/*
+ * zero-zio is a simple zio driver which fill buffer with 0. From the ZIO
+ * point of view is an input device
+ */
+#include <linux/module.h>
+#include <linux/kernel.h>
+#include <linux/init.h>
+#include <linux/slab.h>
+#include <linux/random.h>
+
+#include <linux/zio.h>
+#include <linux/zio-buffer.h>
+
+static char *zzero_trigger;
+static char *zzero_buffer;
+module_param_named(trigger, zzero_trigger, charp, 0444);
+module_param_named(buffer, zzero_buffer, charp, 0444);
+
+static int zzero_input(struct zio_cset *cset)
+{
+	struct zio_channel *chan;
+	struct zio_block *block;
+	static uint8_t datum;
+	uint8_t *data;
+	int i;
+
+	/* Return immediately: just fill the blocks */
+	cset_for_each(cset, chan) {
+		block = chan->active_block;
+		if (!block)
+			continue;
+		switch (chan->index) {
+		case 0: /* zero */
+			memset(block->data, 0x0, block->datalen);
+			break;
+		case 1: /* random */
+			get_random_bytes(block->data, block->datalen);
+			break;
+		case 2: /* sequence */
+			data = block->data;
+			for (i = 0; i < block->datalen; i++)
+				data[i] = datum++;
+		}
+	}
+	return 1; /* Already done */
+}
+
+static const struct zio_device_operations zzero_d_op = {
+	.input_cset =		zzero_input,
+};
+
+static struct zio_cset zzero_cset[] = {
+	{
+		.n_chan =	3,
+		.ssize =	1,
+		.flags =	ZIO_DIR_INPUT | ZCSET_TYPE_ANALOG,
+	},
+};
+
+static struct zio_device zzero_dev = {
+	.owner =		THIS_MODULE,
+	.d_op =			&zzero_d_op,
+	.cset =			zzero_cset,
+	.n_cset =		ARRAY_SIZE(zzero_cset),
+};
+
+static int __init zzero_init(void)
+{
+	if (zzero_trigger)
+		zzero_dev.preferred_trigger = zzero_trigger;
+	if (zzero_buffer)
+		zzero_dev.preferred_buffer = zzero_buffer;
+	return zio_register_dev(&zzero_dev, "zzero");
+}
+
+static void __exit zzero_exit(void)
+{
+	zio_unregister_dev(&zzero_dev);
+}
+
+module_init(zzero_init);
+module_exit(zzero_exit);
+
+MODULE_AUTHOR("Federico Vaga <federico.vaga@...il.com>");
+MODULE_DESCRIPTION("A zio driver which fakes zero, random and sawtooth input");
+MODULE_LICENSE("GPL");
-- 
1.7.7.2
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ