Commit 8e81bbba authored by Borislav Petkov's avatar Borislav Petkov Committed by Bartlomiej Zolnierkiewicz

ide-floppy: remove struct idefloppy_flexible_disk_page

Signed-off-by: default avatarBorislav Petkov <bbpetkov@yahoo.de>
Signed-off-by: default avatarBartlomiej Zolnierkiewicz <bzolnier@gmail.com>
parent 24a5d703
...@@ -119,33 +119,6 @@ typedef struct idefloppy_packet_command_s { ...@@ -119,33 +119,6 @@ typedef struct idefloppy_packet_command_s {
#define PC_SUPPRESS_ERROR 6 /* Suppress error reporting */ #define PC_SUPPRESS_ERROR 6 /* Suppress error reporting */
/*
* Flexible disk page.
*/
typedef struct {
#if defined(__LITTLE_ENDIAN_BITFIELD)
unsigned page_code :6; /* Page code - Should be 0x5 */
unsigned reserved1_6 :1; /* Reserved */
unsigned ps :1; /* The device is capable of saving the page */
#elif defined(__BIG_ENDIAN_BITFIELD)
unsigned ps :1; /* The device is capable of saving the page */
unsigned reserved1_6 :1; /* Reserved */
unsigned page_code :6; /* Page code - Should be 0x5 */
#else
#error "Bitfield endianness not defined! Check your byteorder.h"
#endif
u8 page_length; /* Page Length - Should be 0x1e */
u16 transfer_rate; /* In kilobits per second */
u8 heads, sectors; /* Number of heads, Number of sectors per track */
u16 sector_size; /* Byes per sector */
u16 cyls; /* Number of cylinders */
u8 reserved10[10];
u8 motor_delay; /* Motor off delay */
u8 reserved21[7];
u16 rpm; /* Rotations per minute */
u8 reserved30[2];
} idefloppy_flexible_disk_page_t;
/* /*
* Format capacity * Format capacity
*/ */
...@@ -214,7 +187,7 @@ typedef struct ide_floppy_obj { ...@@ -214,7 +187,7 @@ typedef struct ide_floppy_obj {
/* Last format capacity */ /* Last format capacity */
idefloppy_capacity_descriptor_t capacity; idefloppy_capacity_descriptor_t capacity;
/* Copy of the flexible disk page */ /* Copy of the flexible disk page */
idefloppy_flexible_disk_page_t flexible_disk_page; u8 flexible_disk_page[32];
/* Write protect */ /* Write protect */
int wp; int wp;
/* Supports format progress report */ /* Supports format progress report */
...@@ -1095,48 +1068,57 @@ static int idefloppy_queue_pc_tail (ide_drive_t *drive,idefloppy_pc_t *pc) ...@@ -1095,48 +1068,57 @@ static int idefloppy_queue_pc_tail (ide_drive_t *drive,idefloppy_pc_t *pc)
} }
/* /*
* Look at the flexible disk page parameters. We will ignore the CHS * Look at the flexible disk page parameters. We ignore the CHS capacity
* capacity parameters and use the LBA parameters instead. * parameters and use the LBA parameters instead.
*/ */
static int idefloppy_get_flexible_disk_page (ide_drive_t *drive) static int ide_floppy_get_flexible_disk_page(ide_drive_t *drive)
{ {
idefloppy_floppy_t *floppy = drive->driver_data; idefloppy_floppy_t *floppy = drive->driver_data;
idefloppy_pc_t pc; idefloppy_pc_t pc;
idefloppy_flexible_disk_page_t *page; u8 *page;
int capacity, lba_capacity; int capacity, lba_capacity;
u16 transfer_rate, sector_size, cyls, rpm;
u8 heads, sectors;
idefloppy_create_mode_sense_cmd(&pc, IDEFLOPPY_FLEXIBLE_DISK_PAGE, MODE_SENSE_CURRENT); idefloppy_create_mode_sense_cmd(&pc, IDEFLOPPY_FLEXIBLE_DISK_PAGE,
if (idefloppy_queue_pc_tail(drive,&pc)) { MODE_SENSE_CURRENT);
printk(KERN_ERR "ide-floppy: Can't get flexible disk "
"page parameters\n"); if (idefloppy_queue_pc_tail(drive, &pc)) {
printk(KERN_ERR "ide-floppy: Can't get flexible disk page"
" parameters\n");
return 1; return 1;
} }
floppy->wp = !!(pc.buffer[3] & 0x80); floppy->wp = !!(pc.buffer[3] & 0x80);
set_disk_ro(floppy->disk, floppy->wp); set_disk_ro(floppy->disk, floppy->wp);
page = (idefloppy_flexible_disk_page_t *) &pc.buffer[8]; page = &pc.buffer[8];
page->transfer_rate = be16_to_cpu(page->transfer_rate); transfer_rate = be16_to_cpu(*(u16 *)&pc.buffer[8 + 2]);
page->sector_size = be16_to_cpu(page->sector_size); sector_size = be16_to_cpu(*(u16 *)&pc.buffer[8 + 6]);
page->cyls = be16_to_cpu(page->cyls); cyls = be16_to_cpu(*(u16 *)&pc.buffer[8 + 8]);
page->rpm = be16_to_cpu(page->rpm); rpm = be16_to_cpu(*(u16 *)&pc.buffer[8 + 28]);
capacity = page->cyls * page->heads * page->sectors * page->sector_size; heads = pc.buffer[8 + 4];
if (memcmp (page, &floppy->flexible_disk_page, sizeof (idefloppy_flexible_disk_page_t))) sectors = pc.buffer[8 + 5];
capacity = cyls * heads * sectors * sector_size;
if (memcmp(page, &floppy->flexible_disk_page, 32))
printk(KERN_INFO "%s: %dkB, %d/%d/%d CHS, %d kBps, " printk(KERN_INFO "%s: %dkB, %d/%d/%d CHS, %d kBps, "
"%d sector size, %d rpm\n", "%d sector size, %d rpm\n",
drive->name, capacity / 1024, page->cyls, drive->name, capacity / 1024, cyls, heads,
page->heads, page->sectors, sectors, transfer_rate / 8, sector_size, rpm);
page->transfer_rate / 8, page->sector_size, page->rpm);
memcpy(&floppy->flexible_disk_page, page, 32);
floppy->flexible_disk_page = *page; drive->bios_cyl = cyls;
drive->bios_cyl = page->cyls; drive->bios_head = heads;
drive->bios_head = page->heads; drive->bios_sect = sectors;
drive->bios_sect = page->sectors;
lba_capacity = floppy->blocks * floppy->block_size; lba_capacity = floppy->blocks * floppy->block_size;
if (capacity < lba_capacity) { if (capacity < lba_capacity) {
printk(KERN_NOTICE "%s: The disk reports a capacity of %d " printk(KERN_NOTICE "%s: The disk reports a capacity of %d "
"bytes, but the drive only handles %d\n", "bytes, but the drive only handles %d\n",
drive->name, lba_capacity, capacity); drive->name, lba_capacity, capacity);
floppy->blocks = floppy->block_size ? capacity / floppy->block_size : 0; floppy->blocks = floppy->block_size ?
capacity / floppy->block_size : 0;
} }
return 0; return 0;
} }
...@@ -1243,7 +1225,7 @@ static int idefloppy_get_capacity (ide_drive_t *drive) ...@@ -1243,7 +1225,7 @@ static int idefloppy_get_capacity (ide_drive_t *drive)
/* Clik! disk does not support get_flexible_disk_page */ /* Clik! disk does not support get_flexible_disk_page */
if (!test_bit(IDEFLOPPY_CLIK_DRIVE, &floppy->flags)) { if (!test_bit(IDEFLOPPY_CLIK_DRIVE, &floppy->flags)) {
(void) idefloppy_get_flexible_disk_page(drive); (void) ide_floppy_get_flexible_disk_page(drive);
} }
set_capacity(floppy->disk, floppy->blocks * floppy->bs_factor); set_capacity(floppy->disk, floppy->blocks * floppy->bs_factor);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment