[PATCH 1/1] umem driver: allow multiple magic numbers per model
From: Dr. Net! - Eugen Rieck
Date: Mon Feb 01 2016 - 10:39:17 EST
From: Eugen Rieck <eugen@xxxxxxxx>
Allow for multiple magic numbers per model and include the magic number
for the PCIe-based 5453CN, that shares the device id of the older
PCI-X-based 5425CN.
Signed-off-by: Eugen Rieck <eugen@xxxxxxxx>
---
The umem driver for Micro Memory (now Curtiss-Wright) NVRAM cards relied
on a unique magic number for each PCI device id. Newer cards violate this
and were thus rejected by the driver.
Developed for 3.13.0 (Ubuntu 14.04, ubuntu 3.13.0-76-generic), but merges
cleanly into current (4.5-rc2) as the driver is old and largely unchanged.
umem.c | 29 +++++++++++++++++++++++------
umem.h | 2 ++
2 files changed, 25 insertions(+), 6 deletions(-)
--- drivers/block/umem.c.orig 2016-02-01 14:51:07.463944676 +0100
+++ drivers/block/umem.c 2016-02-01 15:03:52.815934423 +0100
@@ -32,6 +32,8 @@
* 17May2002:NeilBrown - remove init_mem initialisation. Instead detect
* - a sequence of writes that cover the card, and
* - set initialised bit then.
+ * 01Feb2016:Eugen Rieck - allow multiple magic numbers per pci id to
+ * acommodate newer models
*/
#undef DEBUG /* #define DEBUG if you want debugging info (pr_debug) */
@@ -799,6 +801,9 @@
unsigned long csr_base;
unsigned long csr_len;
int magic_number;
+ int magic_numbers[MAGIC_NUMBERS_PER_DEV];
+ int magic_number_ok = 0;
+ int i;
static int printed_version;
if (!printed_version++)
@@ -850,27 +855,39 @@
switch (card->dev->device) {
case 0x5415:
card->flags |= UM_FLAG_NO_BYTE_STATUS | UM_FLAG_NO_BATTREG;
- magic_number = 0x59;
+ magic_numbers[0] = 0x59;
+ magic_numbers[1] = 0x100;
break;
case 0x5425:
card->flags |= UM_FLAG_NO_BYTE_STATUS;
- magic_number = 0x5C;
+ magic_numbers[0] = 0x5C;
+ magic_numbers[1] = 0x5E;
+ magic_numbers[2] = 0x100;
break;
case 0x6155:
card->flags |= UM_FLAG_NO_BYTE_STATUS |
UM_FLAG_NO_BATTREG | UM_FLAG_NO_BATT;
- magic_number = 0x99;
+ magic_numbers[0] = 0x99;
+ magic_numbers[1] = 0x100;
break;
default:
- magic_number = 0x100;
+ magic_numbers[0] = 0x100;
break;
}
- if (readb(card->csr_remap + MEMCTRLSTATUS_MAGIC) != magic_number) {
- dev_printk(KERN_ERR, &card->dev->dev, "Magic number invalid\n");
+ magic_number = readb(card->csr_remap + MEMCTRLSTATUS_MAGIC);
+ for (i = 0; i < MAGIC_NUMBERS_PER_DEV; i++) {
+ if (magic_numbers[i] == magic_number) {
+ magic_number_ok = 1;
+ break;
+ }
+ if (magic_numbers[i] >= 0x100) break;
+ }
+ if (!magic_number_ok) {
+ dev_printk(KERN_ERR, &card->dev->dev, "Magic number 0x%02x invalid for device 0x%04x\n", magic_number, card->dev->device);
ret = -ENOMEM;
goto failed_magic;
}
--- drivers/block/umem.h.orig 2016-02-01 14:51:16.055944561 +0100
+++ drivers/block/umem.h 2016-02-01 14:47:38.463947477 +0100
@@ -15,6 +15,8 @@
#define IRQ_TIMEOUT (1 * HZ)
+#define MAGIC_NUMBERS_PER_DEV 2
+
/* CSR register definition */
#define MEMCTRLSTATUS_MAGIC 0x00
#define MM_MAGIC_VALUE (unsigned char)0x59