diff --git a/.gitignore b/.gitignore
new file mode 100644
index 0000000000000000000000000000000000000000..453edc8111f41d6b3b24bc0799b0e4cc1e2f9c1d
--- /dev/null
+++ b/.gitignore
@@ -0,0 +1,7 @@
+*.aux
+*.dvi
+*.lof
+*.log
+*.lot
+*.pdf
+*.toc
diff --git a/simulation/Makefile b/simulation/Makefile
index 52d93e94a9fb3e925b44e8a5fe2cf5c8f2cc55a6..ac4d9fab31d99729e4704f899ba2070b3d0fdd03 100644
--- a/simulation/Makefile
+++ b/simulation/Makefile
@@ -4,8 +4,7 @@
 LINUX ?= $(HOME)/linux-for-wbonesim
 
 # temporarily, use local <linux/wishbone.h>
-export WISHBONE_DIR ?= $(shell /bin/pwd)
-EXTRA_CFLAGS := -I$(WISHBONE_DIR)/include
+EXTRA_CFLAGS := -I$(obj)/include
 
 obj-m = wishbone.o fakedac.o fakeadc.o fake_wb_bus.o 
 
diff --git a/simulation/README b/simulation/README
index 9eea2d6a81086514df4f13040ac28f04490cd01f..1a4a0ac024c53a2d8cdcb6c88a865e38fbbd3e2b 100644
--- a/simulation/README
+++ b/simulation/README
@@ -56,7 +56,7 @@ in the simulation/fw/ directory.
 
 To generate a firmware file (the wishbone memory space):
 
-$ ./wb_addrgen wbone.def firmware.bin
+$ ./wb_addrgen wbone.list firmware.bin
 
 The wbone.def file specifies the devices that should be attached
 to the Wishbone bus. The format for specifying devices can be seen
diff --git a/simulation/fake_wb_bus.c b/simulation/fake_wb_bus.c
index 1085a63956e85abff43b621cf6ed22e92552e7ae..fe415384de4e4098f4339681f8f650ace24e1d9f 100644
--- a/simulation/fake_wb_bus.c
+++ b/simulation/fake_wb_bus.c
@@ -8,7 +8,7 @@
  * modify it under the terms of the GNU General Public License
  * as published by the Free Software Foundation; either version 2
  * of the License, or (at your option) any later version.
- * 
+ *
  * This program is distributed in the hope that it will be useful,
  * but WITHOUT ANY WARRANTY; without even the implied warranty of
  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
@@ -63,20 +63,20 @@ static int fake_wbbus_probe(struct device *dev)
 	 */
 	sprintf(fwname, "fakespec-%08x-%04x", spec_vendor, spec_device);
 	if (request_firmware(&wb_fw, fwname, dev)) {
-		printk(KERN_ERR KBUILD_MODNAME ": failed to load "
+		pr_err(KBUILD_MODNAME ": failed to load "
 		       "firmware \"%s\"\n", fwname);
 		return -1;
 	}
 
 	header = (struct sdwb_head *)&wb_fw->data[header_addr];
 	if (header->magic != SDWB_HEAD_MAGIC) {
-		printk(KERN_ERR KBUILD_MODNAME ": invalid sdwb header at %p "
+		pr_err(KBUILD_MODNAME ": invalid sdwb header at %p "
 		       "(magic %llx)\n", header, header->magic);
 		goto head_fail;
 	}
 
 	id = (struct sdwb_wbid *)&wb_fw->data[header->wbid_address];
-	printk(KERN_INFO KBUILD_MODNAME ": found sdwb bistream: 0x%llx\n",
+	pr_info(KBUILD_MODNAME ": found sdwb bistream: 0x%llx\n",
 	       id->bstream_type);
 
 	wbd = (struct sdwb_wbd *)&wb_fw->data[header->wbd_address];
@@ -93,7 +93,7 @@ static int fake_wbbus_probe(struct device *dev)
 		mutex_unlock(&list_lock);
 		wbd++;
 	}
-	printk(KERN_INFO KBUILD_MODNAME ": found %d wishbone devices\n", ndev);
+	pr_info(KBUILD_MODNAME ": found %d wishbone devices\n", ndev);
 	return 0;
 
 register_fail:
@@ -133,10 +133,13 @@ static struct device fake_wbbus_device = {
 
 static int __init fake_wb_bus_init(void)
 {
-	if (device_register(&fake_wbbus_device) < 0) {
-		printk(KERN_ERR KBUILD_MODNAME "failed to register fake"
+	int ret;
+
+	ret = device_register(&fake_wbbus_device);
+	if (ret) {
+		pr_err(KBUILD_MODNAME "failed to register fake"
 					"Wishbone bus\n");
-		return -1;
+		return ret;
 	}
 	fake_wbbus_probe(&fake_wbbus_device);
 	return 0;
diff --git a/simulation/fakeadc.c b/simulation/fakeadc.c
index 7fc6ac9b858c382af3dd3609959ef89f626c083c..b39d69599ab532e5b674541ba0d5382d57a75931 100644
--- a/simulation/fakeadc.c
+++ b/simulation/fakeadc.c
@@ -8,7 +8,7 @@
  * modify it under the terms of the GNU General Public License
  * as published by the Free Software Foundation; either version 2
  * of the License, or (at your option) any later version.
- * 
+ *
  * This program is distributed in the hope that it will be useful,
  * but WITHOUT ANY WARRANTY; without even the implied warranty of
  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
@@ -22,7 +22,7 @@
 
 #include <linux/wishbone.h>
 
-#define WB_ADC_VENDOR 	0x0
+#define WB_ADC_VENDOR	0x0
 #define WB_ADC_DEVICE	0x1
 
 static struct wb_device_id fakeadc_ids[] = {
@@ -32,13 +32,13 @@ static struct wb_device_id fakeadc_ids[] = {
 
 static int fakeadc_probe(struct wb_device *dev)
 {
-	printk(KERN_INFO KBUILD_MODNAME ": %s\n", __func__);
+	pr_info(KBUILD_MODNAME ": %s\n", __func__);
 	return 0;
 }
 
 static int fakeadc_remove(struct wb_device *dev)
 {
-	printk(KERN_INFO KBUILD_MODNAME ": %s\n", __func__);
+	pr_info(KBUILD_MODNAME ": %s\n", __func__);
 	return 0;
 }
 
diff --git a/simulation/fakedac.c b/simulation/fakedac.c
index ade61ffdedcbf027f154753a56e0b1e1decd8745..4ff2b156c755c385dcbf9f182aab35e3a5d058a7 100644
--- a/simulation/fakedac.c
+++ b/simulation/fakedac.c
@@ -22,7 +22,7 @@
 
 #include <linux/wishbone.h>
 
-#define WB_DAC_VENDOR 	0x0
+#define WB_DAC_VENDOR	0x0
 #define WB_DAC_DEVICE	0x2
 
 static struct wb_device_id fakedac_ids[] = {
@@ -32,13 +32,13 @@ static struct wb_device_id fakedac_ids[] = {
 
 static int fakedac_probe(struct wb_device *dev)
 {
-	printk(KERN_INFO KBUILD_MODNAME ": %s\n", __func__);
+	pr_info(KBUILD_MODNAME ": %s\n", __func__);
 	return 0;
 }
 
 static int fakedac_remove(struct wb_device *dev)
 {
-	printk(KERN_INFO KBUILD_MODNAME ": %s\n", __func__);
+	pr_info(KBUILD_MODNAME ": %s\n", __func__);
 	return 0;
 }
 
diff --git a/simulation/fw/wb_addrgen.c b/simulation/fw/wb_addrgen.c
index 37845dc32ac65f8e99c4362ec7e9420274f29df2..2f4aea056d46c0dc72fb8992ca06e303cc4b8b98 100644
--- a/simulation/fw/wb_addrgen.c
+++ b/simulation/fw/wb_addrgen.c
@@ -8,7 +8,7 @@
  * modify it under the terms of the GNU General Public License
  * as published by the Free Software Foundation; either version 2
  * of the License, or (at your option) any later version.
- * 
+ *
  * This program is distributed in the hope that it will be useful,
  * but WITHOUT ANY WARRANTY; without even the implied warranty of
  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
@@ -24,12 +24,13 @@
 #include <string.h>
 #include <stdint.h>
 #include <stdlib.h>
+#include <errno.h>
 
 #include <linux/sdwb.h>
 
-#define PRIORITY(flag) 	((flag >> 28) & 0xf)
+#define PRIORITY(flag)		((flag >> 28) & 0xf)
 #define CLASS(flag)		((flag >> 16) & 0xfff)
-#define VERSION(flag)	(flag & 0xffff)
+#define VERSION(flag)		(flag & 0xffff)
 
 void print_wbd(uint8_t major, uint8_t minor,
 				uint64_t vendor, uint32_t device,
@@ -54,7 +55,7 @@ struct sdwb_head *sdwb_create_header(uint64_t wbid_addr, uint64_t wbd_addr)
 	head = malloc(sizeof(struct sdwb_head));
 	if (!head)
 		return NULL;
-	
+
 	head->magic = SDWB_HEAD_MAGIC;
 	head->wbid_address = wbid_addr;
 	head->wbd_address = wbd_addr;
@@ -69,18 +70,18 @@ struct sdwb_wbid *sdwb_create_id()
 	id = malloc(sizeof(struct sdwb_wbid));
 	if (!id)
 		return NULL;
-	
+
 	id->bstream_type = rand();
 
 	return id;
 }
 
 struct sdwb_wbd *sdwb_create_device(uint8_t major, uint8_t minor,
-						uint64_t vendor, uint32_t device,
-						uint64_t base, uint64_t size,
-						uint32_t flags, uint32_t class,
-						uint32_t version, uint32_t date,
-						char *vname, char *dname)
+				    uint64_t vendor, uint32_t device,
+				    uint64_t base, uint64_t size,
+				    uint32_t flags, uint32_t class,
+				    uint32_t version, uint32_t date,
+				    char *vname, char *dname)
 {
 	struct sdwb_wbd *dev;
 
@@ -112,35 +113,39 @@ int main(int argc, char *argv[])
 	char c;
 	struct sdwb_head *header;
 	struct sdwb_wbid *id;
+	FILE *fin, *fout;
+	char buf[128];
+	int size = 0;
+	int num = 0;
 
 	if (argc != 3) {
-		printf("usage: %s <device-list-file> <fw-file>\n", argv[0]);
+		fprintf(stderr, "Usage: %s <device-list-file> <fw-file>\n",
+			argv[0]);
 		return 1;
 	}
-	FILE *fin, *fout;
-	char buf[128];
 
-	/* Header placed at address 0 and ID immediately after it. followed by devices */
-	header = sdwb_create_header(sizeof(struct sdwb_head), sizeof(struct sdwb_head) + sizeof(struct sdwb_wbid));
+	/* Header at address 0 and ID immediately after it. Then, devices */
+	header = sdwb_create_header(sizeof(struct sdwb_head),
+				    sizeof(struct sdwb_head)
+				    + sizeof(struct sdwb_wbid));
 	id = sdwb_create_id();
 
 	fin = fopen(argv[1], "r");
 	if (!fin) {
-		printf("Unable to open wishbone device specification file: %s\n", argv[1]);
+		fprintf(stderr, "%s: %s: %s\n", argv[0], argv[1],
+			strerror(errno));
 		return 1;
 	}
 	fout = fopen(argv[2], "w");
 	if (!fout) {
-		printf("Unable to open output firmware file for writing: %s\b", argv[2]);
-		fclose(fin);
+		fprintf(stderr, "%s: %s: %s\n", argv[0], argv[2],
+			strerror(errno));
 		return 1;
 	}
-	int size = 0;
 	fwrite(header, sizeof(struct sdwb_head), 1, fout);
 	size += sizeof(struct sdwb_head);
 	fwrite(id, sizeof(struct sdwb_wbid), 1, fout);
 	size += sizeof(struct sdwb_wbid);
-	int num = 0;
 	while (fgets(buf, 128, fin) != NULL) {
 		if (strlen(buf) == 0)
 			continue;
@@ -149,16 +154,20 @@ int main(int argc, char *argv[])
 		uint32_t major, minor, vendor, base, sz;
 		uint32_t device, flags, class, version, date;
 		char vname[16], dname[16];
-		sscanf(buf, "%d %d %x %d %x %x %x %x %d %x\n", &major, &minor, &vendor, &device,
-						&base, &sz, &flags, &class, &version, &date);
+		sscanf(buf, "%d %d %x %d %x %x %x %x %d %x\n",
+		       &major, &minor, &vendor, &device,
+		       &base, &sz, &flags, &class, &version, &date);
 		fgets(buf, 128, fin);
 		sscanf(buf, "%s\n", vname);
 		fgets(buf, 128, fin);
 		sscanf(buf, "%s\n", dname);
 
-		print_wbd(major, minor, vendor, device, base, sz, flags, class, version, date, vname, dname);
+		print_wbd(major, minor, vendor, device, base, sz,
+			  flags, class, version, date, vname, dname);
 		struct sdwb_wbd *dev;
-		dev = sdwb_create_device(major, minor, vendor, device, base, sz, flags, class, version, date, vname, dname);
+		dev = sdwb_create_device(major, minor, vendor, device,
+					 base, sz, flags, class, version,
+					 date, vname, dname);
 		fwrite(dev, sizeof(struct sdwb_wbd), 1, fout);
 		size += sizeof(struct sdwb_wbd);
 		num++;
diff --git a/simulation/include/linux/sdwb.h b/simulation/include/linux/sdwb.h
index c0476be0e28ae23f165e39f7c2f603d76b56cd92..413e9ad03523c22dff6307724365b3c08e3d93ba 100644
--- a/simulation/include/linux/sdwb.h
+++ b/simulation/include/linux/sdwb.h
@@ -8,7 +8,7 @@
  * modify it under the terms of the GNU General Public License
  * as published by the Free Software Foundation; either version 2
  * of the License, or (at your option) any later version.
- * 
+ *
  * This program is distributed in the hope that it will be useful,
  * but WITHOUT ANY WARRANTY; without even the implied warranty of
  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
diff --git a/simulation/include/linux/wishbone.h b/simulation/include/linux/wishbone.h
index 2f26c944f6065f5ced4e279f3b147dc399feb516..66ff020e7e79a9d34142ae369ebbaf9284cb5aa8 100644
--- a/simulation/include/linux/wishbone.h
+++ b/simulation/include/linux/wishbone.h
@@ -8,7 +8,7 @@
  * modify it under the terms of the GNU General Public License
  * as published by the Free Software Foundation; either version 2
  * of the License, or (at your option) any later version.
- * 
+ *
  * This program is distributed in the hope that it will be useful,
  * but WITHOUT ANY WARRANTY; without even the implied warranty of
  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
diff --git a/simulation/wishbone.c b/simulation/wishbone.c
index 1e8046901315bc564ed78da9f439d55bb6ede2f9..45f43b9d5ddff76890b6520f25824524d2a3f151 100644
--- a/simulation/wishbone.c
+++ b/simulation/wishbone.c
@@ -8,7 +8,7 @@
  * modify it under the terms of the GNU General Public License
  * as published by the Free Software Foundation; either version 2
  * of the License, or (at your option) any later version.
- * 
+ *
  * This program is distributed in the hope that it will be useful,
  * but WITHOUT ANY WARRANTY; without even the implied warranty of
  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
@@ -25,11 +25,12 @@
 #include <linux/init.h>
 #include <linux/device.h>
 #include <linux/list.h>
-#include <linux/atomic.h>
 #include <linux/slab.h>
 
 #include <linux/wishbone.h>
 
+#include <asm/atomic.h>		/* before 2.6.37 no <linux/atomic.h> */
+
 static struct device wb_dev;
 static struct bus_type wb_bus_type;
 
@@ -103,7 +104,7 @@ int memcpy_from_wb(struct wb_bus *bus, uint64_t addr, size_t len,
 	}
 	return -EIO;
 }
-	
+
 int memcpy_to_wb(struct wb_bus *bus, uint64_t addr, size_t len,
 	const uint8_t *buf)
 {
@@ -125,7 +126,7 @@ static void wb_dev_release(struct device *dev)
 
 	wb_dev = to_wb_device(dev);
 
-	printk(KERN_DEBUG KBUILD_MODNAME ": release %016llx:%08lx\n",
+	pr_info(KBUILD_MODNAME ": release %016llx:%08lx\n",
 	       wb_dev->wbd.vendor, (unsigned long)wb_dev->wbd.device);
 }
 
@@ -138,7 +139,7 @@ int wb_register_device(struct wb_device *wbdev)
 	int devno;
 
 	if (!wbdev || !wbdev->bus) {
-		printk(KERN_ERR KBUILD_MODNAME ": bus not set\n");
+		pr_err(KBUILD_MODNAME ": bus not set\n");
 		return -EFAULT;
 	}
 
@@ -206,7 +207,7 @@ int wb_register_bus(struct wb_bus *bus)
 		return -ENODEV;
 
 	if (!bus->ops) {
-		printk(KERN_ERR KBUILD_MODNAME ": no wb_ops specified\n");
+		pr_err(KBUILD_MODNAME ": no wb_ops specified\n");
 		return -EFAULT;
 	}
 
@@ -214,7 +215,7 @@ int wb_register_bus(struct wb_bus *bus)
 		!bus->ops->read64 || !bus->ops->write8 || !bus->ops->write16 ||
 		!bus->ops->write32 || !bus->ops->write64 ||
 		!bus->ops->memcpy_from_wb || !bus->ops->memcpy_to_wb) {
-		printk(KERN_ERR KBUILD_MODNAME ": all ops are required\n");
+		pr_err(KBUILD_MODNAME ": all ops are required\n");
 		return -EFAULT;
 	}
 
@@ -228,13 +229,13 @@ int wb_register_bus(struct wb_bus *bus)
 	ret = memcpy_from_wb(bus, bus->sdwb_header_base,
 		sizeof(struct sdwb_head), (uint8_t *)&head);
 	if (ret < 0) {
-		printk(KERN_ERR KBUILD_MODNAME ": SDWB header read failed\n");
+		pr_err(KBUILD_MODNAME ": SDWB header read failed\n");
 		return ret;
 	}
 
 	/* verify our header using the magic field */
 	if (head.magic != SDWB_HEAD_MAGIC) {
-		printk(KERN_ERR KBUILD_MODNAME ": invalid sdwb header at %llx "
+		pr_err(KBUILD_MODNAME ": invalid sdwb header at %llx "
 			"(magic %llx)\n", bus->sdwb_header_base, head.magic);
 		return -EFAULT;
 	}
@@ -242,22 +243,22 @@ int wb_register_bus(struct wb_bus *bus)
 	ret = memcpy_from_wb(bus, head.wbid_address, sizeof(struct sdwb_wbid),
 		(uint8_t *)&wbid);
 	if (ret < 0) {
-		printk(KERN_ERR KBUILD_MODNAME ": SDWB ID read failed\n");
+		pr_err(KBUILD_MODNAME ": SDWB ID read failed\n");
 		return ret;
 	}
 
-	printk(KERN_INFO KBUILD_MODNAME ": found sdwb bistream: 0x%llx\n",
+	pr_info(KBUILD_MODNAME ": found sdwb bistream: 0x%llx\n",
 		wbid.bstream_type);
-	
+
 	ret = memcpy_from_wb(bus, head.wbd_address, sizeof(struct sdwb_wbd),
 		(uint8_t *)&wbd);
 	if (ret < 0) {
-		printk(KERN_ERR KBUILD_MODNAME ": SDWB dev read failed\n");
+		pr_err(KBUILD_MODNAME ": SDWB dev read failed\n");
 		return ret;
 	}
 
 	while (wbd.wbd_magic == SDWB_WBD_MAGIC) {
-		wbdev = (struct wb_device *)kzalloc(sizeof(struct wb_device),
+		wbdev = kzalloc(sizeof(struct wb_device),
 			GFP_KERNEL);
 		if (!wbdev) {
 			ret = -ENOMEM;
@@ -281,7 +282,7 @@ int wb_register_bus(struct wb_bus *bus)
 			goto err_wbdev_read;
 	}
 
-	printk(KERN_INFO KBUILD_MODNAME
+	pr_info(KBUILD_MODNAME
 		": found %d wishbone devices on wishbone bus %s\n",
 		bus->ndev, bus->name);