LKML Archive on lore.kernel.org
help / color / mirror / Atom feed
From: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
To: linux-ide@vger.kernel.org
Cc: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>,
	linux-kernel@vger.kernel.org
Subject: [PATCH 12/19] ide: remove ide_drive_t.usage
Date: Fri, 12 Jan 2007 05:27:22 +0100	[thread overview]
Message-ID: <20070112042722.28794.74399.sendpatchset@localhost.localdomain> (raw)
In-Reply-To: <20070112042621.28794.6937.sendpatchset@localhost.localdomain>

[PATCH] ide: remove ide_drive_t.usage

This field is no longer used by the core IDE code so fix ide-{disk,floppy}
drivers to keep openers count in the driver specific objects and remove
it from ide-{cd,scsi,tape} drivers (it was write-only).

Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>

---
 drivers/ide/ide-cd.c     |   15 ++++-----------
 drivers/ide/ide-disk.c   |   14 +++++++++-----
 drivers/ide/ide-floppy.c |   18 +++++++++---------
 drivers/ide/ide-tape.c   |    8 --------
 drivers/scsi/ide-scsi.c  |    8 --------
 include/linux/ide.h      |    1 -
 6 files changed, 22 insertions(+), 42 deletions(-)

Index: a/drivers/ide/ide-cd.c
===================================================================
--- a.orig/drivers/ide/ide-cd.c
+++ a/drivers/ide/ide-cd.c
@@ -3345,21 +3345,16 @@ static int idecd_open(struct inode * ino
 {
 	struct gendisk *disk = inode->i_bdev->bd_disk;
 	struct cdrom_info *info;
-	ide_drive_t *drive;
 	int rc = -ENOMEM;
 
 	if (!(info = ide_cd_get(disk)))
 		return -ENXIO;
 
-	drive = info->drive;
-
-	drive->usage++;
-
 	if (!info->buffer)
-		info->buffer = kmalloc(SECTOR_BUFFER_SIZE,
-					GFP_KERNEL|__GFP_REPEAT);
-        if (!info->buffer || (rc = cdrom_open(&info->devinfo, inode, file)))
-		drive->usage--;
+		info->buffer = kmalloc(SECTOR_BUFFER_SIZE, GFP_KERNEL|__GFP_REPEAT);
+
+	if (info->buffer)
+		rc = cdrom_open(&info->devinfo, inode, file);
 
 	if (rc < 0)
 		ide_cd_put(info);
@@ -3371,10 +3366,8 @@ static int idecd_release(struct inode * 
 {
 	struct gendisk *disk = inode->i_bdev->bd_disk;
 	struct cdrom_info *info = ide_cd_g(disk);
-	ide_drive_t *drive = info->drive;
 
 	cdrom_release (&info->devinfo, file);
-	drive->usage--;
 
 	ide_cd_put(info);
 
Index: a/drivers/ide/ide-disk.c
===================================================================
--- a.orig/drivers/ide/ide-disk.c
+++ a/drivers/ide/ide-disk.c
@@ -77,6 +77,7 @@ struct ide_disk_obj {
 	ide_driver_t	*driver;
 	struct gendisk	*disk;
 	struct kref	kref;
+	unsigned int	openers;	/* protected by BKL for now */
 };
 
 static DEFINE_MUTEX(idedisk_ref_mutex);
@@ -1081,8 +1082,9 @@ static int idedisk_open(struct inode *in
 
 	drive = idkp->drive;
 
-	drive->usage++;
-	if (drive->removable && drive->usage == 1) {
+	idkp->openers++;
+
+	if (drive->removable && idkp->openers == 1) {
 		ide_task_t args;
 		memset(&args, 0, sizeof(ide_task_t));
 		args.tfRegister[IDE_COMMAND_OFFSET] = WIN_DOORLOCK;
@@ -1106,9 +1108,10 @@ static int idedisk_release(struct inode 
 	struct ide_disk_obj *idkp = ide_disk_g(disk);
 	ide_drive_t *drive = idkp->drive;
 
-	if (drive->usage == 1)
+	if (idkp->openers == 1)
 		ide_cacheflush_p(drive);
-	if (drive->removable && drive->usage == 1) {
+
+	if (drive->removable && idkp->openers == 1) {
 		ide_task_t args;
 		memset(&args, 0, sizeof(ide_task_t));
 		args.tfRegister[IDE_COMMAND_OFFSET] = WIN_DOORUNLOCK;
@@ -1117,7 +1120,8 @@ static int idedisk_release(struct inode 
 		if (drive->doorlocking && ide_raw_taskfile(drive, &args, NULL))
 			drive->doorlocking = 0;
 	}
-	drive->usage--;
+
+	idkp->openers--;
 
 	ide_disk_put(idkp);
 
Index: a/drivers/ide/ide-floppy.c
===================================================================
--- a.orig/drivers/ide/ide-floppy.c
+++ a/drivers/ide/ide-floppy.c
@@ -279,6 +279,7 @@ typedef struct ide_floppy_obj {
 	ide_driver_t	*driver;
 	struct gendisk	*disk;
 	struct kref	kref;
+	unsigned int	openers;	/* protected by BKL for now */
 
 	/* Current packet command */
 	idefloppy_pc_t *pc;
@@ -1949,9 +1950,9 @@ static int idefloppy_open(struct inode *
 
 	drive = floppy->drive;
 
-	drive->usage++;
+	floppy->openers++;
 
-	if (drive->usage == 1) {
+	if (floppy->openers == 1) {
 		clear_bit(IDEFLOPPY_FORMAT_IN_PROGRESS, &floppy->flags);
 		/* Just in case */
 
@@ -1969,13 +1970,11 @@ static int idefloppy_open(struct inode *
 		    ** capacity of the drive or begin the format - Sam
 		    */
 		    ) {
-			drive->usage--;
 			ret = -EIO;
 			goto out_put_floppy;
 		}
 
 		if (floppy->wp && (filp->f_mode & 2)) {
-			drive->usage--;
 			ret = -EROFS;
 			goto out_put_floppy;
 		}
@@ -1987,13 +1986,13 @@ static int idefloppy_open(struct inode *
 		}
 		check_disk_change(inode->i_bdev);
 	} else if (test_bit(IDEFLOPPY_FORMAT_IN_PROGRESS, &floppy->flags)) {
-		drive->usage--;
 		ret = -EBUSY;
 		goto out_put_floppy;
 	}
 	return 0;
 
 out_put_floppy:
+	floppy->openers--;
 	ide_floppy_put(floppy);
 	return ret;
 }
@@ -2007,7 +2006,7 @@ static int idefloppy_release(struct inod
 	
 	debug_log(KERN_INFO "Reached idefloppy_release\n");
 
-	if (drive->usage == 1) {
+	if (floppy->openers == 1) {
 		/* IOMEGA Clik! drives do not support lock/unlock commands */
                 if (!test_bit(IDEFLOPPY_CLIK_DRIVE, &floppy->flags)) {
 			idefloppy_create_prevent_cmd(&pc, 0);
@@ -2016,7 +2015,8 @@ static int idefloppy_release(struct inod
 
 		clear_bit(IDEFLOPPY_FORMAT_IN_PROGRESS, &floppy->flags);
 	}
-	drive->usage--;
+
+	floppy->openers--;
 
 	ide_floppy_put(floppy);
 
@@ -2050,7 +2050,7 @@ static int idefloppy_ioctl(struct inode 
 		prevent = 0;
 		/* fall through */
 	case CDROM_LOCKDOOR:
-		if (drive->usage > 1)
+		if (floppy->openers > 1)
 			return -EBUSY;
 
 		/* The IOMEGA Clik! Drive doesn't support this command - no room for an eject mechanism */
@@ -2072,7 +2072,7 @@ static int idefloppy_ioctl(struct inode 
 		if (!(file->f_mode & 2))
 			return -EPERM;
 
-		if (drive->usage > 1) {
+		if (floppy->openers > 1) {
 			/* Don't format if someone is using the disk */
 
 			clear_bit(IDEFLOPPY_FORMAT_IN_PROGRESS,
Index: a/drivers/ide/ide-tape.c
===================================================================
--- a.orig/drivers/ide/ide-tape.c
+++ a/drivers/ide/ide-tape.c
@@ -4792,15 +4792,10 @@ static int idetape_open(struct inode *in
 {
 	struct gendisk *disk = inode->i_bdev->bd_disk;
 	struct ide_tape_obj *tape;
-	ide_drive_t *drive;
 
 	if (!(tape = ide_tape_get(disk)))
 		return -ENXIO;
 
-	drive = tape->drive;
-
-	drive->usage++;
-
 	return 0;
 }
 
@@ -4808,9 +4803,6 @@ static int idetape_release(struct inode 
 {
 	struct gendisk *disk = inode->i_bdev->bd_disk;
 	struct ide_tape_obj *tape = ide_tape_g(disk);
-	ide_drive_t *drive = tape->drive;
-
-	drive->usage--;
 
 	ide_tape_put(tape);
 
Index: a/drivers/scsi/ide-scsi.c
===================================================================
--- a.orig/drivers/scsi/ide-scsi.c
+++ a/drivers/scsi/ide-scsi.c
@@ -801,15 +801,10 @@ static int idescsi_ide_open(struct inode
 {
 	struct gendisk *disk = inode->i_bdev->bd_disk;
 	struct ide_scsi_obj *scsi;
-	ide_drive_t *drive;
 
 	if (!(scsi = ide_scsi_get(disk)))
 		return -ENXIO;
 
-	drive = scsi->drive;
-
-	drive->usage++;
-
 	return 0;
 }
 
@@ -817,9 +812,6 @@ static int idescsi_ide_release(struct in
 {
 	struct gendisk *disk = inode->i_bdev->bd_disk;
 	struct ide_scsi_obj *scsi = ide_scsi_g(disk);
-	ide_drive_t *drive = scsi->drive;
-
-	drive->usage--;
 
 	ide_scsi_put(scsi);
 
Index: a/include/linux/ide.h
===================================================================
--- a.orig/include/linux/ide.h
+++ a/include/linux/ide.h
@@ -628,7 +628,6 @@ typedef struct ide_drive_s {
 	unsigned int	bios_cyl;	/* BIOS/fdisk/LILO number of cyls */
 	unsigned int	cyl;		/* "real" number of cyls */
 	unsigned int	drive_data;	/* use by tuneproc/selectproc */
-	unsigned int	usage;		/* current "open()" count for drive */
 	unsigned int	failures;	/* current failure count */
 	unsigned int	max_failures;	/* maximum allowed failure count */
 	u64		probed_capacity;/* initial reported media capacity (ide-cd only currently) */

  parent reply	other threads:[~2007-01-12  4:24 UTC|newest]

Thread overview: 28+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-01-12  4:26 [PATCH 2/19] ide: add it8213 driver Bartlomiej Zolnierkiewicz
2007-01-12  4:26 ` [PATCH 3/19] ide: it8213 driver update Bartlomiej Zolnierkiewicz
2007-01-12  4:26 ` [PATCH 4/19] ia64: add pci_get_legacy_ide_irq() Bartlomiej Zolnierkiewicz
2007-01-12  4:26 ` [PATCH 5/19] ide: add missing __init tags to IDE PCI host drivers Bartlomiej Zolnierkiewicz
2007-01-12  4:26 ` [PATCH 6/19] pdc202xx_old: remove dead code Bartlomiej Zolnierkiewicz
2007-01-12  4:26 ` [PATCH 7/19] au1xxx-ide: " Bartlomiej Zolnierkiewicz
2007-01-12  4:26 ` [PATCH 8/19] ide: remove write-only ide_pio_data_t.blacklisted Bartlomiej Zolnierkiewicz
2007-01-12  4:27 ` [PATCH 9/19] ide: remove write-only ide_hwif_t.no_dsc flag Bartlomiej Zolnierkiewicz
2007-01-12  4:27 ` [PATCH 10/19] trm290: remove redundant CONFIG_BLK_DEV_IDEDMA Bartlomiej Zolnierkiewicz
2007-01-12  4:27 ` [PATCH 11/19] ide: remove ide_pci_device_t tables with only one entry Bartlomiej Zolnierkiewicz
2007-01-12  4:27 ` Bartlomiej Zolnierkiewicz [this message]
2007-01-12  4:27 ` [PATCH 13/19] hpt366: remove redundant check from init_dma_hpt366() Bartlomiej Zolnierkiewicz
2007-01-12  4:27 ` [PATCH 14/19] cs5530: small cleanup Bartlomiej Zolnierkiewicz
2007-01-12  4:27 ` [PATCH 15/19] svwks: " Bartlomiej Zolnierkiewicz
2007-01-12  4:27 ` [PATCH 16/19] sis5513: sis5513_config_xfer_rate() cleanup Bartlomiej Zolnierkiewicz
2007-01-12  4:27 ` [PATCH 17/19] ide: unexport ide_set_xfer_rate() Bartlomiej Zolnierkiewicz
2007-01-12  4:28 ` [PATCH 18/19] ide: add ide_use_fast_pio() helper Bartlomiej Zolnierkiewicz
2007-01-12 10:08   ` Alan
2007-01-12 14:00     ` Bartlomiej Zolnierkiewicz
2007-01-12 14:30       ` Alan
2007-01-12 14:43         ` Bartlomiej Zolnierkiewicz
2007-01-12 15:16           ` Alan
2007-01-12 17:24             ` Bartlomiej Zolnierkiewicz
2007-01-12  4:28 ` [PATCH 19/19] ide: use PIO/MMIO operations directly where possible Bartlomiej Zolnierkiewicz
2007-01-12 10:06   ` Alan
2007-01-12 14:19     ` Bartlomiej Zolnierkiewicz
2007-06-21 17:16   ` Sergei Shtylyov
2007-06-21 18:19     ` Bartlomiej Zolnierkiewicz

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20070112042722.28794.74399.sendpatchset@localhost.localdomain \
    --to=bzolnier@gmail.com \
    --cc=linux-ide@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --subject='Re: [PATCH 12/19] ide: remove ide_drive_t.usage' \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link

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).