public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH 2/3] mg_disk: fix dependency on libata
@ 2009-04-25 13:09 Bartlomiej Zolnierkiewicz
  2009-04-26  3:48 ` Tejun Heo
  2009-04-26  4:04 ` Jeff Garzik
  0 siblings, 2 replies; 8+ messages in thread
From: Bartlomiej Zolnierkiewicz @ 2009-04-25 13:09 UTC (permalink / raw)
  To: unsik Kim; +Cc: Tejun Heo, linux-kernel

Add local copies of ata_id_string() and ata_id_c_string() to mg_disk
so there is no need for the driver to depend on ATA and SCSI.

Cc: unsik Kim <donari75@gmail.com>
Cc: Tejun Heo <tj@kernel.org>
Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
---
 drivers/block/Kconfig   |    2 +-
 drivers/block/mg_disk.c |   44 ++++++++++++++++++++++++++++++++++++++++----
 2 files changed, 41 insertions(+), 5 deletions(-)

Index: b/drivers/block/Kconfig
===================================================================
--- a/drivers/block/Kconfig
+++ b/drivers/block/Kconfig
@@ -412,7 +412,7 @@ config ATA_OVER_ETH
 
 config MG_DISK
 	tristate "mGine mflash, gflash support"
-	depends on ARM && ATA && GPIOLIB
+	depends on ARM && GPIOLIB
 	help
 	  mGine mFlash(gFlash) block device driver
 
Index: b/drivers/block/mg_disk.c
===================================================================
--- a/drivers/block/mg_disk.c
+++ b/drivers/block/mg_disk.c
@@ -17,7 +17,7 @@
 #include <linux/fs.h>
 #include <linux/blkdev.h>
 #include <linux/hdreg.h>
-#include <linux/libata.h>
+#include <linux/ata.h>
 #include <linux/interrupt.h>
 #include <linux/delay.h>
 #include <linux/platform_device.h>
@@ -356,6 +356,42 @@ static irqreturn_t mg_irq(int irq, void 
 	return IRQ_HANDLED;
 }
 
+/* local copy of ata_id_string() */
+static void mg_id_string(const u16 *id, unsigned char *s,
+			 unsigned int ofs, unsigned int len)
+{
+	unsigned int c;
+
+	BUG_ON(len & 1);
+
+	while (len > 0) {
+		c = id[ofs] >> 8;
+		*s = c;
+		s++;
+
+		c = id[ofs] & 0xff;
+		*s = c;
+		s++;
+
+		ofs++;
+		len -= 2;
+	}
+}
+
+/* local copy of ata_id_c_string() */
+static void mg_id_c_string(const u16 *id, unsigned char *s,
+			   unsigned int ofs, unsigned int len)
+{
+	unsigned char *p;
+
+	mg_id_string(id, s, ofs, len - 1);
+
+	p = s + strnlen(s, len - 1);
+	while (p > s && p[-1] == ' ')
+		p--;
+	*p = '\0';
+}
+
 static int mg_get_disk_id(struct mg_host *host)
 {
 	u32 i;
@@ -402,9 +438,9 @@ static int mg_get_disk_id(struct mg_host
 		host->n_sectors -= host->nres_sectors;
 	}
 
-	ata_id_c_string(id, fwrev, ATA_ID_FW_REV, sizeof(fwrev));
-	ata_id_c_string(id, model, ATA_ID_PROD, sizeof(model));
-	ata_id_c_string(id, serial, ATA_ID_SERNO, sizeof(serial));
+	mg_id_c_string(id, fwrev, ATA_ID_FW_REV, sizeof(fwrev));
+	mg_id_c_string(id, model, ATA_ID_PROD, sizeof(model));
+	mg_id_c_string(id, serial, ATA_ID_SERNO, sizeof(serial));
 	printk(KERN_INFO "mg_disk: model: %s\n", model);
 	printk(KERN_INFO "mg_disk: firm: %.8s\n", fwrev);
 	printk(KERN_INFO "mg_disk: serial: %s\n", serial);

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH 2/3] mg_disk: fix dependency on libata
  2009-04-25 13:09 [PATCH 2/3] mg_disk: fix dependency on libata Bartlomiej Zolnierkiewicz
@ 2009-04-26  3:48 ` Tejun Heo
  2009-04-26  4:02   ` Jeff Garzik
  2009-04-26  9:39   ` Bartlomiej Zolnierkiewicz
  2009-04-26  4:04 ` Jeff Garzik
  1 sibling, 2 replies; 8+ messages in thread
From: Tejun Heo @ 2009-04-26  3:48 UTC (permalink / raw)
  To: Bartlomiej Zolnierkiewicz; +Cc: unsik Kim, linux-kernel

