Skip to contentSkip to conversation

Driver for Ricoh cardreader + few fixes

PATCH RESEND Superseded Maxim Levitsky 2 participants 6 messages Aug 5, 2010 – Aug 6, 2010

Subsystems (4)

v2 of 3 Superseded Latest is v3 →

lore
Share & tools
lore

Maxim Levitsky

author maintainer
#0 lore raw

v2 cover Driver for Ricoh cardreader + few fixes

(resending because I forgot to CC LKML)

Hi,

This is second revision of my patches that conatains one more fix, and few fixes for the driver.

Patches 1-2 have no reason to be held back from beeing merged in 2.6.35 In fact patch #2 should be added to -stable as well.

The actual driver (patch #3) is new driver, so it can't introduce regressions, thus I think it can go to 2.6.36 as well.

I already have report form one user that driver works.

Best regards,
Maxim Levitsky

author maintainer
#1 lore raw

PATCH 1/3 memstick: init sysfs attributes

Otherwise locdep complains.

---
 drivers/memstick/core/mspro_block.c |    1 +
 1 files changed, 1 insertions(+), 0 deletions(-)
drivers/memstick/core/mspro_block.c +1 -0
index 8327e24..369313f 100644
@@ -1040,6 +1040,7 @@ static int mspro_block_read_attributes(struct memstick_dev *card)
 			snprintf(s_attr->name, sizeof(s_attr->name),
 				 "attr_x%02x", attr->entries[cnt].id);
 
+		sysfs_attr_init(&s_attr->dev_attr.attr);
 		s_attr->dev_attr.attr.name = s_attr->name;
 		s_attr->dev_attr.attr.mode = S_IRUGO;
 		s_attr->dev_attr.show = mspro_block_attr_show(s_attr->id);
Signature · 1 line
1.7.0.4
author maintainer
#2 lore raw

PATCH 2/3 MEMSTICK: fix hangs on unexpected device removal in mspro_blk

In reply to Maxim Levitsky

mspro_block_remove is called from detect thread that first calls the mspro_block_stop, which stops the request queue. If we call del_gendisk with queue stopped we get a deadlock.

---
 drivers/memstick/core/mspro_block.c |    5 +++--
 1 files changed, 3 insertions(+), 2 deletions(-)
drivers/memstick/core/mspro_block.c +3 -2
index 369313f..300ec15 100644
@@ -1331,13 +1331,14 @@ static void mspro_block_remove(struct memstick_dev *card)
 	struct mspro_block_data *msb = memstick_get_drvdata(card);
 	unsigned long flags;
 
-	del_gendisk(msb->disk);
-	dev_dbg(&card->dev, "mspro block remove\n");
 	spin_lock_irqsave(&msb->q_lock, flags);
 	msb->eject = 1;
 	blk_start_queue(msb->queue);
 	spin_unlock_irqrestore(&msb->q_lock, flags);
 
+	del_gendisk(msb->disk);
+	dev_dbg(&card->dev, "mspro block remove\n");
+
 	blk_cleanup_queue(msb->queue);
 	msb->queue = NULL;
 
Signature · 1 line
1.7.0.4
author maintainer
#3 lore raw

PATCH 3/3 MEMSTICK: Add driver for Ricoh R5C592 Card reader.

In reply to Maxim Levitsky
---
 MAINTAINERS                    |    6 +
 drivers/memstick/host/Kconfig  |   13 +
 drivers/memstick/host/Makefile |    1 +
 drivers/memstick/host/r592.c   |  889 ++++++++++++++++++++++++++++++++++++++++
 drivers/memstick/host/r592.h   |  177 ++++++++
 drivers/mtd/nand/r852.c        |    2 -
 6 files changed, 1086 insertions(+), 2 deletions(-)
 create mode 100644 drivers/memstick/host/r592.c
 create mode 100644 drivers/memstick/host/r592.h
MAINTAINERS +6 -0
index 88fcb7c..7ebdd32 100644
@@ -4822,6 +4822,12 @@ S:	Maintained
 F:	drivers/mtd/nand/r822.c
 F:	drivers/mtd/nand/r822.h
 
+RICOH R5C592 MEMORYSTICK DRIVER
+M:	Maxim Levitsky <[email protected]>
+S:	Maintained
+F:	drivers/memstick/host/r592.c
+F:	drivers/memstick/host/r592.h
+
 RISCOM8 DRIVER
 S:	Orphan
 F:	Documentation/serial/riscom8.txt
drivers/memstick/host/Kconfig +13 -0
index 4ce5c8d..7022a2a 100644
@@ -30,3 +30,16 @@ config MEMSTICK_JMICRON_38X
 
           To compile this driver as a module, choose M here: the
 	  module will be called jmb38x_ms.
+
+config MEMSTICK_R592
+	tristate "Ricoh R5C592 MemoryStick interface support (EXPERIMENTAL)"
+	depends on EXPERIMENTAL && PCI
+
+	help
+	  Say Y here if you want to be able to access MemoryStick cards with
+	  the Ricoh R5C592 MemoryStick card reader (which is part of 5 in one
+		multifunction reader)
+
+	  To compile this driver as a module, choose M here: the module will
+	  be called r592.
+
drivers/memstick/host/Makefile +1 -0
index 12530e4..ad63c16 100644
@@ -8,3 +8,4 @@ endif
 
 obj-$(CONFIG_MEMSTICK_TIFM_MS)		+= tifm_ms.o
 obj-$(CONFIG_MEMSTICK_JMICRON_38X)	+= jmb38x_ms.o
+obj-$(CONFIG_MEMSTICK_R592)		+= r592.o
drivers/memstick/host/r592.c new file +889 -0

889 lines not on this page · raw message

drivers/memstick/host/r592.h new file +177 -0

177 lines not on this page · raw message

drivers/mtd/nand/r852.c +0 -2
index 026d1a7..288715d 100644
@@ -1030,7 +1030,6 @@ void r852_shutdown(struct pci_dev *pci_dev)
 int r852_suspend(struct device *device)
 {
 	struct r852_device *dev = pci_get_drvdata(to_pci_dev(device));
-	unsigned long flags;
 
 	if (dev->ctlreg & R852_CTL_CARDENABLE)
 		return -EBUSY;
@@ -1052,7 +1051,6 @@ int r852_suspend(struct device *device)
 int r852_resume(struct device *device)
 {
 	struct r852_device *dev = pci_get_drvdata(to_pci_dev(device));
-	unsigned long flags;
 
 	r852_disable_irqs(dev);
 	r852_card_update_present(dev);
Signature · 1 line
1.7.0.4
#4 lore raw

Re: [PATCH 3/3] MEMSTICK: Add driver for Ricoh R5C592 Card reader.

Quoted 1 line · Maxim Levitsky

Trivial comments:

MAINTAINERS S: Maintained · line 4829

Quoted 7 lines
---
 MAINTAINERS                    |    6 +
MAINTAINERS +5 -0
+RICOH R5C592 MEMORYSTICK DRIVER
+M:	Maxim Levitsky <[email protected]>
+S:	Maintained
+F:	drivers/memstick/host/r592.c
+F:	drivers/memstick/host/r592.h

Patterns in maintainers can use wildcards

F: drivers/memstick/host/r592*

drivers/memstick/host/r592.c

Quoted 3 lines
drivers/memstick/host/r592.c new file +0 -0
@@ -0,0 +1,889 @@

[]

drivers/memstick/host/r592.c line 28

Quoted 1 line
drivers/memstick/host/r592.c new file +1 -0
+static char *tpc_names[] = {

const ?

drivers/memstick/host/r592.c line 30

Quoted 2 lines
drivers/memstick/host/r592.c new file +2 -0
+	"MS_TPC_READ_MG_STATUS",
+	"MS_TPC_READ_LONG_DATA",

[]

drivers/memstick/host/r592.c line 15

Quoted 12 lines
drivers/memstick/host/r592.c new file +12 -0
+#define dbg(format, ...) \
+	if (debug) \
+		printk(KERN_DEBUG DRV_NAME ": " format "\n", ## __VA_ARGS__)
+
+#define dbg_verbose(format, ...) \
+	if (debug > 1) \
+		printk(KERN_DEBUG DRV_NAME ": " format "\n", ## __VA_ARGS__)
+
+#define dbg_reg(format, ...) \
+	if (debug > 2) \
+		printk(KERN_DEBUG DRV_NAME ": " format "\n", ## __VA_ARGS__)
+

These style macros should use do { if (test) print(); } while (9) so they could be used without problems in if/else blocks.

Maybe it'd be better to have and use 1 macro with a level passed:

#define dbg(level, format, ...) \

do {									\
	if (debug > level)						\
		printk(KERN_DEBUG pr_fmt(format), ##__VA_ARGS__);	\
} while (0)

drivers/memstick/host/r592.c line 17

Quoted 2 lines
drivers/memstick/host/r592.c new file +2 -0
+#define message(format, ...) \
+	printk(KERN_INFO DRV_NAME ": " format "\n", ## __VA_ARGS__)

Why not just use pr_info?

author maintainer
#5 lore raw

Re: [PATCH 3/3] MEMSTICK: Add driver for Ricoh R5C592 Card reader.

Quoted 5 lines · Joe Perches
Quoted 1 line · Maxim Levitsky

Trivial comments:

Quoted 9 lines

MAINTAINERS S: Maintained · line 4829

Quoted 7 lines
---
 MAINTAINERS                    |    6 +
MAINTAINERS +5 -0
+RICOH R5C592 MEMORYSTICK DRIVER
+M:	Maxim Levitsky <[email protected]>
+S:	Maintained
+F:	drivers/memstick/host/r592.c
+F:	drivers/memstick/host/r592.h

Patterns in maintainers can use wildcards

Didn't know about that, thanks!

Quoted 10 lines

F: drivers/memstick/host/r592*

drivers/memstick/host/r592.c

Quoted 3 lines
drivers/memstick/host/r592.c new file +0 -0
@@ -0,0 +1,889 @@

[]

drivers/memstick/host/r592.c line 28

Quoted 1 line
drivers/memstick/host/r592.c new file +1 -0
+static char *tpc_names[] = {

const ?

Sure

Quoted 22 lines

drivers/memstick/host/r592.c line 30

Quoted 3 lines
drivers/memstick/host/r592.c new file +2 -0
+	"MS_TPC_READ_MG_STATUS",
+	"MS_TPC_READ_LONG_DATA",

[]

drivers/memstick/host/r592.c line 15

Quoted 12 lines
drivers/memstick/host/r592.c new file +12 -0
+#define dbg(format, ...) \
+	if (debug) \
+		printk(KERN_DEBUG DRV_NAME ": " format "\n", ## __VA_ARGS__)
+
+#define dbg_verbose(format, ...) \
+	if (debug > 1) \
+		printk(KERN_DEBUG DRV_NAME ": " format "\n", ## __VA_ARGS__)
+
+#define dbg_reg(format, ...) \
+	if (debug > 2) \
+		printk(KERN_DEBUG DRV_NAME ": " format "\n", ## __VA_ARGS__)
+

These style macros should use do { if (test) print(); } while (9) so they could be used without problems in if/else blocks.

Quoted 7 lines

Maybe it'd be better to have and use 1 macro with a level passed:

#define dbg(level, format, ...) \

do {									\
	if (debug > level)						\
		printk(KERN_DEBUG pr_fmt(format), ##__VA_ARGS__);	\
} while (0)

Thinking again about that, why not...

Quoted 5 lines

drivers/memstick/host/r592.c line 17

Quoted 3 lines
drivers/memstick/host/r592.c new file +2 -0
+#define message(format, ...) \
+	printk(KERN_INFO DRV_NAME ": " format "\n", ## __VA_ARGS__)

Why not just use pr_info?

Will look at that.

Best regards,
Maxim Levitsky