Permalink
Browse files

updates

  • Loading branch information...
1 parent fe8a697 commit 54b54e0325c8b5d0d5b50cacee3645dcad88c942 @makelinux committed Jan 13, 2013
Showing with 14 additions and 19 deletions.
  1. +1 −1 Makefile
  2. +0 −1 ldt-test
  3. +13 −16 misc_loop_drv.c
  4. +0 −1 misc_loop_drv_test
View
@@ -5,13 +5,13 @@ ccflags-y+=-fmax-errors=5
#ccflags-y+=-DCTRACER_ON -include $M/ctracer.h
#ccflags-y+=-D USE_MISCDEV # uncomment to use single misc device instead char devices region
+obj-m+= misc_loop_drv.o
obj-m+= ldt.o
obj-m+= ldt_plat_drv.o # implements platform_driver only
obj-m+= ldt_plat_dev.o # implements platform_device and resource
#obj-m+= chrdev_region_sample.o
obj-m+= ldt_configfs_basic.o
obj-m+= kthread_sample.o
-obj-m+= misc_loop_drv.o
KERNELDIR ?= /lib/modules/$(shell uname -r)/build
View
@@ -13,7 +13,6 @@
RED="\\033[0;31m"
NOCOLOR="\\033[0;39m"
GREEN="\\033[0;32m"
-GRAY="\\033[0;37m"
set -o errtrace
debugfs=`grep debugfs /proc/mounts | awk '{ print $2; }'`
View
@@ -17,6 +17,7 @@
* polling
* kfifo
* interrupt
+ * io
* tasklet
*
* Run test script misc_loop_drv_test to test the driver
@@ -40,20 +41,20 @@
#include <asm/apic.h>
#undef pr_fmt
-#define pr_fmt(fmt) "%s.c:%d %s " fmt, KBUILD_MODNAME, __LINE__, __func__
+#define pr_fmt(fmt) "%s.c:%d %s " fmt, KBUILD_MODNAME, __LINE__, __func__
/*
* It's supposed you computer doesn't use floppy device.
- * We use IRQ and port of floppy device for demonstration.
+ * This drivers uses IRQ and port of floppy device for demonstration.
*/
static int port = 0x3f4;
module_param(port, int, 0);
-MODULE_PARM_DESC(port, "io port number, default 0x3f4 - floppy");
+MODULE_PARM_DESC(port, "I/O port number, default 0x3f4 - floppy");
static int port_size = 2;
module_param(port_size, int, 0);
-MODULE_PARM_DESC(port_size, "number of io ports, default 2");
+MODULE_PARM_DESC(port_size, "size of I/O port mapping, default 2");
static int irq = 6;
module_param(irq, int, 0);
@@ -62,21 +63,18 @@ MODULE_PARM_DESC(irq, "interrupt request number, default 6 - floppy");
/*
* Offsets of registers in port_emulation
*
- * Pay attention that MISC_DRV_TX = MISC_DRV_RX and MISC_DRV_TX_FULL = MISC_DRV_RX_READY.
- * It emulates loopback device. Transmitted data becomes received.
+ * Pay attention that MISC_DRV_TX == MISC_DRV_RX and MISC_DRV_TX_FULL == MISC_DRV_RX_READY.
+ * Transmitted data becomes received and emulates port in loopback mode.
*/
#define MISC_DRV_TX 0
#define MISC_DRV_RX 0
#define MISC_DRV_TX_FULL 1
#define MISC_DRV_RX_READY 1
-/**
- * port_emulation[] - array to emulate port I/0
- */
-
-static char port_emulation[2];
+static char port_emulation[2]; /* array to emulate I/0 port */
+#define FIFO_SIZE 128 /* must be power of two */
/**
* struct misc_loop_drv_data - the driver data
@@ -91,8 +89,6 @@ static char port_emulation[2];
* struct misc_loop_drv_data *drvdata = platform_get_drvdata(pdev);
*/
-#define FIFO_SIZE 128 /* must be power of two */
-
struct misc_loop_drv_data {
struct mutex read_lock;
struct mutex write_lock;
@@ -114,7 +110,7 @@ static void misc_loop_drv_tasklet_func(unsigned long d)
while (!ioread8(drvdata->port_ptr + MISC_DRV_TX_FULL)
&& kfifo_out_spinlocked(&drvdata->out_fifo,
- &data_out, sizeof(data_out), &drvdata->fifo_lock)) {
+ &data_out, sizeof(data_out), &drvdata->fifo_lock)) {
wake_up_interruptible(&drvdata->writeable);
pr_debug("data_out=%d %c\n", data_out, data_out >= 32 ? data_out : ' ');
iowrite8(data_out, drvdata->port_ptr + MISC_DRV_TX);
@@ -128,7 +124,7 @@ static void misc_loop_drv_tasklet_func(unsigned long d)
*/
apic->send_IPI_all(IRQ0_VECTOR+irq);
}
- while (ioread8(drvdata->port_ptr + MISC_DRV_RX_READY)) {
+ while ( ioread8(drvdata->port_ptr + MISC_DRV_RX_READY)) {
data_in = ioread8(drvdata->port_ptr + MISC_DRV_RX);
pr_debug("data_in=%d %c\n", data_in, data_in >= 32 ? data_in : ' ');
kfifo_in_spinlocked(&drvdata->in_fifo, &data_in,
@@ -284,7 +280,8 @@ static struct misc_loop_drv_data *misc_loop_drv_data_init(void)
INIT_KFIFO(drvdata->out_fifo);
mutex_init(&drvdata->read_lock);
mutex_init(&drvdata->write_lock);
- tasklet_init(&drvdata->misc_loop_drv_tasklet, misc_loop_drv_tasklet_func, (unsigned long)drvdata);
+ tasklet_init(&drvdata->misc_loop_drv_tasklet,
+ misc_loop_drv_tasklet_func, (unsigned long)drvdata);
return drvdata;
}
View
@@ -5,7 +5,6 @@
RED="\\033[0;31m"
NOCOLOR="\\033[0;39m"
GREEN="\\033[0;32m"
-GRAY="\\033[0;37m"
dmesg -c > /dev/null # clear log buffer
# It's supposed you computer doesn't use floppy device.

0 comments on commit 54b54e0

Please sign in to comment.