Bartlomiej Zolnierkiewicz wrote:
> Add local copies of ata_id_string() and ata_id_c_string() to mg_disk
> so there is no need for the driver to depend on ATA and SCSI.
> 
> Cc: unsik Kim <donari75@gmail.com>
> Cc: Tejun Heo <tj@kernel.org>
> Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>

Ah.. right, that's a rather large dependency to pull in just for the
string functions.  Yeah, I think it would be better to keep local
copy at elast for now.

Acked-by: Tejun Heo <tj@kernel.org>

(Continuing from the previous message :-) or do you want me to fold
these patches into my series and push them through Jens with other
patches?

Thanks.

-- 
tejun

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH 2/3] mg_disk: fix dependency on libata
  2009-04-26  3:48 ` Tejun Heo
@ 2009-04-26  4:02   ` Jeff Garzik
  2009-04-26  4:08     ` Tejun Heo
  2009-04-26  9:39   ` Bartlomiej Zolnierkiewicz
  1 sibling, 1 reply; 8+ messages in thread
From: Jeff Garzik @ 2009-04-26  4:02 UTC (permalink / raw)
  To: Tejun Heo
  Cc: Bartlomiej Zolnierkiewicz, unsik Kim, linux-kernel,
	Linux IDE mailing list

Tejun Heo wrote:
> Bartlomiej Zolnierkiewicz wrote:
>> Add local copies of ata_id_string() and ata_id_c_string() to mg_disk
>> so there is no need for the driver to depend on ATA and SCSI.
>>
>> Cc: unsik Kim <donari75@gmail.com>
>> Cc: Tejun Heo <tj@kernel.org>
>> Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
> 
> Ah.. right, that's a rather large dependency to pull in just for the
> string functions.  Yeah, I think it would be better to keep local
> copy at elast for now.
> 
> Acked-by: Tejun Heo <tj@kernel.org>

Actually...  NVMHCI[1] uses the same style of id string extraction, even 
though its command set is wholly new and unrelated to ATA.  I copied 
into drivers/block/nvmhci.c[2] id_string, id_c_string and another 
useful, generic routine: ata_wait_register.

So, once nvmhci goes upstream, that will be a third copy...  nvmhci 
still has rough edges, but it's mainly waiting on hardware "it works" 
verification at this point.

	Jeff



[1] http://download.intel.com/standards/nvmhci/spec.pdf

[2] 'nvmhci' branch of 
git://git.kernel.org/pub/scm/linux/kernel/git/jgarzik/misc-2.6.git


^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH 2/3] mg_disk: fix dependency on libata
  2009-04-25 13:09 [PATCH 2/3] mg_disk: fix dependency on libata Bartlomiej Zolnierkiewicz
  2009-04-26  3:48 ` Tejun Heo
@ 2009-04-26  4:04 ` Jeff Garzik
  2009-04-26  9:53   ` Bartlomiej Zolnierkiewicz
  1 sibling, 1 reply; 8+ messages in thread
From: Jeff Garzik @ 2009-04-26  4:04 UTC (permalink / raw)
  To: Bartlomiej Zolnierkiewicz
  Cc: unsik Kim, Tejun Heo, linux-kernel, Linux IDE mailing list

Bartlomiej Zolnierkiewicz wrote:
> Add local copies of ata_id_string() and ata_id_c_string() to mg_disk
> so there is no need for the driver to depend on ATA and SCSI.
> 
> Cc: unsik Kim <donari75@gmail.com>
> Cc: Tejun Heo <tj@kernel.org>
> Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
> ---
>  drivers/block/Kconfig   |    2 +-
>  drivers/block/mg_disk.c |   44 ++++++++++++++++++++++++++++++++++++++++----
>  2 files changed, 41 insertions(+), 5 deletions(-)

Please CC these types of patches to linux-ide also, as it is of interest 
to Linux ATA folks...  thanks.

	Jeff





^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH 2/3] mg_disk: fix dependency on libata
  2009-04-26  4:02   ` Jeff Garzik
@ 2009-04-26  4:08     ` Tejun Heo
  2009-04-26  4:11       ` Jeff Garzik
  0 siblings, 1 reply; 8+ messages in thread
From: Tejun Heo @ 2009-04-26  4:08 UTC (permalink / raw)
  To: Jeff Garzik
  Cc: Bartlomiej Zolnierkiewicz, unsik Kim, linux-kernel,
	Linux IDE mailing list

Jeff Garzik wrote:
> Actually...  NVMHCI[1] uses the same style of id string extraction, even
> though its command set is wholly new and unrelated to ATA.  I copied
> into drivers/block/nvmhci.c[2] id_string, id_c_string and another
> useful, generic routine: ata_wait_register.
>
> So, once nvmhci goes upstream, that will be a third copy...  nvmhci
> still has rough edges, but it's mainly waiting on hardware "it works"
> verification at this point.

For two copies, copying seems to be the right way to go.  For many
more copies, making a library function is.  Three is a difficult
number.  Maybe just make these inline functions for now?

Thanks.

-- 
tejun

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH 2/3] mg_disk: fix dependency on libata
  2009-04-26  4:08     ` Tejun Heo
@ 2009-04-26  4:11       ` Jeff Garzik
  0 siblings, 0 replies; 8+ messages in thread
From: Jeff Garzik @ 2009-04-26  4:11 UTC (permalink / raw)
  To: Tejun Heo
  Cc: Bartlomiej Zolnierkiewicz, unsik Kim, linux-kernel,
	Linux IDE mailing list

Tejun Heo wrote:
> Jeff Garzik wrote:
>> Actually...  NVMHCI[1] uses the same style of id string extraction, even
>> though its command set is wholly new and unrelated to ATA.  I copied
>> into drivers/block/nvmhci.c[2] id_string, id_c_string and another
>> useful, generic routine: ata_wait_register.
>>
>> So, once nvmhci goes upstream, that will be a third copy...  nvmhci
>> still has rough edges, but it's mainly waiting on hardware "it works"
>> verification at this point.
> 
> For two copies, copying seems to be the right way to go.  For many
> more copies, making a library function is.  Three is a difficult
> number.  Maybe just make these inline functions for now?

<shrug>  I'm just adding some data, I don't have a good suggestion :)

The functions do not change very often, so three copies is not 
necessarily the end of the world.

	Jeff




^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH 2/3] mg_disk: fix dependency on libata
  2009-04-26  3:48 ` Tejun Heo
  2009-04-26  4:02   ` Jeff Garzik
@ 2009-04-26  9:39   ` Bartlomiej Zolnierkiewicz
  1 sibling, 0 replies; 8+ messages in thread
From: Bartlomiej Zolnierkiewicz @ 2009-04-26  9:39 UTC (permalink / raw)
  To: Tejun Heo; +Cc: unsik Kim, linux-kernel, linux-ide, Jeff Garzik

On Sunday 26 April 2009 05:48:36 Tejun Heo wrote:
> Bartlomiej Zolnierkiewicz wrote:
> > Add local copies of ata_id_string() and ata_id_c_string() to mg_disk
> > so there is no need for the driver to depend on ATA and SCSI.
> > 
> > Cc: unsik Kim <donari75@gmail.com>
> > Cc: Tejun Heo <tj@kernel.org>
> > Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
> 
> Ah.. right, that's a rather large dependency to pull in just for the
> string functions.  Yeah, I think it would be better to keep local
> copy at elast for now.
> 
> Acked-by: Tejun Heo <tj@kernel.org>
> 
> (Continuing from the previous message :-) or do you want me to fold
> these patches into my series and push them through Jens with other
> patches?

Please include them in your series if possible.  Thanks!

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH 2/3] mg_disk: fix dependency on libata
  2009-04-26  4:04 ` Jeff Garzik
@ 2009-04-26  9:53   ` Bartlomiej Zolnierkiewicz
  0 siblings, 0 replies; 8+ messages in thread
From: Bartlomiej Zolnierkiewicz @ 2009-04-26  9:53 UTC (permalink / raw)
  To: Jeff Garzik; +Cc: unsik Kim, Tejun Heo, linux-kernel, Linux IDE mailing list

On Sunday 26 April 2009 06:04:31 Jeff Garzik wrote:
> Bartlomiej Zolnierkiewicz wrote:
> > Add local copies of ata_id_string() and ata_id_c_string() to mg_disk
> > so there is no need for the driver to depend on ATA and SCSI.
> > 
> > Cc: unsik Kim <donari75@gmail.com>
> > Cc: Tejun Heo <tj@kernel.org>
> > Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
> > ---
> >  drivers/block/Kconfig   |    2 +-
> >  drivers/block/mg_disk.c |   44 ++++++++++++++++++++++++++++++++++++++++----
> >  2 files changed, 41 insertions(+), 5 deletions(-)
> 
> Please CC these types of patches to linux-ide also, as it is of interest 
> to Linux ATA folks...  thanks.

Aye, aye.  I usually do... ;)

^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2009-04-26  9:49 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-04-25 13:09 [PATCH 2/3] mg_disk: fix dependency on libata Bartlomiej Zolnierkiewicz
2009-04-26  3:48 ` Tejun Heo
2009-04-26  4:02   ` Jeff Garzik
2009-04-26  4:08     ` Tejun Heo
2009-04-26  4:11       ` Jeff Garzik
2009-04-26  9:39   ` Bartlomiej Zolnierkiewicz
2009-04-26  4:04 ` Jeff Garzik
2009-04-26  9:53   ` Bartlomiej Zolnierkiewicz

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox