public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Tim Hockin <thockin@sun.com>
To: andre@linux-ide.org, torvalds@transmeta.com, alan@redhat.com,
	Linux Kernel Mailing List <linux-kernel@vger.kernel.org>
Subject: [PATCH] ide busproc() method
Date: Tue, 14 Aug 2001 17:51:13 -0700	[thread overview]
Message-ID: <3B79C781.E16B03B@sun.com> (raw)

[-- Attachment #1: Type: text/plain, Size: 572 bytes --]

All,

Attached is a smallpatch which implements the HDIO_GET/SET_BUSSTATE
ioctls.  These ioctl numbers were added as part of a previous patch I sent,
but the actual use of them did not get included.  

This adds support for the two ioctls and adds a hwif struct member to track
current state and a method to change the bus state.  This code is a key
part of hot-swappable IDE.

We've been using it for months without problems. Please patch this in for
the next 2.4.x.

Tim
-- 
Tim Hockin
Systems Software Engineer
Sun Microsystems, Cobalt Server Appliances
thockin@sun.com

[-- Attachment #2: ide_busproc.diff --]
[-- Type: text/plain, Size: 2074 bytes --]

diff -ruN dist+patches-2.4.8/drivers/ide/ide.c cobalt-2.4.8/drivers/ide/ide.c
--- dist+patches-2.4.8/drivers/ide/ide.c	Mon Aug 13 16:52:18 2001
+++ cobalt-2.4.8/drivers/ide/ide.c	Mon Aug 13 16:41:56 2001
@@ -249,6 +253,7 @@
 	hwif->name[1]	= 'd';
 	hwif->name[2]	= 'e';
 	hwif->name[3]	= '0' + index;
+	hwif->bus_state = BUSSTATE_ON;
 	for (unit = 0; unit < MAX_DRIVES; ++unit) {
 		ide_drive_t *drive = &hwif->drives[unit];
 
@@ -2090,6 +2112,8 @@
 	hwif->quirkproc		= old_hwif.quirkproc;
 	hwif->rwproc		= old_hwif.rwproc;
 	hwif->dmaproc		= old_hwif.dmaproc;
+	hwif->busproc		= old_hwif.busproc;
+	hwif->bus_state		= old_hwif.bus_state;
 	hwif->dma_base		= old_hwif.dma_base;
 	hwif->dma_extra		= old_hwif.dma_extra;
 	hwif->config_data	= old_hwif.config_data;
@@ -2673,6 +2697,20 @@
  		case BLKBSZSET:
 			return blk_ioctl(inode->i_rdev, cmd, arg);
 
+		case HDIO_GET_BUSSTATE:
+			if (!capable(CAP_SYS_ADMIN))
+				return -EACCES;
+			if (put_user(HWIF(drive)->bus_state, (long *)arg))
+				return -EFAULT;
+			return 0;
+
+		case HDIO_SET_BUSSTATE:
+			if (!capable(CAP_SYS_ADMIN))
+				return -EACCES;
+			if (HWIF(drive)->busproc)
+				HWIF(drive)->busproc(HWIF(drive), arg);
+			return 0;
+
 		default:
 			if (drive->driver != NULL)
 				return DRIVER(drive)->ioctl(drive, inode, file, cmd, arg);
diff -ruN dist+patches-2.4.8/include/linux/ide.h cobalt-2.4.8/include/linux/ide.h
--- dist+patches-2.4.8/include/linux/ide.h	Fri Aug 10 18:15:44 2001
+++ cobalt-2.4.8/include/linux/ide.h	Mon Aug 13 16:42:49 2001
@@ -397,6 +403,11 @@
 typedef void (ide_rw_proc_t) (ide_drive_t *, ide_dma_action_t);
 
 /*
+ * ide soft-power support
+ */
+typedef int (ide_busproc_t) (struct hwif_s *, int);
+
+/*
  * hwif_chipset_t is used to keep track of the specific hardware
  * chipset used by each IDE interface, if known.
  */
@@ -467,6 +478,8 @@
 #endif
 	byte		straight8;	/* Alan's straight 8 check */
 	void		*hwif_data;	/* extra hwif data */
+	ide_busproc_t	*busproc;	/* driver soft-power interface */
+	byte		bus_state;	/* power state of the IDE bus */
 } ide_hwif_t;
 
 

                 reply	other threads:[~2001-08-15  0:48 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

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

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

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

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

  git send-email \
    --in-reply-to=3B79C781.E16B03B@sun.com \
    --to=thockin@sun.com \
    --cc=alan@redhat.com \
    --cc=andre@linux-ide.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=torvalds@transmeta.com \
    /path/to/YOUR_REPLY

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

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox