Patchwork Let the programmer driver decide how to do AAI transfers

login
register
about
Submitter Nico Huber
Date 2012-06-15 08:52:41
Message ID <4FDAF7D9.4070608@secunet.com>
Download mbox | patch
Permalink /patch/3661/
State Accepted
Commit r1543
Headers show

Comments

Nico Huber - 2012-06-15 08:52:41
Hello Carl-Daniel,

thank you for your comments. I revised the patch accordingly.

>> -int spi_aai_write(struct flashctx *flash, uint8_t *buf, unsigned int start,
>> -		  unsigned int len)
>> +int default_spi_write_aai(struct flashctx *flash, uint8_t *buf,
>> +			  unsigned int start, unsigned int len)
> 
> Minor formatting nitpick:
> The newly introduced 112 column limit makes it possible to keep this on
> one line.
Corrected.

> 
> register_spi_programmer() needs an additional check for non-null
> .write_aai member.
I thought I had that check. Must have got lost. Added it again, thanks.

> Admittedly we should write down our coding style requirements somewhere.
> Header files are an exception to the 112 column rule. To keep complete
> function signatures grepable (as single lines), header files have no
> column limit.
Fixed that, too.

New patch with original message below.


Currently spi_aai_write() is implemented without an abstraction mechanism
for the programmer driver. This adds another function pointer 'write_aai'
to struct spi_programmer, which is set to default_spi_write_aai (renamed
spi_aai_write) for all programmers for now.

A patch which utilises this abstraction in the dediprog driver will
follow.

Signed-off-by: Nico Huber <nico.huber@secunet.com>
Carl-Daniel Hailfinger - 2012-06-15 22:29:56
Am 15.06.2012 10:52 schrieb Nico Huber:
> Currently spi_aai_write() is implemented without an abstraction mechanism
> for the programmer driver. This adds another function pointer 'write_aai'
> to struct spi_programmer, which is set to default_spi_write_aai (renamed
> spi_aai_write) for all programmers for now.
>
> A patch which utilises this abstraction in the dediprog driver will
> follow.
>
> Signed-off-by: Nico Huber <nico.huber@secunet.com>

Thanks for reworking the patch!
Acked-by: Carl-Daniel Hailfinger <c-d.hailfinger.devel.2006@gmx.net>
and committed in r1543.

Regards,
Carl-Daniel

Patch

Index: dediprog.c
===================================================================
--- dediprog.c	(Revision 1541)
+++ dediprog.c	(Arbeitskopie)
@@ -709,6 +709,7 @@ 
 	.multicommand	= default_spi_send_multicommand,
 	.read		= dediprog_spi_read,
 	.write_256	= dediprog_spi_write_256,
+	.write_aai	= default_spi_write_aai,
 };
 
 static int dediprog_shutdown(void *data)
Index: wbsio_spi.c
===================================================================
--- wbsio_spi.c	(Revision 1541)
+++ wbsio_spi.c	(Arbeitskopie)
@@ -75,6 +75,7 @@ 
 	.multicommand = default_spi_send_multicommand,
 	.read = wbsio_spi_read,
 	.write_256 = spi_chip_write_1,
+	.write_aai = default_spi_write_aai,
 };
 
 int wbsio_check_for_spi(void)
Index: it85spi.c
===================================================================
--- it85spi.c	(Revision 1541)
+++ it85spi.c	(Arbeitskopie)
@@ -283,6 +283,7 @@ 
 	.multicommand	= default_spi_send_multicommand,
 	.read		= default_spi_read,
 	.write_256	= default_spi_write_256,
+	.write_aai	= default_spi_write_aai,
 };
 
 int it85xx_spi_init(struct superio s)
Index: sb600spi.c
===================================================================
--- sb600spi.c	(Revision 1541)
+++ sb600spi.c	(Arbeitskopie)
@@ -201,6 +201,7 @@ 
 	.multicommand = default_spi_send_multicommand,
 	.read = default_spi_read,
 	.write_256 = default_spi_write_256,
+	.write_aai = default_spi_write_aai,
 };
 
 int sb600_probe_spi(struct pci_dev *dev)
Index: ichspi.c
===================================================================
--- ichspi.c	(Revision 1541)
+++ ichspi.c	(Arbeitskopie)
@@ -1521,6 +1521,7 @@ 
 	.multicommand = ich_spi_send_multicommand,
 	.read = default_spi_read,
 	.write_256 = default_spi_write_256,
+	.write_aai = default_spi_write_aai,
 };
 
 static const struct spi_programmer spi_programmer_ich9 = {
@@ -1531,6 +1532,7 @@ 
 	.multicommand = ich_spi_send_multicommand,
 	.read = default_spi_read,
 	.write_256 = default_spi_write_256,
+	.write_aai = default_spi_write_aai,
 };
 
 static const struct opaque_programmer opaque_programmer_ich_hwseq = {
@@ -1838,6 +1840,7 @@ 
 	.multicommand = ich_spi_send_multicommand,
 	.read = default_spi_read,
 	.write_256 = default_spi_write_256,
+	.write_aai = default_spi_write_aai,
 };
 
 int via_init_spi(struct pci_dev *dev)
Index: spi.c
===================================================================
--- spi.c	(Revision 1541)
+++ spi.c	(Arbeitskopie)
@@ -161,11 +161,17 @@ 
 	}
 }
 
+int spi_aai_write(struct flashctx *flash, uint8_t *buf,
+		  unsigned int start, unsigned int len)
+{
+	return flash->pgm->spi.write_aai(flash, buf, start, len);
+}
+
 int register_spi_programmer(const struct spi_programmer *pgm)
 {
 	struct registered_programmer rpgm;
 
-	if (!pgm->write_256 || !pgm->read || !pgm->command ||
+	if (!pgm->write_aai || !pgm->write_256 || !pgm->read || !pgm->command ||
 	    !pgm->multicommand ||
 	    ((pgm->command == default_spi_send_command) &&
 	     (pgm->multicommand == default_spi_send_multicommand))) {
Index: ft2232_spi.c
===================================================================
--- ft2232_spi.c	(Revision 1541)
+++ ft2232_spi.c	(Arbeitskopie)
@@ -148,6 +148,7 @@ 
 	.multicommand	= default_spi_send_multicommand,
 	.read		= default_spi_read,
 	.write_256	= default_spi_write_256,
+	.write_aai	= default_spi_write_aai,
 };
 
 /* Returns 0 upon success, a negative number upon errors. */
Index: dummyflasher.c
===================================================================
--- dummyflasher.c	(Revision 1541)
+++ dummyflasher.c	(Arbeitskopie)
@@ -127,6 +127,7 @@ 
 	.multicommand	= default_spi_send_multicommand,
 	.read		= default_spi_read,
 	.write_256	= dummy_spi_write_256,
+	.write_aai	= default_spi_write_aai,
 };
 
 static const struct par_programmer par_programmer_dummy = {
Index: spi25.c
===================================================================
--- spi25.c	(Revision 1541)
+++ spi25.c	(Arbeitskopie)
@@ -1069,8 +1069,7 @@ 
 	return 0;
 }
 
-int spi_aai_write(struct flashctx *flash, uint8_t *buf, unsigned int start,
-		  unsigned int len)
+int default_spi_write_aai(struct flashctx *flash, uint8_t *buf, unsigned int start, unsigned int len)
 {
 	uint32_t pos = start;
 	int result;
Index: it87spi.c
===================================================================
--- it87spi.c	(Revision 1541)
+++ it87spi.c	(Arbeitskopie)
@@ -120,6 +120,7 @@ 
 	.multicommand	= default_spi_send_multicommand,
 	.read		= it8716f_spi_chip_read,
 	.write_256	= it8716f_spi_chip_write_256,
+	.write_aai	= default_spi_write_aai,
 };
 
 static uint16_t it87spi_probe(uint16_t port)
Index: buspirate_spi.c
===================================================================
--- buspirate_spi.c	(Revision 1541)
+++ buspirate_spi.c	(Arbeitskopie)
@@ -124,6 +124,7 @@ 
 	.multicommand	= default_spi_send_multicommand,
 	.read		= default_spi_read,
 	.write_256	= default_spi_write_256,
+	.write_aai	= default_spi_write_aai,
 };
 
 static const struct buspirate_spispeeds spispeeds[] = {
Index: linux_spi.c
===================================================================
--- linux_spi.c	(Revision 1541)
+++ linux_spi.c	(Arbeitskopie)
@@ -54,6 +54,7 @@ 
 	.multicommand	= default_spi_send_multicommand,
 	.read		= linux_spi_read,
 	.write_256	= linux_spi_write_256,
+	.write_aai	= default_spi_write_aai,
 };
 
 int linux_spi_init(void)
Index: programmer.h
===================================================================
--- programmer.h	(Revision 1541)
+++ programmer.h	(Arbeitskopie)
@@ -530,6 +530,7 @@ 
 	/* Optimized functions for this programmer */
 	int (*read)(struct flashctx *flash, uint8_t *buf, unsigned int start, unsigned int len);
 	int (*write_256)(struct flashctx *flash, uint8_t *buf, unsigned int start, unsigned int len);
+	int (*write_aai)(struct flashctx *flash, uint8_t *buf, unsigned int start, unsigned int len);
 	const void *data;
 };
 
@@ -538,6 +539,7 @@ 
 int default_spi_send_multicommand(struct flashctx *flash, struct spi_command *cmds);
 int default_spi_read(struct flashctx *flash, uint8_t *buf, unsigned int start, unsigned int len);
 int default_spi_write_256(struct flashctx *flash, uint8_t *buf, unsigned int start, unsigned int len);
+int default_spi_write_aai(struct flashctx *flash, uint8_t *buf, unsigned int start, unsigned int len);
 int register_spi_programmer(const struct spi_programmer *programmer);
 
 /* The following enum is needed by ich_descriptor_tool and ich* code. */
Index: serprog.c
===================================================================
--- serprog.c	(Revision 1541)
+++ serprog.c	(Arbeitskopie)
@@ -313,6 +313,7 @@ 
 	.multicommand	= default_spi_send_multicommand,
 	.read		= serprog_spi_read,
 	.write_256	= default_spi_write_256,
+	.write_aai	= default_spi_write_aai,
 };
 
 static void serprog_chip_writeb(const struct flashctx *flash, uint8_t val,
Index: bitbang_spi.c
===================================================================
--- bitbang_spi.c	(Revision 1541)
+++ bitbang_spi.c	(Arbeitskopie)
@@ -71,6 +71,7 @@ 
 	.multicommand	= default_spi_send_multicommand,
 	.read		= default_spi_read,
 	.write_256	= default_spi_write_256,
+	.write_aai	= default_spi_write_aai,
 };
 
 #if 0 // until it is needed