From: Erik Andersen <andersen@codepoet.org>
To: Marcelo Tosatti <marcelo@conectiva.com.br>
Cc: Alan Cox <alan@lxorguk.ukuu.org.uk>,
Andries Brouwer <aebr@win.tue.nl>,
Bartlomiej Zolnierkiewicz <B.Zolnierkiewicz@elka.pw.edu.pl>,
Linux Kernel Mailing List <linux-kernel@vger.kernel.org>
Subject: [PATCH] 7/8 Backport recent 2.6 IDE updates to 2.4.x
Date: Sun, 17 Aug 2003 00:14:02 -0600 [thread overview]
Message-ID: <20030817061402.GH17621@codepoet.org> (raw)
This patch changes the IDE driver to use "capacity64" (describing
the size of the variable) rather than "capacity48" (which
describes that 48 bit addressing is in use). We really do not
care, in this context, what addressing happens to be in use.
This patch then eliminates the artifical distinction between
the old "capacity" and "capacity48" variables.
-Erik
--
Erik B. Andersen http://codepoet-consulting.com/
--This message was written using 73% post-consumer electrons--
--- linux/include/linux/ide.h.orig 2003-08-16 18:55:02.000000000 -0600
+++ linux/include/linux/ide.h 2003-08-16 21:03:26.000000000 -0600
@@ -785,8 +785,7 @@
unsigned int failures; /* current failure count */
unsigned int max_failures; /* maximum allowed failure count */
- u32 capacity; /* total number of sectors */
- u64 capacity48; /* total number of sectors */
+ u64 capacity64; /* total number of sectors */
int last_lun; /* last logical unit */
int forced_lun; /* if hdxlun was given at boot */
--- linux/drivers/ide/ide-disk.c.orig 2003-08-16 20:56:49.000000000 -0600
+++ linux/drivers/ide/ide-disk.c 2003-08-16 21:04:04.000000000 -0600
@@ -1152,53 +1152,33 @@
return (id->command_set_2 & 0x0400) && (id->cfs_enable_2 & 0x0400);
}
-static inline void idedisk_check_hpa_lba28(ide_drive_t *drive)
+static inline void idedisk_check_hpa(ide_drive_t *drive)
{
- unsigned long capacity, set_max;
+ unsigned long long capacity, set_max;
+ int lba48 = idedisk_supports_lba48(drive->id);
- capacity = drive->capacity;
- set_max = idedisk_read_native_max_address(drive);
+ capacity = drive->capacity64;
+ if (lba48)
+ set_max = idedisk_read_native_max_address_ext(drive);
+ else
+ set_max = idedisk_read_native_max_address(drive);
if (set_max <= capacity)
return;
printk(KERN_INFO "%s: Host Protected Area detected.\n"
- "\tcurrent capacity is %ld sectors (%ld MB)\n"
- "\tnative capacity is %ld sectors (%ld MB)\n",
+ "\tcurrent capacity is %llu sectors (%llu MB)\n"
+ "\tnative capacity is %llu sectors (%llu MB)\n",
drive->name,
- capacity, (capacity - capacity/625 + 974)/1950,
- set_max, (set_max - set_max/625 + 974)/1950);
+ capacity, sectors_to_MB(capacity),
+ set_max, sectors_to_MB(set_max));
#ifdef CONFIG_IDEDISK_STROKE
- set_max = idedisk_set_max_address(drive, set_max);
+ if (lba48)
+ set_max = idedisk_set_max_address_ext(drive, set_max);
+ else
+ set_max = idedisk_set_max_address(drive, set_max);
if (set_max) {
- drive->capacity = set_max;
- printk(KERN_INFO "%s: Host Protected Area disabled.\n",
- drive->name);
- }
-#endif
-}
-
-static inline void idedisk_check_hpa_lba48(ide_drive_t *drive)
-{
- unsigned long long capacity_2, set_max_ext;
-
- capacity_2 = drive->capacity48;
- set_max_ext = idedisk_read_native_max_address_ext(drive);
-
- if (set_max_ext <= capacity_2)
- return;
-
- printk(KERN_INFO "%s: Host Protected Area detected.\n"
- "\tcurrent capacity is %lld sectors (%lld MB)\n"
- "\tnative capacity is %lld sectors (%lld MB)\n",
- drive->name,
- capacity_2, sectors_to_MB(capacity_2),
- set_max_ext, sectors_to_MB(set_max_ext));
-#ifdef CONFIG_IDEDISK_STROKE
- set_max_ext = idedisk_set_max_address_ext(drive, set_max_ext);
- if (set_max_ext) {
- drive->capacity48 = set_max_ext;
- drive->capacity = (unsigned long) set_max_ext;
+ drive->capacity64 = set_max;
printk(KERN_INFO "%s: Host Protected Area disabled.\n",
drive->name);
}
@@ -1231,27 +1211,24 @@
if (idedisk_supports_lba48(id)) {
/* drive speaks 48-bit LBA */
drive->select.b.lba = 1;
- drive->capacity48 = id->lba_capacity_2;
- drive->capacity = (unsigned long) drive->capacity48;
+ drive->capacity64 = id->lba_capacity_2;
if (hpa)
- idedisk_check_hpa_lba48(drive);
+ idedisk_check_hpa(drive);
} else if ((id->capability & 2) && lba_capacity_is_ok(id)) {
/* drive speaks 28-bit LBA */
drive->select.b.lba = 1;
- drive->capacity = id->lba_capacity;
+ drive->capacity64 = id->lba_capacity;
if (hpa)
- idedisk_check_hpa_lba28(drive);
+ idedisk_check_hpa(drive);
} else {
/* drive speaks boring old 28-bit CHS */
- drive->capacity = drive->cyl * drive->head * drive->sect;
+ drive->capacity64 = drive->cyl * drive->head * drive->sect;
}
}
static u64 idedisk_capacity (ide_drive_t *drive)
{
- if (idedisk_supports_lba48(drive->id))
- return (drive->capacity48 - drive->sect0);
- return (drive->capacity - drive->sect0);
+ return drive->capacity64 - drive->sect0;
}
static ide_startstop_t idedisk_special (ide_drive_t *drive)
reply other threads:[~2003-08-17 6:18 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
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=20030817061402.GH17621@codepoet.org \
--to=andersen@codepoet.org \
--cc=B.Zolnierkiewicz@elka.pw.edu.pl \
--cc=aebr@win.tue.nl \
--cc=alan@lxorguk.ukuu.org.uk \
--cc=linux-kernel@vger.kernel.org \
--cc=marcelo@conectiva.com.br \
/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