Skip to contentSkip to conversation

MEMSTICK: My 2 drivers for 2.6.38 inclusion

PATCH Superseded Maxim Levitsky 2 participants 7 messages Jan 11, 2011

Subsystems (3)

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore

Maxim Levitsky

author maintainer
#0 lore raw

Hi,

The following patches hopefully address all comments on my code.

I would really be glad to see them in 2.6.38, as many users request me of doing so.

Best regards,
Maxim Levitsky

author maintainer
#1 lore raw

PATCH 1/4 scatterlist: new helper functions

While developing memstick driver for legacy memsticks I found the need in few helpers that I think are ok to have in common sg library

The functions that were added:

* sg_nents/sg_total_len - interate over sg list to figure out its total len, number of entries.
Useful for not keeping that information in side channels.

* sg_copy/sg_advance - Alow to break sg lists apart into smaller chunks. sg_copy creates smaller sg list spanning first 'len' bytes, while sg_advance edits the sg list in such way that it skips over 'len' bytes.

* sg_compare_to_buffer - another function to hide gory details of access to sg list by CPU.
Allows to transparetly compare contents of the sg list to given linear buffer.
If needed later, a function that compares two sgs can be added.

All of this code is used by my ms_block.c driver.

---
 include/linux/scatterlist.h |    6 ++
 lib/scatterlist.c           |  137 +++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 143 insertions(+), 0 deletions(-)
include/linux/scatterlist.h +6 -0
index 9aaf5bf..6305589 100644
@@ -199,6 +199,11 @@ static inline void *sg_virt(struct scatterlist *sg)
 	return page_address(sg_page(sg)) + sg->offset;
 }
 
+struct scatterlist *sg_advance(struct scatterlist *sg, int consumed);
+int sg_nents(struct scatterlist *sg);
+int sg_total_len(struct scatterlist *sg);
+int sg_copy(struct scatterlist *sg_from, struct scatterlist *sg_to, int len);
+
 struct scatterlist *sg_next(struct scatterlist *);
 struct scatterlist *sg_last(struct scatterlist *s, unsigned int);
 void sg_init_table(struct scatterlist *, unsigned int);
@@ -217,6 +222,7 @@ size_t sg_copy_from_buffer(struct scatterlist *sgl, unsigned int nents,
 			   void *buf, size_t buflen);
 size_t sg_copy_to_buffer(struct scatterlist *sgl, unsigned int nents,
 			 void *buf, size_t buflen);
+bool sg_compare_to_buffer(struct scatterlist *sg, u8 *buffer, size_t len);
 
 /*
  * Maximum number of entries that will be allocated in one piece, if
lib/scatterlist.c +137 -0

152 lines not on this page · raw message

Signature · 1 line
1.7.1
author maintainer
#2 lore raw

PATCH 2/4 memstick: Add driver for Ricoh R5C592 card reader.

In reply to Maxim Levitsky
---
 MAINTAINERS                    |    5 +
 drivers/memstick/host/Kconfig  |   12 +
 drivers/memstick/host/Makefile |    1 +
 drivers/memstick/host/r592.c   |  908 ++++++++++++++++++++++++++++++++++++++++
 drivers/memstick/host/r592.h   |  175 ++++++++
 5 files changed, 1101 insertions(+), 0 deletions(-)
 create mode 100644 drivers/memstick/host/r592.c
 create mode 100644 drivers/memstick/host/r592.h
MAINTAINERS +5 -0
index bcb7830..d3aec27 100644
@@ -5059,6 +5059,11 @@ S:	Maintained
 F:	drivers/mtd/nand/r852.c
 F:	drivers/mtd/nand/r852.h
 
+RICOH R5C592 MEMORYSTICK DRIVER
+M:	Maxim Levitsky <[email protected]>
+S:	Maintained
+F:	drivers/memstick/host/r592.*
+
 RISCOM8 DRIVER
 S:	Orphan
 F:	Documentation/serial/riscom8.txt
drivers/memstick/host/Kconfig +12 -0
index 4ce5c8d..cc0997a 100644
@@ -30,3 +30,15 @@ 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 +908 -0

908 lines not on this page · raw message

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

175 lines not on this page · raw message

Signature · 1 line
1.7.1
author maintainer
#4 lore raw

PATCH 3/4 memstick: add support for legacy memorysticks

In reply to Maxim Levitsky

Based partialy on MS standard spec quotes from Alex Dubov.

As any code that works with user data this driver isn't recommened to use with valuable data.

It tries its best though to avoid data corruption and possible damage to the card.

Tested on MS DUO 64 MB card on Ricoh R592 card reader.

---
 MAINTAINERS                      |    5 +
 drivers/memstick/core/Kconfig    |   12 +
 drivers/memstick/core/Makefile   |    2 +-
 drivers/memstick/core/ms_block.c | 2285 ++++++++++++++++++++++++++++++++++++++
 drivers/memstick/core/ms_block.h |  245 ++++
 5 files changed, 2548 insertions(+), 1 deletions(-)
 create mode 100644 drivers/memstick/core/ms_block.c
 create mode 100644 drivers/memstick/core/ms_block.h
MAINTAINERS +5 -0
index d3aec27..c9293f7 100644
@@ -5620,6 +5620,11 @@ W:	http://tifmxx.berlios.de/
 S:	Maintained
 F:	drivers/memstick/host/tifm_ms.c
 
+SONY MEMORYSTICK STANDARD SUPPORT
+M:	Maxim Levitsky <[email protected]>
+S:	Maintained
+F:	drivers/memstick/core/ms_block.*
+
 SOUND
 M:	Jaroslav Kysela <[email protected]>
 M:	Takashi Iwai <[email protected]>
drivers/memstick/core/Kconfig +12 -0
index 95f1814..f79f2a8 100644
@@ -24,3 +24,15 @@ config MSPRO_BLOCK
 	  support. This provides a block device driver, which you can use
 	  to mount the filesystem. Almost everyone wishing MemoryStick
 	  support should say Y or M here.
+
+config MS_BLOCK
+	tristate "MemoryStick Standard device driver"
+	depends on BLOCK && EXPERIMENTAL
+	help
+	  Say Y here to enable the MemoryStick Standard device driver
+	  support. This provides a block device driver, which you can use
+	  to mount the filesystem.
+	  This driver works with old (bulky) MemoryStick and MemoryStick Duo
+	  but not PRO. Say Y if you have such card.
+	  Driver is new and not yet well tested, thus it can damage your card
+	  (even permanently)
drivers/memstick/core/Makefile +1 -1
index 8b2b529..19d960b 100644
@@ -7,5 +7,5 @@ ifeq ($(CONFIG_MEMSTICK_DEBUG),y)
 endif
 
 obj-$(CONFIG_MEMSTICK)		+= memstick.o
-
+obj-$(CONFIG_MS_BLOCK)		+= ms_block.o
 obj-$(CONFIG_MSPRO_BLOCK)	+= mspro_block.o
drivers/memstick/core/ms_block.c new file +2285 -0

2,285 lines not on this page · raw message

drivers/memstick/core/ms_block.h new file +245 -0

245 lines not on this page · raw message

Signature · 1 line
1.7.1
author maintainer
#6 lore raw

PATCH 4/4 memstick: add Alex Dubov to MAINTAINERS of the memstick core

In reply to Maxim Levitsky

This code is supposed to be maintained by him and unless he doesn't want to do so, MAINTAINERS should reflect the state of things, and bugreporters should know whom to blame for bugs.

---
 MAINTAINERS |   13 ++++++++++++-
 1 files changed, 12 insertions(+), 1 deletions(-)
MAINTAINERS +12 -1
index c9293f7..c0dbb69 100644
@@ -5614,7 +5614,18 @@ F:	drivers/char/sonypi.c
 F:	drivers/platform/x86/sony-laptop.c
 F:	include/linux/sony-laptop.h
 
-SONY MEMORYSTICK CARD SUPPORT
+SONY MEMORYSTICK SUBSYSTEM
+M:	Alex Dubov <[email protected]>
+S:	Maintained
+F:	drivers/memstick/memstick.c
+F:	drivers/memstick/mspro_block.c
+
+SONY MEMORYSTICK DRIVER FOR JMICRON CONTRLLERS
+M:	Alex Dubov <[email protected]>
+S:	Maintained
+F:	drivers/memstick/host/jmb38x_ms.c
+
+SONY MEMORYSTICK DRIVER FOR TI CONTROLLERS
 M:	Alex Dubov <[email protected]>
 W:	http://tifmxx.berlios.de/
 S:	Maintained
Signature · 1 line
1.7.1
maintainer
#5 lore raw

Re: [PATCH 3/4] memstick: add support for legacy memorysticks

In reply to Maxim Levitsky
Quoted 9 lines

+
+    case 2: /* send INT request */
+        if
(msb_read_int_reg(msb, -1))
+
break;
+        msb->state++;
+
+    case 3: /* get result of the INT

I still think it would look nicer if you could name your state with explicit names and use "next_state()" or something to move on, instead of just incrementing it.
Otherwise, I have no principal objections.

maintainer
#3 lore raw

Re: [PATCH 2/4] memstick: Add driver for Ricoh R5C592 card reader.

In reply to Maxim Levitsky
Quoted 1 line

Subject: [PATCH 2/4] memstick: Add driver for Ricoh R5C592 card reader

Ok with me.