LKML Archive on lore.kernel.org help / color / mirror / Atom feed
* [PATCH 0/12] ide-floppy redux v2.5 @ 2008-01-13 20:18 Borislav Petkov 2008-01-13 20:18 ` [PATCH 1/12] ide-floppy: remove struct idefloppy_mode_parameter_header Borislav Petkov 2008-01-14 21:38 ` [PATCH 0/12] ide-floppy redux v2.5 Bartlomiej Zolnierkiewicz 0 siblings, 2 replies; 29+ messages in thread From: Borislav Petkov @ 2008-01-13 20:18 UTC (permalink / raw) To: bzolnier; +Cc: linux-kernel, linux-ide, Borislav Petkov Hi Bart, here are the remaining patches which had issues to be worked out. I decided to keep the Flexible Disk Page and Capacity Descriptor in idefloppy_floppy_t for the sake of the two printk calls for which they are used. Otherwise, we'll be changing long-known driver behavior and this won't be acceptable. I'll audit the driver to see whether rq_data_dir() can replace the PC_WRITING flag completely and get rid of that one too. By the way, I have an Iomega ZIP 100 drive somewhere in my hardware pile and will do some testing with the "new" :) driver just in case. ^ permalink raw reply [flat|nested] 29+ messages in thread
* [PATCH 1/12] ide-floppy: remove struct idefloppy_mode_parameter_header 2008-01-13 20:18 [PATCH 0/12] ide-floppy redux v2.5 Borislav Petkov @ 2008-01-13 20:18 ` Borislav Petkov 2008-01-13 20:18 ` [PATCH 2/12] ide-floppy: remove struct idefloppy_flexible_disk_page Borislav Petkov 2008-01-14 21:38 ` [PATCH 0/12] ide-floppy redux v2.5 Bartlomiej Zolnierkiewicz 1 sibling, 1 reply; 29+ messages in thread From: Borislav Petkov @ 2008-01-13 20:18 UTC (permalink / raw) To: bzolnier; +Cc: linux-kernel, linux-ide, Borislav Petkov Signed-off-by: Borislav Petkov <bbpetkov@yahoo.de> --- drivers/ide/ide-floppy.c | 26 +++----------------------- 1 files changed, 3 insertions(+), 23 deletions(-) diff --git a/drivers/ide/ide-floppy.c b/drivers/ide/ide-floppy.c index 2b9885f..7648684 100644 --- a/drivers/ide/ide-floppy.c +++ b/drivers/ide/ide-floppy.c @@ -365,24 +365,6 @@ typedef struct { #define IDEFLOPPY_CAPABILITIES_PAGE 0x1b #define IDEFLOPPY_FLEXIBLE_DISK_PAGE 0x05 -/* - * Mode Parameter Header for the MODE SENSE packet command - */ -typedef struct { - u16 mode_data_length; /* Length of the following data transfer */ - u8 medium_type; /* Medium Type */ -#if defined(__LITTLE_ENDIAN_BITFIELD) - unsigned reserved3 :7; - unsigned wp :1; /* Write protect */ -#elif defined(__BIG_ENDIAN_BITFIELD) - unsigned wp :1; /* Write protect */ - unsigned reserved3 :7; -#else -#error "Bitfield endianness not defined! Check your byteorder.h" -#endif - u8 reserved[4]; -} idefloppy_mode_parameter_header_t; - static DEFINE_MUTEX(idefloppy_ref_mutex); #define to_ide_floppy(obj) container_of(obj, struct ide_floppy_obj, kref) @@ -1029,7 +1011,7 @@ static void idefloppy_create_format_unit_cmd (idefloppy_pc_t *pc, int b, int l, */ static void idefloppy_create_mode_sense_cmd (idefloppy_pc_t *pc, u8 page_code, u8 type) { - u16 length = sizeof(idefloppy_mode_parameter_header_t); + u16 length = 8; /* sizeof(Mode Parameter Header) = 8 Bytes */ idefloppy_init_pc(pc); pc->c[0] = GPCMD_MODE_SENSE_10; @@ -1195,7 +1177,6 @@ static int idefloppy_get_flexible_disk_page (ide_drive_t *drive) { idefloppy_floppy_t *floppy = drive->driver_data; idefloppy_pc_t pc; - idefloppy_mode_parameter_header_t *header; idefloppy_flexible_disk_page_t *page; int capacity, lba_capacity; @@ -1205,10 +1186,9 @@ static int idefloppy_get_flexible_disk_page (ide_drive_t *drive) "page parameters\n"); return 1; } - header = (idefloppy_mode_parameter_header_t *) pc.buffer; - floppy->wp = header->wp; + floppy->wp = !!(pc.buffer[3] & 0x80); set_disk_ro(floppy->disk, floppy->wp); - page = (idefloppy_flexible_disk_page_t *) (header + 1); + page = (idefloppy_flexible_disk_page_t *) &pc.buffer[8]; page->transfer_rate = be16_to_cpu(page->transfer_rate); page->sector_size = be16_to_cpu(page->sector_size); -- 1.5.3.7 ^ permalink raw reply related [flat|nested] 29+ messages in thread
* [PATCH 2/12] ide-floppy: remove struct idefloppy_flexible_disk_page 2008-01-13 20:18 ` [PATCH 1/12] ide-floppy: remove struct idefloppy_mode_parameter_header Borislav Petkov @ 2008-01-13 20:18 ` Borislav Petkov 2008-01-13 20:18 ` [PATCH 3/12] ide-floppy: remove struct idefloppy_capacity_descriptor Borislav Petkov 0 siblings, 1 reply; 29+ messages in thread From: Borislav Petkov @ 2008-01-13 20:18 UTC (permalink / raw) To: bzolnier; +Cc: linux-kernel, linux-ide, Borislav Petkov Signed-off-by: Borislav Petkov <bbpetkov@yahoo.de> --- drivers/ide/ide-floppy.c | 90 ++++++++++++++++++--------------------------- 1 files changed, 36 insertions(+), 54 deletions(-) diff --git a/drivers/ide/ide-floppy.c b/drivers/ide/ide-floppy.c index 7648684..06d83cb 100644 --- a/drivers/ide/ide-floppy.c +++ b/drivers/ide/ide-floppy.c @@ -120,33 +120,6 @@ typedef struct idefloppy_packet_command_s { #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 */ typedef struct { @@ -214,7 +187,7 @@ typedef struct ide_floppy_obj { /* Last format capacity */ idefloppy_capacity_descriptor_t capacity; /* Copy of the flexible disk page */ - idefloppy_flexible_disk_page_t flexible_disk_page; + u8 flexible_disk_page[32]; /* Write protect */ int wp; /* Supports format progress report */ @@ -1170,48 +1143,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 - * capacity parameters and use the LBA parameters instead. + * Look at the flexible disk page parameters. We ignore the CHS capacity + * 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_pc_t pc; - idefloppy_flexible_disk_page_t *page; + u8 *page; 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); - if (idefloppy_queue_pc_tail(drive,&pc)) { - printk(KERN_ERR "ide-floppy: Can't get flexible disk " - "page parameters\n"); + idefloppy_create_mode_sense_cmd(&pc, IDEFLOPPY_FLEXIBLE_DISK_PAGE, + MODE_SENSE_CURRENT); + + if (idefloppy_queue_pc_tail(drive, &pc)) { + printk(KERN_ERR "ide-floppy: Can't get flexible disk page" + " parameters\n"); return 1; } floppy->wp = !!(pc.buffer[3] & 0x80); set_disk_ro(floppy->disk, floppy->wp); - page = (idefloppy_flexible_disk_page_t *) &pc.buffer[8]; - - page->transfer_rate = be16_to_cpu(page->transfer_rate); - page->sector_size = be16_to_cpu(page->sector_size); - page->cyls = be16_to_cpu(page->cyls); - page->rpm = be16_to_cpu(page->rpm); - capacity = page->cyls * page->heads * page->sectors * page->sector_size; - if (memcmp (page, &floppy->flexible_disk_page, sizeof (idefloppy_flexible_disk_page_t))) + page = &pc.buffer[8]; + + transfer_rate = be16_to_cpu(*(u16 *)&pc.buffer[8 + 2]); + sector_size = be16_to_cpu(*(u16 *)&pc.buffer[8 + 6]); + cyls = be16_to_cpu(*(u16 *)&pc.buffer[8 + 8]); + rpm = be16_to_cpu(*(u16 *)&pc.buffer[8 + 28]); + heads = pc.buffer[8 + 4]; + 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, " "%d sector size, %d rpm\n", - drive->name, capacity / 1024, page->cyls, - page->heads, page->sectors, - page->transfer_rate / 8, page->sector_size, page->rpm); - - floppy->flexible_disk_page = *page; - drive->bios_cyl = page->cyls; - drive->bios_head = page->heads; - drive->bios_sect = page->sectors; + drive->name, capacity / 1024, cyls, heads, + sectors, transfer_rate / 8, sector_size, rpm); + + memcpy(&floppy->flexible_disk_page, page, 32); + drive->bios_cyl = cyls; + drive->bios_head = heads; + drive->bios_sect = sectors; lba_capacity = floppy->blocks * floppy->block_size; + if (capacity < lba_capacity) { printk(KERN_NOTICE "%s: The disk reports a capacity of %d " "bytes, but the drive only handles %d\n", 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; } @@ -1318,7 +1300,7 @@ static int idefloppy_get_capacity (ide_drive_t *drive) /* Clik! disk does not support get_flexible_disk_page */ 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); -- 1.5.3.7 ^ permalink raw reply related [flat|nested] 29+ messages in thread
* [PATCH 3/12] ide-floppy: remove struct idefloppy_capacity_descriptor 2008-01-13 20:18 ` [PATCH 2/12] ide-floppy: remove struct idefloppy_flexible_disk_page Borislav Petkov @ 2008-01-13 20:18 ` Borislav Petkov 2008-01-13 20:18 ` [PATCH 4/12] ide-floppy: factor out ioctl handlers from idefloppy_ioctl() Borislav Petkov 0 siblings, 1 reply; 29+ messages in thread From: Borislav Petkov @ 2008-01-13 20:18 UTC (permalink / raw) To: bzolnier; +Cc: linux-kernel, linux-ide, Borislav Petkov Also, - remove the accompanying 4 byte idefloppy_capacity_header. - rename functions from idefloppy_... to ide_floppy_... after cleanup. - simplify loop in ide_floppy_get_capacity() by reversing if-test condition logically. - finally, fix white space and checkpatch.pl issues Signed-off-by: Borislav Petkov <bbpetkov@yahoo.de> --- drivers/ide/ide-floppy.c | 176 ++++++++++++++++++++-------------------------- 1 files changed, 76 insertions(+), 100 deletions(-) diff --git a/drivers/ide/ide-floppy.c b/drivers/ide/ide-floppy.c index 06d83cb..caeffb7 100644 --- a/drivers/ide/ide-floppy.c +++ b/drivers/ide/ide-floppy.c @@ -119,29 +119,7 @@ typedef struct idefloppy_packet_command_s { #define PC_SUPPRESS_ERROR 6 /* Suppress error reporting */ -/* - * Format capacity - */ -typedef struct { - u8 reserved[3]; - u8 length; /* Length of the following descriptors in bytes */ -} idefloppy_capacity_header_t; - -typedef struct { - u32 blocks; /* Number of blocks */ -#if defined(__LITTLE_ENDIAN_BITFIELD) - unsigned dc :2; /* Descriptor Code */ - unsigned reserved :6; -#elif defined(__BIG_ENDIAN_BITFIELD) - unsigned reserved :6; - unsigned dc :2; /* Descriptor Code */ -#else -#error "Bitfield endianness not defined! Check your byteorder.h" -#endif - u8 length_msb; /* Block Length (MSB)*/ - u16 length; /* Block Length */ -} idefloppy_capacity_descriptor_t; - +/* format capacities descriptor codes */ #define CAPACITY_INVALID 0x00 #define CAPACITY_UNFORMATTED 0x01 #define CAPACITY_CURRENT 0x02 @@ -184,8 +162,8 @@ typedef struct ide_floppy_obj { */ /* Current format */ int blocks, block_size, bs_factor; - /* Last format capacity */ - idefloppy_capacity_descriptor_t capacity; + /* Last format capacity descriptor */ + u8 cap_desc[8]; /* Copy of the flexible disk page */ u8 flexible_disk_page[32]; /* Write protect */ @@ -1216,17 +1194,17 @@ static int idefloppy_get_sfrp_bit(ide_drive_t *drive) } /* - * Determine if a media is present in the floppy drive, and if so, - * its LBA capacity. + * Determine if a media is present in the floppy drive, and if so, its LBA + * capacity. */ -static int idefloppy_get_capacity (ide_drive_t *drive) +static int ide_floppy_get_capacity(ide_drive_t *drive) { idefloppy_floppy_t *floppy = drive->driver_data; idefloppy_pc_t pc; - idefloppy_capacity_header_t *header; - idefloppy_capacity_descriptor_t *descriptor; - int i, descriptors, rc = 1, blocks, length; - + u8 *cap_desc; + u8 header_len, desc_cnt; + int i, rc = 1, blocks, length; + drive->bios_cyl = 0; drive->bios_head = drive->bios_sect = 0; floppy->blocks = 0; @@ -1238,17 +1216,26 @@ static int idefloppy_get_capacity (ide_drive_t *drive) printk(KERN_ERR "ide-floppy: Can't get floppy parameters\n"); return 1; } - header = (idefloppy_capacity_header_t *) pc.buffer; - descriptors = header->length / sizeof(idefloppy_capacity_descriptor_t); - descriptor = (idefloppy_capacity_descriptor_t *) (header + 1); + header_len = pc.buffer[3]; + cap_desc = &pc.buffer[4]; + desc_cnt = header_len / 8; /* capacity descriptor of 8 bytes */ + + for (i = 0; i < desc_cnt; i++) { + unsigned int desc_start = 4 + i*8; + + blocks = be32_to_cpu(*(u32 *)&pc.buffer[desc_start]); + length = be16_to_cpu(*(u16 *)&pc.buffer[desc_start + 6]); + + debug_log("Descriptor %d: %dkB, %d blocks, %d sector size\n", + i, blocks * length / 1024, blocks, length); - for (i = 0; i < descriptors; i++, descriptor++) { - blocks = descriptor->blocks = be32_to_cpu(descriptor->blocks); - length = descriptor->length = be16_to_cpu(descriptor->length); + if (i) + continue; + /* + * the code below is valid only for the 1st descriptor, ie i=0 + */ - if (!i) - { - switch (descriptor->dc) { + switch (pc.buffer[desc_start + 4] & 0x03) { /* Clik! drive returns this instead of CAPACITY_CURRENT */ case CAPACITY_UNFORMATTED: if (!test_bit(IDEFLOPPY_CLIK_DRIVE, &floppy->flags)) @@ -1259,23 +1246,25 @@ static int idefloppy_get_capacity (ide_drive_t *drive) break; case CAPACITY_CURRENT: /* Normal Zip/LS-120 disks */ - if (memcmp(descriptor, &floppy->capacity, sizeof (idefloppy_capacity_descriptor_t))) + if (memcmp(cap_desc, &floppy->cap_desc, 8)) printk(KERN_INFO "%s: %dkB, %d blocks, %d " "sector size\n", drive->name, blocks * length / 1024, blocks, length); - floppy->capacity = *descriptor; + memcpy(&floppy->cap_desc, cap_desc, 8); + if (!length || length % 512) { printk(KERN_NOTICE "%s: %d bytes block size " "not supported\n", drive->name, length); } else { - floppy->blocks = blocks; - floppy->block_size = length; - if ((floppy->bs_factor = length / 512) != 1) - printk(KERN_NOTICE "%s: warning: non " + floppy->blocks = blocks; + floppy->block_size = length; + floppy->bs_factor = length / 512; + if (floppy->bs_factor != 1) + printk(KERN_NOTICE "%s: warning: non " "512 bytes block size not " "fully supported\n", drive->name); - rc = 0; + rc = 0; } break; case CAPACITY_NO_CARTRIDGE: @@ -1290,52 +1279,42 @@ static int idefloppy_get_capacity (ide_drive_t *drive) "in drive\n", drive->name); break; } - } - if (!i) { - debug_log("Descriptor 0 Code: %d\n", descriptor->dc); - } - debug_log("Descriptor %d: %dkB, %d blocks, %d sector size\n", - i, blocks * length / 1024, blocks, length); + debug_log("Descriptor 0 Code: %d\n", + pc.buffer[desc_start + 4] & 0x03); } /* 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) ide_floppy_get_flexible_disk_page(drive); - } set_capacity(floppy->disk, floppy->blocks * floppy->bs_factor); return rc; } /* -** Obtain the list of formattable capacities. -** Very similar to idefloppy_get_capacity, except that we push the capacity -** descriptors to userland, instead of our own structures. -** -** Userland gives us the following structure: -** -** struct idefloppy_format_capacities { -** int nformats; -** struct { -** int nblocks; -** int blocksize; -** } formats[]; -** } ; -** -** userland initializes nformats to the number of allocated formats[] -** records. On exit we set nformats to the number of records we've -** actually initialized. -** -*/ + * Obtain the list of formattable capacities. + * Very similar to ide_floppy_get_capacity, except that we push the capacity + * descriptors to userland, instead of our own structures. + * + * Userland gives us the following structure: + * + * struct idefloppy_format_capacities { + * int nformats; + * struct { + * int nblocks; + * int blocksize; + * } formats[]; + * }; + * + * userland initializes nformats to the number of allocated formats[] records. + * On exit we set nformats to the number of records we've actually initialized. + */ -static int idefloppy_get_format_capacities(ide_drive_t *drive, int __user *arg) +static int ide_floppy_get_format_capacities(ide_drive_t *drive, int __user *arg) { - idefloppy_pc_t pc; - idefloppy_capacity_header_t *header; - idefloppy_capacity_descriptor_t *descriptor; - int i, descriptors, blocks, length; - int u_array_size; - int u_index; + idefloppy_pc_t pc; + u8 header_len, desc_cnt; + int i, blocks, length, u_array_size, u_index; int __user *argp; if (get_user(u_array_size, arg)) @@ -1347,30 +1326,27 @@ static int idefloppy_get_format_capacities(ide_drive_t *drive, int __user *arg) idefloppy_create_read_capacity_cmd(&pc); if (idefloppy_queue_pc_tail(drive, &pc)) { printk(KERN_ERR "ide-floppy: Can't get floppy parameters\n"); - return (-EIO); - } - header = (idefloppy_capacity_header_t *) pc.buffer; - descriptors = header->length / - sizeof(idefloppy_capacity_descriptor_t); - descriptor = (idefloppy_capacity_descriptor_t *) (header + 1); + return (-EIO); + } + header_len = pc.buffer[3]; + desc_cnt = header_len / 8; /* capacity descriptor of 8 bytes */ u_index = 0; argp = arg + 1; /* - ** We always skip the first capacity descriptor. That's the - ** current capacity. We are interested in the remaining descriptors, - ** the formattable capacities. - */ + * We always skip the first capacity descriptor. That's the current + * capacity. We are interested in the remaining descriptors, the + * formattable capacities. + */ + for (i = 1; i < desc_cnt; i++) { + unsigned int desc_start = 4 + i*8; - for (i=0; i<descriptors; i++, descriptor++) { if (u_index >= u_array_size) break; /* User-supplied buffer too small */ - if (i == 0) - continue; /* Skip the first descriptor */ - blocks = be32_to_cpu(descriptor->blocks); - length = be16_to_cpu(descriptor->length); + blocks = be32_to_cpu(*(u32 *)&pc.buffer[desc_start]); + length = be16_to_cpu(*(u16 *)&pc.buffer[desc_start + 6]); if (put_user(blocks, argp)) return(-EFAULT); @@ -1610,7 +1586,7 @@ static void idefloppy_setup (ide_drive_t *drive, idefloppy_floppy_t *floppy) } - (void) idefloppy_get_capacity(drive); + (void) ide_floppy_get_capacity(drive); idefloppy_add_settings(drive); } @@ -1705,7 +1681,7 @@ static int idefloppy_open(struct inode *inode, struct file *filp) (void) idefloppy_queue_pc_tail(drive, &pc); } - if (idefloppy_get_capacity (drive) + if (ide_floppy_get_capacity(drive) && (filp->f_flags & O_NDELAY) == 0 /* ** Allow O_NDELAY to open a drive without a disk, or with @@ -1809,7 +1785,7 @@ static int idefloppy_ioctl(struct inode *inode, struct file *file, case IDEFLOPPY_IOCTL_FORMAT_SUPPORTED: return 0; case IDEFLOPPY_IOCTL_FORMAT_GET_CAPACITY: - return idefloppy_get_format_capacities(drive, argp); + return ide_floppy_get_format_capacities(drive, argp); case IDEFLOPPY_IOCTL_FORMAT_START: if (!(file->f_mode & 2)) -- 1.5.3.7 ^ permalink raw reply related [flat|nested] 29+ messages in thread
* [PATCH 4/12] ide-floppy: factor out ioctl handlers from idefloppy_ioctl() 2008-01-13 20:18 ` [PATCH 3/12] ide-floppy: remove struct idefloppy_capacity_descriptor Borislav Petkov @ 2008-01-13 20:18 ` Borislav Petkov 2008-01-13 20:18 ` [PATCH 5/12] ide-floppy: report DMA handling in idefloppy_pc_intr() properly Borislav Petkov 0 siblings, 1 reply; 29+ messages in thread From: Borislav Petkov @ 2008-01-13 20:18 UTC (permalink / raw) To: bzolnier; +Cc: linux-kernel, linux-ide, Borislav Petkov By passing idefloppy_floppy_t *floppy to the factored out functions, we get rid of (almost) all local vars so stack usage should be at minimum here. Also, we merge idefloppy_begin_format() into idefloppy_format_start() since it is its only user. Also, rename idefloppy_format_start() to idefloppy_format_unit(). Finally, rename the reworked functions to ide_floppy..(). Signed-off-by: Borislav Petkov <bbpetkov@yahoo.de> --- drivers/ide/ide-floppy.c | 153 +++++++++++++++++++++++---------------------- 1 files changed, 78 insertions(+), 75 deletions(-) diff --git a/drivers/ide/ide-floppy.c b/drivers/ide/ide-floppy.c index 276731a..00ea8d6 100644 --- a/drivers/ide/ide-floppy.c +++ b/drivers/ide/ide-floppy.c @@ -1290,44 +1290,6 @@ static int ide_floppy_get_format_capacities(ide_drive_t *drive, int __user *arg) } /* -** Send ATAPI_FORMAT_UNIT to the drive. -** -** Userland gives us the following structure: -** -** struct idefloppy_format_command { -** int nblocks; -** int blocksize; -** int flags; -** } ; -** -** flags is a bitmask, currently, the only defined flag is: -** -** 0x01 - verify media after format. -*/ - -static int idefloppy_begin_format(ide_drive_t *drive, int __user *arg) -{ - int blocks; - int length; - int flags; - idefloppy_pc_t pc; - - if (get_user(blocks, arg) || - get_user(length, arg+1) || - get_user(flags, arg+2)) { - return (-EFAULT); - } - - (void) idefloppy_get_sfrp_bit(drive); - idefloppy_create_format_unit_cmd(&pc, blocks, length, flags); - if (idefloppy_queue_pc_tail(drive, &pc)) { - return (-EIO); - } - - return (0); -} - -/* ** Get ATAPI_FORMAT_UNIT progress indication. ** ** Userland gives a pointer to an int. The int is set to a progress @@ -1678,64 +1640,105 @@ static int idefloppy_getgeo(struct block_device *bdev, struct hd_geometry *geo) return 0; } +static int ide_floppy_lockdoor(idefloppy_floppy_t *floppy, idefloppy_pc_t *pc, + unsigned long arg, unsigned int cmd) +{ + if (floppy->openers > 1) + return -EBUSY; + + /* The IOMEGA Clik! Drive doesn't support this command - + * no room for an eject mechanism */ + if (!test_bit(IDEFLOPPY_CLIK_DRIVE, &floppy->flags)) { + int prevent = arg ? 1 : 0; + + if (cmd == CDROMEJECT) + prevent = 0; + + idefloppy_create_prevent_cmd(pc, prevent); + (void) idefloppy_queue_pc_tail(floppy->drive, pc); + } + + if (cmd == CDROMEJECT) { + idefloppy_create_start_stop_cmd(pc, 2); + (void) idefloppy_queue_pc_tail(floppy->drive, pc); + } + + return 0; +} + +static int ide_floppy_format_unit(idefloppy_floppy_t *floppy, + int __user *arg) +{ + int blocks, length, flags, err = 0; + idefloppy_pc_t pc; + + if (floppy->openers > 1) { + /* Don't format if someone is using the disk */ + clear_bit(IDEFLOPPY_FORMAT_IN_PROGRESS, &floppy->flags); + return -EBUSY; + } + + set_bit(IDEFLOPPY_FORMAT_IN_PROGRESS, &floppy->flags); + + /* + * Send ATAPI_FORMAT_UNIT to the drive. + * + * Userland gives us the following structure: + * + * struct idefloppy_format_command { + * int nblocks; + * int blocksize; + * int flags; + * } ; + * + * flags is a bitmask, currently, the only defined flag is: + * + * 0x01 - verify media after format. + */ + if (get_user(blocks, arg) || + get_user(length, arg+1) || + get_user(flags, arg+2)) { + err = -EFAULT; + goto out; + } + + (void) idefloppy_get_sfrp_bit(floppy->drive); + idefloppy_create_format_unit_cmd(&pc, blocks, length, flags); + + if (idefloppy_queue_pc_tail(floppy->drive, &pc)) + err = -EIO; + +out: + if (err) + clear_bit(IDEFLOPPY_FORMAT_IN_PROGRESS, &floppy->flags); + return err; +} + + static int idefloppy_ioctl(struct inode *inode, struct file *file, unsigned int cmd, unsigned long arg) { struct block_device *bdev = inode->i_bdev; struct ide_floppy_obj *floppy = ide_floppy_g(bdev->bd_disk); ide_drive_t *drive = floppy->drive; + idefloppy_pc_t pc; void __user *argp = (void __user *)arg; int err; - int prevent = (arg) ? 1 : 0; - idefloppy_pc_t pc; switch (cmd) { case CDROMEJECT: - prevent = 0; /* fall through */ case CDROM_LOCKDOOR: - if (floppy->openers > 1) - return -EBUSY; - - /* The IOMEGA Clik! Drive doesn't support this command - no room for an eject mechanism */ - if (!test_bit(IDEFLOPPY_CLIK_DRIVE, &floppy->flags)) { - idefloppy_create_prevent_cmd(&pc, prevent); - (void) idefloppy_queue_pc_tail(drive, &pc); - } - if (cmd == CDROMEJECT) { - idefloppy_create_start_stop_cmd(&pc, 2); - (void) idefloppy_queue_pc_tail(drive, &pc); - } - return 0; + return ide_floppy_lockdoor(floppy, &pc, arg, cmd); case IDEFLOPPY_IOCTL_FORMAT_SUPPORTED: return 0; case IDEFLOPPY_IOCTL_FORMAT_GET_CAPACITY: return ide_floppy_get_format_capacities(drive, argp); case IDEFLOPPY_IOCTL_FORMAT_START: - if (!(file->f_mode & 2)) return -EPERM; - if (floppy->openers > 1) { - /* Don't format if someone is using the disk */ - - clear_bit(IDEFLOPPY_FORMAT_IN_PROGRESS, - &floppy->flags); - return -EBUSY; - } - - set_bit(IDEFLOPPY_FORMAT_IN_PROGRESS, &floppy->flags); - - err = idefloppy_begin_format(drive, argp); - if (err) - clear_bit(IDEFLOPPY_FORMAT_IN_PROGRESS, &floppy->flags); - return err; - /* - ** Note, the bit will be cleared when the device is - ** closed. This is the cleanest way to handle the - ** situation where the drive does not support - ** format progress reporting. - */ + return ide_floppy_format_unit(floppy, (int __user *)arg); case IDEFLOPPY_IOCTL_FORMAT_GET_PROGRESS: return idefloppy_get_format_progress(drive, argp); } -- 1.5.3.7 ^ permalink raw reply related [flat|nested] 29+ messages in thread
* [PATCH 5/12] ide-floppy: report DMA handling in idefloppy_pc_intr() properly 2008-01-13 20:18 ` [PATCH 4/12] ide-floppy: factor out ioctl handlers from idefloppy_ioctl() Borislav Petkov @ 2008-01-13 20:18 ` Borislav Petkov 2008-01-13 20:18 ` [PATCH 6/12] ide-floppy: mv idefloppy_{should_,}report_error Borislav Petkov 0 siblings, 1 reply; 29+ messages in thread From: Borislav Petkov @ 2008-01-13 20:18 UTC (permalink / raw) To: bzolnier; +Cc: linux-kernel, linux-ide, Borislav Petkov Signed-off-by: Borislav Petkov <bbpetkov@yahoo.de> --- drivers/ide/ide-floppy.c | 8 +++++++- 1 files changed, 7 insertions(+), 1 deletions(-) diff --git a/drivers/ide/ide-floppy.c b/drivers/ide/ide-floppy.c index 00ea8d6..5004773 100644 --- a/drivers/ide/ide-floppy.c +++ b/drivers/ide/ide-floppy.c @@ -534,11 +534,17 @@ static ide_startstop_t idefloppy_pc_intr (ide_drive_t *drive) unsigned int temp; u16 bcount; u8 stat, ireason; + int dma_error = 0; debug_log("Reached %s interrupt handler\n", __FUNCTION__); if (test_bit(PC_DMA_IN_PROGRESS, &pc->flags)) { - if (HWIF(drive)->ide_dma_end(drive)) { + dma_error = HWIF(drive)->ide_dma_end(drive); + if (dma_error) { + printk(KERN_ERR "%s: DMA %s error\n", + drive->name, + rq_data_dir(rq) == WRITE ? "write" :"read"); + set_bit(PC_DMA_ERROR, &pc->flags); } else { pc->actually_transferred = pc->request_transfer; -- 1.5.3.7 ^ permalink raw reply related [flat|nested] 29+ messages in thread
* [PATCH 6/12] ide-floppy: mv idefloppy_{should_,}report_error 2008-01-13 20:18 ` [PATCH 5/12] ide-floppy: report DMA handling in idefloppy_pc_intr() properly Borislav Petkov @ 2008-01-13 20:18 ` Borislav Petkov 2008-01-13 20:18 ` [PATCH 7/12] ide-floppy: remove IDEFLOPPY_DEBUG_BUGS macro Borislav Petkov 0 siblings, 1 reply; 29+ messages in thread From: Borislav Petkov @ 2008-01-13 20:18 UTC (permalink / raw) To: bzolnier; +Cc: linux-kernel, linux-ide, Borislav Petkov In addition to shortening the function name, move the printk-call into the function thereby saving some code lines. Also, make the function out_of_line since it is not on a performance critical path. Finally, rename the reworked function to ide_floppy..(). Signed-off-by: Borislav Petkov <bbpetkov@yahoo.de> --- drivers/ide/ide-floppy.c | 38 ++++++++++++++------------------------ 1 files changed, 14 insertions(+), 24 deletions(-) diff --git a/drivers/ide/ide-floppy.c b/drivers/ide/ide-floppy.c index 5004773..f1ae9af 100644 --- a/drivers/ide/ide-floppy.c +++ b/drivers/ide/ide-floppy.c @@ -739,18 +739,20 @@ static ide_startstop_t idefloppy_transfer_pc1 (ide_drive_t *drive) return ide_started; } -/** - * idefloppy_should_report_error() - * - * Supresses error messages resulting from Medium not present - */ -static inline int idefloppy_should_report_error(idefloppy_floppy_t *floppy) +static void ide_floppy_report_error(idefloppy_floppy_t *floppy, + idefloppy_pc_t *pc) { + /* supress error messages resulting from Medium not present */ if (floppy->sense_key == 0x02 && floppy->asc == 0x3a && floppy->ascq == 0x00) - return 0; - return 1; + return; + + printk(KERN_ERR "ide-floppy: %s: I/O error, pc = %2x, key = %2x, " + "asc = %2x, ascq = %2x\n", + floppy->drive->name, pc->c[0], floppy->sense_key, + floppy->asc, floppy->ascq); + } /* @@ -777,15 +779,8 @@ static ide_startstop_t idefloppy_issue_pc (ide_drive_t *drive, idefloppy_pc_t *p * a legitimate error code was received. */ if (!test_bit(PC_ABORT, &pc->flags)) { - if (!test_bit(PC_SUPPRESS_ERROR, &pc->flags)) { - if (idefloppy_should_report_error(floppy)) - printk(KERN_ERR "ide-floppy: %s: I/O error, " - "pc = %2x, key = %2x, " - "asc = %2x, ascq = %2x\n", - drive->name, pc->c[0], - floppy->sense_key, - floppy->asc, floppy->ascq); - } + if (!test_bit(PC_SUPPRESS_ERROR, &pc->flags)) + ide_floppy_report_error(floppy, pc); /* Giving up */ pc->error = IDEFLOPPY_ERROR_GENERAL; } @@ -995,13 +990,8 @@ static ide_startstop_t idefloppy_do_request (ide_drive_t *drive, struct request rq->nr_sectors, rq->current_nr_sectors); if (rq->errors >= ERROR_MAX) { - if (floppy->failed_pc != NULL) { - if (idefloppy_should_report_error(floppy)) - printk(KERN_ERR "ide-floppy: %s: I/O error, pc = %2x," - " key = %2x, asc = %2x, ascq = %2x\n", - drive->name, floppy->failed_pc->c[0], - floppy->sense_key, floppy->asc, floppy->ascq); - } + if (floppy->failed_pc != NULL) + ide_floppy_report_error(floppy, floppy->failed_pc); else printk(KERN_ERR "ide-floppy: %s: I/O error\n", drive->name); -- 1.5.3.7 ^ permalink raw reply related [flat|nested] 29+ messages in thread
* [PATCH 7/12] ide-floppy: remove IDEFLOPPY_DEBUG_BUGS macro 2008-01-13 20:18 ` [PATCH 6/12] ide-floppy: mv idefloppy_{should_,}report_error Borislav Petkov @ 2008-01-13 20:18 ` Borislav Petkov 2008-01-13 20:18 ` [PATCH 8/12] ide-floppy: merge idefloppy_{input,output}_buffers Borislav Petkov 0 siblings, 1 reply; 29+ messages in thread From: Borislav Petkov @ 2008-01-13 20:18 UTC (permalink / raw) To: bzolnier; +Cc: linux-kernel, linux-ide, Borislav Petkov Signed-off-by: Borislav Petkov <bbpetkov@yahoo.de> --- drivers/ide/ide-floppy.c | 7 +------ 1 files changed, 1 insertions(+), 6 deletions(-) diff --git a/drivers/ide/ide-floppy.c b/drivers/ide/ide-floppy.c index b826ac5..e7cc9dd 100644 --- a/drivers/ide/ide-floppy.c +++ b/drivers/ide/ide-floppy.c @@ -52,7 +52,6 @@ */ #define IDEFLOPPY_DEBUG_LOG 0 #define IDEFLOPPY_DEBUG_INFO 0 -#define IDEFLOPPY_DEBUG_BUGS 1 /* #define IDEFLOPPY_DEBUG(fmt, args...) printk(KERN_INFO fmt, ## args) */ #define IDEFLOPPY_DEBUG( fmt, args... ) @@ -280,13 +279,11 @@ static void idefloppy_discard_data (ide_drive_t *drive, unsigned int bcount) (void) HWIF(drive)->INB(IDE_DATA_REG); } -#if IDEFLOPPY_DEBUG_BUGS -static void idefloppy_write_zeros (ide_drive_t *drive, unsigned int bcount) +static void idefloppy_write_zeros(ide_drive_t *drive, unsigned int bcount) { while (bcount--) HWIF(drive)->OUTB(0, IDE_DATA_REG); } -#endif /* IDEFLOPPY_DEBUG_BUGS */ /* @@ -382,12 +379,10 @@ static void idefloppy_output_buffers (ide_drive_t *drive, idefloppy_pc_t *pc, un idefloppy_do_end_request(drive, 1, done >> 9); -#if IDEFLOPPY_DEBUG_BUGS if (bcount) { printk(KERN_ERR "%s: leftover data in idefloppy_output_buffers, bcount == %d\n", drive->name, bcount); idefloppy_write_zeros(drive, bcount); } -#endif } static void idefloppy_update_buffers (ide_drive_t *drive, idefloppy_pc_t *pc) -- 1.5.3.7 ^ permalink raw reply related [flat|nested] 29+ messages in thread
* [PATCH 8/12] ide-floppy: merge idefloppy_{input,output}_buffers 2008-01-13 20:18 ` [PATCH 7/12] ide-floppy: remove IDEFLOPPY_DEBUG_BUGS macro Borislav Petkov @ 2008-01-13 20:18 ` Borislav Petkov 2008-01-13 20:18 ` [PATCH 9/12] ide-floppy: remove unused IDEFLOPPY_USE_READ12 Borislav Petkov 2008-01-14 21:38 ` [PATCH 8/12] ide-floppy: merge idefloppy_{input,output}_buffers Bartlomiej Zolnierkiewicz 0 siblings, 2 replies; 29+ messages in thread From: Borislav Petkov @ 2008-01-13 20:18 UTC (permalink / raw) To: bzolnier; +Cc: linux-kernel, linux-ide, Borislav Petkov We merge idefloppy_{input,output}_buffers() into idefloppy_io_buffers() by introducing a 4th arg. called direction. According to its value we atapi_input_bytes() or atapi_output_bytes(). Also, this simplifies the interrupt handler logic a bit. Finally, rename idefloppy_io_buffers() to ide_floppy_io_buffers(). Signed-off-by: Borislav Petkov <bbpetkov@yahoo.de> --- drivers/ide/ide-floppy.c | 67 +++++++++++++-------------------------------- 1 files changed, 20 insertions(+), 47 deletions(-) diff --git a/drivers/ide/ide-floppy.c b/drivers/ide/ide-floppy.c index e7cc9dd..6c917fc 100644 --- a/drivers/ide/ide-floppy.c +++ b/drivers/ide/ide-floppy.c @@ -321,39 +321,8 @@ static int idefloppy_do_end_request(ide_drive_t *drive, int uptodate, int nsecs) return 0; } -static void idefloppy_input_buffers (ide_drive_t *drive, idefloppy_pc_t *pc, unsigned int bcount) -{ - struct request *rq = pc->rq; - struct bio_vec *bvec; - struct req_iterator iter; - unsigned long flags; - char *data; - int count, done = 0; - - rq_for_each_segment(bvec, rq, iter) { - if (!bcount) - break; - - count = min(bvec->bv_len, bcount); - - data = bvec_kmap_irq(bvec, &flags); - drive->hwif->atapi_input_bytes(drive, data, count); - bvec_kunmap_irq(data, &flags); - - bcount -= count; - pc->b_count += count; - done += count; - } - - idefloppy_do_end_request(drive, 1, done >> 9); - - if (bcount) { - printk(KERN_ERR "%s: leftover data in idefloppy_input_buffers, bcount == %d\n", drive->name, bcount); - idefloppy_discard_data(drive, bcount); - } -} - -static void idefloppy_output_buffers (ide_drive_t *drive, idefloppy_pc_t *pc, unsigned int bcount) +static void ide_floppy_io_buffers(ide_drive_t *drive, idefloppy_pc_t *pc, + unsigned int bcount, int direction) { struct request *rq = pc->rq; struct req_iterator iter; @@ -369,7 +338,10 @@ static void idefloppy_output_buffers (ide_drive_t *drive, idefloppy_pc_t *pc, un count = min(bvec->bv_len, bcount); data = bvec_kmap_irq(bvec, &flags); - drive->hwif->atapi_output_bytes(drive, data, count); + if (direction) + drive->hwif->atapi_output_bytes(drive, data, count); + else + drive->hwif->atapi_input_bytes(drive, data, count); bvec_kunmap_irq(data, &flags); bcount -= count; @@ -380,8 +352,13 @@ static void idefloppy_output_buffers (ide_drive_t *drive, idefloppy_pc_t *pc, un idefloppy_do_end_request(drive, 1, done >> 9); if (bcount) { - printk(KERN_ERR "%s: leftover data in idefloppy_output_buffers, bcount == %d\n", drive->name, bcount); - idefloppy_write_zeros(drive, bcount); + printk(KERN_ERR "%s: leftover data in idefloppy_output_buffers," + " bcount == %d\n", drive->name, bcount); + if (direction) + idefloppy_write_zeros(drive, bcount); + else + idefloppy_discard_data(drive, bcount); + } } @@ -516,8 +493,6 @@ static void idefloppy_retry_pc (ide_drive_t *drive) idefloppy_queue_pc_head(drive, pc, rq); } -typedef void (io_buf_t)(ide_drive_t *, idefloppy_pc_t *, unsigned int); - static ide_startstop_t idefloppy_pc_intr(ide_drive_t *drive) { idefloppy_floppy_t *floppy = drive->driver_data; @@ -525,7 +500,6 @@ static ide_startstop_t idefloppy_pc_intr(ide_drive_t *drive) idefloppy_pc_t *pc = floppy->pc; struct request *rq = pc->rq; xfer_func_t *xferfunc; - io_buf_t *iobuf_func; unsigned int temp; u16 bcount; u8 stat, ireason; @@ -625,24 +599,23 @@ static ide_startstop_t idefloppy_pc_intr(ide_drive_t *drive) " expected - allowing transfer\n"); } } - if (test_bit(PC_WRITING, &pc->flags)) { + if (test_bit(PC_WRITING, &pc->flags)) xferfunc = hwif->atapi_output_bytes; - iobuf_func = &idefloppy_output_buffers; - } else { + else xferfunc = hwif->atapi_input_bytes; - iobuf_func = &idefloppy_input_buffers; - } - if (pc->buffer != NULL) + if (pc->buffer) xferfunc(drive, pc->current_position, bcount); else - iobuf_func(drive, pc, bcount); + ide_floppy_io_buffers(drive, pc, bcount, + test_bit(PC_WRITING, &pc->flags)); /* Update the current position */ pc->actually_transferred += bcount; pc->current_position += bcount; - ide_set_handler(drive, &idefloppy_pc_intr, IDEFLOPPY_WAIT_CMD, NULL); /* And set the interrupt handler again */ + /* And set the interrupt handler again */ + ide_set_handler(drive, &idefloppy_pc_intr, IDEFLOPPY_WAIT_CMD, NULL); return ide_started; } -- 1.5.3.7 ^ permalink raw reply related [flat|nested] 29+ messages in thread
* [PATCH 9/12] ide-floppy: remove unused IDEFLOPPY_USE_READ12 2008-01-13 20:18 ` [PATCH 8/12] ide-floppy: merge idefloppy_{input,output}_buffers Borislav Petkov @ 2008-01-13 20:18 ` Borislav Petkov 2008-01-13 20:18 ` [PATCH 10/12] ide-floppy: remove atomic test_*bit macros Borislav Petkov 2008-01-14 21:38 ` [PATCH 8/12] ide-floppy: merge idefloppy_{input,output}_buffers Bartlomiej Zolnierkiewicz 1 sibling, 1 reply; 29+ messages in thread From: Borislav Petkov @ 2008-01-13 20:18 UTC (permalink / raw) To: bzolnier; +Cc: linux-kernel, linux-ide, Borislav Petkov This flag is not being set anywhere in the driver so it can go. Signed-off-by: Borislav Petkov <bbpetkov@yahoo.de> --- drivers/ide/ide-floppy.c | 17 ++++++----------- 1 files changed, 6 insertions(+), 11 deletions(-) diff --git a/drivers/ide/ide-floppy.c b/drivers/ide/ide-floppy.c index 6c917fc..790e33f 100644 --- a/drivers/ide/ide-floppy.c +++ b/drivers/ide/ide-floppy.c @@ -180,7 +180,6 @@ typedef struct ide_floppy_obj { */ #define IDEFLOPPY_DRQ_INTERRUPT 0 /* DRQ interrupt device */ #define IDEFLOPPY_MEDIA_CHANGED 1 /* Media may have changed */ -#define IDEFLOPPY_USE_READ12 2 /* Use READ12/WRITE12 or READ10/WRITE10 */ #define IDEFLOPPY_FORMAT_IN_PROGRESS 3 /* Format in progress */ #define IDEFLOPPY_CLIK_DRIVE 4 /* Avoid commands not supported in Clik drive */ #define IDEFLOPPY_ZIP_DRIVE 5 /* Requires BH algorithm for packets */ @@ -889,25 +888,21 @@ static void idefloppy_create_test_unit_ready_cmd(idefloppy_pc_t *pc) pc->c[0] = GPCMD_TEST_UNIT_READY; } -static void idefloppy_create_rw_cmd (idefloppy_floppy_t *floppy, idefloppy_pc_t *pc, struct request *rq, unsigned long sector) +static void idefloppy_create_rw_cmd(idefloppy_floppy_t *floppy, + idefloppy_pc_t *pc, struct request *rq, unsigned long sector) { int block = sector / floppy->bs_factor; int blocks = rq->nr_sectors / floppy->bs_factor; int cmd = rq_data_dir(rq); - debug_log("create_rw1%d_cmd: block == %d, blocks == %d\n", - 2 * test_bit (IDEFLOPPY_USE_READ12, &floppy->flags), + debug_log("create_rw10_cmd: block == %d, blocks == %d\n", block, blocks); idefloppy_init_pc(pc); - if (test_bit(IDEFLOPPY_USE_READ12, &floppy->flags)) { - pc->c[0] = cmd == READ ? GPCMD_READ_12 : GPCMD_WRITE_12; - put_unaligned(cpu_to_be32(blocks), (unsigned int *) &pc->c[6]); - } else { - pc->c[0] = cmd == READ ? GPCMD_READ_10 : GPCMD_WRITE_10; - put_unaligned(cpu_to_be16(blocks), (unsigned short *)&pc->c[7]); - } + pc->c[0] = cmd == READ ? GPCMD_READ_10 : GPCMD_WRITE_10; + put_unaligned(cpu_to_be16(blocks), (unsigned short *)&pc->c[7]); put_unaligned(cpu_to_be32(block), (unsigned int *) &pc->c[2]); + pc->callback = &idefloppy_rw_callback; pc->rq = rq; pc->b_count = cmd == READ ? 0 : rq->bio->bi_size; -- 1.5.3.7 ^ permalink raw reply related [flat|nested] 29+ messages in thread
* [PATCH 10/12] ide-floppy: remove atomic test_*bit macros 2008-01-13 20:18 ` [PATCH 9/12] ide-floppy: remove unused IDEFLOPPY_USE_READ12 Borislav Petkov @ 2008-01-13 20:18 ` Borislav Petkov 2008-01-13 20:18 ` [PATCH 11/12] ide-floppy: remove IDEFLOPPY_DEBUG_INFO Borislav Petkov 2008-01-14 21:50 ` [PATCH 10/12] ide-floppy: remove atomic test_*bit macros Bartlomiej Zolnierkiewicz 0 siblings, 2 replies; 29+ messages in thread From: Borislav Petkov @ 2008-01-13 20:18 UTC (permalink / raw) To: bzolnier; +Cc: linux-kernel, linux-ide, Borislav Petkov ..and replace them with flag enums. Signed-off-by: Borislav Petkov <bbpetkov@yahoo.de> --- drivers/ide/ide-floppy.c | 132 +++++++++++++++++++++++++-------------------- 1 files changed, 73 insertions(+), 59 deletions(-) diff --git a/drivers/ide/ide-floppy.c b/drivers/ide/ide-floppy.c index 790e33f..8e7714a 100644 --- a/drivers/ide/ide-floppy.c +++ b/drivers/ide/ide-floppy.c @@ -107,16 +107,21 @@ typedef struct idefloppy_packet_command_s { unsigned long flags; /* Status/Action bit flags: long for set_bit */ } idefloppy_pc_t; -/* - * Packet command flag bits. - */ -#define PC_ABORT 0 /* Set when an error is considered normal - We won't retry */ -#define PC_DMA_RECOMMENDED 2 /* 1 when we prefer to use DMA if possible */ -#define PC_DMA_IN_PROGRESS 3 /* 1 while DMA in progress */ -#define PC_DMA_ERROR 4 /* 1 when encountered problem during DMA */ -#define PC_WRITING 5 /* Data direction */ - -#define PC_SUPPRESS_ERROR 6 /* Suppress error reporting */ +/* Packet command flag bits. */ +enum { + /* Set when an error is considered normal - We won't retry */ + PC_FLAG_ABORT = (1 << 0), + /* 1 when we prefer to use DMA if possible */ + PC_FLAG_DMA_RECOMMENDED = (1 << 1), + /* 1 while DMA in progress */ + PC_FLAG_DMA_IN_PROGRESS = (1 << 2), + /* 1 when encountered problem during DMA */ + PC_FLAG_DMA_ERROR = (1 << 3), + /* Data direction */ + PC_FLAG_WRITING = (1 << 4), + /* Suppress error reporting */ + PC_FLAG_SUPPRESS_ERROR = (1 << 5), +}; /* format capacities descriptor codes */ #define CAPACITY_INVALID 0x00 @@ -175,14 +180,19 @@ typedef struct ide_floppy_obj { #define IDEFLOPPY_TICKS_DELAY HZ/20 /* default delay for ZIP 100 (50ms) */ -/* - * Floppy flag bits values. - */ -#define IDEFLOPPY_DRQ_INTERRUPT 0 /* DRQ interrupt device */ -#define IDEFLOPPY_MEDIA_CHANGED 1 /* Media may have changed */ -#define IDEFLOPPY_FORMAT_IN_PROGRESS 3 /* Format in progress */ -#define IDEFLOPPY_CLIK_DRIVE 4 /* Avoid commands not supported in Clik drive */ -#define IDEFLOPPY_ZIP_DRIVE 5 /* Requires BH algorithm for packets */ +/* Floppy flag bits values. */ +enum { + /* DRQ interrupt device */ + IDEFLOPPY_FLAG_DRQ_INTERRUPT = (1 << 0), + /* Media may have changed */ + IDEFLOPPY_FLAG_MEDIA_CHANGED = (1 << 1), + /* Format in progress */ + IDEFLOPPY_FLAG_FORMAT_IN_PROGRESS = (1 << 2), + /* Avoid commands not supported in Clik drive */ + IDEFLOPPY_FLAG_CLIK_DRIVE = (1 << 3), + /* Requires BH algorithm for packets */ + IDEFLOPPY_FLAG_ZIP_DRIVE = (1 << 4), +}; /* * Defines for the mode sense command @@ -506,14 +516,14 @@ static ide_startstop_t idefloppy_pc_intr(ide_drive_t *drive) debug_log("Reached %s interrupt handler\n", __FUNCTION__); - if (test_bit(PC_DMA_IN_PROGRESS, &pc->flags)) { + if (PC_FLAG_DMA_IN_PROGRESS & pc->flags) { dma_error = HWIF(drive)->ide_dma_end(drive); if (dma_error) { printk(KERN_ERR "%s: DMA %s error\n", drive->name, rq_data_dir(rq) == WRITE ? "write" :"read"); - set_bit(PC_DMA_ERROR, &pc->flags); + pc->flags |= PC_FLAG_DMA_ERROR; } else { pc->actually_transferred = pc->request_transfer; idefloppy_update_buffers(drive, pc); @@ -527,11 +537,11 @@ static ide_startstop_t idefloppy_pc_intr(ide_drive_t *drive) if ((stat & DRQ_STAT) == 0) { /* No more interrupts */ debug_log("Packet command completed, %d bytes transferred\n", pc->actually_transferred); - clear_bit(PC_DMA_IN_PROGRESS, &pc->flags); + pc->flags &= ~PC_FLAG_DMA_IN_PROGRESS; local_irq_enable_in_hardirq(); - if ((stat & ERR_STAT) || test_bit(PC_DMA_ERROR, &pc->flags)) { + if ((stat & ERR_STAT) || (PC_FLAG_DMA_ERROR & pc->flags)) { /* Error detected */ debug_log("I/O error\n", drive->name); rq->errors++; @@ -553,7 +563,8 @@ static ide_startstop_t idefloppy_pc_intr(ide_drive_t *drive) return ide_stopped; } - if (test_and_clear_bit(PC_DMA_IN_PROGRESS, &pc->flags)) { + if (PC_FLAG_DMA_IN_PROGRESS & pc->flags) { + pc->flags &= ~PC_FLAG_DMA_IN_PROGRESS; printk(KERN_ERR "ide-floppy: The floppy wants to issue " "more interrupts in DMA mode\n"); ide_dma_off(drive); @@ -570,7 +581,7 @@ static ide_startstop_t idefloppy_pc_intr(ide_drive_t *drive) printk(KERN_ERR "ide-floppy: CoD != 0 in %s\n", __FUNCTION__); return ide_do_reset(drive); } - if (((ireason & IO) == IO) == test_bit(PC_WRITING, &pc->flags)) { + if (((ireason & IO) == IO) == (PC_FLAG_WRITING & pc->flags)) { /* Hopefully, we will never get here */ printk(KERN_ERR "ide-floppy: We wanted to %s, ", (ireason & IO) ? "Write" : "Read"); @@ -578,7 +589,7 @@ static ide_startstop_t idefloppy_pc_intr(ide_drive_t *drive) (ireason & IO) ? "Read" : "Write"); return ide_do_reset(drive); } - if (!test_bit(PC_WRITING, &pc->flags)) { + if (!(PC_FLAG_WRITING & pc->flags)) { /* Reading - Check that we have enough space */ temp = pc->actually_transferred + bcount; if (temp > pc->request_transfer) { @@ -598,7 +609,7 @@ static ide_startstop_t idefloppy_pc_intr(ide_drive_t *drive) " expected - allowing transfer\n"); } } - if (test_bit(PC_WRITING, &pc->flags)) + if (PC_FLAG_WRITING & pc->flags) xferfunc = hwif->atapi_output_bytes; else xferfunc = hwif->atapi_input_bytes; @@ -607,7 +618,7 @@ static ide_startstop_t idefloppy_pc_intr(ide_drive_t *drive) xferfunc(drive, pc->current_position, bcount); else ide_floppy_io_buffers(drive, pc, bcount, - test_bit(PC_WRITING, &pc->flags)); + (PC_FLAG_WRITING & pc->flags)); /* Update the current position */ pc->actually_transferred += bcount; @@ -738,13 +749,13 @@ static ide_startstop_t idefloppy_issue_pc (ide_drive_t *drive, idefloppy_pc_t *p floppy->pc = pc; if (pc->retries > IDEFLOPPY_MAX_PC_RETRIES || - test_bit(PC_ABORT, &pc->flags)) { + (PC_FLAG_ABORT & pc->flags)) { /* * We will "abort" retrying a packet command in case * a legitimate error code was received. */ - if (!test_bit(PC_ABORT, &pc->flags)) { - if (!test_bit(PC_SUPPRESS_ERROR, &pc->flags)) + if (!(PC_FLAG_ABORT & pc->flags)) { + if (!(PC_FLAG_SUPPRESS_ERROR & pc->flags)) ide_floppy_report_error(floppy, pc); /* Giving up */ pc->error = IDEFLOPPY_ERROR_GENERAL; @@ -762,24 +773,25 @@ static ide_startstop_t idefloppy_issue_pc (ide_drive_t *drive, idefloppy_pc_t *p pc->current_position = pc->buffer; bcount = min(pc->request_transfer, 63 * 1024); - if (test_and_clear_bit(PC_DMA_ERROR, &pc->flags)) + if (PC_FLAG_DMA_ERROR & pc->flags) { + pc->flags &= ~PC_FLAG_DMA_ERROR; ide_dma_off(drive); - + } dma = 0; - if (test_bit(PC_DMA_RECOMMENDED, &pc->flags) && drive->using_dma) + if ((PC_FLAG_DMA_RECOMMENDED & pc->flags) && drive->using_dma) dma = !hwif->dma_setup(drive); ide_pktcmd_tf_load(drive, IDE_TFLAG_NO_SELECT_MASK | IDE_TFLAG_OUT_DEVICE, bcount, dma); if (dma) { /* Begin DMA, if necessary */ - set_bit(PC_DMA_IN_PROGRESS, &pc->flags); + pc->flags |= PC_FLAG_DMA_IN_PROGRESS; hwif->dma_start(drive); } /* Can we transfer the packet when we get the interrupt or wait? */ - if (test_bit(IDEFLOPPY_ZIP_DRIVE, &floppy->flags)) { + if (IDEFLOPPY_FLAG_ZIP_DRIVE & floppy->flags) { /* wait */ pkt_xfer_routine = &idefloppy_transfer_pc1; } else { @@ -787,7 +799,7 @@ static ide_startstop_t idefloppy_issue_pc (ide_drive_t *drive, idefloppy_pc_t *p pkt_xfer_routine = &idefloppy_transfer_pc; } - if (test_bit (IDEFLOPPY_DRQ_INTERRUPT, &floppy->flags)) { + if (IDEFLOPPY_FLAG_DRQ_INTERRUPT & floppy->flags) { /* Issue the packet command */ ide_execute_command(drive, WIN_PACKETCMD, pkt_xfer_routine, @@ -845,7 +857,7 @@ static void idefloppy_create_format_unit_cmd (idefloppy_pc_t *pc, int b, int l, put_unaligned(cpu_to_be32(b), (unsigned int *)(&pc->buffer[4])); put_unaligned(cpu_to_be32(l), (unsigned int *)(&pc->buffer[8])); pc->buffer_size=12; - set_bit(PC_WRITING, &pc->flags); + pc->flags |= PC_FLAG_WRITING; } /* @@ -907,10 +919,10 @@ static void idefloppy_create_rw_cmd(idefloppy_floppy_t *floppy, pc->rq = rq; pc->b_count = cmd == READ ? 0 : rq->bio->bi_size; if (rq->cmd_flags & REQ_RW) - set_bit(PC_WRITING, &pc->flags); + pc->flags |= PC_FLAG_WRITING; pc->buffer = NULL; pc->request_transfer = pc->buffer_size = blocks * floppy->block_size; - set_bit(PC_DMA_RECOMMENDED, &pc->flags); + pc->flags |= PC_FLAG_DMA_RECOMMENDED; } static void @@ -922,11 +934,10 @@ idefloppy_blockpc_cmd(idefloppy_floppy_t *floppy, idefloppy_pc_t *pc, struct req pc->rq = rq; pc->b_count = rq->data_len; if (rq->data_len && rq_data_dir(rq) == WRITE) - set_bit(PC_WRITING, &pc->flags); + pc->flags |= PC_FLAG_WRITING; pc->buffer = rq->data; if (rq->bio) - set_bit(PC_DMA_RECOMMENDED, &pc->flags); - + pc->flags |= PC_FLAG_DMA_RECOMMENDED; /* * possibly problematic, doesn't look like ide-floppy correctly * handled scattered requests if dma fails... @@ -1067,7 +1078,7 @@ static int idefloppy_get_sfrp_bit(ide_drive_t *drive) idefloppy_create_mode_sense_cmd(&pc, IDEFLOPPY_CAPABILITIES_PAGE, MODE_SENSE_CURRENT); - set_bit(PC_SUPPRESS_ERROR, &pc.flags); + pc.flags |= PC_FLAG_SUPPRESS_ERROR; if (idefloppy_queue_pc_tail(drive, &pc)) return 1; @@ -1120,7 +1131,7 @@ static int ide_floppy_get_capacity(ide_drive_t *drive) switch (pc.buffer[desc_start + 4] & 0x03) { /* Clik! drive returns this instead of CAPACITY_CURRENT */ case CAPACITY_UNFORMATTED: - if (!test_bit(IDEFLOPPY_CLIK_DRIVE, &floppy->flags)) + if (!(IDEFLOPPY_FLAG_CLIK_DRIVE & floppy->flags)) /* * If it is not a clik drive, break out * (maintains previous driver behaviour) @@ -1166,7 +1177,7 @@ static int ide_floppy_get_capacity(ide_drive_t *drive) } /* Clik! disk does not support get_flexible_disk_page */ - if (!test_bit(IDEFLOPPY_CLIK_DRIVE, &floppy->flags)) + if (!(IDEFLOPPY_FLAG_CLIK_DRIVE & floppy->flags)) (void) ide_floppy_get_flexible_disk_page(drive); set_capacity(floppy->disk, floppy->blocks * floppy->bs_factor); @@ -1400,7 +1411,7 @@ static void idefloppy_setup (ide_drive_t *drive, idefloppy_floppy_t *floppy) *((u16 *) &gcw) = drive->id->config; floppy->pc = floppy->pc_stack; if (gcw.drq_type == 1) - set_bit(IDEFLOPPY_DRQ_INTERRUPT, &floppy->flags); + floppy->flags |= IDEFLOPPY_FLAG_DRQ_INTERRUPT; /* * We used to check revisions here. At this point however * I'm giving up. Just assume they are all broken, its easier. @@ -1413,7 +1424,7 @@ static void idefloppy_setup (ide_drive_t *drive, idefloppy_floppy_t *floppy) */ if (!strncmp(drive->id->model, "IOMEGA ZIP 100 ATAPI", 20)) { - set_bit(IDEFLOPPY_ZIP_DRIVE, &floppy->flags); + floppy->flags |= IDEFLOPPY_FLAG_ZIP_DRIVE; /* This value will be visible in the /proc/ide/hdx/settings */ floppy->ticks = IDEFLOPPY_TICKS_DELAY; blk_queue_max_sectors(drive->queue, 64); @@ -1426,7 +1437,7 @@ static void idefloppy_setup (ide_drive_t *drive, idefloppy_floppy_t *floppy) */ if (strncmp(drive->id->model, "IOMEGA Clik!", 11) == 0) { blk_queue_max_sectors(drive->queue, 64); - set_bit(IDEFLOPPY_CLIK_DRIVE, &floppy->flags); + floppy->flags |= IDEFLOPPY_FLAG_CLIK_DRIVE; } @@ -1516,7 +1527,7 @@ static int idefloppy_open(struct inode *inode, struct file *filp) floppy->openers++; if (floppy->openers == 1) { - clear_bit(IDEFLOPPY_FORMAT_IN_PROGRESS, &floppy->flags); + floppy->flags &= ~IDEFLOPPY_FLAG_FORMAT_IN_PROGRESS; /* Just in case */ idefloppy_create_test_unit_ready_cmd(&pc); @@ -1541,14 +1552,14 @@ static int idefloppy_open(struct inode *inode, struct file *filp) ret = -EROFS; goto out_put_floppy; } - set_bit(IDEFLOPPY_MEDIA_CHANGED, &floppy->flags); + floppy->flags |= IDEFLOPPY_FLAG_MEDIA_CHANGED; /* IOMEGA Clik! drives do not support lock/unlock commands */ - if (!test_bit(IDEFLOPPY_CLIK_DRIVE, &floppy->flags)) { + if (!(IDEFLOPPY_FLAG_CLIK_DRIVE & floppy->flags)) { idefloppy_create_prevent_cmd(&pc, 1); (void) idefloppy_queue_pc_tail(drive, &pc); } check_disk_change(inode->i_bdev); - } else if (test_bit(IDEFLOPPY_FORMAT_IN_PROGRESS, &floppy->flags)) { + } else if (IDEFLOPPY_FLAG_FORMAT_IN_PROGRESS & floppy->flags) { ret = -EBUSY; goto out_put_floppy; } @@ -1571,12 +1582,12 @@ static int idefloppy_release(struct inode *inode, struct file *filp) if (floppy->openers == 1) { /* IOMEGA Clik! drives do not support lock/unlock commands */ - if (!test_bit(IDEFLOPPY_CLIK_DRIVE, &floppy->flags)) { + if (!(IDEFLOPPY_FLAG_CLIK_DRIVE & floppy->flags)) { idefloppy_create_prevent_cmd(&pc, 0); (void) idefloppy_queue_pc_tail(drive, &pc); } - clear_bit(IDEFLOPPY_FORMAT_IN_PROGRESS, &floppy->flags); + floppy->flags &= ~IDEFLOPPY_FLAG_FORMAT_IN_PROGRESS; } floppy->openers--; @@ -1605,7 +1616,7 @@ static int ide_floppy_lockdoor(idefloppy_floppy_t *floppy, idefloppy_pc_t *pc, /* The IOMEGA Clik! Drive doesn't support this command - * no room for an eject mechanism */ - if (!test_bit(IDEFLOPPY_CLIK_DRIVE, &floppy->flags)) { + if (!(IDEFLOPPY_FLAG_CLIK_DRIVE & floppy->flags)) { int prevent = arg ? 1 : 0; if (cmd == CDROMEJECT) @@ -1631,11 +1642,11 @@ static int ide_floppy_format_unit(idefloppy_floppy_t *floppy, if (floppy->openers > 1) { /* Don't format if someone is using the disk */ - clear_bit(IDEFLOPPY_FORMAT_IN_PROGRESS, &floppy->flags); + floppy->flags &= ~IDEFLOPPY_FLAG_FORMAT_IN_PROGRESS; return -EBUSY; } - set_bit(IDEFLOPPY_FORMAT_IN_PROGRESS, &floppy->flags); + floppy->flags |= IDEFLOPPY_FLAG_FORMAT_IN_PROGRESS; /* * Send ATAPI_FORMAT_UNIT to the drive. @@ -1667,7 +1678,7 @@ static int ide_floppy_format_unit(idefloppy_floppy_t *floppy, out: if (err) - clear_bit(IDEFLOPPY_FORMAT_IN_PROGRESS, &floppy->flags); + floppy->flags &= ~IDEFLOPPY_FLAG_FORMAT_IN_PROGRESS; return err; } @@ -1720,13 +1731,16 @@ static int idefloppy_media_changed(struct gendisk *disk) { struct ide_floppy_obj *floppy = ide_floppy_g(disk); ide_drive_t *drive = floppy->drive; + int ret; /* do not scan partitions twice if this is a removable device */ if (drive->attach) { drive->attach = 0; return 0; } - return test_and_clear_bit(IDEFLOPPY_MEDIA_CHANGED, &floppy->flags); + ret = IDEFLOPPY_FLAG_MEDIA_CHANGED & floppy->flags; + floppy->flags &= ~IDEFLOPPY_FLAG_MEDIA_CHANGED; + return ret; } static int idefloppy_revalidate_disk(struct gendisk *disk) -- 1.5.3.7 ^ permalink raw reply related [flat|nested] 29+ messages in thread
* [PATCH 11/12] ide-floppy: remove IDEFLOPPY_DEBUG_INFO 2008-01-13 20:18 ` [PATCH 10/12] ide-floppy: remove atomic test_*bit macros Borislav Petkov @ 2008-01-13 20:18 ` Borislav Petkov 2008-01-13 20:18 ` [PATCH 12/12] ide-floppy: fix most of the remaining checkpatch.pl issues Borislav Petkov 2008-01-14 21:51 ` [PATCH 11/12] ide-floppy: remove IDEFLOPPY_DEBUG_INFO Bartlomiej Zolnierkiewicz 2008-01-14 21:50 ` [PATCH 10/12] ide-floppy: remove atomic test_*bit macros Bartlomiej Zolnierkiewicz 1 sibling, 2 replies; 29+ messages in thread From: Borislav Petkov @ 2008-01-13 20:18 UTC (permalink / raw) To: bzolnier; +Cc: linux-kernel, linux-ide, Borislav Petkov This info is already available through ioctl() and /proc Signed-off-by: Borislav Petkov <bbpetkov@yahoo.de> --- drivers/ide/ide-floppy.c | 63 +++++++++------------------------------------ 1 files changed, 13 insertions(+), 50 deletions(-) diff --git a/drivers/ide/ide-floppy.c b/drivers/ide/ide-floppy.c index 8e7714a..f9faf26 100644 --- a/drivers/ide/ide-floppy.c +++ b/drivers/ide/ide-floppy.c @@ -47,11 +47,8 @@ #include <linux/io.h> #include <asm/unaligned.h> -/* - * The following are used to debug the driver. - */ +/* define to see debug info */ #define IDEFLOPPY_DEBUG_LOG 0 -#define IDEFLOPPY_DEBUG_INFO 0 /* #define IDEFLOPPY_DEBUG(fmt, args...) printk(KERN_INFO fmt, ## args) */ #define IDEFLOPPY_DEBUG( fmt, args... ) @@ -1314,15 +1311,12 @@ static sector_t idefloppy_capacity (ide_drive_t *drive) } /* - * idefloppy_identify_device checks if we can support a drive, - * based on the ATAPI IDENTIFY command results. + * Check whether we can support a drive, based on the ATAPI IDENTIFY command + * results. */ -static int idefloppy_identify_device (ide_drive_t *drive,struct hd_driveid *id) +static int idefloppy_identify_device(ide_drive_t *drive, struct hd_driveid *id) { struct idefloppy_id_gcw gcw; -#if IDEFLOPPY_DEBUG_INFO - char buffer[80]; -#endif /* IDEFLOPPY_DEBUG_INFO */ *((u16 *) &gcw) = id->config; @@ -1331,54 +1325,23 @@ static int idefloppy_identify_device (ide_drive_t *drive,struct hd_driveid *id) if ((gcw.device_type == 5) && !strstr(id->model, "CD-ROM") && strstr(id->model, "ZIP")) - gcw.device_type = 0; + gcw.device_type = 0; #endif -#if IDEFLOPPY_DEBUG_INFO - printk(KERN_INFO "Dumping ATAPI Identify Device floppy parameters\n"); - switch (gcw.protocol) { - case 0: case 1: sprintf(buffer, "ATA");break; - case 2: sprintf(buffer, "ATAPI");break; - case 3: sprintf(buffer, "Reserved (Unknown to ide-floppy)");break; - } - printk(KERN_INFO "Protocol Type: %s\n", buffer); - switch (gcw.device_type) { - case 0: sprintf(buffer, "Direct-access Device");break; - case 1: sprintf(buffer, "Streaming Tape Device");break; - case 2: case 3: case 4: sprintf (buffer, "Reserved");break; - case 5: sprintf(buffer, "CD-ROM Device");break; - case 6: sprintf(buffer, "Reserved"); - case 7: sprintf(buffer, "Optical memory Device");break; - case 0x1f: sprintf(buffer, "Unknown or no Device type");break; - default: sprintf(buffer, "Reserved"); - } - printk(KERN_INFO "Device Type: %x - %s\n", gcw.device_type, buffer); - printk(KERN_INFO "Removable: %s\n",gcw.removable ? "Yes":"No"); - switch (gcw.drq_type) { - case 0: sprintf(buffer, "Microprocessor DRQ");break; - case 1: sprintf(buffer, "Interrupt DRQ");break; - case 2: sprintf(buffer, "Accelerated DRQ");break; - case 3: sprintf(buffer, "Reserved");break; - } - printk(KERN_INFO "Command Packet DRQ Type: %s\n", buffer); - switch (gcw.packet_size) { - case 0: sprintf(buffer, "12 bytes");break; - case 1: sprintf(buffer, "16 bytes");break; - default: sprintf(buffer, "Reserved");break; - } - printk(KERN_INFO "Command Packet Size: %s\n", buffer); -#endif /* IDEFLOPPY_DEBUG_INFO */ - if (gcw.protocol != 2) - printk(KERN_ERR "ide-floppy: Protocol is not ATAPI\n"); + printk(KERN_ERR "ide-floppy: Protocol 0x%02x not ATAPI\n", + gcw.protocol); else if (gcw.device_type != 0) - printk(KERN_ERR "ide-floppy: Device type is not set to floppy\n"); + printk(KERN_ERR "ide-floppy: Device type 0x%02x is not set to " + "floppy\n", gcw.device_type); else if (!gcw.removable) printk(KERN_ERR "ide-floppy: The removable flag is not set\n"); else if (gcw.drq_type == 3) { - printk(KERN_ERR "ide-floppy: Sorry, DRQ type %d not supported\n", gcw.drq_type); + printk(KERN_ERR "ide-floppy: Sorry, DRQ type %d not " + "supported\n", gcw.drq_type); } else if (gcw.packet_size != 0) { - printk(KERN_ERR "ide-floppy: Packet size is not 12 bytes long\n"); + printk(KERN_ERR "ide-floppy: Packet size is not 12 bytes " + "long\n"); } else return 1; return 0; -- 1.5.3.7 ^ permalink raw reply related [flat|nested] 29+ messages in thread
* [PATCH 12/12] ide-floppy: fix most of the remaining checkpatch.pl issues 2008-01-13 20:18 ` [PATCH 11/12] ide-floppy: remove IDEFLOPPY_DEBUG_INFO Borislav Petkov @ 2008-01-13 20:18 ` Borislav Petkov 2008-01-15 20:12 ` (was: Re:...) [PATCH 12/12] ide-floppy: fix most of the remaining checkpatch.pl issues-v2 Borislav Petkov 2008-01-14 21:51 ` [PATCH 11/12] ide-floppy: remove IDEFLOPPY_DEBUG_INFO Bartlomiej Zolnierkiewicz 1 sibling, 1 reply; 29+ messages in thread From: Borislav Petkov @ 2008-01-13 20:18 UTC (permalink / raw) To: bzolnier; +Cc: linux-kernel, linux-ide, Borislav Petkov such as ERROR: switch and case should be at the same indent ERROR: need spaces around that '=' (ctx:VxV) ERROR: trailing statements should be on next line WARNING: no space between function name and open parenthesis '(' WARNING: printk() should include KERN_ facility level ERROR: That open brace { should be on the previous line ERROR: use tabs not spaces ERROR: do not use assignment in if condition WARNING: braces {} are not necessary for single statement blocks ERROR: need space after that ',' (ctx:VxV) WARNING: line over 80 characters ERROR: do not use assignment in if condition ... and so on. Signed-off-by: Borislav Petkov <bbpetkov@yahoo.de> --- drivers/ide/ide-floppy.c | 357 +++++++++++++++++++++------------------------- 1 files changed, 161 insertions(+), 196 deletions(-) diff --git a/drivers/ide/ide-floppy.c b/drivers/ide/ide-floppy.c index f9faf26..9361dfd 100644 --- a/drivers/ide/ide-floppy.c +++ b/drivers/ide/ide-floppy.c @@ -4,9 +4,7 @@ * Copyright (C) 1996-1999 Gadi Oxman <gadio@netvision.net.il> * Copyright (C) 2000-2002 Paul Bristow <paul@paulbristow.net> * Copyright (C) 2005 Bartlomiej Zolnierkiewicz - */ - -/* + * * The driver currently doesn't have any fancy features, just the bare * minimum read/write support. * @@ -51,57 +49,56 @@ #define IDEFLOPPY_DEBUG_LOG 0 /* #define IDEFLOPPY_DEBUG(fmt, args...) printk(KERN_INFO fmt, ## args) */ -#define IDEFLOPPY_DEBUG( fmt, args... ) +#define IDEFLOPPY_DEBUG(fmt, args...) #if IDEFLOPPY_DEBUG_LOG #define debug_log(fmt, args...) \ printk(KERN_INFO "ide-floppy: " fmt, ## args) #else -#define debug_log(fmt, args... ) do {} while(0) +#define debug_log(fmt, args...) do {} while (0) #endif -/* - * Some drives require a longer irq timeout. - */ +/* Some drives require a longer irq timeout. */ #define IDEFLOPPY_WAIT_CMD (5 * WAIT_CMD) /* - * After each failed packet command we issue a request sense command - * and retry the packet command IDEFLOPPY_MAX_PC_RETRIES times. + * After each failed packet command we issue a request sense command and retry + * the packet command IDEFLOPPY_MAX_PC_RETRIES times. */ #define IDEFLOPPY_MAX_PC_RETRIES 3 /* - * With each packet command, we allocate a buffer of - * IDEFLOPPY_PC_BUFFER_SIZE bytes. + * With each packet command, we allocate a buffer of IDEFLOPPY_PC_BUFFER_SIZE + * bytes. */ #define IDEFLOPPY_PC_BUFFER_SIZE 256 /* - * In various places in the driver, we need to allocate storage - * for packet commands and requests, which will remain valid while - * we leave the driver to wait for an interrupt or a timeout event. + * In various places in the driver, we need to allocate storage for packet + * commands and requests, which will remain valid while we leave the driver to + * wait for an interrupt or a timeout event. */ #define IDEFLOPPY_PC_STACK (10 + IDEFLOPPY_MAX_PC_RETRIES) -/* - * Our view of a packet command. - */ typedef struct idefloppy_packet_command_s { u8 c[12]; /* Actual packet bytes */ - int retries; /* On each retry, we increment retries */ + int retries; /* On each retry, we increment + retries */ int error; /* Error code */ int request_transfer; /* Bytes to transfer */ int actually_transferred; /* Bytes actually transferred */ int buffer_size; /* Size of our data buffer */ - int b_count; /* Missing/Available data on the current buffer */ + int b_count; /* Missing/Available data on + the current buffer */ struct request *rq; /* The corresponding request */ u8 *buffer; /* Data buffer */ - u8 *current_position; /* Pointer into the above buffer */ - void (*callback) (ide_drive_t *); /* Called when this packet command is completed */ + u8 *current_position; /* Pointer into above buffer */ + void (*callback) (ide_drive_t *); /* Called when this packet + command is completed */ u8 pc_buffer[IDEFLOPPY_PC_BUFFER_SIZE]; /* Temporary buffer */ - unsigned long flags; /* Status/Action bit flags: long for set_bit */ + unsigned long flags; /* Status/Action bit flags: long + for set_bit */ } idefloppy_pc_t; /* Packet command flag bits. */ @@ -127,9 +124,9 @@ enum { #define CAPACITY_NO_CARTRIDGE 0x03 /* - * Most of our global data which we need to save even as we leave the - * driver due to an interrupt or a timer event is stored in a variable - * of type idefloppy_floppy_t, defined below. + * Most of our global data which we need to save even as we leave the driver + * due to an interrupt or a timer event is stored in a variable of type + * idefloppy_floppy_t, defined below. */ typedef struct ide_floppy_obj { ide_drive_t *drive; @@ -150,17 +147,13 @@ typedef struct ide_floppy_obj { /* We implement a circular array */ int rq_stack_index; - /* - * Last error information - */ + /* Last error information */ u8 sense_key, asc, ascq; /* delay this long before sending packet command */ u8 ticks; int progress_indication; - /* - * Device information - */ + /* Device information */ /* Current format */ int blocks, block_size, bs_factor; /* Last format capacity descriptor */ @@ -191,34 +184,26 @@ enum { IDEFLOPPY_FLAG_ZIP_DRIVE = (1 << 4), }; -/* - * Defines for the mode sense command - */ +/* Defines for the MODE SENSE command */ #define MODE_SENSE_CURRENT 0x00 #define MODE_SENSE_CHANGEABLE 0x01 -#define MODE_SENSE_DEFAULT 0x02 +#define MODE_SENSE_DEFAULT 0x02 #define MODE_SENSE_SAVED 0x03 -/* - * IOCTLs used in low-level formatting. - */ - +/* IOCTLs used in low-level formatting. */ #define IDEFLOPPY_IOCTL_FORMAT_SUPPORTED 0x4600 #define IDEFLOPPY_IOCTL_FORMAT_GET_CAPACITY 0x4601 #define IDEFLOPPY_IOCTL_FORMAT_START 0x4602 #define IDEFLOPPY_IOCTL_FORMAT_GET_PROGRESS 0x4603 -/* - * Error codes which are returned in rq->errors to the higher part - * of the driver. - */ +/* Error code returned in rq->errors to the higher part of the driver. */ #define IDEFLOPPY_ERROR_GENERAL 101 /* - * The following is used to format the general configuration word of - * the ATAPI IDENTIFY DEVICE command. + * The following is used to format the general configuration word of the + * ATAPI IDENTIFY DEVICE command. */ -struct idefloppy_id_gcw { +struct idefloppy_id_gcw { #if defined(__LITTLE_ENDIAN_BITFIELD) unsigned packet_size :2; /* Packet Size */ unsigned reserved234 :3; /* Reserved */ @@ -276,10 +261,10 @@ static void ide_floppy_put(struct ide_floppy_obj *floppy) } /* - * Too bad. The drive wants to send us data which we are not ready to accept. - * Just throw it away. + * Too bad. The drive wants to send us data which we are not ready to accept. + * Just throw it away. */ -static void idefloppy_discard_data (ide_drive_t *drive, unsigned int bcount) +static void idefloppy_discard_data(ide_drive_t *drive, unsigned int bcount) { while (bcount--) (void) HWIF(drive)->INB(IDE_DATA_REG); @@ -293,10 +278,8 @@ static void idefloppy_write_zeros(ide_drive_t *drive, unsigned int bcount) /* - * idefloppy_do_end_request is used to finish servicing a request. - * - * For read/write requests, we will call ide_end_request to pass to the - * next buffer. + * Used to finish servicing a request. For read/write requests, we will call + * ide_end_request to pass to the next buffer. */ static int idefloppy_do_end_request(ide_drive_t *drive, int uptodate, int nsecs) { @@ -307,9 +290,9 @@ static int idefloppy_do_end_request(ide_drive_t *drive, int uptodate, int nsecs) debug_log("Reached %s\n", __FUNCTION__); switch (uptodate) { - case 0: error = IDEFLOPPY_ERROR_GENERAL; break; - case 1: error = 0; break; - default: error = uptodate; + case 0: error = IDEFLOPPY_ERROR_GENERAL; break; + case 1: error = 0; break; + default: error = uptodate; } if (error) floppy->failed_pc = NULL; @@ -368,7 +351,7 @@ static void ide_floppy_io_buffers(ide_drive_t *drive, idefloppy_pc_t *pc, } } -static void idefloppy_update_buffers (ide_drive_t *drive, idefloppy_pc_t *pc) +static void idefloppy_update_buffers(ide_drive_t *drive, idefloppy_pc_t *pc) { struct request *rq = pc->rq; struct bio *bio = rq->bio; @@ -378,11 +361,12 @@ static void idefloppy_update_buffers (ide_drive_t *drive, idefloppy_pc_t *pc) } /* - * idefloppy_queue_pc_head generates a new packet command request in front - * of the request queue, before the current request, so that it will be - * processed immediately, on the next pass through the driver. + * Generate a new packet command request in front of the request queue, before + * the current request so that it will be processed immediately, on the next + * pass through the driver. */ -static void idefloppy_queue_pc_head (ide_drive_t *drive,idefloppy_pc_t *pc,struct request *rq) +static void idefloppy_queue_pc_head(ide_drive_t *drive, idefloppy_pc_t *pc, + struct request *rq) { struct ide_floppy_obj *floppy = drive->driver_data; @@ -393,16 +377,16 @@ static void idefloppy_queue_pc_head (ide_drive_t *drive,idefloppy_pc_t *pc,struc (void) ide_do_drive_cmd(drive, rq, ide_preempt); } -static idefloppy_pc_t *idefloppy_next_pc_storage (ide_drive_t *drive) +static idefloppy_pc_t *idefloppy_next_pc_storage(ide_drive_t *drive) { idefloppy_floppy_t *floppy = drive->driver_data; if (floppy->pc_stack_index == IDEFLOPPY_PC_STACK) - floppy->pc_stack_index=0; + floppy->pc_stack_index = 0; return (&floppy->pc_stack[floppy->pc_stack_index++]); } -static struct request *idefloppy_next_rq_storage (ide_drive_t *drive) +static struct request *idefloppy_next_rq_storage(ide_drive_t *drive) { idefloppy_floppy_t *floppy = drive->driver_data; @@ -447,10 +431,8 @@ static void idefloppy_request_sense_callback(ide_drive_t *drive) } } -/* - * General packet command callback function. - */ -static void idefloppy_pc_callback (ide_drive_t *drive) +/* General packet command callback function. */ +static void idefloppy_pc_callback(ide_drive_t *drive) { idefloppy_floppy_t *floppy = drive->driver_data; @@ -459,10 +441,7 @@ static void idefloppy_pc_callback (ide_drive_t *drive) idefloppy_do_end_request(drive, floppy->pc->error ? 0 : 1, 0); } -/* - * idefloppy_init_pc initializes a packet command. - */ -static void idefloppy_init_pc (idefloppy_pc_t *pc) +static void idefloppy_init_pc(idefloppy_pc_t *pc) { memset(pc->c, 0, 12); pc->retries = 0; @@ -473,7 +452,7 @@ static void idefloppy_init_pc (idefloppy_pc_t *pc) pc->callback = &idefloppy_pc_callback; } -static void idefloppy_create_request_sense_cmd (idefloppy_pc_t *pc) +static void idefloppy_create_request_sense_cmd(idefloppy_pc_t *pc) { idefloppy_init_pc(pc); pc->c[0] = GPCMD_REQUEST_SENSE; @@ -483,11 +462,10 @@ static void idefloppy_create_request_sense_cmd (idefloppy_pc_t *pc) } /* - * idefloppy_retry_pc is called when an error was detected during the - * last packet command. We queue a request sense packet command in - * the head of the request list. + * Called when an error was detected during the last packet command. We queue a + * request sense packet command in the head of the request list. */ -static void idefloppy_retry_pc (ide_drive_t *drive) +static void idefloppy_retry_pc(ide_drive_t *drive) { idefloppy_pc_t *pc; struct request *rq; @@ -531,7 +509,8 @@ static ide_startstop_t idefloppy_pc_intr(ide_drive_t *drive) /* Clear the interrupt */ stat = drive->hwif->INB(IDE_STATUS_REG); - if ((stat & DRQ_STAT) == 0) { /* No more interrupts */ + /* No more interrupts */ + if ((stat & DRQ_STAT) == 0) { debug_log("Packet command completed, %d bytes transferred\n", pc->actually_transferred); pc->flags &= ~PC_FLAG_DMA_IN_PROGRESS; @@ -631,7 +610,7 @@ static ide_startstop_t idefloppy_pc_intr(ide_drive_t *drive) * It fails at high speeds on the Iomega ZIP drive, so there's a slower version * for that drive below. The algorithm is chosen based on drive type */ -static ide_startstop_t idefloppy_transfer_pc (ide_drive_t *drive) +static ide_startstop_t idefloppy_transfer_pc(ide_drive_t *drive) { ide_startstop_t startstop; idefloppy_floppy_t *floppy = drive->driver_data; @@ -658,18 +637,16 @@ static ide_startstop_t idefloppy_transfer_pc (ide_drive_t *drive) /* - * What we have here is a classic case of a top half / bottom half - * interrupt service routine. In interrupt mode, the device sends - * an interrupt to signal it's ready to receive a packet. However, - * we need to delay about 2-3 ticks before issuing the packet or we - * gets in trouble. + * What we have here is a classic case of a top half / bottom half interrupt + * service routine. In interrupt mode, the device sends an interrupt to signal + * that it is ready to receive a packet. However, we need to delay about 2-3 + * ticks before issuing the packet or we gets in trouble. * - * So, follow carefully. transfer_pc1 is called as an interrupt (or - * directly). In either case, when the device says it's ready for a - * packet, we schedule the packet transfer to occur about 2-3 ticks - * later in transfer_pc2. + * So, follow carefully. transfer_pc1 is called as an interrupt (or directly). + * In either case, when the device says it's ready for a packet, we schedule + * the packet transfer to occur about 2-3 ticks later in transfer_pc2. */ -static int idefloppy_transfer_pc2 (ide_drive_t *drive) +static int idefloppy_transfer_pc2(ide_drive_t *drive) { idefloppy_floppy_t *floppy = drive->driver_data; @@ -679,7 +656,7 @@ static int idefloppy_transfer_pc2 (ide_drive_t *drive) return IDEFLOPPY_WAIT_CMD; } -static ide_startstop_t idefloppy_transfer_pc1 (ide_drive_t *drive) +static ide_startstop_t idefloppy_transfer_pc1(ide_drive_t *drive) { idefloppy_floppy_t *floppy = drive->driver_data; ide_startstop_t startstop; @@ -696,7 +673,7 @@ static ide_startstop_t idefloppy_transfer_pc1 (ide_drive_t *drive) "while issuing a packet command\n"); return ide_do_reset(drive); } - /* + /* * The following delay solves a problem with ATAPI Zip 100 drives * where the Busy flag was apparently being deasserted before the * unit was ready to receive data. This was happening on a @@ -705,10 +682,8 @@ static ide_startstop_t idefloppy_transfer_pc1 (ide_drive_t *drive) * used until after the packet is moved in about 50 msec. */ - ide_set_handler(drive, - &idefloppy_pc_intr, /* service routine for packet command */ - floppy->ticks, /* wait this long before "failing" */ - &idefloppy_transfer_pc2); /* fail == transfer_pc2 */ + ide_set_handler(drive, &idefloppy_pc_intr, floppy->ticks, + &idefloppy_transfer_pc2); return ide_started; } @@ -728,10 +703,8 @@ static void ide_floppy_report_error(idefloppy_floppy_t *floppy, } -/* - * Issue a packet command - */ -static ide_startstop_t idefloppy_issue_pc (ide_drive_t *drive, idefloppy_pc_t *pc) +static ide_startstop_t idefloppy_issue_pc(ide_drive_t *drive, + idefloppy_pc_t *pc) { idefloppy_floppy_t *floppy = drive->driver_data; ide_hwif_t *hwif = drive->hwif; @@ -782,7 +755,8 @@ static ide_startstop_t idefloppy_issue_pc (ide_drive_t *drive, idefloppy_pc_t *p ide_pktcmd_tf_load(drive, IDE_TFLAG_NO_SELECT_MASK | IDE_TFLAG_OUT_DEVICE, bcount, dma); - if (dma) { /* Begin DMA, if necessary */ + if (dma) { + /* Begin DMA, if necessary */ pc->flags |= PC_FLAG_DMA_IN_PROGRESS; hwif->dma_start(drive); } @@ -795,7 +769,7 @@ static ide_startstop_t idefloppy_issue_pc (ide_drive_t *drive, idefloppy_pc_t *p /* immediate */ pkt_xfer_routine = &idefloppy_transfer_pc; } - + if (IDEFLOPPY_FLAG_DRQ_INTERRUPT & floppy->flags) { /* Issue the packet command */ ide_execute_command(drive, WIN_PACKETCMD, @@ -810,7 +784,7 @@ static ide_startstop_t idefloppy_issue_pc (ide_drive_t *drive, idefloppy_pc_t *p } } -static void idefloppy_rw_callback (ide_drive_t *drive) +static void idefloppy_rw_callback(ide_drive_t *drive) { debug_log("Reached %s\n", __FUNCTION__); @@ -818,7 +792,7 @@ static void idefloppy_rw_callback (ide_drive_t *drive) return; } -static void idefloppy_create_prevent_cmd (idefloppy_pc_t *pc, int prevent) +static void idefloppy_create_prevent_cmd(idefloppy_pc_t *pc, int prevent) { debug_log("creating prevent removal command, prevent = %d\n", prevent); @@ -827,7 +801,7 @@ static void idefloppy_create_prevent_cmd (idefloppy_pc_t *pc, int prevent) pc->c[4] = prevent; } -static void idefloppy_create_read_capacity_cmd (idefloppy_pc_t *pc) +static void idefloppy_create_read_capacity_cmd(idefloppy_pc_t *pc) { idefloppy_init_pc(pc); pc->c[0] = GPCMD_READ_FORMAT_CAPACITIES; @@ -836,7 +810,7 @@ static void idefloppy_create_read_capacity_cmd (idefloppy_pc_t *pc) pc->request_transfer = 255; } -static void idefloppy_create_format_unit_cmd (idefloppy_pc_t *pc, int b, int l, +static void idefloppy_create_format_unit_cmd(idefloppy_pc_t *pc, int b, int l, int flags) { idefloppy_init_pc(pc); @@ -853,38 +827,37 @@ static void idefloppy_create_format_unit_cmd (idefloppy_pc_t *pc, int b, int l, put_unaligned(cpu_to_be32(b), (unsigned int *)(&pc->buffer[4])); put_unaligned(cpu_to_be32(l), (unsigned int *)(&pc->buffer[8])); - pc->buffer_size=12; + pc->buffer_size = 12; pc->flags |= PC_FLAG_WRITING; } -/* - * A mode sense command is used to "sense" floppy parameters. - */ -static void idefloppy_create_mode_sense_cmd (idefloppy_pc_t *pc, u8 page_code, u8 type) +/* A mode sense command is used to "sense" floppy parameters. */ +static void idefloppy_create_mode_sense_cmd(idefloppy_pc_t *pc, u8 page_code, + u8 type) { u16 length = 8; /* sizeof(Mode Parameter Header) = 8 Bytes */ - + idefloppy_init_pc(pc); pc->c[0] = GPCMD_MODE_SENSE_10; pc->c[1] = 0; pc->c[2] = page_code + (type << 6); switch (page_code) { - case IDEFLOPPY_CAPABILITIES_PAGE: - length += 12; - break; - case IDEFLOPPY_FLEXIBLE_DISK_PAGE: - length += 32; - break; - default: - printk(KERN_ERR "ide-floppy: unsupported page code " + case IDEFLOPPY_CAPABILITIES_PAGE: + length += 12; + break; + case IDEFLOPPY_FLEXIBLE_DISK_PAGE: + length += 32; + break; + default: + printk(KERN_ERR "ide-floppy: unsupported page code " "in create_mode_sense_cmd\n"); } put_unaligned(cpu_to_be16(length), (u16 *) &pc->c[7]); pc->request_transfer = length; } -static void idefloppy_create_start_stop_cmd (idefloppy_pc_t *pc, int start) +static void idefloppy_create_start_stop_cmd(idefloppy_pc_t *pc, int start) { idefloppy_init_pc(pc); pc->c[0] = GPCMD_START_STOP_UNIT; @@ -922,8 +895,8 @@ static void idefloppy_create_rw_cmd(idefloppy_floppy_t *floppy, pc->flags |= PC_FLAG_DMA_RECOMMENDED; } -static void -idefloppy_blockpc_cmd(idefloppy_floppy_t *floppy, idefloppy_pc_t *pc, struct request *rq) +static void idefloppy_blockpc_cmd(idefloppy_floppy_t *floppy, + idefloppy_pc_t *pc, struct request *rq) { idefloppy_init_pc(pc); pc->callback = &idefloppy_rw_callback; @@ -942,10 +915,8 @@ idefloppy_blockpc_cmd(idefloppy_floppy_t *floppy, idefloppy_pc_t *pc, struct req pc->request_transfer = pc->buffer_size = rq->data_len; } -/* - * idefloppy_do_request is our request handling function. - */ -static ide_startstop_t idefloppy_do_request (ide_drive_t *drive, struct request *rq, sector_t block_s) +static ide_startstop_t idefloppy_do_request(ide_drive_t *drive, + struct request *rq, sector_t block_s) { idefloppy_floppy_t *floppy = drive->driver_data; idefloppy_pc_t *pc; @@ -970,8 +941,8 @@ static ide_startstop_t idefloppy_do_request (ide_drive_t *drive, struct request if (blk_fs_request(rq)) { if (((long)rq->sector % floppy->bs_factor) || (rq->nr_sectors % floppy->bs_factor)) { - printk("%s: unsupported r/w request size\n", - drive->name); + printk(KERN_ERR "%s: unsupported r/w request size\n", + drive->name); idefloppy_do_end_request(drive, 0, 0); return ide_stopped; } @@ -994,15 +965,15 @@ static ide_startstop_t idefloppy_do_request (ide_drive_t *drive, struct request } /* - * idefloppy_queue_pc_tail adds a special packet command request to the - * tail of the request queue, and waits for it to be serviced. + * Add a special packet command request to the tail of the request queue, + * and wait for it to be serviced. */ -static int idefloppy_queue_pc_tail (ide_drive_t *drive,idefloppy_pc_t *pc) +static int idefloppy_queue_pc_tail(ide_drive_t *drive, idefloppy_pc_t *pc) { struct ide_floppy_obj *floppy = drive->driver_data; struct request rq; - ide_init_drive_cmd (&rq); + ide_init_drive_cmd(&rq); rq.buffer = (char *) pc; rq.cmd_type = REQ_TYPE_SPECIAL; rq.rq_disk = floppy->disk; @@ -1129,7 +1100,7 @@ static int ide_floppy_get_capacity(ide_drive_t *drive) /* Clik! drive returns this instead of CAPACITY_CURRENT */ case CAPACITY_UNFORMATTED: if (!(IDEFLOPPY_FLAG_CLIK_DRIVE & floppy->flags)) - /* + /* * If it is not a clik drive, break out * (maintains previous driver behaviour) */ @@ -1255,14 +1226,14 @@ static int ide_floppy_get_format_capacities(ide_drive_t *drive, int __user *arg) } /* -** Get ATAPI_FORMAT_UNIT progress indication. -** -** Userland gives a pointer to an int. The int is set to a progress -** indicator 0-65536, with 65536=100%. -** -** If the drive does not support format progress indication, we just check -** the dsc bit, and return either 0 or 65536. -*/ + * Get ATAPI_FORMAT_UNIT progress indication. + * + * Userland gives a pointer to an int. The int is set to a progress + * indicator 0-65536, with 65536=100%. + * + * If the drive does not support format progress indication, we just check + * the dsc bit, and return either 0 or 65536. + */ static int idefloppy_get_format_progress(ide_drive_t *drive, int __user *arg) { @@ -1272,17 +1243,15 @@ static int idefloppy_get_format_progress(ide_drive_t *drive, int __user *arg) if (floppy->srfp) { idefloppy_create_request_sense_cmd(&pc); - if (idefloppy_queue_pc_tail(drive, &pc)) { + if (idefloppy_queue_pc_tail(drive, &pc)) return (-EIO); - } if (floppy->sense_key == 2 && floppy->asc == 4 && - floppy->ascq == 4) { + floppy->ascq == 4) progress_indication = floppy->progress_indication; - } - /* Else assume format_unit has finished, and we're - ** at 0x10000 */ + + /* Else assume format_unit has finished, and we're at 0x10000 */ } else { unsigned long flags; u8 stat; @@ -1299,10 +1268,7 @@ static int idefloppy_get_format_progress(ide_drive_t *drive, int __user *arg) return (0); } -/* - * Return the current floppy capacity. - */ -static sector_t idefloppy_capacity (ide_drive_t *drive) +static sector_t idefloppy_capacity(ide_drive_t *drive) { idefloppy_floppy_t *floppy = drive->driver_data; unsigned long capacity = floppy->blocks * floppy->bs_factor; @@ -1352,22 +1318,20 @@ static void idefloppy_add_settings(ide_drive_t *drive) { idefloppy_floppy_t *floppy = drive->driver_data; -/* - * drive setting name read/write data type min max mul_factor div_factor data pointer set function - */ - ide_add_setting(drive, "bios_cyl", SETTING_RW, TYPE_INT, 0, 1023, 1, 1, &drive->bios_cyl, NULL); - ide_add_setting(drive, "bios_head", SETTING_RW, TYPE_BYTE, 0, 255, 1, 1, &drive->bios_head, NULL); - ide_add_setting(drive, "bios_sect", SETTING_RW, TYPE_BYTE, 0, 63, 1, 1, &drive->bios_sect, NULL); - ide_add_setting(drive, "ticks", SETTING_RW, TYPE_BYTE, 0, 255, 1, 1, &floppy->ticks, NULL); + ide_add_setting(drive, "bios_cyl", SETTING_RW, TYPE_INT, 0, 1023, 1, 1, + &drive->bios_cyl, NULL); + ide_add_setting(drive, "bios_head", SETTING_RW, TYPE_BYTE, 0, 255, 1, 1, + &drive->bios_head, NULL); + ide_add_setting(drive, "bios_sect", SETTING_RW, TYPE_BYTE, 0, 63, 1, 1, + &drive->bios_sect, NULL); + ide_add_setting(drive, "ticks", SETTING_RW, TYPE_BYTE, 0, 255, 1, 1, + &floppy->ticks, NULL); } #else static inline void idefloppy_add_settings(ide_drive_t *drive) { ; } #endif -/* - * Driver initialization. - */ -static void idefloppy_setup (ide_drive_t *drive, idefloppy_floppy_t *floppy) +static void idefloppy_setup(ide_drive_t *drive, idefloppy_floppy_t *floppy) { struct idefloppy_id_gcw gcw; @@ -1376,16 +1340,14 @@ static void idefloppy_setup (ide_drive_t *drive, idefloppy_floppy_t *floppy) if (gcw.drq_type == 1) floppy->flags |= IDEFLOPPY_FLAG_DRQ_INTERRUPT; /* - * We used to check revisions here. At this point however - * I'm giving up. Just assume they are all broken, its easier. + * We used to check revisions here. At this point however I'm giving up. + * Just assume they are all broken, its easier. * - * The actual reason for the workarounds was likely - * a driver bug after all rather than a firmware bug, - * and the workaround below used to hide it. It should - * be fixed as of version 1.9, but to be on the safe side - * we'll leave the limitation below for the 2.2.x tree. + * The actual reason for the workarounds was likely a driver bug after + * all rather than a firmware bug, and the workaround below used to hide + * it. It should be fixed as of version 1.9, but to be on the safe side + * we'll leave the limitation below for the 2.2.x tree. */ - if (!strncmp(drive->id->model, "IOMEGA ZIP 100 ATAPI", 20)) { floppy->flags |= IDEFLOPPY_FLAG_ZIP_DRIVE; /* This value will be visible in the /proc/ide/hdx/settings */ @@ -1394,16 +1356,14 @@ static void idefloppy_setup (ide_drive_t *drive, idefloppy_floppy_t *floppy) } /* - * Guess what? The IOMEGA Clik! drive also needs the - * above fix. It makes nasty clicking noises without - * it, so please don't remove this. - */ + * Guess what? The IOMEGA Clik! drive also needs the above fix. It makes + * nasty clicking noises without it, so please don't remove this. + */ if (strncmp(drive->id->model, "IOMEGA Clik!", 11) == 0) { blk_queue_max_sectors(drive->queue, 64); floppy->flags |= IDEFLOPPY_FLAG_CLIK_DRIVE; } - (void) ide_floppy_get_capacity(drive); idefloppy_add_settings(drive); } @@ -1433,19 +1393,19 @@ static void idefloppy_cleanup_obj(struct kref *kref) } #ifdef CONFIG_IDE_PROC_FS -static int proc_idefloppy_read_capacity - (char *page, char **start, off_t off, int count, int *eof, void *data) +static int proc_idefloppy_read_capacity(char *page, char **start, off_t off, + int count, int *eof, void *data) { ide_drive_t*drive = (ide_drive_t *)data; int len; - len = sprintf(page,"%llu\n", (long long)idefloppy_capacity(drive)); - PROC_IDE_READ_RETURN(page,start,off,count,eof,len); + len = sprintf(page, "%llu\n", (long long)idefloppy_capacity(drive)); + PROC_IDE_READ_RETURN(page, start, off, count, eof, len); } static ide_proc_entry_t idefloppy_proc[] = { - { "capacity", S_IFREG|S_IRUGO, proc_idefloppy_read_capacity, NULL }, - { "geometry", S_IFREG|S_IRUGO, proc_ide_read_geometry, NULL }, + { "capacity", S_IFREG|S_IRUGO, proc_idefloppy_read_capacity, NULL }, + { "geometry", S_IFREG|S_IRUGO, proc_ide_read_geometry, NULL }, { NULL, 0, NULL, NULL } }; #endif /* CONFIG_IDE_PROC_FS */ @@ -1482,7 +1442,8 @@ static int idefloppy_open(struct inode *inode, struct file *filp) debug_log("Reached %s\n", __FUNCTION__); - if (!(floppy = ide_floppy_get(disk))) + floppy = ide_floppy_get(disk); + if (!floppy) return -ENXIO; drive = floppy->drive; @@ -1502,10 +1463,10 @@ static int idefloppy_open(struct inode *inode, struct file *filp) if (ide_floppy_get_capacity(drive) && (filp->f_flags & O_NDELAY) == 0 /* - ** Allow O_NDELAY to open a drive without a disk, or with - ** an unreadable disk, so that we can get the format - ** capacity of the drive or begin the format - Sam - */ + * Allow O_NDELAY to open a drive without a disk, or with an + * unreadable disk, so that we can get the format capacity + * of the drive or begin the format - Sam + */ ) { ret = -EIO; goto out_put_floppy; @@ -1734,16 +1695,20 @@ static int ide_floppy_probe(ide_drive_t *drive) goto failed; if (drive->media != ide_floppy) goto failed; - if (!idefloppy_identify_device (drive, drive->id)) { - printk (KERN_ERR "ide-floppy: %s: not supported by this version of ide-floppy\n", drive->name); + if (!idefloppy_identify_device(drive, drive->id)) { + printk(KERN_ERR "ide-floppy: %s: not supported by this version" + " of ide-floppy\n", drive->name); goto failed; } if (drive->scsi) { - printk("ide-floppy: passing drive %s to ide-scsi emulation.\n", drive->name); + printk(KERN_INFO "ide-floppy: passing drive %s to ide-scsi" + " emulation.\n", drive->name); goto failed; } - if ((floppy = kzalloc(sizeof (idefloppy_floppy_t), GFP_KERNEL)) == NULL) { - printk (KERN_ERR "ide-floppy: %s: Can't allocate a floppy structure\n", drive->name); + floppy = kzalloc(sizeof(idefloppy_floppy_t), GFP_KERNEL); + if (!floppy) { + printk(KERN_ERR "ide-floppy: %s: Can't allocate a floppy" + " structure\n", drive->name); goto failed; } @@ -1765,7 +1730,7 @@ static int ide_floppy_probe(ide_drive_t *drive) drive->driver_data = floppy; - idefloppy_setup (drive, floppy); + idefloppy_setup(drive, floppy); g->minors = 1 << PARTN_BITS; g->driverfs_dev = &drive->gendev; @@ -1781,9 +1746,7 @@ failed: return -ENODEV; } -MODULE_DESCRIPTION("ATAPI FLOPPY Driver"); - -static void __exit idefloppy_exit (void) +static void __exit idefloppy_exit(void) { driver_unregister(&idefloppy_driver.gen_driver); } @@ -1798,3 +1761,5 @@ MODULE_ALIAS("ide:*m-floppy*"); module_init(idefloppy_init); module_exit(idefloppy_exit); MODULE_LICENSE("GPL"); +MODULE_DESCRIPTION("ATAPI FLOPPY Driver"); + -- 1.5.3.7 ^ permalink raw reply related [flat|nested] 29+ messages in thread
* (was: Re:...) [PATCH 12/12] ide-floppy: fix most of the remaining checkpatch.pl issues-v2 2008-01-13 20:18 ` [PATCH 12/12] ide-floppy: fix most of the remaining checkpatch.pl issues Borislav Petkov @ 2008-01-15 20:12 ` Borislav Petkov 2008-01-16 22:51 ` Bartlomiej Zolnierkiewicz 0 siblings, 1 reply; 29+ messages in thread From: Borislav Petkov @ 2008-01-15 20:12 UTC (permalink / raw) To: bzolnier; +Cc: linux-kernel, linux-ide ... and finally the last one. Whew! I think we're done here for now. :) -- From: Borislav Petkov <bbpetkov@yahoo.de> Date: Tue, 15 Jan 2008 21:01:04 +0100 Subject: ide-floppy: fix most of the remaining checkpatch.pl issues-v2 such as ERROR: switch and case should be at the same indent ERROR: need spaces around that '=' (ctx:VxV) ERROR: trailing statements should be on next line WARNING: no space between function name and open parenthesis '(' WARNING: printk() should include KERN_ facility level ERROR: That open brace { should be on the previous line ERROR: use tabs not spaces ERROR: do not use assignment in if condition WARNING: braces {} are not necessary for single statement blocks ERROR: need space after that ',' (ctx:VxV) WARNING: line over 80 characters ERROR: do not use assignment in if condition ... and so on. Signed-off-by: Borislav Petkov <bbpetkov@yahoo.de> :100644 100644 4b9a7e9... 0bf6596... M drivers/ide/ide-floppy.c diff --git a/drivers/ide/ide-floppy.c b/drivers/ide/ide-floppy.c index 4b9a7e9..0bf6596 100644 --- a/drivers/ide/ide-floppy.c +++ b/drivers/ide/ide-floppy.c @@ -4,9 +4,7 @@ * Copyright (C) 1996-1999 Gadi Oxman <gadio@netvision.net.il> * Copyright (C) 2000-2002 Paul Bristow <paul@paulbristow.net> * Copyright (C) 2005 Bartlomiej Zolnierkiewicz - */ - -/* + * * The driver currently doesn't have any fancy features, just the bare * minimum read/write support. * @@ -51,57 +49,56 @@ #define IDEFLOPPY_DEBUG_LOG 0 /* #define IDEFLOPPY_DEBUG(fmt, args...) printk(KERN_INFO fmt, ## args) */ -#define IDEFLOPPY_DEBUG( fmt, args... ) +#define IDEFLOPPY_DEBUG(fmt, args...) #if IDEFLOPPY_DEBUG_LOG #define debug_log(fmt, args...) \ printk(KERN_INFO "ide-floppy: " fmt, ## args) #else -#define debug_log(fmt, args... ) do {} while(0) +#define debug_log(fmt, args...) do {} while (0) #endif -/* - * Some drives require a longer irq timeout. - */ +/* Some drives require a longer irq timeout. */ #define IDEFLOPPY_WAIT_CMD (5 * WAIT_CMD) /* - * After each failed packet command we issue a request sense command - * and retry the packet command IDEFLOPPY_MAX_PC_RETRIES times. + * After each failed packet command we issue a request sense command and retry + * the packet command IDEFLOPPY_MAX_PC_RETRIES times. */ #define IDEFLOPPY_MAX_PC_RETRIES 3 /* - * With each packet command, we allocate a buffer of - * IDEFLOPPY_PC_BUFFER_SIZE bytes. + * With each packet command, we allocate a buffer of IDEFLOPPY_PC_BUFFER_SIZE + * bytes. */ #define IDEFLOPPY_PC_BUFFER_SIZE 256 /* - * In various places in the driver, we need to allocate storage - * for packet commands and requests, which will remain valid while - * we leave the driver to wait for an interrupt or a timeout event. + * In various places in the driver, we need to allocate storage for packet + * commands and requests, which will remain valid while we leave the driver to + * wait for an interrupt or a timeout event. */ #define IDEFLOPPY_PC_STACK (10 + IDEFLOPPY_MAX_PC_RETRIES) -/* - * Our view of a packet command. - */ typedef struct idefloppy_packet_command_s { u8 c[12]; /* Actual packet bytes */ - int retries; /* On each retry, we increment retries */ + int retries; /* On each retry, we increment + retries */ int error; /* Error code */ int request_transfer; /* Bytes to transfer */ int actually_transferred; /* Bytes actually transferred */ int buffer_size; /* Size of our data buffer */ - int b_count; /* Missing/Available data on the current buffer */ + int b_count; /* Missing/Available data on + the current buffer */ struct request *rq; /* The corresponding request */ u8 *buffer; /* Data buffer */ - u8 *current_position; /* Pointer into the above buffer */ - void (*callback) (ide_drive_t *); /* Called when this packet command is completed */ + u8 *current_position; /* Pointer into above buffer */ + void (*callback) (ide_drive_t *); /* Called when this packet + command is completed */ u8 pc_buffer[IDEFLOPPY_PC_BUFFER_SIZE]; /* Temporary buffer */ - unsigned long flags; /* Status/Action bit flags: long for set_bit */ + unsigned long flags; /* Status/Action bit flags: long + for set_bit */ } idefloppy_pc_t; /* Packet command flag bits. */ @@ -125,9 +122,9 @@ enum { #define CAPACITY_NO_CARTRIDGE 0x03 /* - * Most of our global data which we need to save even as we leave the - * driver due to an interrupt or a timer event is stored in a variable - * of type idefloppy_floppy_t, defined below. + * Most of our global data which we need to save even as we leave the driver + * due to an interrupt or a timer event is stored in a variable of type + * idefloppy_floppy_t, defined below. */ typedef struct ide_floppy_obj { ide_drive_t *drive; @@ -148,17 +145,13 @@ typedef struct ide_floppy_obj { /* We implement a circular array */ int rq_stack_index; - /* - * Last error information - */ + /* Last error information */ u8 sense_key, asc, ascq; /* delay this long before sending packet command */ u8 ticks; int progress_indication; - /* - * Device information - */ + /* Device information */ /* Current format */ int blocks, block_size, bs_factor; /* Last format capacity descriptor */ @@ -189,34 +182,26 @@ enum { IDEFLOPPY_FLAG_ZIP_DRIVE = (1 << 4), }; -/* - * Defines for the mode sense command - */ +/* Defines for the MODE SENSE command */ #define MODE_SENSE_CURRENT 0x00 #define MODE_SENSE_CHANGEABLE 0x01 -#define MODE_SENSE_DEFAULT 0x02 +#define MODE_SENSE_DEFAULT 0x02 #define MODE_SENSE_SAVED 0x03 -/* - * IOCTLs used in low-level formatting. - */ - +/* IOCTLs used in low-level formatting. */ #define IDEFLOPPY_IOCTL_FORMAT_SUPPORTED 0x4600 #define IDEFLOPPY_IOCTL_FORMAT_GET_CAPACITY 0x4601 #define IDEFLOPPY_IOCTL_FORMAT_START 0x4602 #define IDEFLOPPY_IOCTL_FORMAT_GET_PROGRESS 0x4603 -/* - * Error codes which are returned in rq->errors to the higher part - * of the driver. - */ +/* Error code returned in rq->errors to the higher part of the driver. */ #define IDEFLOPPY_ERROR_GENERAL 101 /* - * The following is used to format the general configuration word of - * the ATAPI IDENTIFY DEVICE command. + * The following is used to format the general configuration word of the + * ATAPI IDENTIFY DEVICE command. */ -struct idefloppy_id_gcw { +struct idefloppy_id_gcw { #if defined(__LITTLE_ENDIAN_BITFIELD) unsigned packet_size :2; /* Packet Size */ unsigned reserved234 :3; /* Reserved */ @@ -274,10 +259,10 @@ static void ide_floppy_put(struct ide_floppy_obj *floppy) } /* - * Too bad. The drive wants to send us data which we are not ready to accept. - * Just throw it away. + * Too bad. The drive wants to send us data which we are not ready to accept. + * Just throw it away. */ -static void idefloppy_discard_data (ide_drive_t *drive, unsigned int bcount) +static void idefloppy_discard_data(ide_drive_t *drive, unsigned int bcount) { while (bcount--) (void) HWIF(drive)->INB(IDE_DATA_REG); @@ -291,10 +276,8 @@ static void idefloppy_write_zeros(ide_drive_t *drive, unsigned int bcount) /* - * idefloppy_do_end_request is used to finish servicing a request. - * - * For read/write requests, we will call ide_end_request to pass to the - * next buffer. + * Used to finish servicing a request. For read/write requests, we will call + * ide_end_request to pass to the next buffer. */ static int idefloppy_do_end_request(ide_drive_t *drive, int uptodate, int nsecs) { @@ -305,9 +288,9 @@ static int idefloppy_do_end_request(ide_drive_t *drive, int uptodate, int nsecs) debug_log("Reached %s\n", __FUNCTION__); switch (uptodate) { - case 0: error = IDEFLOPPY_ERROR_GENERAL; break; - case 1: error = 0; break; - default: error = uptodate; + case 0: error = IDEFLOPPY_ERROR_GENERAL; break; + case 1: error = 0; break; + default: error = uptodate; } if (error) floppy->failed_pc = NULL; @@ -366,7 +349,7 @@ static void ide_floppy_io_buffers(ide_drive_t *drive, idefloppy_pc_t *pc, } } -static void idefloppy_update_buffers (ide_drive_t *drive, idefloppy_pc_t *pc) +static void idefloppy_update_buffers(ide_drive_t *drive, idefloppy_pc_t *pc) { struct request *rq = pc->rq; struct bio *bio = rq->bio; @@ -376,11 +359,12 @@ static void idefloppy_update_buffers (ide_drive_t *drive, idefloppy_pc_t *pc) } /* - * idefloppy_queue_pc_head generates a new packet command request in front - * of the request queue, before the current request, so that it will be - * processed immediately, on the next pass through the driver. + * Generate a new packet command request in front of the request queue, before + * the current request so that it will be processed immediately, on the next + * pass through the driver. */ -static void idefloppy_queue_pc_head (ide_drive_t *drive,idefloppy_pc_t *pc,struct request *rq) +static void idefloppy_queue_pc_head(ide_drive_t *drive, idefloppy_pc_t *pc, + struct request *rq) { struct ide_floppy_obj *floppy = drive->driver_data; @@ -391,16 +375,16 @@ static void idefloppy_queue_pc_head (ide_drive_t *drive,idefloppy_pc_t *pc,struc (void) ide_do_drive_cmd(drive, rq, ide_preempt); } -static idefloppy_pc_t *idefloppy_next_pc_storage (ide_drive_t *drive) +static idefloppy_pc_t *idefloppy_next_pc_storage(ide_drive_t *drive) { idefloppy_floppy_t *floppy = drive->driver_data; if (floppy->pc_stack_index == IDEFLOPPY_PC_STACK) - floppy->pc_stack_index=0; + floppy->pc_stack_index = 0; return (&floppy->pc_stack[floppy->pc_stack_index++]); } -static struct request *idefloppy_next_rq_storage (ide_drive_t *drive) +static struct request *idefloppy_next_rq_storage(ide_drive_t *drive) { idefloppy_floppy_t *floppy = drive->driver_data; @@ -445,10 +429,8 @@ static void idefloppy_request_sense_callback(ide_drive_t *drive) } } -/* - * General packet command callback function. - */ -static void idefloppy_pc_callback (ide_drive_t *drive) +/* General packet command callback function. */ +static void idefloppy_pc_callback(ide_drive_t *drive) { idefloppy_floppy_t *floppy = drive->driver_data; @@ -457,10 +439,7 @@ static void idefloppy_pc_callback (ide_drive_t *drive) idefloppy_do_end_request(drive, floppy->pc->error ? 0 : 1, 0); } -/* - * idefloppy_init_pc initializes a packet command. - */ -static void idefloppy_init_pc (idefloppy_pc_t *pc) +static void idefloppy_init_pc(idefloppy_pc_t *pc) { memset(pc->c, 0, 12); pc->retries = 0; @@ -471,7 +450,7 @@ static void idefloppy_init_pc (idefloppy_pc_t *pc) pc->callback = &idefloppy_pc_callback; } -static void idefloppy_create_request_sense_cmd (idefloppy_pc_t *pc) +static void idefloppy_create_request_sense_cmd(idefloppy_pc_t *pc) { idefloppy_init_pc(pc); pc->c[0] = GPCMD_REQUEST_SENSE; @@ -481,11 +460,10 @@ static void idefloppy_create_request_sense_cmd (idefloppy_pc_t *pc) } /* - * idefloppy_retry_pc is called when an error was detected during the - * last packet command. We queue a request sense packet command in - * the head of the request list. + * Called when an error was detected during the last packet command. We queue a + * request sense packet command in the head of the request list. */ -static void idefloppy_retry_pc (ide_drive_t *drive) +static void idefloppy_retry_pc(ide_drive_t *drive) { idefloppy_pc_t *pc; struct request *rq; @@ -529,7 +507,8 @@ static ide_startstop_t idefloppy_pc_intr(ide_drive_t *drive) /* Clear the interrupt */ stat = drive->hwif->INB(IDE_STATUS_REG); - if ((stat & DRQ_STAT) == 0) { /* No more interrupts */ + /* No more interrupts */ + if ((stat & DRQ_STAT) == 0) { debug_log("Packet command completed, %d bytes transferred\n", pc->actually_transferred); pc->flags &= ~PC_FLAG_DMA_IN_PROGRESS; @@ -629,7 +608,7 @@ static ide_startstop_t idefloppy_pc_intr(ide_drive_t *drive) * It fails at high speeds on the Iomega ZIP drive, so there's a slower version * for that drive below. The algorithm is chosen based on drive type */ -static ide_startstop_t idefloppy_transfer_pc (ide_drive_t *drive) +static ide_startstop_t idefloppy_transfer_pc(ide_drive_t *drive) { ide_startstop_t startstop; idefloppy_floppy_t *floppy = drive->driver_data; @@ -656,18 +635,16 @@ static ide_startstop_t idefloppy_transfer_pc (ide_drive_t *drive) /* - * What we have here is a classic case of a top half / bottom half - * interrupt service routine. In interrupt mode, the device sends - * an interrupt to signal it's ready to receive a packet. However, - * we need to delay about 2-3 ticks before issuing the packet or we - * gets in trouble. + * What we have here is a classic case of a top half / bottom half interrupt + * service routine. In interrupt mode, the device sends an interrupt to signal + * that it is ready to receive a packet. However, we need to delay about 2-3 + * ticks before issuing the packet or we gets in trouble. * - * So, follow carefully. transfer_pc1 is called as an interrupt (or - * directly). In either case, when the device says it's ready for a - * packet, we schedule the packet transfer to occur about 2-3 ticks - * later in transfer_pc2. + * So, follow carefully. transfer_pc1 is called as an interrupt (or directly). + * In either case, when the device says it's ready for a packet, we schedule + * the packet transfer to occur about 2-3 ticks later in transfer_pc2. */ -static int idefloppy_transfer_pc2 (ide_drive_t *drive) +static int idefloppy_transfer_pc2(ide_drive_t *drive) { idefloppy_floppy_t *floppy = drive->driver_data; @@ -677,7 +654,7 @@ static int idefloppy_transfer_pc2 (ide_drive_t *drive) return IDEFLOPPY_WAIT_CMD; } -static ide_startstop_t idefloppy_transfer_pc1 (ide_drive_t *drive) +static ide_startstop_t idefloppy_transfer_pc1(ide_drive_t *drive) { idefloppy_floppy_t *floppy = drive->driver_data; ide_startstop_t startstop; @@ -694,7 +671,7 @@ static ide_startstop_t idefloppy_transfer_pc1 (ide_drive_t *drive) "while issuing a packet command\n"); return ide_do_reset(drive); } - /* + /* * The following delay solves a problem with ATAPI Zip 100 drives * where the Busy flag was apparently being deasserted before the * unit was ready to receive data. This was happening on a @@ -703,10 +680,8 @@ static ide_startstop_t idefloppy_transfer_pc1 (ide_drive_t *drive) * used until after the packet is moved in about 50 msec. */ - ide_set_handler(drive, - &idefloppy_pc_intr, /* service routine for packet command */ - floppy->ticks, /* wait this long before "failing" */ - &idefloppy_transfer_pc2); /* fail == transfer_pc2 */ + ide_set_handler(drive, &idefloppy_pc_intr, floppy->ticks, + &idefloppy_transfer_pc2); return ide_started; } @@ -726,10 +701,8 @@ static void ide_floppy_report_error(idefloppy_floppy_t *floppy, } -/* - * Issue a packet command - */ -static ide_startstop_t idefloppy_issue_pc (ide_drive_t *drive, idefloppy_pc_t *pc) +static ide_startstop_t idefloppy_issue_pc(ide_drive_t *drive, + idefloppy_pc_t *pc) { idefloppy_floppy_t *floppy = drive->driver_data; ide_hwif_t *hwif = drive->hwif; @@ -774,7 +747,8 @@ static ide_startstop_t idefloppy_issue_pc (ide_drive_t *drive, idefloppy_pc_t *p ide_pktcmd_tf_load(drive, IDE_TFLAG_NO_SELECT_MASK | IDE_TFLAG_OUT_DEVICE, bcount, dma); - if (dma) { /* Begin DMA, if necessary */ + if (dma) { + /* Begin DMA, if necessary */ pc->flags |= PC_FLAG_DMA_IN_PROGRESS; hwif->dma_start(drive); } @@ -802,7 +776,7 @@ static ide_startstop_t idefloppy_issue_pc (ide_drive_t *drive, idefloppy_pc_t *p } } -static void idefloppy_rw_callback (ide_drive_t *drive) +static void idefloppy_rw_callback(ide_drive_t *drive) { debug_log("Reached %s\n", __FUNCTION__); @@ -810,7 +784,7 @@ static void idefloppy_rw_callback (ide_drive_t *drive) return; } -static void idefloppy_create_prevent_cmd (idefloppy_pc_t *pc, int prevent) +static void idefloppy_create_prevent_cmd(idefloppy_pc_t *pc, int prevent) { debug_log("creating prevent removal command, prevent = %d\n", prevent); @@ -819,7 +793,7 @@ static void idefloppy_create_prevent_cmd (idefloppy_pc_t *pc, int prevent) pc->c[4] = prevent; } -static void idefloppy_create_read_capacity_cmd (idefloppy_pc_t *pc) +static void idefloppy_create_read_capacity_cmd(idefloppy_pc_t *pc) { idefloppy_init_pc(pc); pc->c[0] = GPCMD_READ_FORMAT_CAPACITIES; @@ -828,7 +802,7 @@ static void idefloppy_create_read_capacity_cmd (idefloppy_pc_t *pc) pc->request_transfer = 255; } -static void idefloppy_create_format_unit_cmd (idefloppy_pc_t *pc, int b, int l, +static void idefloppy_create_format_unit_cmd(idefloppy_pc_t *pc, int b, int l, int flags) { idefloppy_init_pc(pc); @@ -845,38 +819,37 @@ static void idefloppy_create_format_unit_cmd (idefloppy_pc_t *pc, int b, int l, put_unaligned(cpu_to_be32(b), (unsigned int *)(&pc->buffer[4])); put_unaligned(cpu_to_be32(l), (unsigned int *)(&pc->buffer[8])); - pc->buffer_size=12; + pc->buffer_size = 12; pc->flags |= PC_FLAG_WRITING; } -/* - * A mode sense command is used to "sense" floppy parameters. - */ -static void idefloppy_create_mode_sense_cmd (idefloppy_pc_t *pc, u8 page_code, u8 type) +/* A mode sense command is used to "sense" floppy parameters. */ +static void idefloppy_create_mode_sense_cmd(idefloppy_pc_t *pc, u8 page_code, + u8 type) { u16 length = 8; /* sizeof(Mode Parameter Header) = 8 Bytes */ - + idefloppy_init_pc(pc); pc->c[0] = GPCMD_MODE_SENSE_10; pc->c[1] = 0; pc->c[2] = page_code + (type << 6); switch (page_code) { - case IDEFLOPPY_CAPABILITIES_PAGE: - length += 12; - break; - case IDEFLOPPY_FLEXIBLE_DISK_PAGE: - length += 32; - break; - default: - printk(KERN_ERR "ide-floppy: unsupported page code " + case IDEFLOPPY_CAPABILITIES_PAGE: + length += 12; + break; + case IDEFLOPPY_FLEXIBLE_DISK_PAGE: + length += 32; + break; + default: + printk(KERN_ERR "ide-floppy: unsupported page code " "in create_mode_sense_cmd\n"); } put_unaligned(cpu_to_be16(length), (u16 *) &pc->c[7]); pc->request_transfer = length; } -static void idefloppy_create_start_stop_cmd (idefloppy_pc_t *pc, int start) +static void idefloppy_create_start_stop_cmd(idefloppy_pc_t *pc, int start) { idefloppy_init_pc(pc); pc->c[0] = GPCMD_START_STOP_UNIT; @@ -914,8 +887,8 @@ static void idefloppy_create_rw_cmd(idefloppy_floppy_t *floppy, pc->flags |= PC_FLAG_DMA_RECOMMENDED; } -static void -idefloppy_blockpc_cmd(idefloppy_floppy_t *floppy, idefloppy_pc_t *pc, struct request *rq) +static void idefloppy_blockpc_cmd(idefloppy_floppy_t *floppy, + idefloppy_pc_t *pc, struct request *rq) { idefloppy_init_pc(pc); pc->callback = &idefloppy_rw_callback; @@ -934,10 +907,8 @@ idefloppy_blockpc_cmd(idefloppy_floppy_t *floppy, idefloppy_pc_t *pc, struct req pc->request_transfer = pc->buffer_size = rq->data_len; } -/* - * idefloppy_do_request is our request handling function. - */ -static ide_startstop_t idefloppy_do_request (ide_drive_t *drive, struct request *rq, sector_t block_s) +static ide_startstop_t idefloppy_do_request(ide_drive_t *drive, + struct request *rq, sector_t block_s) { idefloppy_floppy_t *floppy = drive->driver_data; idefloppy_pc_t *pc; @@ -962,8 +933,8 @@ static ide_startstop_t idefloppy_do_request (ide_drive_t *drive, struct request if (blk_fs_request(rq)) { if (((long)rq->sector % floppy->bs_factor) || (rq->nr_sectors % floppy->bs_factor)) { - printk("%s: unsupported r/w request size\n", - drive->name); + printk(KERN_ERR "%s: unsupported r/w request size\n", + drive->name); idefloppy_do_end_request(drive, 0, 0); return ide_stopped; } @@ -986,15 +957,15 @@ static ide_startstop_t idefloppy_do_request (ide_drive_t *drive, struct request } /* - * idefloppy_queue_pc_tail adds a special packet command request to the - * tail of the request queue, and waits for it to be serviced. + * Add a special packet command request to the tail of the request queue, + * and wait for it to be serviced. */ -static int idefloppy_queue_pc_tail (ide_drive_t *drive,idefloppy_pc_t *pc) +static int idefloppy_queue_pc_tail(ide_drive_t *drive, idefloppy_pc_t *pc) { struct ide_floppy_obj *floppy = drive->driver_data; struct request rq; - ide_init_drive_cmd (&rq); + ide_init_drive_cmd(&rq); rq.buffer = (char *) pc; rq.cmd_type = REQ_TYPE_SPECIAL; rq.rq_disk = floppy->disk; @@ -1121,7 +1092,7 @@ static int ide_floppy_get_capacity(ide_drive_t *drive) /* Clik! drive returns this instead of CAPACITY_CURRENT */ case CAPACITY_UNFORMATTED: if (!(floppy->flags & IDEFLOPPY_FLAG_CLIK_DRIVE)) - /* + /* * If it is not a clik drive, break out * (maintains previous driver behaviour) */ @@ -1247,14 +1218,14 @@ static int ide_floppy_get_format_capacities(ide_drive_t *drive, int __user *arg) } /* -** Get ATAPI_FORMAT_UNIT progress indication. -** -** Userland gives a pointer to an int. The int is set to a progress -** indicator 0-65536, with 65536=100%. -** -** If the drive does not support format progress indication, we just check -** the dsc bit, and return either 0 or 65536. -*/ + * Get ATAPI_FORMAT_UNIT progress indication. + * + * Userland gives a pointer to an int. The int is set to a progress + * indicator 0-65536, with 65536=100%. + * + * If the drive does not support format progress indication, we just check + * the dsc bit, and return either 0 or 65536. + */ static int idefloppy_get_format_progress(ide_drive_t *drive, int __user *arg) { @@ -1264,17 +1235,15 @@ static int idefloppy_get_format_progress(ide_drive_t *drive, int __user *arg) if (floppy->srfp) { idefloppy_create_request_sense_cmd(&pc); - if (idefloppy_queue_pc_tail(drive, &pc)) { + if (idefloppy_queue_pc_tail(drive, &pc)) return (-EIO); - } if (floppy->sense_key == 2 && floppy->asc == 4 && - floppy->ascq == 4) { + floppy->ascq == 4) progress_indication = floppy->progress_indication; - } - /* Else assume format_unit has finished, and we're - ** at 0x10000 */ + + /* Else assume format_unit has finished, and we're at 0x10000 */ } else { unsigned long flags; u8 stat; @@ -1291,10 +1260,7 @@ static int idefloppy_get_format_progress(ide_drive_t *drive, int __user *arg) return (0); } -/* - * Return the current floppy capacity. - */ -static sector_t idefloppy_capacity (ide_drive_t *drive) +static sector_t idefloppy_capacity(ide_drive_t *drive) { idefloppy_floppy_t *floppy = drive->driver_data; unsigned long capacity = floppy->blocks * floppy->bs_factor; @@ -1344,22 +1310,20 @@ static void idefloppy_add_settings(ide_drive_t *drive) { idefloppy_floppy_t *floppy = drive->driver_data; -/* - * drive setting name read/write data type min max mul_factor div_factor data pointer set function - */ - ide_add_setting(drive, "bios_cyl", SETTING_RW, TYPE_INT, 0, 1023, 1, 1, &drive->bios_cyl, NULL); - ide_add_setting(drive, "bios_head", SETTING_RW, TYPE_BYTE, 0, 255, 1, 1, &drive->bios_head, NULL); - ide_add_setting(drive, "bios_sect", SETTING_RW, TYPE_BYTE, 0, 63, 1, 1, &drive->bios_sect, NULL); - ide_add_setting(drive, "ticks", SETTING_RW, TYPE_BYTE, 0, 255, 1, 1, &floppy->ticks, NULL); + ide_add_setting(drive, "bios_cyl", SETTING_RW, TYPE_INT, 0, 1023, 1, 1, + &drive->bios_cyl, NULL); + ide_add_setting(drive, "bios_head", SETTING_RW, TYPE_BYTE, 0, 255, 1, 1, + &drive->bios_head, NULL); + ide_add_setting(drive, "bios_sect", SETTING_RW, TYPE_BYTE, 0, 63, 1, 1, + &drive->bios_sect, NULL); + ide_add_setting(drive, "ticks", SETTING_RW, TYPE_BYTE, 0, 255, 1, 1, + &floppy->ticks, NULL); } #else static inline void idefloppy_add_settings(ide_drive_t *drive) { ; } #endif -/* - * Driver initialization. - */ -static void idefloppy_setup (ide_drive_t *drive, idefloppy_floppy_t *floppy) +static void idefloppy_setup(ide_drive_t *drive, idefloppy_floppy_t *floppy) { struct idefloppy_id_gcw gcw; @@ -1368,16 +1332,14 @@ static void idefloppy_setup (ide_drive_t *drive, idefloppy_floppy_t *floppy) if (gcw.drq_type == 1) floppy->flags |= IDEFLOPPY_FLAG_DRQ_INTERRUPT; /* - * We used to check revisions here. At this point however - * I'm giving up. Just assume they are all broken, its easier. + * We used to check revisions here. At this point however I'm giving up. + * Just assume they are all broken, its easier. * - * The actual reason for the workarounds was likely - * a driver bug after all rather than a firmware bug, - * and the workaround below used to hide it. It should - * be fixed as of version 1.9, but to be on the safe side - * we'll leave the limitation below for the 2.2.x tree. + * The actual reason for the workarounds was likely a driver bug after + * all rather than a firmware bug, and the workaround below used to hide + * it. It should be fixed as of version 1.9, but to be on the safe side + * we'll leave the limitation below for the 2.2.x tree. */ - if (!strncmp(drive->id->model, "IOMEGA ZIP 100 ATAPI", 20)) { floppy->flags |= IDEFLOPPY_FLAG_ZIP_DRIVE; /* This value will be visible in the /proc/ide/hdx/settings */ @@ -1386,16 +1348,14 @@ static void idefloppy_setup (ide_drive_t *drive, idefloppy_floppy_t *floppy) } /* - * Guess what? The IOMEGA Clik! drive also needs the - * above fix. It makes nasty clicking noises without - * it, so please don't remove this. - */ + * Guess what? The IOMEGA Clik! drive also needs the above fix. It makes + * nasty clicking noises without it, so please don't remove this. + */ if (strncmp(drive->id->model, "IOMEGA Clik!", 11) == 0) { blk_queue_max_sectors(drive->queue, 64); floppy->flags |= IDEFLOPPY_FLAG_CLIK_DRIVE; } - (void) ide_floppy_get_capacity(drive); idefloppy_add_settings(drive); } @@ -1425,19 +1385,19 @@ static void idefloppy_cleanup_obj(struct kref *kref) } #ifdef CONFIG_IDE_PROC_FS -static int proc_idefloppy_read_capacity - (char *page, char **start, off_t off, int count, int *eof, void *data) +static int proc_idefloppy_read_capacity(char *page, char **start, off_t off, + int count, int *eof, void *data) { ide_drive_t*drive = (ide_drive_t *)data; int len; - len = sprintf(page,"%llu\n", (long long)idefloppy_capacity(drive)); - PROC_IDE_READ_RETURN(page,start,off,count,eof,len); + len = sprintf(page, "%llu\n", (long long)idefloppy_capacity(drive)); + PROC_IDE_READ_RETURN(page, start, off, count, eof, len); } static ide_proc_entry_t idefloppy_proc[] = { - { "capacity", S_IFREG|S_IRUGO, proc_idefloppy_read_capacity, NULL }, - { "geometry", S_IFREG|S_IRUGO, proc_ide_read_geometry, NULL }, + { "capacity", S_IFREG|S_IRUGO, proc_idefloppy_read_capacity, NULL }, + { "geometry", S_IFREG|S_IRUGO, proc_ide_read_geometry, NULL }, { NULL, 0, NULL, NULL } }; #endif /* CONFIG_IDE_PROC_FS */ @@ -1474,7 +1434,8 @@ static int idefloppy_open(struct inode *inode, struct file *filp) debug_log("Reached %s\n", __FUNCTION__); - if (!(floppy = ide_floppy_get(disk))) + floppy = ide_floppy_get(disk); + if (!floppy) return -ENXIO; drive = floppy->drive; @@ -1494,10 +1455,10 @@ static int idefloppy_open(struct inode *inode, struct file *filp) if (ide_floppy_get_capacity(drive) && (filp->f_flags & O_NDELAY) == 0 /* - ** Allow O_NDELAY to open a drive without a disk, or with - ** an unreadable disk, so that we can get the format - ** capacity of the drive or begin the format - Sam - */ + * Allow O_NDELAY to open a drive without a disk, or with an + * unreadable disk, so that we can get the format capacity + * of the drive or begin the format - Sam + */ ) { ret = -EIO; goto out_put_floppy; @@ -1726,16 +1687,20 @@ static int ide_floppy_probe(ide_drive_t *drive) goto failed; if (drive->media != ide_floppy) goto failed; - if (!idefloppy_identify_device (drive, drive->id)) { - printk (KERN_ERR "ide-floppy: %s: not supported by this version of ide-floppy\n", drive->name); + if (!idefloppy_identify_device(drive, drive->id)) { + printk(KERN_ERR "ide-floppy: %s: not supported by this version" + " of ide-floppy\n", drive->name); goto failed; } if (drive->scsi) { - printk("ide-floppy: passing drive %s to ide-scsi emulation.\n", drive->name); + printk(KERN_INFO "ide-floppy: passing drive %s to ide-scsi" + " emulation.\n", drive->name); goto failed; } - if ((floppy = kzalloc(sizeof (idefloppy_floppy_t), GFP_KERNEL)) == NULL) { - printk (KERN_ERR "ide-floppy: %s: Can't allocate a floppy structure\n", drive->name); + floppy = kzalloc(sizeof(idefloppy_floppy_t), GFP_KERNEL); + if (!floppy) { + printk(KERN_ERR "ide-floppy: %s: Can't allocate a floppy" + " structure\n", drive->name); goto failed; } @@ -1757,7 +1722,7 @@ static int ide_floppy_probe(ide_drive_t *drive) drive->driver_data = floppy; - idefloppy_setup (drive, floppy); + idefloppy_setup(drive, floppy); g->minors = 1 << PARTN_BITS; g->driverfs_dev = &drive->gendev; @@ -1773,9 +1738,7 @@ failed: return -ENODEV; } -MODULE_DESCRIPTION("ATAPI FLOPPY Driver"); - -static void __exit idefloppy_exit (void) +static void __exit idefloppy_exit(void) { driver_unregister(&idefloppy_driver.gen_driver); } @@ -1790,3 +1753,5 @@ MODULE_ALIAS("ide:*m-floppy*"); module_init(idefloppy_init); module_exit(idefloppy_exit); MODULE_LICENSE("GPL"); +MODULE_DESCRIPTION("ATAPI FLOPPY Driver"); + -- 1.5.3.7 -- Regards/Gruß, Boris. ^ permalink raw reply related [flat|nested] 29+ messages in thread
* Re: (was: Re:...) [PATCH 12/12] ide-floppy: fix most of the remaining checkpatch.pl issues-v2 2008-01-15 20:12 ` (was: Re:...) [PATCH 12/12] ide-floppy: fix most of the remaining checkpatch.pl issues-v2 Borislav Petkov @ 2008-01-16 22:51 ` Bartlomiej Zolnierkiewicz 0 siblings, 0 replies; 29+ messages in thread From: Bartlomiej Zolnierkiewicz @ 2008-01-16 22:51 UTC (permalink / raw) To: bbpetkov; +Cc: linux-kernel, linux-ide On Tuesday 15 January 2008, Borislav Petkov wrote: > ... and finally the last one. Whew! I think we're done here for now. :) > > -- > From: Borislav Petkov <bbpetkov@yahoo.de> > Date: Tue, 15 Jan 2008 21:01:04 +0100 > Subject: ide-floppy: fix most of the remaining checkpatch.pl issues-v2 > > such as > ERROR: switch and case should be at the same indent > ERROR: need spaces around that '=' (ctx:VxV) > ERROR: trailing statements should be on next line > WARNING: no space between function name and open parenthesis '(' > WARNING: printk() should include KERN_ facility level > ERROR: That open brace { should be on the previous line > ERROR: use tabs not spaces > ERROR: do not use assignment in if condition > WARNING: braces {} are not necessary for single statement blocks > ERROR: need space after that ',' (ctx:VxV) > WARNING: line over 80 characters > ERROR: do not use assignment in if condition > ... > and so on. > > Signed-off-by: Borislav Petkov <bbpetkov@yahoo.de> applied ^ permalink raw reply [flat|nested] 29+ messages in thread
* Re: [PATCH 11/12] ide-floppy: remove IDEFLOPPY_DEBUG_INFO 2008-01-13 20:18 ` [PATCH 11/12] ide-floppy: remove IDEFLOPPY_DEBUG_INFO Borislav Petkov 2008-01-13 20:18 ` [PATCH 12/12] ide-floppy: fix most of the remaining checkpatch.pl issues Borislav Petkov @ 2008-01-14 21:51 ` Bartlomiej Zolnierkiewicz 1 sibling, 0 replies; 29+ messages in thread From: Bartlomiej Zolnierkiewicz @ 2008-01-14 21:51 UTC (permalink / raw) To: Borislav Petkov; +Cc: linux-kernel, linux-ide On Sunday 13 January 2008, Borislav Petkov wrote: [...] > - printk(KERN_ERR "ide-floppy: Packet size is not 12 bytes long\n"); > + printk(KERN_ERR "ide-floppy: Packet size is not 12 bytes " > + "long\n"); I added dumping 'gcw.packet_size' for unsupported packet sizes while merging the patch. ^ permalink raw reply [flat|nested] 29+ messages in thread
* Re: [PATCH 10/12] ide-floppy: remove atomic test_*bit macros 2008-01-13 20:18 ` [PATCH 10/12] ide-floppy: remove atomic test_*bit macros Borislav Petkov 2008-01-13 20:18 ` [PATCH 11/12] ide-floppy: remove IDEFLOPPY_DEBUG_INFO Borislav Petkov @ 2008-01-14 21:50 ` Bartlomiej Zolnierkiewicz 2008-01-14 22:32 ` Bartlomiej Zolnierkiewicz ` (2 more replies) 1 sibling, 3 replies; 29+ messages in thread From: Bartlomiej Zolnierkiewicz @ 2008-01-14 21:50 UTC (permalink / raw) To: Borislav Petkov; +Cc: linux-kernel, linux-ide On Sunday 13 January 2008, Borislav Petkov wrote: > ..and replace them with flag enums. > > Signed-off-by: Borislav Petkov <bbpetkov@yahoo.de> > --- > drivers/ide/ide-floppy.c | 132 +++++++++++++++++++++++++-------------------- > 1 files changed, 73 insertions(+), 59 deletions(-) [...] > @@ -506,14 +516,14 @@ static ide_startstop_t idefloppy_pc_intr(ide_drive_t *drive) > > debug_log("Reached %s interrupt handler\n", __FUNCTION__); > > - if (test_bit(PC_DMA_IN_PROGRESS, &pc->flags)) { > + if (PC_FLAG_DMA_IN_PROGRESS & pc->flags) { the usual kernel convention is to put flag last, i.e. pc->flags & PC_FLAG_DMA_IN_PROGRESS [...] > @@ -570,7 +581,7 @@ static ide_startstop_t idefloppy_pc_intr(ide_drive_t *drive) > printk(KERN_ERR "ide-floppy: CoD != 0 in %s\n", __FUNCTION__); > return ide_do_reset(drive); > } > - if (((ireason & IO) == IO) == test_bit(PC_WRITING, &pc->flags)) { > + if (((ireason & IO) == IO) == (PC_FLAG_WRITING & pc->flags)) { - test_bit() returns 1 or 0 (=> boolean) - (pc->flags & PC_FLAG_WRITING) is 0x10 or 0 so the above comparison will fail > @@ -607,7 +618,7 @@ static ide_startstop_t idefloppy_pc_intr(ide_drive_t *drive) > xferfunc(drive, pc->current_position, bcount); > else > ide_floppy_io_buffers(drive, pc, bcount, > - test_bit(PC_WRITING, &pc->flags)); > + (PC_FLAG_WRITING & pc->flags)); ditto, this may actually work but '(pc->flags & PC_FLAG_WRITING) ? 1 : 0' would be much safer from maintainability POV [...] > @@ -1720,13 +1731,16 @@ static int idefloppy_media_changed(struct gendisk *disk) > { > struct ide_floppy_obj *floppy = ide_floppy_g(disk); > ide_drive_t *drive = floppy->drive; > + int ret; > > /* do not scan partitions twice if this is a removable device */ > if (drive->attach) { > drive->attach = 0; > return 0; > } > - return test_and_clear_bit(IDEFLOPPY_MEDIA_CHANGED, &floppy->flags); > + ret = IDEFLOPPY_FLAG_MEDIA_CHANGED & floppy->flags; > + floppy->flags &= ~IDEFLOPPY_FLAG_MEDIA_CHANGED; > + return ret; > } same issue otherwise looks good, please fix/resubmit (together with patch #12) ^ permalink raw reply [flat|nested] 29+ messages in thread
* Re: [PATCH 10/12] ide-floppy: remove atomic test_*bit macros 2008-01-14 21:50 ` [PATCH 10/12] ide-floppy: remove atomic test_*bit macros Bartlomiej Zolnierkiewicz @ 2008-01-14 22:32 ` Bartlomiej Zolnierkiewicz 2008-01-15 20:09 ` Borislav Petkov 2008-01-15 7:07 ` Borislav Petkov 2008-01-15 20:10 ` Borislav Petkov 2 siblings, 1 reply; 29+ messages in thread From: Bartlomiej Zolnierkiewicz @ 2008-01-14 22:32 UTC (permalink / raw) To: Borislav Petkov; +Cc: linux-kernel, linux-ide On Monday 14 January 2008, Bartlomiej Zolnierkiewicz wrote: > On Sunday 13 January 2008, Borislav Petkov wrote: > > ..and replace them with flag enums. > > > > Signed-off-by: Borislav Petkov <bbpetkov@yahoo.de> small update: PC_ABORT is never set and may as well be removed in a pre-patch ^ permalink raw reply [flat|nested] 29+ messages in thread
* Re: [PATCH 10/12] ide-floppy: remove atomic test_*bit macros 2008-01-14 22:32 ` Bartlomiej Zolnierkiewicz @ 2008-01-15 20:09 ` Borislav Petkov 2008-01-16 22:08 ` Bartlomiej Zolnierkiewicz 0 siblings, 1 reply; 29+ messages in thread From: Borislav Petkov @ 2008-01-15 20:09 UTC (permalink / raw) To: Bartlomiej Zolnierkiewicz; +Cc: linux-kernel, linux-ide On Mon, Jan 14, 2008 at 11:32:58PM +0100, Bartlomiej Zolnierkiewicz wrote: > On Monday 14 January 2008, Bartlomiej Zolnierkiewicz wrote: > > On Sunday 13 January 2008, Borislav Petkov wrote: > > > ..and replace them with flag enums. > > > > > > Signed-off-by: Borislav Petkov <bbpetkov@yahoo.de> > > small update: > > PC_ABORT is never set and may as well be removed in a pre-patch Here you go, the one below should be pushed first... -- From: Borislav Petkov <bbpetkov@yahoo.de> Date: Tue, 15 Jan 2008 20:34:50 +0100 Subject: ide-floppy: remove unused flag PC_ABORT This flag was never being set in the code so remove it. By the way, the code in the second patch was being executed unconditionally, i.e. in case pc->retries > IDEFLOPPY_MAX_PC_RETRIES is true (actually that is the only case when the outer if-test passed), !test_bit(PC_ABORT, &pc->flags) was always true so the comment is now incorrect and has to go. Signed-off-by: Borislav Petkov <bbpetkov@yahoo.de> diff --git a/drivers/ide/ide-floppy.c b/drivers/ide/ide-floppy.c index 790e33f..8e9063f 100644 --- a/drivers/ide/ide-floppy.c +++ b/drivers/ide/ide-floppy.c @@ -110,7 +110,6 @@ typedef struct idefloppy_packet_command_s { /* * Packet command flag bits. */ -#define PC_ABORT 0 /* Set when an error is considered normal - We won't retry */ #define PC_DMA_RECOMMENDED 2 /* 1 when we prefer to use DMA if possible */ #define PC_DMA_IN_PROGRESS 3 /* 1 while DMA in progress */ #define PC_DMA_ERROR 4 /* 1 when encountered problem during DMA */ @@ -737,18 +736,12 @@ static ide_startstop_t idefloppy_issue_pc (ide_drive_t *drive, idefloppy_pc_t *p /* Set the current packet command */ floppy->pc = pc; - if (pc->retries > IDEFLOPPY_MAX_PC_RETRIES || - test_bit(PC_ABORT, &pc->flags)) { - /* - * We will "abort" retrying a packet command in case - * a legitimate error code was received. - */ - if (!test_bit(PC_ABORT, &pc->flags)) { - if (!test_bit(PC_SUPPRESS_ERROR, &pc->flags)) - ide_floppy_report_error(floppy, pc); - /* Giving up */ - pc->error = IDEFLOPPY_ERROR_GENERAL; - } + if (pc->retries > IDEFLOPPY_MAX_PC_RETRIES) { + if (!test_bit(PC_SUPPRESS_ERROR, &pc->flags)) + ide_floppy_report_error(floppy, pc); + /* Giving up */ + pc->error = IDEFLOPPY_ERROR_GENERAL; + floppy->failed_pc = NULL; pc->callback(drive); return ide_stopped; -- 1.5.3.7 -- Regards/Gruß, Boris. ^ permalink raw reply related [flat|nested] 29+ messages in thread
* Re: [PATCH 10/12] ide-floppy: remove atomic test_*bit macros 2008-01-15 20:09 ` Borislav Petkov @ 2008-01-16 22:08 ` Bartlomiej Zolnierkiewicz 0 siblings, 0 replies; 29+ messages in thread From: Bartlomiej Zolnierkiewicz @ 2008-01-16 22:08 UTC (permalink / raw) To: bbpetkov; +Cc: linux-kernel, linux-ide On Tuesday 15 January 2008, Borislav Petkov wrote: > On Mon, Jan 14, 2008 at 11:32:58PM +0100, Bartlomiej Zolnierkiewicz wrote: > > On Monday 14 January 2008, Bartlomiej Zolnierkiewicz wrote: > > > On Sunday 13 January 2008, Borislav Petkov wrote: > > > > ..and replace them with flag enums. > > > > > > > > Signed-off-by: Borislav Petkov <bbpetkov@yahoo.de> > > > > small update: > > > > PC_ABORT is never set and may as well be removed in a pre-patch > > Here you go, the one below should be pushed first... > > -- > From: Borislav Petkov <bbpetkov@yahoo.de> > Date: Tue, 15 Jan 2008 20:34:50 +0100 > Subject: ide-floppy: remove unused flag PC_ABORT > > This flag was never being set in the code so remove it. By the way, the > code in the second patch was being executed unconditionally, i.e. in case > pc->retries > IDEFLOPPY_MAX_PC_RETRIES is true (actually that is the only case > when the outer if-test passed), !test_bit(PC_ABORT, &pc->flags) > was always true so the comment is now incorrect and has to go. > > Signed-off-by: Borislav Petkov <bbpetkov@yahoo.de> thanks, applied ^ permalink raw reply [flat|nested] 29+ messages in thread
* Re: [PATCH 10/12] ide-floppy: remove atomic test_*bit macros 2008-01-14 21:50 ` [PATCH 10/12] ide-floppy: remove atomic test_*bit macros Bartlomiej Zolnierkiewicz 2008-01-14 22:32 ` Bartlomiej Zolnierkiewicz @ 2008-01-15 7:07 ` Borislav Petkov 2008-01-15 20:10 ` Borislav Petkov 2 siblings, 0 replies; 29+ messages in thread From: Borislav Petkov @ 2008-01-15 7:07 UTC (permalink / raw) To: Bartlomiej Zolnierkiewicz; +Cc: linux-kernel, linux-ide On Mon, Jan 14, 2008 at 10:50:58PM +0100, Bartlomiej Zolnierkiewicz wrote: > On Sunday 13 January 2008, Borislav Petkov wrote: > > ..and replace them with flag enums. > > > > Signed-off-by: Borislav Petkov <bbpetkov@yahoo.de> > > --- > > drivers/ide/ide-floppy.c | 132 +++++++++++++++++++++++++-------------------- > > 1 files changed, 73 insertions(+), 59 deletions(-) > > [...] > > > @@ -506,14 +516,14 @@ static ide_startstop_t idefloppy_pc_intr(ide_drive_t *drive) > > > > debug_log("Reached %s interrupt handler\n", __FUNCTION__); > > > > - if (test_bit(PC_DMA_IN_PROGRESS, &pc->flags)) { > > + if (PC_FLAG_DMA_IN_PROGRESS & pc->flags) { > > the usual kernel convention is to put flag last, i.e. > > pc->flags & PC_FLAG_DMA_IN_PROGRESS > > [...] > > > @@ -570,7 +581,7 @@ static ide_startstop_t idefloppy_pc_intr(ide_drive_t *drive) > > printk(KERN_ERR "ide-floppy: CoD != 0 in %s\n", __FUNCTION__); > > return ide_do_reset(drive); > > } > > - if (((ireason & IO) == IO) == test_bit(PC_WRITING, &pc->flags)) { > > + if (((ireason & IO) == IO) == (PC_FLAG_WRITING & pc->flags)) { > > - test_bit() returns 1 or 0 (=> boolean) > - (pc->flags & PC_FLAG_WRITING) is 0x10 or 0 > > so the above comparison will fail > > > @@ -607,7 +618,7 @@ static ide_startstop_t idefloppy_pc_intr(ide_drive_t *drive) > > xferfunc(drive, pc->current_position, bcount); > > else > > ide_floppy_io_buffers(drive, pc, bcount, > > - test_bit(PC_WRITING, &pc->flags)); > > + (PC_FLAG_WRITING & pc->flags)); > > ditto, this may actually work but '(pc->flags & PC_FLAG_WRITING) ? 1 : 0' > would be much safer from maintainability POV Hi Bart, i must've been sleeping while i've been doing this :) Will redo them tonight and resend. Thanks. -- Regards/Gruß, Boris. ^ permalink raw reply [flat|nested] 29+ messages in thread
* Re: [PATCH 10/12] ide-floppy: remove atomic test_*bit macros 2008-01-14 21:50 ` [PATCH 10/12] ide-floppy: remove atomic test_*bit macros Bartlomiej Zolnierkiewicz 2008-01-14 22:32 ` Bartlomiej Zolnierkiewicz 2008-01-15 7:07 ` Borislav Petkov @ 2008-01-15 20:10 ` Borislav Petkov 2008-01-16 22:25 ` Bartlomiej Zolnierkiewicz 2 siblings, 1 reply; 29+ messages in thread From: Borislav Petkov @ 2008-01-15 20:10 UTC (permalink / raw) To: Bartlomiej Zolnierkiewicz; +Cc: linux-kernel, linux-ide On Mon, Jan 14, 2008 at 10:50:58PM +0100, Bartlomiej Zolnierkiewicz wrote: > On Sunday 13 January 2008, Borislav Petkov wrote: > > ..and replace them with flag enums. > > > > Signed-off-by: Borislav Petkov <bbpetkov@yahoo.de> > > --- > > drivers/ide/ide-floppy.c | 132 +++++++++++++++++++++++++-------------------- > > 1 files changed, 73 insertions(+), 59 deletions(-) > > [...] > > > @@ -506,14 +516,14 @@ static ide_startstop_t idefloppy_pc_intr(ide_drive_t *drive) > > > > debug_log("Reached %s interrupt handler\n", __FUNCTION__); > > > > - if (test_bit(PC_DMA_IN_PROGRESS, &pc->flags)) { > > + if (PC_FLAG_DMA_IN_PROGRESS & pc->flags) { > > the usual kernel convention is to put flag last, i.e. > > pc->flags & PC_FLAG_DMA_IN_PROGRESS > > [...] > > > @@ -570,7 +581,7 @@ static ide_startstop_t idefloppy_pc_intr(ide_drive_t *drive) > > printk(KERN_ERR "ide-floppy: CoD != 0 in %s\n", __FUNCTION__); > > return ide_do_reset(drive); > > } > > - if (((ireason & IO) == IO) == test_bit(PC_WRITING, &pc->flags)) { > > + if (((ireason & IO) == IO) == (PC_FLAG_WRITING & pc->flags)) { > > - test_bit() returns 1 or 0 (=> boolean) > - (pc->flags & PC_FLAG_WRITING) is 0x10 or 0 > > so the above comparison will fail > > > @@ -607,7 +618,7 @@ static ide_startstop_t idefloppy_pc_intr(ide_drive_t *drive) > > xferfunc(drive, pc->current_position, bcount); > > else > > ide_floppy_io_buffers(drive, pc, bcount, > > - test_bit(PC_WRITING, &pc->flags)); > > + (PC_FLAG_WRITING & pc->flags)); > > ditto, this may actually work but '(pc->flags & PC_FLAG_WRITING) ? 1 : 0' > would be much safer from maintainability POV > > [...] > > > @@ -1720,13 +1731,16 @@ static int idefloppy_media_changed(struct gendisk *disk) > > { > > struct ide_floppy_obj *floppy = ide_floppy_g(disk); > > ide_drive_t *drive = floppy->drive; > > + int ret; > > > > /* do not scan partitions twice if this is a removable device */ > > if (drive->attach) { > > drive->attach = 0; > > return 0; > > } > > - return test_and_clear_bit(IDEFLOPPY_MEDIA_CHANGED, &floppy->flags); > > + ret = IDEFLOPPY_FLAG_MEDIA_CHANGED & floppy->flags; > > + floppy->flags &= ~IDEFLOPPY_FLAG_MEDIA_CHANGED; > > + return ret; > > } > > same issue > > otherwise looks good, please fix/resubmit > (together with patch #12) .. this is the second one... From: Borislav Petkov <bbpetkov@yahoo.de> Date: Tue, 15 Jan 2008 20:49:18 +0100 Subject: [PATCH 16/18] ide-floppy: remove atomic test_*bit macros ..and replace them with flag enums. Signed-off-by: Borislav Petkov <bbpetkov@yahoo.de> :100644 100644 8e9063f... 8a4791d... M drivers/ide/ide-floppy.c diff --git a/drivers/ide/ide-floppy.c b/drivers/ide/ide-floppy.c index 8e9063f..8a4791d 100644 --- a/drivers/ide/ide-floppy.c +++ b/drivers/ide/ide-floppy.c @@ -107,15 +107,19 @@ typedef struct idefloppy_packet_command_s { unsigned long flags; /* Status/Action bit flags: long for set_bit */ } idefloppy_pc_t; -/* - * Packet command flag bits. - */ -#define PC_DMA_RECOMMENDED 2 /* 1 when we prefer to use DMA if possible */ -#define PC_DMA_IN_PROGRESS 3 /* 1 while DMA in progress */ -#define PC_DMA_ERROR 4 /* 1 when encountered problem during DMA */ -#define PC_WRITING 5 /* Data direction */ - -#define PC_SUPPRESS_ERROR 6 /* Suppress error reporting */ +/* Packet command flag bits. */ +enum { + /* 1 when we prefer to use DMA if possible */ + PC_FLAG_DMA_RECOMMENDED = (1 << 0), + /* 1 while DMA in progress */ + PC_FLAG_DMA_IN_PROGRESS = (1 << 1), + /* 1 when encountered problem during DMA */ + PC_FLAG_DMA_ERROR = (1 << 2), + /* Data direction */ + PC_FLAG_WRITING = (1 << 3), + /* Suppress error reporting */ + PC_FLAG_SUPPRESS_ERROR = (1 << 4), +}; /* format capacities descriptor codes */ #define CAPACITY_INVALID 0x00 @@ -174,14 +178,19 @@ typedef struct ide_floppy_obj { #define IDEFLOPPY_TICKS_DELAY HZ/20 /* default delay for ZIP 100 (50ms) */ -/* - * Floppy flag bits values. - */ -#define IDEFLOPPY_DRQ_INTERRUPT 0 /* DRQ interrupt device */ -#define IDEFLOPPY_MEDIA_CHANGED 1 /* Media may have changed */ -#define IDEFLOPPY_FORMAT_IN_PROGRESS 3 /* Format in progress */ -#define IDEFLOPPY_CLIK_DRIVE 4 /* Avoid commands not supported in Clik drive */ -#define IDEFLOPPY_ZIP_DRIVE 5 /* Requires BH algorithm for packets */ +/* Floppy flag bits values. */ +enum { + /* DRQ interrupt device */ + IDEFLOPPY_FLAG_DRQ_INTERRUPT = (1 << 0), + /* Media may have changed */ + IDEFLOPPY_FLAG_MEDIA_CHANGED = (1 << 1), + /* Format in progress */ + IDEFLOPPY_FLAG_FORMAT_IN_PROGRESS = (1 << 2), + /* Avoid commands not supported in Clik drive */ + IDEFLOPPY_FLAG_CLIK_DRIVE = (1 << 3), + /* Requires BH algorithm for packets */ + IDEFLOPPY_FLAG_ZIP_DRIVE = (1 << 4), +}; /* * Defines for the mode sense command @@ -505,14 +514,14 @@ static ide_startstop_t idefloppy_pc_intr(ide_drive_t *drive) debug_log("Reached %s interrupt handler\n", __FUNCTION__); - if (test_bit(PC_DMA_IN_PROGRESS, &pc->flags)) { + if (pc->flags & PC_FLAG_DMA_IN_PROGRESS) { dma_error = HWIF(drive)->ide_dma_end(drive); if (dma_error) { printk(KERN_ERR "%s: DMA %s error\n", drive->name, rq_data_dir(rq) == WRITE ? "write" :"read"); - set_bit(PC_DMA_ERROR, &pc->flags); + pc->flags |= PC_FLAG_DMA_ERROR; } else { pc->actually_transferred = pc->request_transfer; idefloppy_update_buffers(drive, pc); @@ -526,11 +535,11 @@ static ide_startstop_t idefloppy_pc_intr(ide_drive_t *drive) if ((stat & DRQ_STAT) == 0) { /* No more interrupts */ debug_log("Packet command completed, %d bytes transferred\n", pc->actually_transferred); - clear_bit(PC_DMA_IN_PROGRESS, &pc->flags); + pc->flags &= ~PC_FLAG_DMA_IN_PROGRESS; local_irq_enable_in_hardirq(); - if ((stat & ERR_STAT) || test_bit(PC_DMA_ERROR, &pc->flags)) { + if ((stat & ERR_STAT) || (pc->flags & PC_FLAG_DMA_ERROR)) { /* Error detected */ debug_log("I/O error\n", drive->name); rq->errors++; @@ -552,7 +561,8 @@ static ide_startstop_t idefloppy_pc_intr(ide_drive_t *drive) return ide_stopped; } - if (test_and_clear_bit(PC_DMA_IN_PROGRESS, &pc->flags)) { + if (pc->flags & PC_FLAG_DMA_IN_PROGRESS) { + pc->flags &= ~PC_FLAG_DMA_IN_PROGRESS; printk(KERN_ERR "ide-floppy: The floppy wants to issue " "more interrupts in DMA mode\n"); ide_dma_off(drive); @@ -569,7 +579,7 @@ static ide_startstop_t idefloppy_pc_intr(ide_drive_t *drive) printk(KERN_ERR "ide-floppy: CoD != 0 in %s\n", __FUNCTION__); return ide_do_reset(drive); } - if (((ireason & IO) == IO) == test_bit(PC_WRITING, &pc->flags)) { + if (((ireason & IO) == IO) == !!(pc->flags & PC_FLAG_WRITING)) { /* Hopefully, we will never get here */ printk(KERN_ERR "ide-floppy: We wanted to %s, ", (ireason & IO) ? "Write" : "Read"); @@ -577,7 +587,7 @@ static ide_startstop_t idefloppy_pc_intr(ide_drive_t *drive) (ireason & IO) ? "Read" : "Write"); return ide_do_reset(drive); } - if (!test_bit(PC_WRITING, &pc->flags)) { + if (!(pc->flags & PC_FLAG_WRITING)) { /* Reading - Check that we have enough space */ temp = pc->actually_transferred + bcount; if (temp > pc->request_transfer) { @@ -597,7 +607,7 @@ static ide_startstop_t idefloppy_pc_intr(ide_drive_t *drive) " expected - allowing transfer\n"); } } - if (test_bit(PC_WRITING, &pc->flags)) + if (pc->flags & PC_FLAG_WRITING) xferfunc = hwif->atapi_output_bytes; else xferfunc = hwif->atapi_input_bytes; @@ -606,7 +616,7 @@ static ide_startstop_t idefloppy_pc_intr(ide_drive_t *drive) xferfunc(drive, pc->current_position, bcount); else ide_floppy_io_buffers(drive, pc, bcount, - test_bit(PC_WRITING, &pc->flags)); + !!(pc->flags & PC_FLAG_WRITING)); /* Update the current position */ pc->actually_transferred += bcount; @@ -737,7 +747,7 @@ static ide_startstop_t idefloppy_issue_pc (ide_drive_t *drive, idefloppy_pc_t *p floppy->pc = pc; if (pc->retries > IDEFLOPPY_MAX_PC_RETRIES) { - if (!test_bit(PC_SUPPRESS_ERROR, &pc->flags)) + if (!(pc->flags & PC_FLAG_SUPPRESS_ERROR)) ide_floppy_report_error(floppy, pc); /* Giving up */ pc->error = IDEFLOPPY_ERROR_GENERAL; @@ -755,24 +765,25 @@ static ide_startstop_t idefloppy_issue_pc (ide_drive_t *drive, idefloppy_pc_t *p pc->current_position = pc->buffer; bcount = min(pc->request_transfer, 63 * 1024); - if (test_and_clear_bit(PC_DMA_ERROR, &pc->flags)) + if (pc->flags & PC_FLAG_DMA_ERROR) { + pc->flags &= ~PC_FLAG_DMA_ERROR; ide_dma_off(drive); - + } dma = 0; - if (test_bit(PC_DMA_RECOMMENDED, &pc->flags) && drive->using_dma) + if ((pc->flags & PC_FLAG_DMA_RECOMMENDED) && drive->using_dma) dma = !hwif->dma_setup(drive); ide_pktcmd_tf_load(drive, IDE_TFLAG_NO_SELECT_MASK | IDE_TFLAG_OUT_DEVICE, bcount, dma); if (dma) { /* Begin DMA, if necessary */ - set_bit(PC_DMA_IN_PROGRESS, &pc->flags); + pc->flags |= PC_FLAG_DMA_IN_PROGRESS; hwif->dma_start(drive); } /* Can we transfer the packet when we get the interrupt or wait? */ - if (test_bit(IDEFLOPPY_ZIP_DRIVE, &floppy->flags)) { + if (floppy->flags & IDEFLOPPY_FLAG_ZIP_DRIVE) { /* wait */ pkt_xfer_routine = &idefloppy_transfer_pc1; } else { @@ -780,7 +791,7 @@ static ide_startstop_t idefloppy_issue_pc (ide_drive_t *drive, idefloppy_pc_t *p pkt_xfer_routine = &idefloppy_transfer_pc; } - if (test_bit (IDEFLOPPY_DRQ_INTERRUPT, &floppy->flags)) { + if (floppy->flags & IDEFLOPPY_FLAG_DRQ_INTERRUPT) { /* Issue the packet command */ ide_execute_command(drive, WIN_PACKETCMD, pkt_xfer_routine, @@ -838,7 +849,7 @@ static void idefloppy_create_format_unit_cmd (idefloppy_pc_t *pc, int b, int l, put_unaligned(cpu_to_be32(b), (unsigned int *)(&pc->buffer[4])); put_unaligned(cpu_to_be32(l), (unsigned int *)(&pc->buffer[8])); pc->buffer_size=12; - set_bit(PC_WRITING, &pc->flags); + pc->flags |= PC_FLAG_WRITING; } /* @@ -900,10 +911,10 @@ static void idefloppy_create_rw_cmd(idefloppy_floppy_t *floppy, pc->rq = rq; pc->b_count = cmd == READ ? 0 : rq->bio->bi_size; if (rq->cmd_flags & REQ_RW) - set_bit(PC_WRITING, &pc->flags); + pc->flags |= PC_FLAG_WRITING; pc->buffer = NULL; pc->request_transfer = pc->buffer_size = blocks * floppy->block_size; - set_bit(PC_DMA_RECOMMENDED, &pc->flags); + pc->flags |= PC_FLAG_DMA_RECOMMENDED; } static void @@ -915,11 +926,10 @@ idefloppy_blockpc_cmd(idefloppy_floppy_t *floppy, idefloppy_pc_t *pc, struct req pc->rq = rq; pc->b_count = rq->data_len; if (rq->data_len && rq_data_dir(rq) == WRITE) - set_bit(PC_WRITING, &pc->flags); + pc->flags |= PC_FLAG_WRITING; pc->buffer = rq->data; if (rq->bio) - set_bit(PC_DMA_RECOMMENDED, &pc->flags); - + pc->flags |= PC_FLAG_DMA_RECOMMENDED; /* * possibly problematic, doesn't look like ide-floppy correctly * handled scattered requests if dma fails... @@ -1060,7 +1070,7 @@ static int idefloppy_get_sfrp_bit(ide_drive_t *drive) idefloppy_create_mode_sense_cmd(&pc, IDEFLOPPY_CAPABILITIES_PAGE, MODE_SENSE_CURRENT); - set_bit(PC_SUPPRESS_ERROR, &pc.flags); + pc.flags |= PC_FLAG_SUPPRESS_ERROR; if (idefloppy_queue_pc_tail(drive, &pc)) return 1; @@ -1113,7 +1123,7 @@ static int ide_floppy_get_capacity(ide_drive_t *drive) switch (pc.buffer[desc_start + 4] & 0x03) { /* Clik! drive returns this instead of CAPACITY_CURRENT */ case CAPACITY_UNFORMATTED: - if (!test_bit(IDEFLOPPY_CLIK_DRIVE, &floppy->flags)) + if (!(floppy->flags & IDEFLOPPY_FLAG_CLIK_DRIVE)) /* * If it is not a clik drive, break out * (maintains previous driver behaviour) @@ -1159,7 +1169,7 @@ static int ide_floppy_get_capacity(ide_drive_t *drive) } /* Clik! disk does not support get_flexible_disk_page */ - if (!test_bit(IDEFLOPPY_CLIK_DRIVE, &floppy->flags)) + if (!(floppy->flags & IDEFLOPPY_FLAG_CLIK_DRIVE)) (void) ide_floppy_get_flexible_disk_page(drive); set_capacity(floppy->disk, floppy->blocks * floppy->bs_factor); @@ -1393,7 +1403,7 @@ static void idefloppy_setup (ide_drive_t *drive, idefloppy_floppy_t *floppy) *((u16 *) &gcw) = drive->id->config; floppy->pc = floppy->pc_stack; if (gcw.drq_type == 1) - set_bit(IDEFLOPPY_DRQ_INTERRUPT, &floppy->flags); + floppy->flags |= IDEFLOPPY_FLAG_DRQ_INTERRUPT; /* * We used to check revisions here. At this point however * I'm giving up. Just assume they are all broken, its easier. @@ -1406,7 +1416,7 @@ static void idefloppy_setup (ide_drive_t *drive, idefloppy_floppy_t *floppy) */ if (!strncmp(drive->id->model, "IOMEGA ZIP 100 ATAPI", 20)) { - set_bit(IDEFLOPPY_ZIP_DRIVE, &floppy->flags); + floppy->flags |= IDEFLOPPY_FLAG_ZIP_DRIVE; /* This value will be visible in the /proc/ide/hdx/settings */ floppy->ticks = IDEFLOPPY_TICKS_DELAY; blk_queue_max_sectors(drive->queue, 64); @@ -1419,7 +1429,7 @@ static void idefloppy_setup (ide_drive_t *drive, idefloppy_floppy_t *floppy) */ if (strncmp(drive->id->model, "IOMEGA Clik!", 11) == 0) { blk_queue_max_sectors(drive->queue, 64); - set_bit(IDEFLOPPY_CLIK_DRIVE, &floppy->flags); + floppy->flags |= IDEFLOPPY_FLAG_CLIK_DRIVE; } @@ -1509,7 +1519,7 @@ static int idefloppy_open(struct inode *inode, struct file *filp) floppy->openers++; if (floppy->openers == 1) { - clear_bit(IDEFLOPPY_FORMAT_IN_PROGRESS, &floppy->flags); + floppy->flags &= ~IDEFLOPPY_FLAG_FORMAT_IN_PROGRESS; /* Just in case */ idefloppy_create_test_unit_ready_cmd(&pc); @@ -1534,14 +1544,14 @@ static int idefloppy_open(struct inode *inode, struct file *filp) ret = -EROFS; goto out_put_floppy; } - set_bit(IDEFLOPPY_MEDIA_CHANGED, &floppy->flags); + floppy->flags |= IDEFLOPPY_FLAG_MEDIA_CHANGED; /* IOMEGA Clik! drives do not support lock/unlock commands */ - if (!test_bit(IDEFLOPPY_CLIK_DRIVE, &floppy->flags)) { + if (!(floppy->flags & IDEFLOPPY_FLAG_CLIK_DRIVE)) { idefloppy_create_prevent_cmd(&pc, 1); (void) idefloppy_queue_pc_tail(drive, &pc); } check_disk_change(inode->i_bdev); - } else if (test_bit(IDEFLOPPY_FORMAT_IN_PROGRESS, &floppy->flags)) { + } else if (floppy->flags & IDEFLOPPY_FLAG_FORMAT_IN_PROGRESS) { ret = -EBUSY; goto out_put_floppy; } @@ -1564,12 +1574,12 @@ static int idefloppy_release(struct inode *inode, struct file *filp) if (floppy->openers == 1) { /* IOMEGA Clik! drives do not support lock/unlock commands */ - if (!test_bit(IDEFLOPPY_CLIK_DRIVE, &floppy->flags)) { + if (!(floppy->flags & IDEFLOPPY_FLAG_CLIK_DRIVE)) { idefloppy_create_prevent_cmd(&pc, 0); (void) idefloppy_queue_pc_tail(drive, &pc); } - clear_bit(IDEFLOPPY_FORMAT_IN_PROGRESS, &floppy->flags); + floppy->flags &= ~IDEFLOPPY_FLAG_FORMAT_IN_PROGRESS; } floppy->openers--; @@ -1598,7 +1608,7 @@ static int ide_floppy_lockdoor(idefloppy_floppy_t *floppy, idefloppy_pc_t *pc, /* The IOMEGA Clik! Drive doesn't support this command - * no room for an eject mechanism */ - if (!test_bit(IDEFLOPPY_CLIK_DRIVE, &floppy->flags)) { + if (!(floppy->flags & IDEFLOPPY_FLAG_CLIK_DRIVE)) { int prevent = arg ? 1 : 0; if (cmd == CDROMEJECT) @@ -1624,11 +1634,11 @@ static int ide_floppy_format_unit(idefloppy_floppy_t *floppy, if (floppy->openers > 1) { /* Don't format if someone is using the disk */ - clear_bit(IDEFLOPPY_FORMAT_IN_PROGRESS, &floppy->flags); + floppy->flags &= ~IDEFLOPPY_FLAG_FORMAT_IN_PROGRESS; return -EBUSY; } - set_bit(IDEFLOPPY_FORMAT_IN_PROGRESS, &floppy->flags); + floppy->flags |= IDEFLOPPY_FLAG_FORMAT_IN_PROGRESS; /* * Send ATAPI_FORMAT_UNIT to the drive. @@ -1660,7 +1670,7 @@ static int ide_floppy_format_unit(idefloppy_floppy_t *floppy, out: if (err) - clear_bit(IDEFLOPPY_FORMAT_IN_PROGRESS, &floppy->flags); + floppy->flags &= ~IDEFLOPPY_FLAG_FORMAT_IN_PROGRESS; return err; } @@ -1713,13 +1723,16 @@ static int idefloppy_media_changed(struct gendisk *disk) { struct ide_floppy_obj *floppy = ide_floppy_g(disk); ide_drive_t *drive = floppy->drive; + int ret; /* do not scan partitions twice if this is a removable device */ if (drive->attach) { drive->attach = 0; return 0; } - return test_and_clear_bit(IDEFLOPPY_MEDIA_CHANGED, &floppy->flags); + ret = floppy->flags & IDEFLOPPY_FLAG_MEDIA_CHANGED; + floppy->flags &= ~IDEFLOPPY_FLAG_MEDIA_CHANGED; + return ret; } static int idefloppy_revalidate_disk(struct gendisk *disk) -- 1.5.3.7 -- Regards/Gruß, Boris. ^ permalink raw reply related [flat|nested] 29+ messages in thread
* Re: [PATCH 10/12] ide-floppy: remove atomic test_*bit macros 2008-01-15 20:10 ` Borislav Petkov @ 2008-01-16 22:25 ` Bartlomiej Zolnierkiewicz 0 siblings, 0 replies; 29+ messages in thread From: Bartlomiej Zolnierkiewicz @ 2008-01-16 22:25 UTC (permalink / raw) To: bbpetkov; +Cc: linux-kernel, linux-ide On Tuesday 15 January 2008, Borislav Petkov wrote: [...] > .. this is the second one... > > > From: Borislav Petkov <bbpetkov@yahoo.de> > Date: Tue, 15 Jan 2008 20:49:18 +0100 > Subject: [PATCH 16/18] ide-floppy: remove atomic test_*bit macros > > ..and replace them with flag enums. > > Signed-off-by: Borislav Petkov <bbpetkov@yahoo.de> applied [...] > @@ -1713,13 +1723,16 @@ static int idefloppy_media_changed(struct gendisk *disk) > { > struct ide_floppy_obj *floppy = ide_floppy_g(disk); > ide_drive_t *drive = floppy->drive; > + int ret; > > /* do not scan partitions twice if this is a removable device */ > if (drive->attach) { > drive->attach = 0; > return 0; > } > - return test_and_clear_bit(IDEFLOPPY_MEDIA_CHANGED, &floppy->flags); > + ret = floppy->flags & IDEFLOPPY_FLAG_MEDIA_CHANGED; > + floppy->flags &= ~IDEFLOPPY_FLAG_MEDIA_CHANGED; > + return ret; > } this chunk (idefloppy_media_changed() return value is now 2 instead of 1 if IDEFLOPPY_FLAG_MEDIA_CHANGED flag is set) seems to have slipped through [ I fixed it while merging the patch ] ^ permalink raw reply [flat|nested] 29+ messages in thread
* Re: [PATCH 8/12] ide-floppy: merge idefloppy_{input,output}_buffers 2008-01-13 20:18 ` [PATCH 8/12] ide-floppy: merge idefloppy_{input,output}_buffers Borislav Petkov 2008-01-13 20:18 ` [PATCH 9/12] ide-floppy: remove unused IDEFLOPPY_USE_READ12 Borislav Petkov @ 2008-01-14 21:38 ` Bartlomiej Zolnierkiewicz 2008-01-15 7:14 ` Borislav Petkov 1 sibling, 1 reply; 29+ messages in thread From: Bartlomiej Zolnierkiewicz @ 2008-01-14 21:38 UTC (permalink / raw) To: Borislav Petkov; +Cc: linux-kernel, linux-ide On Sunday 13 January 2008, Borislav Petkov wrote: > We merge idefloppy_{input,output}_buffers() into idefloppy_io_buffers() by > introducing a 4th arg. called direction. According to its value > we atapi_input_bytes() or atapi_output_bytes(). Also, this simplifies the > interrupt handler logic a bit. Finally, rename idefloppy_io_buffers() to > ide_floppy_io_buffers(). > > Signed-off-by: Borislav Petkov <bbpetkov@yahoo.de> This change depends on "ide-floppy: use an xfer_func_t and io_buf_t typedefs in order to unify rw" which was not in the "v2.5" series. I took the patch #16/21 from the previous series and applied it manually fixing rejects, please verify that I didn't brake something in the process. [...] > @@ -380,8 +352,13 @@ static void idefloppy_output_buffers (ide_drive_t *drive, idefloppy_pc_t *pc, un > idefloppy_do_end_request(drive, 1, done >> 9); > > if (bcount) { > - printk(KERN_ERR "%s: leftover data in idefloppy_output_buffers, bcount == %d\n", drive->name, bcount); > - idefloppy_write_zeros(drive, bcount); > + printk(KERN_ERR "%s: leftover data in idefloppy_output_buffers," > + " bcount == %d\n", drive->name, bcount); I fixed the above to use __func__ while at it. [ __FUNCTION__ is gcc-specific, __func__ is in C99 and is shorter ] ^ permalink raw reply [flat|nested] 29+ messages in thread
* Re: [PATCH 8/12] ide-floppy: merge idefloppy_{input,output}_buffers 2008-01-14 21:38 ` [PATCH 8/12] ide-floppy: merge idefloppy_{input,output}_buffers Bartlomiej Zolnierkiewicz @ 2008-01-15 7:14 ` Borislav Petkov 0 siblings, 0 replies; 29+ messages in thread From: Borislav Petkov @ 2008-01-15 7:14 UTC (permalink / raw) To: Bartlomiej Zolnierkiewicz; +Cc: linux-kernel, linux-ide On Mon, Jan 14, 2008 at 10:38:35PM +0100, Bartlomiej Zolnierkiewicz wrote: > On Sunday 13 January 2008, Borislav Petkov wrote: > > We merge idefloppy_{input,output}_buffers() into idefloppy_io_buffers() by > > introducing a 4th arg. called direction. According to its value > > we atapi_input_bytes() or atapi_output_bytes(). Also, this simplifies the > > interrupt handler logic a bit. Finally, rename idefloppy_io_buffers() to > > ide_floppy_io_buffers(). > > > > Signed-off-by: Borislav Petkov <bbpetkov@yahoo.de> > > This change depends on "ide-floppy: use an xfer_func_t and io_buf_t typedefs > in order to unify rw" which was not in the "v2.5" series. Yep, this is correct. Probably i should've mentioned that in the preamble. It is rather confusing, imho, when sending only a subset of the patches. Rather, I should've sent the whole series after tagging the ones already applied so that you have an idea about their ordering. Will note that for the next time. > I took the patch #16/21 from the previous series and applied it manually > fixing rejects, please verify that I didn't brake something in the process. Will do the whole driver testing in the weekend. :) -- Regards/Gruß, Boris. ^ permalink raw reply [flat|nested] 29+ messages in thread
* Re: [PATCH 0/12] ide-floppy redux v2.5 2008-01-13 20:18 [PATCH 0/12] ide-floppy redux v2.5 Borislav Petkov 2008-01-13 20:18 ` [PATCH 1/12] ide-floppy: remove struct idefloppy_mode_parameter_header Borislav Petkov @ 2008-01-14 21:38 ` Bartlomiej Zolnierkiewicz 2008-01-20 12:38 ` Borislav Petkov 1 sibling, 1 reply; 29+ messages in thread From: Bartlomiej Zolnierkiewicz @ 2008-01-14 21:38 UTC (permalink / raw) To: Borislav Petkov; +Cc: linux-kernel, linux-ide Hi, On Sunday 13 January 2008, Borislav Petkov wrote: > Hi Bart, > > here are the remaining patches which had issues to be worked out. I decided > to keep the Flexible Disk Page and Capacity Descriptor in > idefloppy_floppy_t for the sake of the two printk calls for which they are > used. Otherwise, we'll be changing long-known driver behavior and this won't > be acceptable. I'll audit the driver to see whether rq_data_dir() can replace > the PC_WRITING flag completely and get rid of that one too. Thanks, I applied patches #1-9 and #11, #10 needs small corrections and will be applied once they are addressed (#12 is fine but since it depends on #11 it has also to wait a bit more). > By the way, I have an Iomega ZIP 100 drive somewhere in my hardware pile and > will do some testing with the "new" :) driver just in case. This would be great. :) Cheers, Bart ^ permalink raw reply [flat|nested] 29+ messages in thread
* Re: [PATCH 0/12] ide-floppy redux v2.5 2008-01-14 21:38 ` [PATCH 0/12] ide-floppy redux v2.5 Bartlomiej Zolnierkiewicz @ 2008-01-20 12:38 ` Borislav Petkov 2008-01-21 22:45 ` Bartlomiej Zolnierkiewicz 0 siblings, 1 reply; 29+ messages in thread From: Borislav Petkov @ 2008-01-20 12:38 UTC (permalink / raw) To: Bartlomiej Zolnierkiewicz; +Cc: linux-kernel, linux-ide On Mon, Jan 14, 2008 at 10:38:17PM +0100, Bartlomiej Zolnierkiewicz wrote: > > By the way, I have an Iomega ZIP 100 drive somewhere in my hardware pile and > > will do some testing with the "new" :) driver just in case. > > This would be great. :) Hi Bart, i just whipped rc8 along with your pata-2.6 tree on top and had several test runs of the ide-floppy driver (raw reads, software floppy disk eject, etc) and everything seems to work fine. I will keep this hardware setup here so that we could at least test ide-floppy occasionally. We should probably acknowledge this major driver cleanup with a new driver version? --- >From 6f948b93839cdf397cb38ca75c3c6cc9a21e6070 Mon Sep 17 00:00:00 2001 From: Borislav Petkov <bbpetkov@yahoo.de> Date: Sun, 20 Jan 2008 13:32:24 +0100 Subject: [PATCH] ide-floppy: bump driver version number Acknowledge major ide-floppy code refactoring and cleanup by bumping the driver version number. Also, remove a wrong comment. Signed-off-by: Borislav Petkov <bbpetkov@yahoo.de> --- drivers/ide/ide-floppy.c | 5 +---- 1 files changed, 1 insertions(+), 4 deletions(-) diff --git a/drivers/ide/ide-floppy.c b/drivers/ide/ide-floppy.c index 0bf6596..b455cf1 100644 --- a/drivers/ide/ide-floppy.c +++ b/drivers/ide/ide-floppy.c @@ -5,9 +5,6 @@ * Copyright (C) 2000-2002 Paul Bristow <paul@paulbristow.net> * Copyright (C) 2005 Bartlomiej Zolnierkiewicz * - * The driver currently doesn't have any fancy features, just the bare - * minimum read/write support. - * * This driver supports the following IDE floppy drives: * * LS-120/240 SuperDisk @@ -18,7 +15,7 @@ * Documentation/ide/ChangeLog.ide-floppy.1996-2002 */ -#define IDEFLOPPY_VERSION "0.99.newide" +#define IDEFLOPPY_VERSION "1.00" #include <linux/module.h> #include <linux/types.h> -- 1.5.3.7 -- Regards/Gruß, Boris. ^ permalink raw reply related [flat|nested] 29+ messages in thread
* Re: [PATCH 0/12] ide-floppy redux v2.5 2008-01-20 12:38 ` Borislav Petkov @ 2008-01-21 22:45 ` Bartlomiej Zolnierkiewicz 2008-01-22 5:32 ` Borislav Petkov 0 siblings, 1 reply; 29+ messages in thread From: Bartlomiej Zolnierkiewicz @ 2008-01-21 22:45 UTC (permalink / raw) To: bbpetkov; +Cc: linux-kernel, linux-ide Hi Borislav, On Sunday 20 January 2008, Borislav Petkov wrote: > On Mon, Jan 14, 2008 at 10:38:17PM +0100, Bartlomiej Zolnierkiewicz wrote: > > > By the way, I have an Iomega ZIP 100 drive somewhere in my hardware pile and > > > will do some testing with the "new" :) driver just in case. > > > > This would be great. :) > Hi Bart, > > i just whipped rc8 along with your pata-2.6 tree on top and had several test > runs of the ide-floppy driver (raw reads, software floppy disk eject, etc) and > everything seems to work fine. I will keep this hardware setup here so that we > could at least test ide-floppy occasionally. We should probably acknowledge this Big thanks for all great ide-floppy work! I hope that you'll continue with putting IDE device drivers in shape. :) > major driver cleanup with a new driver version? Yep. > --- > From 6f948b93839cdf397cb38ca75c3c6cc9a21e6070 Mon Sep 17 00:00:00 2001 > From: Borislav Petkov <bbpetkov@yahoo.de> > Date: Sun, 20 Jan 2008 13:32:24 +0100 > Subject: [PATCH] ide-floppy: bump driver version number > > Acknowledge major ide-floppy code refactoring and cleanup by bumping the driver > version number. Also, remove a wrong comment. > > Signed-off-by: Borislav Petkov <bbpetkov@yahoo.de> applied ^ permalink raw reply [flat|nested] 29+ messages in thread
* Re: [PATCH 0/12] ide-floppy redux v2.5 2008-01-21 22:45 ` Bartlomiej Zolnierkiewicz @ 2008-01-22 5:32 ` Borislav Petkov 0 siblings, 0 replies; 29+ messages in thread From: Borislav Petkov @ 2008-01-22 5:32 UTC (permalink / raw) To: Bartlomiej Zolnierkiewicz; +Cc: linux-kernel, linux-ide On Mon, Jan 21, 2008 at 11:45:35PM +0100, Bartlomiej Zolnierkiewicz wrote: > > Hi Borislav, > > On Sunday 20 January 2008, Borislav Petkov wrote: > > On Mon, Jan 14, 2008 at 10:38:17PM +0100, Bartlomiej Zolnierkiewicz wrote: > > > > By the way, I have an Iomega ZIP 100 drive somewhere in my hardware pile and > > > > will do some testing with the "new" :) driver just in case. > > > > > > This would be great. :) > > Hi Bart, > > > > i just whipped rc8 along with your pata-2.6 tree on top and had several test > > runs of the ide-floppy driver (raw reads, software floppy disk eject, etc) and > > everything seems to work fine. I will keep this hardware setup here so that we > > could at least test ide-floppy occasionally. We should probably acknowledge this > > Big thanks for all great ide-floppy work! I hope that you'll continue with > putting IDE device drivers in shape. :) Sure, no problem :). I'm on ide-tape right now and probably will have most of it ready for submission on the weekend so keep your fingers crossed... :) -- Regards/Gruß, Boris. ^ permalink raw reply [flat|nested] 29+ messages in thread
end of thread, other threads:[~2008-01-22 5:32 UTC | newest] Thread overview: 29+ messages (download: mbox.gz / follow: Atom feed) -- links below jump to the message on this page -- 2008-01-13 20:18 [PATCH 0/12] ide-floppy redux v2.5 Borislav Petkov 2008-01-13 20:18 ` [PATCH 1/12] ide-floppy: remove struct idefloppy_mode_parameter_header Borislav Petkov 2008-01-13 20:18 ` [PATCH 2/12] ide-floppy: remove struct idefloppy_flexible_disk_page Borislav Petkov 2008-01-13 20:18 ` [PATCH 3/12] ide-floppy: remove struct idefloppy_capacity_descriptor Borislav Petkov 2008-01-13 20:18 ` [PATCH 4/12] ide-floppy: factor out ioctl handlers from idefloppy_ioctl() Borislav Petkov 2008-01-13 20:18 ` [PATCH 5/12] ide-floppy: report DMA handling in idefloppy_pc_intr() properly Borislav Petkov 2008-01-13 20:18 ` [PATCH 6/12] ide-floppy: mv idefloppy_{should_,}report_error Borislav Petkov 2008-01-13 20:18 ` [PATCH 7/12] ide-floppy: remove IDEFLOPPY_DEBUG_BUGS macro Borislav Petkov 2008-01-13 20:18 ` [PATCH 8/12] ide-floppy: merge idefloppy_{input,output}_buffers Borislav Petkov 2008-01-13 20:18 ` [PATCH 9/12] ide-floppy: remove unused IDEFLOPPY_USE_READ12 Borislav Petkov 2008-01-13 20:18 ` [PATCH 10/12] ide-floppy: remove atomic test_*bit macros Borislav Petkov 2008-01-13 20:18 ` [PATCH 11/12] ide-floppy: remove IDEFLOPPY_DEBUG_INFO Borislav Petkov 2008-01-13 20:18 ` [PATCH 12/12] ide-floppy: fix most of the remaining checkpatch.pl issues Borislav Petkov 2008-01-15 20:12 ` (was: Re:...) [PATCH 12/12] ide-floppy: fix most of the remaining checkpatch.pl issues-v2 Borislav Petkov 2008-01-16 22:51 ` Bartlomiej Zolnierkiewicz 2008-01-14 21:51 ` [PATCH 11/12] ide-floppy: remove IDEFLOPPY_DEBUG_INFO Bartlomiej Zolnierkiewicz 2008-01-14 21:50 ` [PATCH 10/12] ide-floppy: remove atomic test_*bit macros Bartlomiej Zolnierkiewicz 2008-01-14 22:32 ` Bartlomiej Zolnierkiewicz 2008-01-15 20:09 ` Borislav Petkov 2008-01-16 22:08 ` Bartlomiej Zolnierkiewicz 2008-01-15 7:07 ` Borislav Petkov 2008-01-15 20:10 ` Borislav Petkov 2008-01-16 22:25 ` Bartlomiej Zolnierkiewicz 2008-01-14 21:38 ` [PATCH 8/12] ide-floppy: merge idefloppy_{input,output}_buffers Bartlomiej Zolnierkiewicz 2008-01-15 7:14 ` Borislav Petkov 2008-01-14 21:38 ` [PATCH 0/12] ide-floppy redux v2.5 Bartlomiej Zolnierkiewicz 2008-01-20 12:38 ` Borislav Petkov 2008-01-21 22:45 ` Bartlomiej Zolnierkiewicz 2008-01-22 5:32 ` Borislav Petkov
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).