From: Tobias Lorenz <tobias.lorenz@gmx.net>
To: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
Cc: linux-ide@vger.kernel.org, Jeff Garzik <jgarzik@pobox.com>
Subject: Re: [PATCH 2.6.9-libata1-dev1] libata-scsi: hdparm support
Date: Thu, 04 Nov 2004 17:55:34 +0100 [thread overview]
Message-ID: <1099587334.26343.13.camel@server.lorenz.priv> (raw)
In-Reply-To: <58cb370e041102135138f50dac@mail.gmail.com>
Hi,
Bartlomiej Zolnierkiewicz wrote:
> Speaking about correctness...
>
> HDIO_GET_IDENTIFY returns ID block in CPU order (not LE).
>
> If you decide to add it sooner or later you will need something ala
> ide_fix_driveid() from ide-iops.c (bloat).
Okay, I am wondering, who defined, that hd_driveid has to be little
endian and not cpu order. Does that really has to be platform
independent ? But anyway...
There are two possible solutions:
The quick way is attached and just adds the missing conversions by
copy&paste from ide-iops:ide_fix_driveid.
The better and less redundant way would be to use the original function:
- by setting a Kconfig dependency on CONFIG_IDE.
- or by moving ide_fix_driveid to a seperate file (header file ?).
What do you mean ?
Toby
Signed-off-by: Tobias Lorenz <tobias.lorenz@gmx.net>
--- a/drivers/scsi/libata-scsi.c 2004-10-30 16:31:01.000000000 +0200
+++ b/drivers/scsi/libata-scsi.c 2004-11-04 17:39:58.000000000 +0100
@@ -31,6 +31,7 @@
#include <linux/libata.h>
#include <linux/hdreg.h>
#include <asm/uaccess.h>
+#include <asm/byteorder.h>
#include "libata.h"
@@ -215,6 +216,17 @@
struct ata_port *ap;
struct ata_device *dev;
int val = -EINVAL, rc = -EINVAL;
+ struct hd_driveid drv_id = {
+ .cyls = 0,
+ .sectors = 0,
+ .heads = 0,
+ .fw_rev = "",
+ .model = "",
+ .cur_cyls = 0,
+ .cur_heads = 0,
+ .cur_sectors = 0,
+ };
+ int geom[3];
ap = (struct ata_port *) &scsidev->host->hostdata[0];
if (!ap)
@@ -249,6 +261,40 @@
return -EACCES;
return ata_task_ioctl(scsidev, arg);
+ case HDIO_GET_IDENTITY:
+ ata_std_bios_param(scsidev, NULL, dev->n_sectors, geom);
+ drv_id.cur_heads = drv_id.heads = geom[0];
+ drv_id.cur_sectors = drv_id.sectors = geom[1];
+ drv_id.cur_cyls = drv_id.cyls = geom[2];
+ strncpy((char *) &drv_id.model, scsidev->model, sizeof(drv_id.model));
+ strncpy((char *) &drv_id.fw_rev, scsidev->rev, sizeof(drv_id.fw_rev));
+#ifndef __LITTLE_ENDIAN
+# ifdef __BIG_ENDIAN
+ {
+ int i;
+ u16 *stringcast;
+
+ drv_id.cyls = __le16_to_cpu(drv_id.cyls);
+ drv_id.heads = __le16_to_cpu(drv_id.heads);
+ drv_id.sectors = __le16_to_cpu(drv_id.sectors);
+ stringcast = (u16 *)&drv_id.fw_rev[0];
+ for (i = 0; i < (8/2); i++)
+ stringcast[i] = __le16_to_cpu(stringcast[i]);
+ stringcast = (u16 *)&drv_id.model[0];
+ for (i = 0; i < (40/2); i++)
+ stringcast[i] = __le16_to_cpu(stringcast[i]);
+ drv_id.cur_cyls = __le16_to_cpu(drv_id.cur_cyls);
+ drv_id.cur_heads = __le16_to_cpu(drv_id.cur_heads);
+ drv_id.cur_sectors = __le16_to_cpu(drv_id.cur_sectors);
+ }
+# else
+# error "Please fix <asm/byteorder.h>"
+# endif
+#endif
+ if(copy_to_user((char *) arg, (char *) &drv_id, sizeof(drv_id)))
+ return(-EFAULT);
+ return 0;
+
default:
rc = -EOPNOTSUPP;
break;
next prev parent reply other threads:[~2004-11-04 16:55 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2004-10-22 23:20 [PATCH 2.6.9-libata1-dev1] libata-scsi: hdparm support Tobias Lorenz
2004-10-23 12:36 ` Bartlomiej Zolnierkiewicz
2004-10-23 21:59 ` Tobias Lorenz
2004-10-30 12:43 ` Jeff Garzik
2004-10-30 14:58 ` Tobias Lorenz
2004-10-30 15:27 ` Jeff Garzik
2004-11-02 21:51 ` Bartlomiej Zolnierkiewicz
2004-11-04 16:55 ` Tobias Lorenz [this message]
2004-11-04 19:50 ` Bartlomiej Zolnierkiewicz
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1099587334.26343.13.camel@server.lorenz.priv \
--to=tobias.lorenz@gmx.net \
--cc=bzolnier@gmail.com \
--cc=jgarzik@pobox.com \
--cc=linux-ide@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).