From 0be53f272bd1e45378781314423bf238f0493f74 Mon Sep 17 00:00:00 2001 From: Trond Myklebust Date: Fri, 26 Jul 2002 00:00:01 -0700 Subject: [PATCH] clean up RPC write_space() code Make the RPC write_space() algoritm use the standard socket flags SOCK_ASYNC_NOSPACE and SOCK_NOSPACE instead of its own custom flag. --- include/linux/sunrpc/xprt.h | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) (limited to 'include/linux') diff --git a/include/linux/sunrpc/xprt.h b/include/linux/sunrpc/xprt.h index eca42599039f..e3c7a6b9c5ba 100644 --- a/include/linux/sunrpc/xprt.h +++ b/include/linux/sunrpc/xprt.h @@ -178,12 +178,7 @@ void xprt_release(struct rpc_task *); void xprt_reconnect(struct rpc_task *); int xprt_clear_backlog(struct rpc_xprt *); -#define XPRT_WSPACE 0 -#define XPRT_CONNECT 1 - -#define xprt_wspace(xp) (test_bit(XPRT_WSPACE, &(xp)->sockstate)) -#define xprt_test_and_set_wspace(xp) (test_and_set_bit(XPRT_WSPACE, &(xp)->sockstate)) -#define xprt_clear_wspace(xp) (clear_bit(XPRT_WSPACE, &(xp)->sockstate)) +#define XPRT_CONNECT 0 #define xprt_connected(xp) (!(xp)->stream || test_bit(XPRT_CONNECT, &(xp)->sockstate)) #define xprt_set_connected(xp) (set_bit(XPRT_CONNECT, &(xp)->sockstate)) -- cgit v1.2.3 From ff3cc6a09251f437f18029a7bd96f6bd55bccfb2 Mon Sep 17 00:00:00 2001 From: Trond Myklebust Date: Fri, 26 Jul 2002 00:00:14 -0700 Subject: [PATCH] increase socket buffer for RPC over UDP Make RPC over UDP use a socket buffer size that is large enough to fit all the messages. Congestion control is in any case handled by the Van Jacobson algoritm, and we need to work around a bug in ip_build_xmit_slow() w.r.t. fragmentation when there is insufficient buffer memory to fit the entire message. --- fs/nfs/inode.c | 3 ++- include/linux/sunrpc/clnt.h | 1 + include/linux/sunrpc/xprt.h | 4 ++++ net/sunrpc/clnt.c | 14 ++++++++++++++ net/sunrpc/sunrpc_syms.c | 1 + net/sunrpc/xprt.c | 21 +++++++++++++++++++++ 6 files changed, 43 insertions(+), 1 deletion(-) (limited to 'include/linux') diff --git a/fs/nfs/inode.c b/fs/nfs/inode.c index 40ad8333e475..ce7ad8ae64a3 100644 --- a/fs/nfs/inode.c +++ b/fs/nfs/inode.c @@ -425,7 +425,8 @@ int nfs_fill_super(struct super_block *sb, struct nfs_mount_data *data, int sile goto failure_kill_reqlist; } - /* We're airborne */ + /* We're airborne Set socket buffersize */ + rpc_setbufsize(clnt, server->wsize + 100, server->rsize + 100); /* Check whether to start the lockd process */ if (!(server->flags & NFS_MOUNT_NONLM)) diff --git a/include/linux/sunrpc/clnt.h b/include/linux/sunrpc/clnt.h index d278df00ecb9..92fa9755592e 100644 --- a/include/linux/sunrpc/clnt.h +++ b/include/linux/sunrpc/clnt.h @@ -127,6 +127,7 @@ int rpc_call_sync(struct rpc_clnt *clnt, struct rpc_message *msg, void rpc_restart_call(struct rpc_task *); void rpc_clnt_sigmask(struct rpc_clnt *clnt, sigset_t *oldset); void rpc_clnt_sigunmask(struct rpc_clnt *clnt, sigset_t *oldset); +void rpc_setbufsize(struct rpc_clnt *, unsigned int, unsigned int); static __inline__ int rpc_call(struct rpc_clnt *clnt, u32 proc, void *argp, void *resp, int flags) diff --git a/include/linux/sunrpc/xprt.h b/include/linux/sunrpc/xprt.h index e3c7a6b9c5ba..c9b93c6a7a27 100644 --- a/include/linux/sunrpc/xprt.h +++ b/include/linux/sunrpc/xprt.h @@ -122,6 +122,9 @@ struct rpc_xprt { unsigned long cong; /* current congestion */ unsigned long cwnd; /* congestion window */ + unsigned int rcvsize, /* socket receive buffer size */ + sndsize; /* socket send buffer size */ + struct rpc_wait_queue sending; /* requests waiting to send */ struct rpc_wait_queue resend; /* requests waiting to resend */ struct rpc_wait_queue pending; /* requests in flight */ @@ -177,6 +180,7 @@ int xprt_adjust_timeout(struct rpc_timeout *); void xprt_release(struct rpc_task *); void xprt_reconnect(struct rpc_task *); int xprt_clear_backlog(struct rpc_xprt *); +void xprt_sock_setbufsize(struct rpc_xprt *); #define XPRT_CONNECT 0 diff --git a/net/sunrpc/clnt.c b/net/sunrpc/clnt.c index 4d98ac870e85..001c2253ec8f 100644 --- a/net/sunrpc/clnt.c +++ b/net/sunrpc/clnt.c @@ -335,6 +335,20 @@ rpc_call_setup(struct rpc_task *task, struct rpc_message *msg, int flags) rpcproc_count(task->tk_client, task->tk_msg.rpc_proc)++; } +void +rpc_setbufsize(struct rpc_clnt *clnt, unsigned int sndsize, unsigned int rcvsize) +{ + struct rpc_xprt *xprt = clnt->cl_xprt; + + xprt->sndsize = 0; + if (sndsize) + xprt->sndsize = sndsize + RPC_SLACK_SPACE; + xprt->rcvsize = 0; + if (rcvsize) + xprt->rcvsize = rcvsize + RPC_SLACK_SPACE; + xprt_sock_setbufsize(xprt); +} + /* * Restart an (async) RPC call. Usually called from within the * exit handler. diff --git a/net/sunrpc/sunrpc_syms.c b/net/sunrpc/sunrpc_syms.c index d6bdb4630d2d..2b41eb87de5d 100644 --- a/net/sunrpc/sunrpc_syms.c +++ b/net/sunrpc/sunrpc_syms.c @@ -50,6 +50,7 @@ EXPORT_SYMBOL(rpc_clnt_sigmask); EXPORT_SYMBOL(rpc_clnt_sigunmask); EXPORT_SYMBOL(rpc_delay); EXPORT_SYMBOL(rpc_restart_call); +EXPORT_SYMBOL(rpc_setbufsize); /* Client transport */ EXPORT_SYMBOL(xprt_create_proto); diff --git a/net/sunrpc/xprt.c b/net/sunrpc/xprt.c index d805ed6c08d1..3d4ba37b48e1 100644 --- a/net/sunrpc/xprt.c +++ b/net/sunrpc/xprt.c @@ -1420,6 +1420,27 @@ xprt_bind_socket(struct rpc_xprt *xprt, struct socket *sock) return 0; } +/* + * Set socket buffer length + */ +void +xprt_sock_setbufsize(struct rpc_xprt *xprt) +{ + struct sock *sk = xprt->inet; + + if (xprt->stream) + return; + if (xprt->rcvsize) { + sk->userlocks |= SOCK_RCVBUF_LOCK; + sk->rcvbuf = xprt->rcvsize * RPC_MAXCONG * 2; + } + if (xprt->sndsize) { + sk->userlocks |= SOCK_SNDBUF_LOCK; + sk->sndbuf = xprt->sndsize * RPC_MAXCONG * 2; + sk->write_space(sk); + } +} + /* * Create a client socket given the protocol and peer address. */ -- cgit v1.2.3 From bea92fd5b343aec2b7e3b3637e3651709dd226ca Mon Sep 17 00:00:00 2001 From: Trond Myklebust Date: Fri, 26 Jul 2002 00:00:40 -0700 Subject: [PATCH] add proper NFSv3 permissions checking. Add full support for the NFSv3 permissions checking. Ensures that we work properly with NFSv3 servers that do uid/gid mapping and/or have support for ACLs. Permissions are cached in the struct nfs_inode in order to reduce the number of RPC calls. The cache timeout period is given by the ordinary attribute timeout. --- fs/nfs/dir.c | 82 ++++++++++++++++++++++++++++++++++--------------- fs/nfs/inode.c | 17 +++++++++- fs/nfs/nfs3proc.c | 17 ++++++---- include/linux/nfs_fs.h | 12 ++++++++ include/linux/nfs_xdr.h | 2 +- 5 files changed, 97 insertions(+), 33 deletions(-) (limited to 'include/linux') diff --git a/fs/nfs/dir.c b/fs/nfs/dir.c index 1bc397eaca7b..c03054d0e721 100644 --- a/fs/nfs/dir.c +++ b/fs/nfs/dir.c @@ -1080,38 +1080,70 @@ out: int nfs_permission(struct inode *inode, int mask) { - int error = vfs_permission(inode, mask); + struct nfs_access_cache *cache = &NFS_I(inode)->cache_access; + struct rpc_cred *cred; + int mode = inode->i_mode; + int res; - if (!NFS_PROTO(inode)->access) - goto out; - - if (error == -EROFS) - goto out; + if (mask & MAY_WRITE) { + /* + * + * Nobody gets write access to a read-only fs. + * + */ + if (IS_RDONLY(inode) && + (S_ISREG(mode) || S_ISDIR(mode) || S_ISLNK(mode))) + return -EROFS; - /* - * Trust UNIX mode bits except: - * - * 1) When override capabilities may have been invoked - * 2) When root squashing may be involved - * 3) When ACLs may overturn a negative answer */ - if (!capable(CAP_DAC_OVERRIDE) && !capable(CAP_DAC_READ_SEARCH) - && (current->fsuid != 0) && (current->fsgid != 0) - && error != -EACCES) - goto out; + /* + * + * Nobody gets write access to an immutable file. + * + */ + if (IS_IMMUTABLE(inode)) + return -EACCES; + } lock_kernel(); - error = NFS_PROTO(inode)->access(inode, mask, 0); - - if (error == -EACCES && NFS_CLIENT(inode)->cl_droppriv && - current->uid != 0 && current->gid != 0 && - (current->fsuid != current->uid || current->fsgid != current->gid)) - error = NFS_PROTO(inode)->access(inode, mask, 1); + if (!NFS_PROTO(inode)->access) + goto out_notsup; + + cred = rpcauth_lookupcred(NFS_CLIENT(inode)->cl_auth, 0); + if (cache->cred == cred + && time_before(jiffies, cache->jiffies + NFS_ATTRTIMEO(inode))) { + if (!(res = cache->err)) { + /* Is the mask a subset of an accepted mask? */ + if ((cache->mask & mask) == mask) + goto out; + } else { + /* ...or is it a superset of a rejected mask? */ + if ((cache->mask & mask) == cache->mask) + goto out; + } + } + res = NFS_PROTO(inode)->access(inode, cred, mask); + if (!res || res == -EACCES) + goto add_cache; +out: + put_rpccred(cred); unlock_kernel(); - - out: - return error; + return res; +out_notsup: + nfs_revalidate_inode(NFS_SERVER(inode), inode); + res = vfs_permission(inode, mask); + unlock_kernel(); + return res; +add_cache: + cache->jiffies = jiffies; + if (cache->cred) + put_rpccred(cache->cred); + cache->cred = cred; + cache->mask = mask; + cache->err = res; + unlock_kernel(); + return res; } /* diff --git a/fs/nfs/inode.c b/fs/nfs/inode.c index 805bf9a737c9..12985cb77ede 100644 --- a/fs/nfs/inode.c +++ b/fs/nfs/inode.c @@ -125,8 +125,12 @@ nfs_delete_inode(struct inode * inode) static void nfs_clear_inode(struct inode *inode) { - struct rpc_cred *cred = NFS_I(inode)->mm_cred; + struct nfs_inode *nfsi = NFS_I(inode); + struct rpc_cred *cred = nfsi->mm_cred; + if (cred) + put_rpccred(cred); + cred = nfsi->cache_access.cred; if (cred) put_rpccred(cred); } @@ -722,6 +726,7 @@ __nfs_fhget(struct super_block *sb, struct nfs_fh *fh, struct nfs_fattr *fattr) NFS_ATTRTIMEO(inode) = NFS_MINATTRTIMEO(inode); NFS_ATTRTIMEO_UPDATE(inode) = jiffies; memset(NFS_COOKIEVERF(inode), 0, sizeof(NFS_COOKIEVERF(inode))); + NFS_I(inode)->cache_access.cred = NULL; unlock_new_inode(inode); } else @@ -1085,6 +1090,16 @@ __nfs_refresh_inode(struct inode *inode, struct nfs_fattr *fattr) NFS_CACHE_ISIZE(inode) = new_size; inode->i_size = new_isize; + if (inode->i_mode != fattr->mode || + inode->i_uid != fattr->uid || + inode->i_gid != fattr->gid) { + struct rpc_cred **cred = &NFS_I(inode)->cache_access.cred; + if (*cred) { + put_rpccred(*cred); + *cred = NULL; + } + } + inode->i_mode = fattr->mode; inode->i_nlink = fattr->nlink; inode->i_uid = fattr->uid; diff --git a/fs/nfs/nfs3proc.c b/fs/nfs/nfs3proc.c index bf24dabd2984..1f4610d1405d 100644 --- a/fs/nfs/nfs3proc.c +++ b/fs/nfs/nfs3proc.c @@ -133,16 +133,22 @@ nfs3_proc_lookup(struct inode *dir, struct qstr *name, } static int -nfs3_proc_access(struct inode *inode, int mode, int ruid) +nfs3_proc_access(struct inode *inode, struct rpc_cred *cred, int mode) { struct nfs_fattr fattr; struct nfs3_accessargs arg = { - fh: NFS_FH(inode), + .fh = NFS_FH(inode), }; struct nfs3_accessres res = { - fattr: &fattr, + .fattr = &fattr, + }; + struct rpc_message msg = { + .rpc_proc = NFS3PROC_ACCESS, + .rpc_argp = &arg, + .rpc_resp = &res, + .rpc_cred = cred }; - int status, flags; + int status; dprintk("NFS call access\n"); fattr.valid = 0; @@ -160,8 +166,7 @@ nfs3_proc_access(struct inode *inode, int mode, int ruid) if (mode & MAY_EXEC) arg.access |= NFS3_ACCESS_EXECUTE; } - flags = (ruid) ? RPC_CALL_REALUID : 0; - status = rpc_call(NFS_CLIENT(inode), NFS3PROC_ACCESS, &arg, &res, flags); + status = rpc_call_sync(NFS_CLIENT(inode), &msg, 0); nfs_refresh_inode(inode, &fattr); dprintk("NFS reply access\n"); diff --git a/include/linux/nfs_fs.h b/include/linux/nfs_fs.h index f45c35f298e6..02ef81aee197 100644 --- a/include/linux/nfs_fs.h +++ b/include/linux/nfs_fs.h @@ -89,6 +89,16 @@ #ifdef __KERNEL__ +/* + * NFSv3 Access mode cache + */ +struct nfs_access_cache { + unsigned long jiffies; + struct rpc_cred * cred; + int mask; + int err; +}; + /* * nfs fs inode data in memory */ @@ -138,6 +148,8 @@ struct nfs_inode { */ unsigned long cache_mtime_jiffies; + struct nfs_access_cache cache_access; + /* * This is the cookie verifier used for NFSv3 readdir * operations diff --git a/include/linux/nfs_xdr.h b/include/linux/nfs_xdr.h index 110e5b661b58..53ec9c0b94d0 100644 --- a/include/linux/nfs_xdr.h +++ b/include/linux/nfs_xdr.h @@ -300,7 +300,7 @@ struct nfs_rpc_ops { struct iattr *); int (*lookup) (struct inode *, struct qstr *, struct nfs_fh *, struct nfs_fattr *); - int (*access) (struct inode *, int , int); + int (*access) (struct inode *, struct rpc_cred *, int); int (*readlink)(struct inode *, struct page *); int (*read) (struct inode *, struct rpc_cred *, struct nfs_fattr *, -- cgit v1.2.3 From cc1d784041442a6eb4d5b0fadf2fcb095c093e89 Mon Sep 17 00:00:00 2001 From: Martin Dalecki Date: Fri, 26 Jul 2002 01:14:19 -0700 Subject: [PATCH] 2.5.28 small REQ_SPECIAL abstraction The attached patch does the following: 1. Remove blkdev_release_request(Request); it was an unnecessary wrapper around blk_put_request(Request). Likely some leftover from pre-BIO time... 2. Abstract out the fine __scsi_insert_special() function out from the SCSI code. Now that I have finally managed to kill all those IDE 'specific' REQ_BLAH request types, we can do this final step, and it will be used soon at least by ATA code as well. The goal is that scsi_request_fn and do_ide_request should start to look similar like silblings. Its called blk_insert_request() now and even documented in code. 3. Change some stuff over from extern inline to static inline in blkdev.h. (trivia...) This patch doesn't change *any* functionality, so its not exposing SCSI to any danger :-). --- drivers/block/DAC960.c | 2 +- drivers/block/ll_rw_blk.c | 52 ++++++++++++++++++++++++++++++++++++++++------- drivers/scsi/scsi_lib.c | 51 ++-------------------------------------------- include/linux/blkdev.h | 31 ++++++++++++++-------------- include/linux/nbd.h | 2 +- 5 files changed, 64 insertions(+), 74 deletions(-) (limited to 'include/linux') diff --git a/drivers/block/DAC960.c b/drivers/block/DAC960.c index dc372aa4dbb1..59e4b53dfce5 100644 --- a/drivers/block/DAC960.c +++ b/drivers/block/DAC960.c @@ -2884,7 +2884,7 @@ static boolean DAC960_ProcessRequest(DAC960_Controller_T *Controller, Command->BufferHeader = Request->bio; Command->RequestBuffer = Request->buffer; blkdev_dequeue_request(Request); - blkdev_release_request(Request); + blk_put_request(Request); DAC960_QueueReadWriteCommand(Command); return true; } diff --git a/drivers/block/ll_rw_blk.c b/drivers/block/ll_rw_blk.c index e73c1d823428..53f1706d2877 100644 --- a/drivers/block/ll_rw_blk.c +++ b/drivers/block/ll_rw_blk.c @@ -1233,9 +1233,47 @@ struct request *__blk_get_request(request_queue_t *q, int rw) return rq; } -void blk_put_request(struct request *rq) +/** + * blk_insert_request - insert a special request in to a request queue + * @q: request queue where request should be inserted + * @rq: request to be inserted + * @at_head: insert request at head or tail of queue + * @data: private data + * + * Description: + * Many block devices need to execute commands asynchronously, so they don't + * block the whole kernel from preemption during request execution. This is + * accomplished normally by inserting aritficial requests tagged as + * REQ_SPECIAL in to the corresponding request queue, and letting them be + * scheduled for actual execution by the request queue. + * + * We have the option of inserting the head or the tail of the queue. + * Typically we use the tail for new ioctls and so forth. We use the head + * of the queue for things like a QUEUE_FULL message from a device, or a + * host that is unable to accept a particular command. + */ +void blk_insert_request(request_queue_t *q, struct request *rq, + int at_head, void *data) { - blkdev_release_request(rq); + unsigned long flags; + + /* + * tell I/O scheduler that this isn't a regular read/write (ie it + * must not attempt merges on this) and that it acts as a soft + * barrier + */ + rq->flags &= REQ_QUEUED; + rq->flags |= REQ_SPECIAL | REQ_BARRIER; + + rq->special = data; + + spin_lock_irqsave(q->queue_lock, flags); + /* If command is tagged, release the tag */ + if(blk_rq_tagged(rq)) + blk_queue_end_tag(q, rq); + _elv_add_request(q, rq, !at_head, 0); + q->request_fn(q); + spin_unlock_irqrestore(q->queue_lock, flags); } /* RO fail safe mechanism */ @@ -1307,7 +1345,7 @@ static inline void add_request(request_queue_t * q, struct request * req, /* * Must be called with queue lock held and interrupts disabled */ -void blkdev_release_request(struct request *req) +void blk_put_request(struct request *req) { struct request_list *rl = req->rl; request_queue_t *q = req->q; @@ -1370,7 +1408,7 @@ static void attempt_merge(request_queue_t *q, struct request *req, req->nr_sectors = req->hard_nr_sectors += next->hard_nr_sectors; - blkdev_release_request(next); + blk_put_request(next); } } @@ -1568,7 +1606,7 @@ get_rq: add_request(q, req, insert_here); out: if (freereq) - blkdev_release_request(freereq); + blk_put_request(freereq); spin_unlock_irq(q->queue_lock); return 0; @@ -2003,7 +2041,7 @@ void end_that_request_last(struct request *req) if (req->waiting) complete(req->waiting); - blkdev_release_request(req); + blk_put_request(req); } #define MB(kb) ((kb) << 10) @@ -2064,7 +2102,6 @@ EXPORT_SYMBOL(blk_cleanup_queue); EXPORT_SYMBOL(blk_queue_make_request); EXPORT_SYMBOL(blk_queue_bounce_limit); EXPORT_SYMBOL(generic_make_request); -EXPORT_SYMBOL(blkdev_release_request); EXPORT_SYMBOL(generic_unplug_device); EXPORT_SYMBOL(blk_plug_device); EXPORT_SYMBOL(blk_remove_plug); @@ -2088,6 +2125,7 @@ EXPORT_SYMBOL(blk_hw_contig_segment); EXPORT_SYMBOL(blk_get_request); EXPORT_SYMBOL(__blk_get_request); EXPORT_SYMBOL(blk_put_request); +EXPORT_SYMBOL(blk_insert_request); EXPORT_SYMBOL(blk_queue_prep_rq); diff --git a/drivers/scsi/scsi_lib.c b/drivers/scsi/scsi_lib.c index 0bbb215e7a8d..9f516d0d204d 100644 --- a/drivers/scsi/scsi_lib.c +++ b/drivers/scsi/scsi_lib.c @@ -50,53 +50,6 @@ * This entire source file deals with the new queueing code. */ -/* - * Function: __scsi_insert_special() - * - * Purpose: worker for scsi_insert_special_*() - * - * Arguments: q - request queue where request should be inserted - * rq - request to be inserted - * data - private data - * at_head - insert request at head or tail of queue - * - * Lock status: Assumed that queue lock is not held upon entry. - * - * Returns: Nothing - */ -static void __scsi_insert_special(request_queue_t *q, struct request *rq, - void *data, int at_head) -{ - unsigned long flags; - - ASSERT_LOCK(q->queue_lock, 0); - - /* - * tell I/O scheduler that this isn't a regular read/write (ie it - * must not attempt merges on this) and that it acts as a soft - * barrier - */ - rq->flags &= REQ_QUEUED; - rq->flags |= REQ_SPECIAL | REQ_BARRIER; - - rq->special = data; - - /* - * We have the option of inserting the head or the tail of the queue. - * Typically we use the tail for new ioctls and so forth. We use the - * head of the queue for things like a QUEUE_FULL message from a - * device, or a host that is unable to accept a particular command. - */ - spin_lock_irqsave(q->queue_lock, flags); - /* If command is tagged, release the tag */ - if(blk_rq_tagged(rq)) - blk_queue_end_tag(q, rq); - _elv_add_request(q, rq, !at_head, 0); - q->request_fn(q); - spin_unlock_irqrestore(q->queue_lock, flags); -} - - /* * Function: scsi_insert_special_cmd() * @@ -121,7 +74,7 @@ int scsi_insert_special_cmd(Scsi_Cmnd * SCpnt, int at_head) { request_queue_t *q = &SCpnt->device->request_queue; - __scsi_insert_special(q, SCpnt->request, SCpnt, at_head); + blk_insert_request(q, SCpnt->request, at_head, SCpnt); return 0; } @@ -149,7 +102,7 @@ int scsi_insert_special_req(Scsi_Request * SRpnt, int at_head) { request_queue_t *q = &SRpnt->sr_device->request_queue; - __scsi_insert_special(q, SRpnt->sr_request, SRpnt, at_head); + blk_insert_request(q, SRpnt->sr_request, at_head, SRpnt); return 0; } diff --git a/include/linux/blkdev.h b/include/linux/blkdev.h index 726492d4c45a..f83c52f82ab0 100644 --- a/include/linux/blkdev.h +++ b/include/linux/blkdev.h @@ -281,12 +281,13 @@ extern int wipe_partitions(kdev_t dev); extern void register_disk(struct gendisk *dev, kdev_t first, unsigned minors, struct block_device_operations *ops, long size); extern void generic_make_request(struct bio *bio); extern inline request_queue_t *bdev_get_queue(struct block_device *bdev); -extern void blkdev_release_request(struct request *); +extern void blk_put_request(struct request *); extern void blk_attempt_remerge(request_queue_t *, struct request *); extern void __blk_attempt_remerge(request_queue_t *, struct request *); extern struct request *blk_get_request(request_queue_t *, int, int); extern struct request *__blk_get_request(request_queue_t *, int); extern void blk_put_request(struct request *); +extern void blk_insert_request(request_queue_t *, struct request *, int, void *); extern void blk_plug_device(request_queue_t *); extern int blk_remove_plug(request_queue_t *); extern void blk_recount_segments(request_queue_t *, struct bio *); @@ -309,20 +310,21 @@ extern int blk_init_queue(request_queue_t *, request_fn_proc *, spinlock_t *); extern void blk_cleanup_queue(request_queue_t *); extern void blk_queue_make_request(request_queue_t *, make_request_fn *); extern void blk_queue_bounce_limit(request_queue_t *, u64); -extern void blk_queue_max_sectors(request_queue_t *q, unsigned short); -extern void blk_queue_max_phys_segments(request_queue_t *q, unsigned short); -extern void blk_queue_max_hw_segments(request_queue_t *q, unsigned short); -extern void blk_queue_max_segment_size(request_queue_t *q, unsigned int); -extern void blk_queue_hardsect_size(request_queue_t *q, unsigned short); -extern void blk_queue_segment_boundary(request_queue_t *q, unsigned long); -extern void blk_queue_assign_lock(request_queue_t *q, spinlock_t *); -extern void blk_queue_prep_rq(request_queue_t *q, prep_rq_fn *pfn); +extern void blk_queue_max_sectors(request_queue_t *, unsigned short); +extern void blk_queue_max_phys_segments(request_queue_t *, unsigned short); +extern void blk_queue_max_hw_segments(request_queue_t *, unsigned short); +extern void blk_queue_max_segment_size(request_queue_t *, unsigned int); +extern void blk_queue_hardsect_size(request_queue_t *, unsigned short); +extern void blk_queue_segment_boundary(request_queue_t *, unsigned long); +extern void blk_queue_assign_lock(request_queue_t *, spinlock_t *); +extern void blk_queue_prep_rq(request_queue_t *, prep_rq_fn *pfn); extern struct backing_dev_info *blk_get_backing_dev_info(struct block_device *bdev); extern int blk_rq_map_sg(request_queue_t *, struct request *, struct scatterlist *); extern void blk_dump_rq_flags(struct request *, char *); extern void generic_unplug_device(void *); + /* * tag stuff */ @@ -348,15 +350,12 @@ extern int * blk_size[MAX_BLKDEV]; /* in units of 1024 bytes */ extern void drive_stat_acct(struct request *, int, int); -extern inline void blk_clear(int major) +static inline void blk_clear(int major) { blk_size[major] = NULL; -#if 0 - blk_size_in_bytes[major] = NULL; -#endif } -extern inline int queue_hardsect_size(request_queue_t *q) +static inline int queue_hardsect_size(request_queue_t *q) { int retval = 512; @@ -366,7 +365,7 @@ extern inline int queue_hardsect_size(request_queue_t *q) return retval; } -extern inline int bdev_hardsect_size(struct block_device *bdev) +static inline int bdev_hardsect_size(struct block_device *bdev) { return queue_hardsect_size(bdev_get_queue(bdev)); } @@ -375,7 +374,7 @@ extern inline int bdev_hardsect_size(struct block_device *bdev) #define blk_started_io(nsects) do { } while (0) /* assumes size > 256 */ -extern inline unsigned int blksize_bits(unsigned int size) +static inline unsigned int blksize_bits(unsigned int size) { unsigned int bits = 8; do { diff --git a/include/linux/nbd.h b/include/linux/nbd.h index eae4f5bbb65a..e2c507ba6b08 100644 --- a/include/linux/nbd.h +++ b/include/linux/nbd.h @@ -61,7 +61,7 @@ nbd_end_request(struct request *req) bio->bi_next = NULL; bio_endio(bio, uptodate); } - blkdev_release_request(req); + blk_put_request(req); spin_unlock_irqrestore(q->queue_lock, flags); } -- cgit v1.2.3 From 81fed994891521cc72808f48845077a6cb1365a9 Mon Sep 17 00:00:00 2001 From: Martin Dalecki Date: Fri, 26 Jul 2002 01:14:58 -0700 Subject: [PATCH] IDE 104 - Make the bit-sliced data types in hdreg.h use the bit-slice data types instead of the generic ones. This makes clear that those are supposed to be register masks. --- include/linux/hdreg.h | 488 +++++++++++++++++++++++++------------------------- 1 file changed, 241 insertions(+), 247 deletions(-) (limited to 'include/linux') diff --git a/include/linux/hdreg.h b/include/linux/hdreg.h index 6f1fd4aae99a..dcedacb849ea 100644 --- a/include/linux/hdreg.h +++ b/include/linux/hdreg.h @@ -261,17 +261,17 @@ struct hd_drive_task_hdr { #define SECURITY_DISABLE_PASSWORD 0xBF struct hd_geometry { - unsigned char heads; - unsigned char sectors; - unsigned short cylinders; + u8 heads; + u8 sectors; + u16 cylinders; unsigned long start; }; /* BIG GEOMETRY - dying, used only by HDIO_GETGEO_BIG_RAW */ struct hd_big_geometry { - unsigned char heads; - unsigned char sectors; - unsigned int cylinders; + u8 heads; + u8 sectors; + u32 cylinders; unsigned long start; }; @@ -326,249 +326,243 @@ enum { * ide/probe.c. */ struct hd_driveid { - unsigned short config; /* lots of obsolete bit flags */ - unsigned short cyls; /* Obsolete, "physical" cyls */ - unsigned short reserved2; /* reserved (word 2) */ - unsigned short heads; /* Obsolete, "physical" heads */ - unsigned short track_bytes; /* unformatted bytes per track */ - unsigned short sector_bytes; /* unformatted bytes per sector */ - unsigned short sectors; /* Obsolete, "physical" sectors per track */ - unsigned short vendor0; /* vendor unique */ - unsigned short vendor1; /* vendor unique */ - unsigned short vendor2; /* Retired vendor unique */ - unsigned char serial_no[20]; /* 0 = not_specified */ - unsigned short buf_type; /* Retired */ - unsigned short buf_size; /* Retired, 512 byte increments - * 0 = not_specified - */ - unsigned short ecc_bytes; /* for r/w long cmds; 0 = not_specified */ - unsigned char fw_rev[8]; /* 0 = not_specified */ - unsigned char model[40]; /* 0 = not_specified */ - unsigned char max_multsect; /* 0=not_implemented */ - unsigned char vendor3; /* vendor unique */ - unsigned short dword_io; /* 0=not_implemented; 1=implemented */ - unsigned char vendor4; /* vendor unique */ - unsigned char capability; /* (upper byte of word 49) - * 3: IORDYsup - * 2: IORDYsw - * 1: LBA - * 0: DMA - */ - unsigned short reserved50; /* reserved (word 50) */ - unsigned char vendor5; /* Obsolete, vendor unique */ - unsigned char tPIO; /* Obsolete, 0=slow, 1=medium, 2=fast */ - unsigned char vendor6; /* Obsolete, vendor unique */ - unsigned char tDMA; /* Obsolete, 0=slow, 1=medium, 2=fast */ - unsigned short field_valid; /* (word 53) - * 2: ultra_ok word 88 - * 1: eide_ok words 64-70 - * 0: cur_ok words 54-58 - */ - unsigned short cur_cyls; /* Obsolete, logical cylinders */ - unsigned short cur_heads; /* Obsolete, l heads */ - unsigned short cur_sectors; /* Obsolete, l sectors per track */ - unsigned short cur_capacity0; /* Obsolete, l total sectors on drive */ - unsigned short cur_capacity1; /* Obsolete, (2 words, misaligned int) */ - unsigned char multsect; /* current multiple sector count */ - unsigned char multsect_valid; /* when (bit0==1) multsect is ok */ - unsigned int lba_capacity; /* Obsolete, total number of sectors */ - unsigned short dma_1word; /* Obsolete, single-word dma info */ - unsigned short dma_mword; /* multiple-word dma info */ - unsigned short eide_pio_modes; /* bits 0:mode3 1:mode4 */ - unsigned short eide_dma_min; /* min mword dma cycle time (ns) */ - unsigned short eide_dma_time; /* recommended mword dma cycle time (ns) */ - unsigned short eide_pio; /* min cycle time (ns), no IORDY */ - unsigned short eide_pio_iordy; /* min cycle time (ns), with IORDY */ - unsigned short words69_70[2]; /* reserved words 69-70 - * future command overlap and queuing - */ + u16 config; /* lots of obsolete bit flags */ + u16 cyls; /* Obsolete, "physical" cyls */ + u16 reserved2; /* reserved (word 2) */ + u16 heads; /* Obsolete, "physical" heads */ + u16 track_bytes; /* unformatted bytes per track */ + u16 sector_bytes; /* unformatted bytes per sector */ + u16 sectors; /* Obsolete, "physical" sectors per track */ + u16 vendor0; /* vendor unique */ + u16 vendor1; /* vendor unique */ + u16 vendor2; /* Retired vendor unique */ + u8 serial_no[20]; /* 0 = not_specified */ + u16 buf_type; /* Retired */ + u16 buf_size; /* Retired, 512 byte increments + * 0 = not_specified + */ + u16 ecc_bytes; /* for r/w long cmds; 0 = not_specified */ + u8 fw_rev[8]; /* 0 = not_specified */ + char model[40]; /* 0 = not_specified */ + u8 max_multsect; /* 0=not_implemented */ + u8 vendor3; /* vendor unique */ + u16 dword_io; /* 0=not_implemented; 1=implemented */ + u8 vendor4; /* vendor unique */ + u8 capability; /* (upper byte of word 49) + * 3: IORDYsup + * 2: IORDYsw + * 1: LBA + * 0: DMA + */ + u16 reserved50; /* reserved (word 50) */ + u8 vendor5; /* Obsolete, vendor unique */ + u8 tPIO; /* Obsolete, 0=slow, 1=medium, 2=fast */ + u8 vendor6; /* Obsolete, vendor unique */ + u8 tDMA; /* Obsolete, 0=slow, 1=medium, 2=fast */ + u16 field_valid; /* (word 53) + * 2: ultra_ok word 88 + * 1: eide_ok words 64-70 + * 0: cur_ok words 54-58 + */ + u16 cur_cyls; /* Obsolete, logical cylinders */ + u16 cur_heads; /* Obsolete, l heads */ + u16 cur_sectors; /* Obsolete, l sectors per track */ + u16 cur_capacity0; /* Obsolete, l total sectors on drive */ + u16 cur_capacity1; /* Obsolete, (2 words, misaligned int) */ + u8 multsect; /* current multiple sector count */ + u8 multsect_valid; /* when (bit0==1) multsect is ok */ + u32 lba_capacity; /* Obsolete, total number of sectors */ + u16 dma_1word; /* Obsolete, single-word dma info */ + u16 dma_mword; /* multiple-word dma info */ + u16 eide_pio_modes; /* bits 0:mode3 1:mode4 */ + u16 eide_dma_min; /* min mword dma cycle time (ns) */ + u16 eide_dma_time; /* recommended mword dma cycle time (ns) */ + u16 eide_pio; /* min cycle time (ns), no IORDY */ + u16 eide_pio_iordy; /* min cycle time (ns), with IORDY */ + u16 words69_70[2]; /* reserved words 69-70 + * future command overlap and queuing + */ /* HDIO_GET_IDENTITY currently returns only words 0 through 70 */ - unsigned short words71_74[4]; /* reserved words 71-74 - * for IDENTIFY PACKET DEVICE command - */ - unsigned short queue_depth; /* (word 75) - * 15:5 reserved - * 4:0 Maximum queue depth -1 - */ - unsigned short words76_79[4]; /* reserved words 76-79 */ - unsigned short major_rev_num; /* (word 80) */ - unsigned short minor_rev_num; /* (word 81) */ - unsigned short command_set_1; /* (word 82) supported - * 15: Obsolete - * 14: NOP command - * 13: READ_BUFFER - * 12: WRITE_BUFFER - * 11: Obsolete - * 10: Host Protected Area - * 9: DEVICE Reset - * 8: SERVICE Interrupt - * 7: Release Interrupt - * 6: look-ahead - * 5: write cache - * 4: PACKET Command - * 3: Power Management Feature Set - * 2: Removable Feature Set - * 1: Security Feature Set - * 0: SMART Feature Set - */ - unsigned short command_set_2; /* (word 83) - * 15: Shall be ZERO - * 14: Shall be ONE - * 13: FLUSH CACHE EXT - * 12: FLUSH CACHE - * 11: Device Configuration Overlay - * 10: 48-bit Address Feature Set - * 9: Automatic Acoustic Management - * 8: SET MAX security - * 7: reserved 1407DT PARTIES - * 6: SetF sub-command Power-Up - * 5: Power-Up in Standby Feature Set - * 4: Removable Media Notification - * 3: APM Feature Set - * 2: CFA Feature Set - * 1: READ/WRITE DMA QUEUED - * 0: Download MicroCode - */ - unsigned short cfsse; /* (word 84) - * cmd set-feature supported extensions - * 15: Shall be ZERO - * 14: Shall be ONE - * 13:3 reserved - * 2: Media Serial Number Valid - * 1: SMART selt-test supported - * 0: SMART error logging - */ - unsigned short cfs_enable_1; /* (word 85) - * command set-feature enabled - * 15: Obsolete - * 14: NOP command - * 13: READ_BUFFER - * 12: WRITE_BUFFER - * 11: Obsolete - * 10: Host Protected Area - * 9: DEVICE Reset - * 8: SERVICE Interrupt - * 7: Release Interrupt - * 6: look-ahead - * 5: write cache - * 4: PACKET Command - * 3: Power Management Feature Set - * 2: Removable Feature Set - * 1: Security Feature Set - * 0: SMART Feature Set - */ - unsigned short cfs_enable_2; /* (word 86) - * command set-feature enabled - * 15: Shall be ZERO - * 14: Shall be ONE - * 13: FLUSH CACHE EXT - * 12: FLUSH CACHE - * 11: Device Configuration Overlay - * 10: 48-bit Address Feature Set - * 9: Automatic Acoustic Management - * 8: SET MAX security - * 7: reserved 1407DT PARTIES - * 6: SetF sub-command Power-Up - * 5: Power-Up in Standby Feature Set - * 4: Removable Media Notification - * 3: APM Feature Set - * 2: CFA Feature Set - * 1: READ/WRITE DMA QUEUED - * 0: Download MicroCode - */ - unsigned short csf_default; /* (word 87) - * command set-feature default - * 15: Shall be ZERO - * 14: Shall be ONE - * 13:3 reserved - * 2: Media Serial Number Valid - * 1: SMART selt-test supported - * 0: SMART error logging - */ - unsigned short dma_ultra; /* (word 88) */ - unsigned short word89; /* reserved (word 89) */ - unsigned short word90; /* reserved (word 90) */ - unsigned short CurAPMvalues; /* current APM values */ - unsigned short word92; /* reserved (word 92) */ - unsigned short hw_config; /* hardware config (word 93) - * 15: - * 14: - * 13: - * 12: - * 11: - * 10: - * 9: - * 8: - * 7: - * 6: - * 5: - * 4: - * 3: - * 2: - * 1: - * 0: - */ - unsigned short acoustic; /* (word 94) - * 15:8 Vendor's recommended value - * 7:0 current value - */ - unsigned short words95_99[5]; /* reserved words 95-99 */ - unsigned long long lba_capacity_2;/* 48-bit total number of sectors */ - unsigned short words104_125[22];/* reserved words 104-125 */ - unsigned short last_lun; /* (word 126) */ - unsigned short word127; /* (word 127) Feature Set - * Removable Media Notification - * 15:2 reserved - * 1:0 00 = not supported - * 01 = supported - * 10 = reserved - * 11 = reserved - */ - unsigned short dlf; /* (word 128) - * device lock function - * 15:9 reserved - * 8 security level 1:max 0:high - * 7:6 reserved - * 5 enhanced erase - * 4 expire - * 3 frozen - * 2 locked - * 1 en/disabled - * 0 capability - */ - unsigned short csfo; /* (word 129) - * current set features options - * 15:4 reserved - * 3: auto reassign - * 2: reverting - * 1: read-look-ahead - * 0: write cache - */ - unsigned short words130_155[26];/* reserved vendor words 130-155 */ - unsigned short word156; /* reserved vendor word 156 */ - unsigned short words157_159[3];/* reserved vendor words 157-159 */ - unsigned short cfa_power; /* (word 160) CFA Power Mode - * 15 word 160 supported - * 14 reserved - * 13 - * 12 - * 11:0 - */ - unsigned short words161_175[14];/* Reserved for CFA */ - unsigned short words176_205[31];/* Current Media Serial Number */ - unsigned short words206_254[48];/* reserved words 206-254 */ - unsigned short integrity_word; /* (word 255) - * 15:8 Checksum - * 7:0 Signature - */ + u16 words71_74[4]; /* reserved words 71-74 + * for IDENTIFY PACKET DEVICE command + */ + u16 queue_depth; /* (word 75) + * 15:5 reserved + * 4:0 Maximum queue depth -1 + */ + u16 words76_79[4]; /* reserved words 76-79 */ + u16 major_rev_num; /* (word 80) */ + u16 minor_rev_num; /* (word 81) */ + u16 command_set_1; /* (word 82) supported + * 15: Obsolete + * 14: NOP command + * 13: READ_BUFFER + * 12: WRITE_BUFFER + * 11: Obsolete + * 10: Host Protected Area + * 9: DEVICE Reset + * 8: SERVICE Interrupt + * 7: Release Interrupt + * 6: look-ahead + * 5: write cache + * 4: PACKET Command + * 3: Power Management Feature Set + * 2: Removable Feature Set + * 1: Security Feature Set + * 0: SMART Feature Set + */ + u16 command_set_2; /* (word 83) + * 15: Shall be ZERO + * 14: Shall be ONE + * 13: FLUSH CACHE EXT + * 12: FLUSH CACHE + * 11: Device Configuration Overlay + * 10: 48-bit Address Feature Set + * 9: Automatic Acoustic Management + * 8: SET MAX security + * 7: reserved 1407DT PARTIES + * 6: SetF sub-command Power-Up + * 5: Power-Up in Standby Feature Set + * 4: Removable Media Notification + * 3: APM Feature Set + * 2: CFA Feature Set + * 1: READ/WRITE DMA QUEUED + * 0: Download MicroCode + */ + u16 cfsse; /* (word 84) + * cmd set-feature supported extensions + * 15: Shall be ZERO + * 14: Shall be ONE + * 13:3 reserved + * 2: Media Serial Number Valid + * 1: SMART selt-test supported + * 0: SMART error logging + */ + u16 cfs_enable_1; /* (word 85) + * command set-feature enabled + * 15: Obsolete + * 14: NOP command + * 13: READ_BUFFER + * 12: WRITE_BUFFER + * 11: Obsolete + * 10: Host Protected Area + * 9: DEVICE Reset + * 8: SERVICE Interrupt + * 7: Release Interrupt + * 6: look-ahead + * 5: write cache + * 4: PACKET Command + * 3: Power Management Feature Set + * 2: Removable Feature Set + * 1: Security Feature Set + * 0: SMART Feature Set + */ + u16 cfs_enable_2; /* (word 86) + * command set-feature enabled + * 15: Shall be ZERO + * 14: Shall be ONE + * 13: FLUSH CACHE EXT + * 12: FLUSH CACHE + * 11: Device Configuration Overlay + * 10: 48-bit Address Feature Set + * 9: Automatic Acoustic Management + * 8: SET MAX security + * 7: reserved 1407DT PARTIES + * 6: SetF sub-command Power-Up + * 5: Power-Up in Standby Feature Set + * 4: Removable Media Notification + * 3: APM Feature Set + * 2: CFA Feature Set + * 1: READ/WRITE DMA QUEUED + * 0: Download MicroCode + */ + u16 csf_default; /* (word 87) + * command set-feature default + * 15: Shall be ZERO + * 14: Shall be ONE + * 13:3 reserved + * 2: Media Serial Number Valid + * 1: SMART selt-test supported + * 0: SMART error logging + */ + u16 dma_ultra; /* (word 88) */ + u16 word89; /* reserved (word 89) */ + u16 word90; /* reserved (word 90) */ + u16 CurAPMvalues; /* current APM values */ + u16 word92; /* reserved (word 92) */ + u16 hw_config; /* hardware config (word 93) + * 15: + * 14: + * 13: + * 12: + * 11: + * 10: + * 9: + * 8: + * 7: + * 6: + * 5: + * 4: + * 3: + * 2: + * 1: + * 0: + */ + u16 acoustic; /* (word 94) + * 15:8 Vendor's recommended value + * 7:0 current value + */ + u16 words95_99[5]; /* reserved words 95-99 */ + u64 lba_capacity_2; /* 48-bit total number of sectors */ + u16 words104_125[22];/* reserved words 104-125 */ + u16 last_lun; /* (word 126) */ + u16 word127; /* (word 127) Feature Set + * Removable Media Notification + * 15:2 reserved + * 1:0 00 = not supported + * 01 = supported + * 10 = reserved + * 11 = reserved + */ + u16 dlf; /* (word 128) + * device lock function + * 15:9 reserved + * 8 security level 1:max 0:high + * 7:6 reserved + * 5 enhanced erase + * 4 expire + * 3 frozen + * 2 locked + * 1 en/disabled + * 0 capability + */ + u16 csfo; /* (word 129) + * current set features options + * 15:4 reserved + * 3: auto reassign + * 2: reverting + * 1: read-look-ahead + * 0: write cache + */ + u16 words130_155[26];/* reserved vendor words 130-155 */ + u16 word156; /* reserved vendor word 156 */ + u16 words157_159[3];/* reserved vendor words 157-159 */ + u16 cfa_power; /* (word 160) CFA Power Mode + * 15 word 160 supported + * 14 reserved + * 13 + * 12 + * 11:0 + */ + u16 words161_175[14];/* Reserved for CFA */ + u16 words176_205[31];/* Current Media Serial Number */ + u16 words206_254[48];/* reserved words 206-254 */ + u16 integrity_word; /* (word 255) + * 15:8 Checksum + * 7:0 Signature + */ } __attribute__((packed)); -/* - * IDE "nice" flags. These are used on a per drive basis to determine - * when to be nice and give more bandwidth to the other devices which - * share the same IDE bus. - */ #define IDE_NICE_DSC_OVERLAP (0) /* per the DSC overlap protocol */ -#define IDE_NICE_ATAPI_OVERLAP (1) /* not supported yet */ -#endif /* _LINUX_HDREG_H */ +#endif -- cgit v1.2.3 From e7a6bdfdb183ba2e3985fe874eef3992505ad0d2 Mon Sep 17 00:00:00 2001 From: Martin Dalecki Date: Fri, 26 Jul 2002 01:16:19 -0700 Subject: [PATCH] IDE 105 - Rename ata-timings.h to timings.h. Same arguments as for agp. - Always include hdparm.h just before ide.h. Include them last where used. This is preparing to split out the IDE register declarations out of this file, since many other files in the kernel include it, which don't have anything to do with IDE. - Don't use the "IDE special" data type "byte". Just use the u8 data type for consistency with the rest of the kernel where applicable. --- drivers/ide/aec62xx.c | 5 ++- drivers/ide/ali14xx.c | 5 ++- drivers/ide/alim15x3.c | 34 ++++++++--------- drivers/ide/amd74xx.c | 5 ++- drivers/ide/ata-timing.c | 5 ++- drivers/ide/ata-timing.h | 95 ----------------------------------------------- drivers/ide/cmd640.c | 10 ++--- drivers/ide/cmd64x.c | 34 ++++++++--------- drivers/ide/cs5530.c | 14 +++---- drivers/ide/cy82c693.c | 13 ++++--- drivers/ide/dtc2278.c | 6 +-- drivers/ide/hpt34x.c | 4 +- drivers/ide/hpt366.c | 5 +-- drivers/ide/hptraid.c | 4 +- drivers/ide/ht6560b.c | 20 +++++----- drivers/ide/icside.c | 2 +- drivers/ide/ide-cd.c | 4 +- drivers/ide/ide-cd.h | 26 ++++++------- drivers/ide/ide-disk.c | 3 +- drivers/ide/ide-floppy.c | 4 +- drivers/ide/ide-m8xx.c | 9 +++-- drivers/ide/ide-pci.c | 3 +- drivers/ide/ide-pmac.c | 28 +++++++------- drivers/ide/ide-tape.c | 6 +-- drivers/ide/ide.c | 7 ++-- drivers/ide/ioctl.c | 16 ++++---- drivers/ide/it8172.c | 5 +-- drivers/ide/main.c | 5 ++- drivers/ide/ns87415.c | 2 +- drivers/ide/opti621.c | 16 ++++---- drivers/ide/pcidma.c | 5 ++- drivers/ide/pdc202xx.c | 14 +++---- drivers/ide/pdc4030.c | 4 +- drivers/ide/pdcraid.c | 4 +- drivers/ide/piix.c | 5 ++- drivers/ide/probe.c | 11 +++--- drivers/ide/qd65xx.c | 47 +++++++++++------------ drivers/ide/qd65xx.h | 4 +- drivers/ide/quirks.c | 7 ++-- drivers/ide/serverworks.c | 4 +- drivers/ide/sis5513.c | 34 +++++++++-------- drivers/ide/sl82c105.c | 10 ++--- drivers/ide/tcq.c | 1 + drivers/ide/timing.h | 83 +++++++++++++++++++++++++++++++++++++++++ drivers/ide/trm290.c | 2 +- drivers/ide/umc8672.c | 18 ++++----- drivers/ide/via82cxxx.c | 5 ++- fs/partitions/msdos.c | 1 + include/linux/ide.h | 61 +++++++++++++++--------------- 49 files changed, 359 insertions(+), 356 deletions(-) delete mode 100644 drivers/ide/ata-timing.h create mode 100644 drivers/ide/timing.h (limited to 'include/linux') diff --git a/drivers/ide/aec62xx.c b/drivers/ide/aec62xx.c index d2dca5e1a1a4..468a4b788644 100644 --- a/drivers/ide/aec62xx.c +++ b/drivers/ide/aec62xx.c @@ -42,10 +42,11 @@ #include #include #include +#include #include #include -#include "ata-timing.h" +#include "timing.h" #include "pcihost.h" #define AEC_DRIVE_TIMING 0x40 @@ -167,7 +168,7 @@ static void aec62xx_tune_drive(struct ata_device *drive, unsigned char pio) return; } - aec_set_drive(drive, XFER_PIO_0 + min_t(byte, pio, 5)); + aec_set_drive(drive, XFER_PIO_0 + min_t(u8, pio, 5)); } #ifdef CONFIG_BLK_DEV_IDEDMA diff --git a/drivers/ide/ali14xx.c b/drivers/ide/ali14xx.c index 33f175c92e0b..9d2e97c47d36 100644 --- a/drivers/ide/ali14xx.c +++ b/drivers/ide/ali14xx.c @@ -37,12 +37,13 @@ #include #include -#include #include +#include +#include #include -#include "ata-timing.h" +#include "timing.h" /* port addresses for auto-detection */ #define ALI_NUM_PORTS 4 diff --git a/drivers/ide/alim15x3.c b/drivers/ide/alim15x3.c index f8422ad5e897..e862b5c98dfd 100644 --- a/drivers/ide/alim15x3.c +++ b/drivers/ide/alim15x3.c @@ -26,30 +26,30 @@ #include -#include "ata-timing.h" +#include "timing.h" #include "pcihost.h" -static byte m5229_revision; -static byte chip_is_1543c_e; +static u8 m5229_revision; +static int chip_is_1543c_e; static struct pci_dev *isa_dev; -static void ali15x3_tune_drive(struct ata_device *drive, byte pio) +static void ali15x3_tune_drive(struct ata_device *drive, u8 pio) { struct ata_timing *t; struct ata_channel *hwif = drive->channel; struct pci_dev *dev = hwif->pci_dev; int s_time, a_time, c_time; - byte s_clc, a_clc, r_clc; + u8 s_clc, a_clc, r_clc; unsigned long flags; int port = hwif->unit ? 0x5c : 0x58; int portFIFO = hwif->unit ? 0x55 : 0x54; - byte cd_dma_fifo = 0; + u8 cd_dma_fifo = 0; if (pio == 255) pio = ata_timing_mode(drive, XFER_PIO | XFER_EPIO); else - pio = XFER_PIO_0 + min_t(byte, pio, 4); + pio = XFER_PIO_0 + min_t(u8, pio, 4); t = ata_timing_data(pio); @@ -100,15 +100,15 @@ static void ali15x3_tune_drive(struct ata_device *drive, byte pio) local_irq_restore(flags); } -static int ali15x3_tune_chipset(struct ata_device *drive, byte speed) +static int ali15x3_tune_chipset(struct ata_device *drive, u8 speed) { struct pci_dev *dev = drive->channel->pci_dev; - byte unit = (drive->select.b.unit & 0x01); - byte tmpbyte = 0x00; - int m5229_udma = drive->channel->unit ? 0x57 : 0x56; + u8 unit = (drive->select.b.unit & 0x01); + u8 tmpbyte = 0x00; + int m5229_udma = drive->channel->unit ? 0x57 : 0x56; if (speed < XFER_UDMA_0) { - byte ultra_enable = (unit) ? 0x7f : 0xf7; + u8 ultra_enable = unit ? 0x7f : 0xf7; /* * clear "ultra enable" bit */ @@ -135,7 +135,7 @@ static int ali15x3_tune_chipset(struct ata_device *drive, byte speed) pci_write_config_byte(dev, 0x4b, tmpbyte); } } -#endif /* CONFIG_BLK_DEV_IDEDMA */ +#endif return ide_config_drive_speed(drive, speed); } @@ -212,10 +212,10 @@ static unsigned int __init ali15x3_ata66_check(struct ata_channel *hwif) { struct pci_dev *dev = hwif->pci_dev; unsigned int ata66 = 0; - byte cable_80_pin[2] = { 0, 0 }; + u8 cable_80_pin[2] = { 0, 0 }; unsigned long flags; - byte tmpbyte; + u8 tmpbyte; local_irq_save(flags); @@ -305,8 +305,8 @@ static unsigned int __init ali15x3_ata66_check(struct ata_channel *hwif) static void __init ali15x3_init_channel(struct ata_channel *hwif) { #ifndef CONFIG_SPARC64 - byte ideic, inmir; - byte irq_routing_table[] = { -1, 9, 3, 10, 4, 5, 7, 6, + u8 ideic, inmir; + u8 irq_routing_table[] = { -1, 9, 3, 10, 4, 5, 7, 6, 1, 11, 0, 12, 0, 14, 0, 15 }; hwif->irq = hwif->unit ? 15 : 14; diff --git a/drivers/ide/amd74xx.c b/drivers/ide/amd74xx.c index 485f31e3f4cb..5e2e1e27e850 100644 --- a/drivers/ide/amd74xx.c +++ b/drivers/ide/amd74xx.c @@ -42,11 +42,12 @@ #include #include #include +#include #include #include -#include "ata-timing.h" +#include "timing.h" #include "pcihost.h" #define AMD_IDE_ENABLE (0x00 + amd_config->base) @@ -171,7 +172,7 @@ static void amd74xx_tune_drive(struct ata_device *drive, u8 pio) return; } - amd_set_drive(drive, XFER_PIO_0 + min_t(byte, pio, 5)); + amd_set_drive(drive, XFER_PIO_0 + min_t(u8, pio, 5)); } #ifdef CONFIG_BLK_DEV_IDEDMA diff --git a/drivers/ide/ata-timing.c b/drivers/ide/ata-timing.c index 01a312044242..f713a15b047a 100644 --- a/drivers/ide/ata-timing.c +++ b/drivers/ide/ata-timing.c @@ -23,7 +23,10 @@ */ #include -#include "ata-timing.h" +#include +#include + +#include "timing.h" /* * PIO 0-5, MWDMA 0-2 and UDMA 0-6 timings (in nanoseconds). These were taken diff --git a/drivers/ide/ata-timing.h b/drivers/ide/ata-timing.h deleted file mode 100644 index 9f01f07e8329..000000000000 --- a/drivers/ide/ata-timing.h +++ /dev/null @@ -1,95 +0,0 @@ -#ifndef _ATA_TIMING_H -#define _ATA_TIMING_H - -/* - * $Id: ata-timing.h,v 2.0 2002/03/12 13:02:22 vojtech Exp $ - * - * Copyright (C) 1996 Linus Torvalds, Igor Abramov, and Mark Lord - * Copyright (C) 1999-2001 Vojtech Pavlik - */ - -/* - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -#include -#include - -#define XFER_PIO_5 0x0d -#define XFER_UDMA_SLOW 0x4f - -struct ata_timing { - short mode; - short setup; /* t1 */ - short act8b; /* t2 for 8-bit io */ - short rec8b; /* t2i for 8-bit io */ - short cyc8b; /* t0 for 8-bit io */ - short active; /* t2 or tD */ - short recover; /* t2i or tK */ - short cycle; /* t0 */ - short udma; /* t2CYCTYP/2 */ -}; - -extern struct ata_timing ata_timing[]; - -#define IDE_TIMING_SETUP 0x01 -#define IDE_TIMING_ACT8B 0x02 -#define IDE_TIMING_REC8B 0x04 -#define IDE_TIMING_CYC8B 0x08 -#define IDE_TIMING_8BIT 0x0e -#define IDE_TIMING_ACTIVE 0x10 -#define IDE_TIMING_RECOVER 0x20 -#define IDE_TIMING_CYCLE 0x40 -#define IDE_TIMING_UDMA 0x80 -#define IDE_TIMING_ALL 0xff - -#define FIT(v,x,y) max_t(int,min_t(int,v,y),x) -#define ENOUGH(v,unit) (((v)-1)/(unit)+1) -#define EZ(v,unit) ((v)?ENOUGH(v,unit):0) - -/* see hpt366.c for details */ -#define XFER_UDMA_66_3 0x100 -#define XFER_UDMA_66_4 0x200 - -#define XFER_MODE 0xff0 -#define XFER_UDMA_133 0x800 -#define XFER_UDMA_100 0x400 -#define XFER_UDMA_66 0x300 -#define XFER_UDMA 0x040 -#define XFER_MWDMA 0x020 -#define XFER_SWDMA 0x010 -#define XFER_EPIO 0x001 -#define XFER_PIO 0x000 - -#define XFER_UDMA_ALL 0xf40 -#define XFER_UDMA_80W 0xf00 - -/* External interface to host chips channel timing setup. - * - * It's a bit elaborate due to the legacy we have to bear. - */ - -extern short ata_timing_mode(struct ata_device *drive, int map); -extern void ata_timing_quantize(struct ata_timing *t, struct ata_timing *q, - int T, int UT); -extern void ata_timing_merge(struct ata_timing *a, struct ata_timing *b, - struct ata_timing *m, unsigned int what); -void ata_timing_merge_8bit(struct ata_timing *t); -extern struct ata_timing* ata_timing_data(short speed); -extern int ata_timing_compute(struct ata_device *drive, - short speed, struct ata_timing *t, int T, int UT); -extern u8 ata_best_pio_mode(struct ata_device *drive); - -#endif diff --git a/drivers/ide/cmd640.c b/drivers/ide/cmd640.c index 742f8c7a54f3..e8325b9e7690 100644 --- a/drivers/ide/cmd640.c +++ b/drivers/ide/cmd640.c @@ -106,13 +106,13 @@ #include #include #include +#include #include #include -#include #include -#include "ata-timing.h" +#include "timing.h" /* * This flag is set in ide.c by the parameter: ide0=cmd640_vlb @@ -200,7 +200,7 @@ static struct ata_device *cmd_drives[4]; * Interface to access cmd640x registers */ static unsigned int cmd640_key; -static void (*put_cmd640_reg)(unsigned short reg, byte val); +static void (*put_cmd640_reg)(unsigned short reg, u8 val); static u8 (*get_cmd640_reg)(unsigned short reg); /* @@ -219,7 +219,7 @@ static spinlock_t cmd640_lock = SPIN_LOCK_UNLOCKED; /* PCI method 1 access */ -static void put_cmd640_reg_pci1 (unsigned short reg, byte val) +static void put_cmd640_reg_pci1 (unsigned short reg, u8 val) { unsigned long flags; @@ -641,7 +641,7 @@ static void cmd640_set_mode (unsigned int index, u8 pio_mode, unsigned int cycle /* * Drive PIO mode selection: */ -static void cmd640_tune_drive(struct ata_device *drive, byte mode_wanted) +static void cmd640_tune_drive(struct ata_device *drive, u8 mode_wanted) { u8 b; struct ata_timing *t; diff --git a/drivers/ide/cmd64x.c b/drivers/ide/cmd64x.c index 188aeac9074c..0d6c087b361f 100644 --- a/drivers/ide/cmd64x.c +++ b/drivers/ide/cmd64x.c @@ -18,13 +18,13 @@ #include #include #include -#include #include +#include #include #include -#include "ata-timing.h" +#include "timing.h" #include "pcihost.h" #define CMD_DEBUG 0 @@ -81,8 +81,8 @@ * Registers and masks for easy access by drive index: */ #if 0 -static byte prefetch_regs[4] = {CNTRL, CNTRL, ARTTIM23, ARTTIM23}; -static byte prefetch_masks[4] = {CNTRL_DIS_RA0, CNTRL_DIS_RA1, ARTTIM23_DIS_RA2, ARTTIM23_DIS_RA3}; +static u8 prefetch_regs[4] = {CNTRL, CNTRL, ARTTIM23, ARTTIM23}; +static u8 prefetch_masks[4] = {CNTRL_DIS_RA0, CNTRL_DIS_RA1, ARTTIM23_DIS_RA2, ARTTIM23_DIS_RA3}; #endif /* @@ -93,15 +93,15 @@ static void program_drive_counts(struct ata_device *drive, int setup_count, int { unsigned long flags; struct ata_device *drives = drive->channel->drives; - byte temp_b; - static const byte setup_counts[] = {0x40, 0x40, 0x40, 0x80, 0, 0xc0}; - static const byte recovery_counts[] = + u8 temp_b; + static const u8 setup_counts[] = {0x40, 0x40, 0x40, 0x80, 0, 0xc0}; + static const u8 recovery_counts[] = {15, 15, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 0}; - static const byte arttim_regs[2][2] = { + static const u8 arttim_regs[2][2] = { { ARTTIM0, ARTTIM1 }, { ARTTIM23, ARTTIM23 } }; - static const byte drwtim_regs[2][2] = { + static const u8 drwtim_regs[2][2] = { { DRWTIM0, DRWTIM1 }, { DRWTIM2, DRWTIM3 } }; @@ -142,11 +142,11 @@ static void program_drive_counts(struct ata_device *drive, int setup_count, int */ (void) pci_read_config_byte(drive->channel->pci_dev, arttim_regs[channel][slave], &temp_b); (void) pci_write_config_byte(drive->channel->pci_dev, arttim_regs[channel][slave], - ((byte) setup_count) | (temp_b & 0x3f)); + ((u8) setup_count) | (temp_b & 0x3f)); (void) pci_write_config_byte(drive->channel->pci_dev, drwtim_regs[channel][slave], - (byte) ((active_count << 4) | recovery_count)); - cmdprintk ("Write %x to %x\n", ((byte) setup_count) | (temp_b & 0x3f), arttim_regs[channel][slave]); - cmdprintk ("Write %x to %x\n", (byte) ((active_count << 4) | recovery_count), drwtim_regs[channel][slave]); + (u8) ((active_count << 4) | recovery_count)); + cmdprintk ("Write %x to %x\n", ((u8) setup_count) | (temp_b & 0x3f), arttim_regs[channel][slave]); + cmdprintk ("Write %x to %x\n", (u8) ((active_count << 4) | recovery_count), drwtim_regs[channel][slave]); local_irq_restore(flags); } @@ -405,7 +405,7 @@ static int cmd64x_tune_chipset(struct ata_device *drive, u8 speed) return ide_config_drive_speed(drive, speed); } -static int cmd680_tune_chipset(struct ata_device *drive, byte speed) +static int cmd680_tune_chipset(struct ata_device *drive, u8 speed) { struct ata_channel *hwif = drive->channel; struct pci_dev *dev = hwif->pci_dev; @@ -520,9 +520,9 @@ static int cmd64x_udma_stop(struct ata_device *drive) dma_stat = inb(dma_base+2); /* get DMA status */ outb(dma_stat|6, dma_base+2); /* clear the INTR & ERROR bits */ if (jack_slap) { - byte dma_intr = 0; - byte dma_mask = (ch->unit) ? ARTTIM23_INTR_CH1 : CFR_INTR_CH0; - byte dma_reg = (ch->unit) ? ARTTIM2 : CFR; + u8 dma_intr = 0; + u8 dma_mask = (ch->unit) ? ARTTIM23_INTR_CH1 : CFR_INTR_CH0; + u8 dma_reg = (ch->unit) ? ARTTIM2 : CFR; (void) pci_read_config_byte(dev, dma_reg, &dma_intr); /* * DAMN BMIDE is not connected to PCI space! diff --git a/drivers/ide/cs5530.c b/drivers/ide/cs5530.c index b761e7896385..89ee79cfcda3 100644 --- a/drivers/ide/cs5530.c +++ b/drivers/ide/cs5530.c @@ -20,22 +20,22 @@ #include #include #include -#include #include #include #include +#include #include #include #include -#include "ata-timing.h" +#include "timing.h" #include "pcihost.h" /* * Set a new transfer mode at the drive */ -int cs5530_set_xfer_mode(struct ata_device *drive, byte mode) +int cs5530_set_xfer_mode(struct ata_device *drive, u8 mode) { int error = 0; @@ -67,7 +67,7 @@ static unsigned int cs5530_pio_timings[2][5] = * The ide_init_cs5530() routine guarantees that all drives * will have valid default PIO timings set up before we get here. */ -static void cs5530_tuneproc(struct ata_device *drive, byte pio) /* pio=255 means "autotune" */ +static void cs5530_tuneproc(struct ata_device *drive, u8 pio) { struct ata_channel *hwif = drive->channel; unsigned int format, basereg = CS5530_BASEREG(hwif); @@ -75,7 +75,7 @@ static void cs5530_tuneproc(struct ata_device *drive, byte pio) /* pio=255 means if (pio == 255) pio = ata_timing_mode(drive, XFER_PIO | XFER_EPIO); else - pio = XFER_PIO_0 + min_t(byte, pio, 4); + pio = XFER_PIO_0 + min_t(u8, pio, 4); if (!cs5530_set_xfer_mode(drive, pio)) { format = (inl(basereg+4) >> 31) & 1; @@ -206,7 +206,7 @@ static unsigned int __init pci_init_cs5530(struct pci_dev *dev) unsigned short pcicmd = 0; unsigned long flags; - pci_for_each_dev (dev) { + pci_for_each_dev(dev) { if (dev->vendor == PCI_VENDOR_ID_CYRIX) { switch (dev->device) { case PCI_DEVICE_ID_CYRIX_PCI_MASTER: @@ -256,7 +256,7 @@ static unsigned int __init pci_init_cs5530(struct pci_dev *dev) */ pci_write_config_byte(master_0, 0x40, 0x1e); - /* + /* * Set max PCI burst size (16-bytes seems to work best): * 16bytes: set bit-1 at 0x41 (reg value of 0x16) * all others: clear bit-1 at 0x41, and do: diff --git a/drivers/ide/cy82c693.c b/drivers/ide/cy82c693.c index 297b55d18ce2..acf889aad4dd 100644 --- a/drivers/ide/cy82c693.c +++ b/drivers/ide/cy82c693.c @@ -47,11 +47,12 @@ #include #include #include +#include #include #include -#include "ata-timing.h" +#include "timing.h" #include "pcihost.h" /* the current version */ @@ -141,7 +142,7 @@ static u8 calc_clk(int time, int bus_speed) * for mode 3 and 4 drives 8 and 16-bit timings are the same * */ -/* FIXME: use generic ata-timings library --bkz */ +/* FIXME: use generic timings library --bkz */ static void compute_clocks(u8 pio, pio_clocks_t *p_pclk) { struct ata_timing *t; @@ -186,8 +187,8 @@ static void compute_clocks(u8 pio, pio_clocks_t *p_pclk) */ static void cy82c693_dma_enable(struct ata_device *drive, int mode, int single) { - byte index; - byte data; + u8 index; + u8 data; if (mode>2) /* make sure we set a valid mode */ mode = 2; @@ -206,7 +207,7 @@ static void cy82c693_dma_enable(struct ata_device *drive, int mode, int single) printk (KERN_INFO "%s (ch=%d, dev=%d): DMA mode is %d (single=%d)\n", drive->name, drive->channel->unit, drive->select.b.unit, (data&0x3), ((data>>2)&1)); #endif - data = (byte)mode|(byte)(single<<2); + data = (u8) mode | (u8) (single << 2); OUT_BYTE(index, CY82_INDEX_PORT); OUT_BYTE(data, CY82_DATA_PORT); @@ -271,7 +272,7 @@ static int cy82c693_udma_setup(struct ata_device *drive, int map) /* * tune ide drive - set PIO mode */ -static void cy82c693_tune_drive(struct ata_device *drive, byte pio) +static void cy82c693_tune_drive(struct ata_device *drive, u8 pio) { struct ata_channel *hwif = drive->channel; struct pci_dev *dev = hwif->pci_dev; diff --git a/drivers/ide/dtc2278.c b/drivers/ide/dtc2278.c index 45cd4d9c7f81..8d947231d2ab 100644 --- a/drivers/ide/dtc2278.c +++ b/drivers/ide/dtc2278.c @@ -9,13 +9,13 @@ #include #include #include +#include #include #include -#include #include -#include "ata-timing.h" +#include "timing.h" /* * Changing this #undef to #define may solve start up problems in some systems. @@ -66,7 +66,7 @@ static void sub22 (char b, char c) } } -static void tune_dtc2278(struct ata_device *drive, byte pio) +static void tune_dtc2278(struct ata_device *drive, u8 pio) { unsigned long flags; diff --git a/drivers/ide/hpt34x.c b/drivers/ide/hpt34x.c index 9f5d08d42f2c..8fb181800602 100644 --- a/drivers/ide/hpt34x.c +++ b/drivers/ide/hpt34x.c @@ -21,16 +21,16 @@ #include #include #include -#include #include #include #include +#include #include #include #include -#include "ata-timing.h" +#include "timing.h" #include "pcihost.h" #define HPT343_DEBUG_DRIVE_INFO 0 diff --git a/drivers/ide/hpt366.c b/drivers/ide/hpt366.c index a24e170bee2e..c2204b5b7ef4 100644 --- a/drivers/ide/hpt366.c +++ b/drivers/ide/hpt366.c @@ -53,18 +53,17 @@ #include #include #include -#include - #include #include #include +#include #include #include #include #include -#include "ata-timing.h" +#include "timing.h" #include "pcihost.h" diff --git a/drivers/ide/hptraid.c b/drivers/ide/hptraid.c index 43b45c6e06eb..d4742834b864 100644 --- a/drivers/ide/hptraid.c +++ b/drivers/ide/hptraid.c @@ -105,10 +105,10 @@ static int hptraid_ioctl(struct inode *inode, struct file *file, if (!loc) return -EINVAL; val = 255; - if (put_user(val, (byte *) & loc->heads)) + if (put_user(val, (u8 *) & loc->heads)) return -EFAULT; val = 63; - if (put_user(val, (byte *) & loc->sectors)) + if (put_user(val, (u8 *) & loc->sectors)) return -EFAULT; bios_cyl = raid[minor].sectors / 63 / 255; if (put_user diff --git a/drivers/ide/ht6560b.c b/drivers/ide/ht6560b.c index 55f39b8c506e..34207cd5d911 100644 --- a/drivers/ide/ht6560b.c +++ b/drivers/ide/ht6560b.c @@ -38,13 +38,13 @@ #include #include #include +#include #include #include -#include #include -#include "ata-timing.h" +#include "timing.h" /* #define DEBUG */ /* remove comments for DEBUG messages */ @@ -61,7 +61,7 @@ * bit3 (0x08): "1" 3 cycle time, "0" 2 cycle time (?) */ #define HT_CONFIG_PORT 0x3e6 -#define HT_CONFIG(drivea) (byte)(((drivea)->drive_data & 0xff00) >> 8) +#define HT_CONFIG(drivea) (u8)(((drivea)->drive_data & 0xff00) >> 8) /* * FIFO + PREFETCH (both a/b-model) */ @@ -107,7 +107,7 @@ * Active Time for each drive. Smaller value gives higher speed. * In case of failures you should probably fall back to a higher value. */ -#define HT_TIMING(drivea) (byte)((drivea)->drive_data & 0x00ff) +#define HT_TIMING(drivea) (u8)((drivea)->drive_data & 0x00ff) #define HT_TIMING_DEFAULT 0xff /* @@ -194,7 +194,7 @@ static int __init try_to_init_ht6560b(void) return 1; } -static byte ht_pio2timings(struct ata_device *drive, byte pio) +static u8 ht_pio2timings(struct ata_device *drive, u8 pio) { int active_time, recovery_time; int active_cycles, recovery_cycles; @@ -204,7 +204,7 @@ static byte ht_pio2timings(struct ata_device *drive, byte pio) if (pio == 255) pio = ata_timing_mode(drive, XFER_PIO | XFER_EPIO); else - pio = XFER_PIO_0 + min_t(byte, pio, 4); + pio = XFER_PIO_0 + min_t(u8, pio, 4); t = ata_timing_data(pio); @@ -233,7 +233,7 @@ static byte ht_pio2timings(struct ata_device *drive, byte pio) drive->name, pio - XFER_PIO_0, recovery_cycles, recovery_time, active_cycles, active_time); #endif - return (byte)((recovery_cycles << 4) | active_cycles); + return (u8)((recovery_cycles << 4) | active_cycles); } else { #ifdef DEBUG @@ -247,7 +247,7 @@ static byte ht_pio2timings(struct ata_device *drive, byte pio) /* * Enable/Disable so called prefetch mode */ -static void ht_set_prefetch(struct ata_device *drive, byte state) +static void ht_set_prefetch(struct ata_device *drive, u8 state) { unsigned long flags; int t = HT_PREFETCH_MODE << 8; @@ -274,10 +274,10 @@ static void ht_set_prefetch(struct ata_device *drive, byte state) #endif } -static void tune_ht6560b(struct ata_device *drive, byte pio) +static void tune_ht6560b(struct ata_device *drive, u8 pio) { unsigned long flags; - byte timing; + u8 timing; switch (pio) { case 8: /* set prefetch off */ diff --git a/drivers/ide/icside.c b/drivers/ide/icside.c index cd2af4ca8faa..a93846b806a6 100644 --- a/drivers/ide/icside.c +++ b/drivers/ide/icside.c @@ -377,7 +377,7 @@ icside_config_if(struct ata_device *drive, int xfer_mode) return on; } -static int icside_set_speed(struct ata_device *drive, byte speed) +static int icside_set_speed(struct ata_device *drive, u8 speed) { return icside_config_if(drive, speed); } diff --git a/drivers/ide/ide-cd.c b/drivers/ide/ide-cd.c index 166971c7307d..1e4dbbebcec7 100644 --- a/drivers/ide/ide-cd.c +++ b/drivers/ide/ide-cd.c @@ -1716,7 +1716,7 @@ void msf_from_bcd (struct atapi_msf *msf) static inline -void lba_to_msf (int lba, byte *m, byte *s, byte *f) +void lba_to_msf(int lba, u8 *m, u8 *s, u8 *f) { lba += CD_MSF_OFFSET; lba &= 0xffffff; /* negative lbas use only 24 bits */ @@ -1728,7 +1728,7 @@ void lba_to_msf (int lba, byte *m, byte *s, byte *f) static inline -int msf_to_lba (byte m, byte s, byte f) +int msf_to_lba(u8 m, u8 s, u8 f) { return (((m * CD_SECS) + s) * CD_FRAMES + f) - CD_MSF_OFFSET; } diff --git a/drivers/ide/ide-cd.h b/drivers/ide/ide-cd.h index dcd660ce6ce1..7f4ac20a5b5a 100644 --- a/drivers/ide/ide-cd.h +++ b/drivers/ide/ide-cd.h @@ -80,7 +80,7 @@ struct ide_cd_config_flags { __u8 close_tray : 1; /* can close the tray */ __u8 writing : 1; /* pseudo write in progress */ __u8 reserved : 3; - byte max_speed; /* Max speed of the drive */ + u8 max_speed; /* Max speed of the drive */ }; #define CDROM_CONFIG_FLAGS(drive) (&(((struct cdrom_info *)(drive->driver_data))->config_flags)) @@ -92,7 +92,7 @@ struct ide_cd_state_flags { __u8 door_locked : 1; /* We think that the drive door is locked. */ __u8 writing : 1; /* the drive is currently writing */ __u8 reserved : 4; - byte current_speed; /* Current speed of the drive */ + u8 current_speed; /* Current speed of the drive */ }; #define CDROM_STATE_FLAGS(drive) (&(((struct cdrom_info *)(drive->driver_data))->state_flags)) @@ -132,7 +132,7 @@ struct atapi_toc_header { } __attribute__((packed)); struct atapi_toc_entry { - byte reserved1; + u8 reserved1; #if defined(__BIG_ENDIAN_BITFIELD) __u8 adr : 4; __u8 control : 4; @@ -142,8 +142,8 @@ struct atapi_toc_entry { #else #error "Please fix " #endif - byte track; - byte reserved2; + u8 track; + u8 reserved2; union { unsigned lba; struct atapi_msf msf; @@ -176,8 +176,8 @@ struct atapi_cdrom_subchnl { #else #error "Please fix " #endif - u_char acdsc_trk; - u_char acdsc_ind; + u8 acdsc_trk; + u8 acdsc_ind; union { struct atapi_msf msf; int lba; @@ -207,7 +207,7 @@ struct atapi_capabilities_page { #error "Please fix " #endif - byte page_length; + u8 page_length; #if defined(__BIG_ENDIAN_BITFIELD) __u8 reserved2 : 2; @@ -435,8 +435,8 @@ struct atapi_mechstat_header { #error "Please fix " #endif - byte curlba[3]; - byte nslots; + u8 curlba[3]; + u8 nslots; __u16 slot_tablelen; }; @@ -454,7 +454,7 @@ struct atapi_slot { #error "Please fix " #endif - byte reserved2[3]; + u8 reserved2[3]; }; struct atapi_changer_info { @@ -514,13 +514,11 @@ struct cdrom_info { #define ABORTED_COMMAND 0x0b #define MISCOMPARE 0x0e - - /* This stuff should be in cdrom.h, since it is now generic... */ #if VERBOSE_IDE_CD_ERRORS /* The generic packet command opcodes for CD/DVD Logical Units, - * From Table 57 of the SFF8090 Ver. 3 (Mt. Fuji) draft standard. */ + * From Table 57 of the SFF8090 Ver. 3 (Mt. Fuji) draft standard. */ const struct { unsigned short packet_command; const char * const text; diff --git a/drivers/ide/ide-disk.c b/drivers/ide/ide-disk.c index cd3fd43b4b23..4070de3d2832 100644 --- a/drivers/ide/ide-disk.c +++ b/drivers/ide/ide-disk.c @@ -24,8 +24,9 @@ #include #include #include -#include #include /* for invalidate_bdev() */ +#include +#include #include #include diff --git a/drivers/ide/ide-floppy.c b/drivers/ide/ide-floppy.c index a05c8b00c9ce..e346d1d12b58 100644 --- a/drivers/ide/ide-floppy.c +++ b/drivers/ide/ide-floppy.c @@ -245,8 +245,8 @@ typedef struct { /* * Last error information */ - byte sense_key, asc, ascq; - byte ticks; /* delay this long before sending packet command */ + u8 sense_key, asc, ascq; + u8 ticks; /* delay this long before sending packet command */ int progress_indication; /* diff --git a/drivers/ide/ide-m8xx.c b/drivers/ide/ide-m8xx.c index a04398c9e12c..c842699af329 100644 --- a/drivers/ide/ide-m8xx.c +++ b/drivers/ide/ide-m8xx.c @@ -29,8 +29,9 @@ #include #include #include -#include #include +#include +#include #include #include @@ -43,7 +44,7 @@ #include #include -#include "ata-timing.h" +#include "timing.h" static int identify (volatile unsigned char *p); static void print_fixed (volatile unsigned char *p); @@ -51,7 +52,7 @@ static void print_funcid (int func); static int check_ide_device (unsigned long base); static int ide_interrupt_ack(struct ata_channel *); -static void m8xx_ide_tuneproc(struct ata_device *drive, byte pio); +static void m8xx_ide_tuneproc(struct ata_device *drive, u8 pio); typedef struct ide_ioport_desc { unsigned long base_off; /* Offset to PCMCIA memory */ @@ -437,7 +438,7 @@ void m8xx_ide_init_hwif_ports (hw_regs_t *hw, /* Calculate PIO timings */ static void -m8xx_ide_tuneproc(struct ata_device *drive, byte pio) +m8xx_ide_tuneproc(struct ata_device *drive, u8 pio) { #if defined(CONFIG_IDE_8xx_PCCARD) || defined(CONFIG_IDE_8xx_DIRECT) volatile pcmconf8xx_t *pcmp; diff --git a/drivers/ide/ide-pci.c b/drivers/ide/ide-pci.c index e9076cb4869c..a9173ffad2dd 100644 --- a/drivers/ide/ide-pci.c +++ b/drivers/ide/ide-pci.c @@ -20,6 +20,7 @@ #include #include #include +#include #include #include @@ -30,7 +31,7 @@ /* * This is the list of registered PCI chipset driver data structures. */ -static struct ata_pci_device *ata_pci_device_list = NULL; +static struct ata_pci_device *ata_pci_device_list; /* = NULL */ /* * This function supplies the data necessary to detect the particular chipset. diff --git a/drivers/ide/ide-pmac.c b/drivers/ide/ide-pmac.c index 5a52c4fa4169..4630dbc4fe5d 100644 --- a/drivers/ide/ide-pmac.c +++ b/drivers/ide/ide-pmac.c @@ -34,8 +34,9 @@ #include #include #include -#include #include +#include +#include #include #include @@ -51,7 +52,7 @@ #include #include #endif -#include "ata-timing.h" +#include "timing.h" #undef IDE_PMAC_DEBUG @@ -262,8 +263,8 @@ static int pmac_udma_init(struct ata_device *drive, struct request *rq); static int pmac_udma_irq_status(struct ata_device *drive); static int pmac_udma_setup(struct ata_device *drive, int map); static int pmac_ide_build_dmatable(struct ata_device *drive, struct request *rq, int ix, int wr); -static int pmac_ide_tune_chipset(struct ata_device *drive, byte speed); -static void pmac_ide_tuneproc(struct ata_device *drive, byte pio); +static int pmac_ide_tune_chipset(struct ata_device *drive, u8 speed); +static void pmac_ide_tuneproc(struct ata_device *drive, u8 pio); static void pmac_ide_selectproc(struct ata_device *drive); #endif /* CONFIG_BLK_DEV_IDEDMA_PMAC */ @@ -457,7 +458,7 @@ out: /* Calculate PIO timings */ static void __pmac -pmac_ide_tuneproc(struct ata_device *drive, byte pio) +pmac_ide_tuneproc(struct ata_device *drive, u8 pio) { struct ata_timing *t; int i; @@ -472,7 +473,7 @@ pmac_ide_tuneproc(struct ata_device *drive, byte pio) if (pio == 255) pio = ata_timing_mode(drive, XFER_PIO | XFER_EPIO); else - pio = XFER_PIO_0 + min_t(byte, pio, 4); + pio = XFER_PIO_0 + min_t(u8, pio, 4); t = ata_timing_data(pio); @@ -523,8 +524,7 @@ pmac_ide_tuneproc(struct ata_device *drive, byte pio) } #ifdef CONFIG_BLK_DEV_IDEDMA_PMAC -static int __pmac -set_timings_udma(u32 *timings, byte speed) +static int __pmac set_timings_udma(u32 *timings, u8 speed) { unsigned rdyToPauseTicks, wrDataSetupTicks, addrTicks; @@ -546,7 +546,7 @@ set_timings_udma(u32 *timings, byte speed) } static int __pmac -set_timings_mdma(int intf_type, u32 *timings, byte speed, int drive_cycle_time) +set_timings_mdma(int intf_type, u32 *timings, u8 speed, int drive_cycle_time) { int cycleTime, accessTime, recTime; unsigned accessTicks, recTicks; @@ -659,7 +659,7 @@ set_timings_mdma(int intf_type, u32 *timings, byte speed, int drive_cycle_time) * our, normal mdma function is supposed to be more precise */ static int __pmac -pmac_ide_tune_chipset (struct ata_device *drive, byte speed) +pmac_ide_tune_chipset (struct ata_device *drive, u8 speed) { int intf = pmac_ide_find(drive); int unit = (drive->select.b.unit & 0x01); @@ -1211,8 +1211,8 @@ udma_bits_to_command(unsigned char bits, int high_speed) static int __pmac pmac_ide_mdma_enable(struct ata_device *drive, int idx) { - byte bits = drive->id->dma_mword & 0x07; - byte feature = dma_bits_to_command(bits); + u8 bits = drive->id->dma_mword & 0x07; + u8 feature = dma_bits_to_command(bits); u32 *timings; int drive_cycle_time; struct hd_driveid *id = drive->id; @@ -1249,8 +1249,8 @@ pmac_ide_mdma_enable(struct ata_device *drive, int idx) static int __pmac pmac_ide_udma_enable(struct ata_device *drive, int idx, int high_speed) { - byte bits = drive->id->dma_ultra & 0x1f; - byte feature = udma_bits_to_command(bits, high_speed); + u8 bits = drive->id->dma_ultra & 0x1f; + u8 feature = udma_bits_to_command(bits, high_speed); u32 *timings; int ret; diff --git a/drivers/ide/ide-tape.c b/drivers/ide/ide-tape.c index 2c1fe77c4cb2..4dc463ba33fa 100644 --- a/drivers/ide/ide-tape.c +++ b/drivers/ide/ide-tape.c @@ -827,7 +827,7 @@ typedef struct { /* * Read position information */ - byte partition; + u8 partition; unsigned int first_frame_position; /* Current block */ unsigned int last_frame_position; unsigned int blocks_in_buffer; @@ -835,7 +835,7 @@ typedef struct { /* * Last error information */ - byte sense_key, asc, ascq; + u8 sense_key, asc, ascq; /* * Character device operation @@ -1237,7 +1237,7 @@ static int idetape_chrdev_present = 0; * DO NOT REMOVE, BUILDING A VERBOSE DEBUG SCHEME FOR ATAPI */ -char *idetape_sense_key_verbose (byte idetape_sense_key) +char *idetape_sense_key_verbose(u8 idetape_sense_key) { switch (idetape_sense_key) { default: { diff --git a/drivers/ide/ide.c b/drivers/ide/ide.c index 230bad45d91d..3b776c4dae02 100644 --- a/drivers/ide/ide.c +++ b/drivers/ide/ide.c @@ -49,12 +49,13 @@ #endif #include #include -#include #include #include #include #include #include +#include +#include #include #include @@ -62,7 +63,7 @@ #include #include -#include "ata-timing.h" +#include "timing.h" #include "pcihost.h" #include "ioctl.h" @@ -258,7 +259,7 @@ static struct ata_bit_messages ata_error_msgs[] = { { MARK_ERR, MARK_ERR, "addr mark not found" } }; -static void dump_bits(struct ata_bit_messages *msgs, int nr, byte bits) +static void dump_bits(struct ata_bit_messages *msgs, int nr, u8 bits) { int i; int first = 1; diff --git a/drivers/ide/ioctl.c b/drivers/ide/ioctl.c index 003b743b4772..d1b5f6f8d4ad 100644 --- a/drivers/ide/ioctl.c +++ b/drivers/ide/ioctl.c @@ -26,7 +26,7 @@ #include #include #include - +#include #include #include @@ -230,13 +230,13 @@ int ata_ioctl(struct inode *inode, struct file *file, unsigned int cmd, unsigned if (!loc || (drive->type != ATA_DISK && drive->type != ATA_FLOPPY)) return -EINVAL; - if (put_user(drive->bios_head, (byte *) &loc->heads)) + if (put_user(drive->bios_head, (u8 *) &loc->heads)) return -EFAULT; - if (put_user(drive->bios_sect, (byte *) &loc->sectors)) + if (put_user(drive->bios_sect, (u8 *) &loc->sectors)) return -EFAULT; - if (put_user(bios_cyl, (unsigned short *) &loc->cylinders)) + if (put_user(bios_cyl, (u16 *) &loc->cylinders)) return -EFAULT; if (put_user((unsigned)drive->part[minor(inode->i_rdev)&PARTN_MASK].start_sect, @@ -283,18 +283,18 @@ int ata_ioctl(struct inode *inode, struct file *file, unsigned int cmd, unsigned case HDIO_GET_NICE: - return put_user(drive->dsc_overlap << IDE_NICE_DSC_OVERLAP | - drive->atapi_overlap << IDE_NICE_ATAPI_OVERLAP, + return put_user(drive->dsc_overlap | drive->atapi_overlap << 1, (long *) arg); case HDIO_SET_NICE: if (!capable(CAP_SYS_ADMIN)) return -EACCES; - if (arg != (arg & ((1 << IDE_NICE_DSC_OVERLAP)))) + if (arg != (arg & 1)) return -EPERM; - drive->dsc_overlap = (arg >> IDE_NICE_DSC_OVERLAP) & 1; + drive->dsc_overlap = arg & 1; + /* Only CD-ROM's and tapes support DSC overlap. */ if (drive->dsc_overlap && !(drive->type == ATA_ROM || drive->type == ATA_TAPE)) { drive->dsc_overlap = 0; diff --git a/drivers/ide/it8172.c b/drivers/ide/it8172.c index 002dc1766fd0..838718764c4f 100644 --- a/drivers/ide/it8172.c +++ b/drivers/ide/it8172.c @@ -33,16 +33,15 @@ #include #include #include -#include -#include #include #include +#include #include #include #include -#include "ata-timing.h" +#include "timing.h" #include "pcihost.h" diff --git a/drivers/ide/main.c b/drivers/ide/main.c index a3e134deef6b..c59fe6307400 100644 --- a/drivers/ide/main.c +++ b/drivers/ide/main.c @@ -35,12 +35,13 @@ #endif #include #include -#include #include #include #include #include #include +#include +#include #include #include @@ -48,7 +49,7 @@ #include #include -#include "ata-timing.h" +#include "timing.h" #include "pcihost.h" #include "ioctl.h" diff --git a/drivers/ide/ns87415.c b/drivers/ide/ns87415.c index 379bde73032d..61f9b75eef67 100644 --- a/drivers/ide/ns87415.c +++ b/drivers/ide/ns87415.c @@ -126,7 +126,7 @@ static void __init ide_init_ns87415(struct ata_channel *hwif) { struct pci_dev *dev = hwif->pci_dev; unsigned int ctrl, using_inta; - byte progif; + u8 progif; /* Set a good latency timer and cache line size value. */ (void) pci_write_config_byte(dev, PCI_LATENCY_TIMER, 64); diff --git a/drivers/ide/opti621.c b/drivers/ide/opti621.c index 6b025f3e93ce..c141def6663d 100644 --- a/drivers/ide/opti621.c +++ b/drivers/ide/opti621.c @@ -99,7 +99,7 @@ #include -#include "ata-timing.h" +#include "timing.h" #include "pcihost.h" #define OPTI621_MAX_PIO 3 @@ -137,7 +137,7 @@ int reg_base; /* there are stored pio numbers from other calls of opti621_tune_drive */ -static void compute_pios(struct ata_device *drive, byte pio) +static void compute_pios(struct ata_device *drive, u8 pio) /* Store values into drive->drive_data * second_contr - 0 for primary controller, 1 for secondary * slave_drive - 0 -> pio is for master, 1 -> pio is for slave @@ -178,7 +178,7 @@ static int cmpt_clk(int time, int bus_speed) return ((time*bus_speed+999999)/1000000); } -static void write_reg(byte value, int reg) +static void write_reg(u8 value, int reg) /* Write value to register reg, base of register * is at reg_base (0x1f0 primary, 0x170 secondary, * if not changed by PCI configuration). @@ -192,14 +192,14 @@ static void write_reg(byte value, int reg) outb(0x83, reg_base+2); } -static byte read_reg(int reg) +static u8 read_reg(int reg) /* Read value from register reg, base of register * is at reg_base (0x1f0 primary, 0x170 secondary, * if not changed by PCI configuration). * This is from setupvic.exe program. */ { - byte ret; + u8 ret; inw(reg_base+1); inw(reg_base+1); outb(3, reg_base+2); @@ -245,16 +245,16 @@ static void compute_clocks(int pio, pio_clocks_t *clks) } /* Main tune procedure, called from tuneproc. */ -static void opti621_tune_drive(struct ata_device *drive, byte pio) +static void opti621_tune_drive(struct ata_device *drive, u8 pio) { /* primary and secondary drives share some registers, * so we have to program both drives */ unsigned long flags; - byte pio1, pio2; + u8 pio1, pio2; pio_clocks_t first, second; int ax, drdy; - byte cycle1, cycle2, misc; + u8 cycle1, cycle2, misc; struct ata_channel *hwif = drive->channel; /* sets drive->drive_data for both drives */ diff --git a/drivers/ide/pcidma.c b/drivers/ide/pcidma.c index a476693a3820..2674e69327dc 100644 --- a/drivers/ide/pcidma.c +++ b/drivers/ide/pcidma.c @@ -24,10 +24,11 @@ #include #include #include -#include #include +#include +#include -#include "ata-timing.h" +#include "timing.h" #include #include diff --git a/drivers/ide/pdc202xx.c b/drivers/ide/pdc202xx.c index 28f888d4a9c4..1d871fdcc1d2 100644 --- a/drivers/ide/pdc202xx.c +++ b/drivers/ide/pdc202xx.c @@ -48,16 +48,16 @@ #include #include #include -#include #include #include #include +#include #include #include #include -#include "ata-timing.h" +#include "timing.h" #include "pcihost.h" #define PDC202XX_DEBUG_DRIVE_INFO 0 @@ -105,7 +105,7 @@ static struct pdc_bit_messages pdc_reg_C[] = { /* MC3-MC0 - DMA "C" timing */ }; -static void pdc_dump_bits(struct pdc_bit_messages *msgs, byte bits) +static void pdc_dump_bits(struct pdc_bit_messages *msgs, u8 bits) { int i; @@ -174,7 +174,7 @@ static int __init pdc202xx_modes_map(struct ata_channel *ch) return map; } -static int pdc202xx_tune_chipset(struct ata_device *drive, byte speed) +static int pdc202xx_tune_chipset(struct ata_device *drive, u8 speed) { struct pci_dev *dev = drive->channel->pci_dev; u32 drive_conf; @@ -315,7 +315,7 @@ static int pdc202xx_tune_chipset(struct ata_device *drive, byte speed) OUT_BYTE(value, reg); \ mdelay(delay); -static int pdc202xx_new_tune_chipset(struct ata_device *drive, byte speed) +static int pdc202xx_new_tune_chipset(struct ata_device *drive, u8 speed) { struct ata_channel *hwif = drive->channel; u32 high_16 = pci_resource_start(hwif->pci_dev, 4); @@ -453,7 +453,7 @@ static void pdc202xx_tune_drive(struct ata_device *drive, u8 pio) if (pio == 255) speed = ata_best_pio_mode(drive); else - speed = XFER_PIO_0 + min_t(byte, pio, 4); + speed = XFER_PIO_0 + min_t(u8, pio, 4); pdc202xx_tune_chipset(drive, speed); } @@ -695,7 +695,7 @@ static unsigned int __init pdc202xx_init_chipset(struct pci_dev *dev) break; default: if ((dev->class >> 8) != PCI_CLASS_STORAGE_IDE) { - byte irq = 0, irq2 = 0; + u8 irq = 0, irq2 = 0; pci_read_config_byte(dev, PCI_INTERRUPT_LINE, &irq); pci_read_config_byte(dev, (PCI_INTERRUPT_LINE) | 0x80, &irq2); /* 0xbc */ diff --git a/drivers/ide/pdc4030.c b/drivers/ide/pdc4030.c index 323be48b0e30..c08a6914c7ff 100644 --- a/drivers/ide/pdc4030.c +++ b/drivers/ide/pdc4030.c @@ -175,10 +175,10 @@ static void promise_selectproc(struct ata_device *drive) * by command F0. They all have the same success/failure notification - * 'P' (=0x50) on success, 'p' (=0x70) on failure. */ -int pdc4030_cmd(struct ata_device *drive, byte cmd) +int pdc4030_cmd(struct ata_device *drive, u8 cmd) { unsigned long timeout, timer; - byte status_val; + u8 status_val; promise_selectproc(drive); /* redundant? */ outb(0xF3, IDE_SECTOR_REG); diff --git a/drivers/ide/pdcraid.c b/drivers/ide/pdcraid.c index d1bd67ba7f45..f4b7fc0f82e1 100644 --- a/drivers/ide/pdcraid.c +++ b/drivers/ide/pdcraid.c @@ -135,11 +135,11 @@ static int pdcraid_ioctl(struct inode *inode, struct file *file, return -EINVAL; if (put_user (raid[minor].geom.heads, - (byte *) & loc->heads)) + (u8 *) & loc->heads)) return -EFAULT; if (put_user (raid[minor].geom.sectors, - (byte *) & loc->sectors)) + (u8 *) & loc->sectors)) return -EFAULT; if (put_user (bios_cyl, (unsigned short *) &loc->cylinders)) diff --git a/drivers/ide/piix.c b/drivers/ide/piix.c index a5fb9998bf56..b56759830069 100644 --- a/drivers/ide/piix.c +++ b/drivers/ide/piix.c @@ -45,11 +45,12 @@ #include #include #include +#include #include #include -#include "ata-timing.h" +#include "timing.h" #include "pcihost.h" #define PIIX_IDETIM0 0x40 @@ -240,7 +241,7 @@ static void piix_tune_drive(struct ata_device *drive, unsigned char pio) return; } - piix_set_drive(drive, XFER_PIO_0 + min_t(byte, pio, 5)); + piix_set_drive(drive, XFER_PIO_0 + min_t(u8, pio, 5)); } #ifdef CONFIG_BLK_DEV_IDEDMA diff --git a/drivers/ide/probe.c b/drivers/ide/probe.c index abe93fece6cf..3766b7531c78 100644 --- a/drivers/ide/probe.c +++ b/drivers/ide/probe.c @@ -28,9 +28,10 @@ #include #include #include -#include #include #include +#include +#include #include #include @@ -302,18 +303,18 @@ void ide_fixstring(char *s, const int bytecount, const int byteswap) /* * All hosts that use the 80c ribbon must use this! */ -byte eighty_ninty_three(struct ata_device *drive) +int eighty_ninty_three(struct ata_device *drive) { - return ((u8) ((drive->channel->udma_four) && + return ((drive->channel->udma_four) && #ifndef CONFIG_IDEDMA_IVB (drive->id->hw_config & 0x4000) && #endif - (drive->id->hw_config & 0x6000)) ? 1 : 0); + (drive->id->hw_config & 0x6000)) ? 1 : 0; } /* FIXME: Channel lock should be held. */ -int ide_config_drive_speed(struct ata_device *drive, byte speed) +int ide_config_drive_speed(struct ata_device *drive, u8 speed) { struct ata_channel *ch = drive->channel; int ret; diff --git a/drivers/ide/qd65xx.c b/drivers/ide/qd65xx.c index 6fce3b4bf491..633a75950d60 100644 --- a/drivers/ide/qd65xx.c +++ b/drivers/ide/qd65xx.c @@ -29,12 +29,13 @@ #include #include #include +#include #include #include -#include + #include -#include "ata-timing.h" +#include "timing.h" #include "qd65xx.h" /* @@ -85,7 +86,7 @@ static int timings[4]={-1,-1,-1,-1}; /* stores current timing for each timer */ -static void qd_write_reg(byte content, byte reg) +static void qd_write_reg(u8 content, unsigned int reg) { unsigned long flags; @@ -95,10 +96,10 @@ static void qd_write_reg(byte content, byte reg) restore_flags(flags); /* all CPUs */ } -byte __init qd_read_reg(byte reg) +static u8 __init qd_read_reg(unsigned int reg) { unsigned long flags; - byte read; + u8 read; save_flags(flags); /* all CPUs */ cli(); /* all CPUs */ @@ -115,8 +116,8 @@ byte __init qd_read_reg(byte reg) static void qd_select(struct ata_device *drive) { - byte index = (( (QD_TIMREG(drive)) & 0x80 ) >> 7) | - (QD_TIMREG(drive) & 0x02); + u8 index = (((QD_TIMREG(drive)) & 0x80 ) >> 7) | + (QD_TIMREG(drive) & 0x02); if (timings[index] != QD_TIMING(drive)) qd_write_reg(timings[index] = QD_TIMING(drive), QD_TIMREG(drive)); @@ -130,9 +131,9 @@ static void qd_select(struct ata_device *drive) * upper nibble represents recovery time, in count of VLB clocks */ -static byte qd6500_compute_timing(struct ata_channel *hwif, int active_time, int recovery_time) +static u8 qd6500_compute_timing(struct ata_channel *hwif, int active_time, int recovery_time) { - byte active_cycle,recovery_cycle; + u8 active_cycle,recovery_cycle; if (system_bus_speed <= 33333) { active_cycle = 9 - IDE_IN(active_time * system_bus_speed / 1000000 + 1, 2, 9); @@ -151,12 +152,12 @@ static byte qd6500_compute_timing(struct ata_channel *hwif, int active_time, int * idem for qd6580 */ -static byte qd6580_compute_timing(int active_time, int recovery_time) +static u8 qd6580_compute_timing(int active_time, int recovery_time) { - byte active_cycle = 17 - IDE_IN(active_time * system_bus_speed / 1000000 + 1, 2, 17); - byte recovery_cycle = 15 - IDE_IN(recovery_time * system_bus_speed / 1000000 + 1, 2, 15); + u8 active_cycle = 17 - IDE_IN(active_time * system_bus_speed / 1000000 + 1, 2, 17); + u8 recovery_cycle = 15 - IDE_IN(recovery_time * system_bus_speed / 1000000 + 1, 2, 15); - return((recovery_cycle<<4) | active_cycle); + return (recovery_cycle<<4) | active_cycle; } /* @@ -205,7 +206,7 @@ static int qd_timing_ok(struct ata_device drives[]) * records the timing, and enables selectproc as needed */ -static void qd_set_timing(struct ata_device *drive, byte timing) +static void qd_set_timing(struct ata_device *drive, u8 timing) { struct ata_channel *hwif = drive->channel; @@ -224,7 +225,7 @@ static void qd_set_timing(struct ata_device *drive, byte timing) * qd6500_tune_drive */ -static void qd6500_tune_drive(struct ata_device *drive, byte pio) +static void qd6500_tune_drive(struct ata_device *drive, u8 pio) { int active_time = 175; int recovery_time = 415; /* worst case values from the dos driver */ @@ -245,7 +246,7 @@ static void qd6500_tune_drive(struct ata_device *drive, byte pio) * qd6580_tune_drive */ -static void qd6580_tune_drive(struct ata_device *drive, byte pio) +static void qd6580_tune_drive(struct ata_device *drive, u8 pio) { struct ata_timing *t; int base = drive->channel->select_data; @@ -257,7 +258,7 @@ static void qd6580_tune_drive(struct ata_device *drive, byte pio) if (pio == 255) pio = ata_timing_mode(drive, XFER_PIO | XFER_EPIO); else - pio = XFER_PIO_0 + min_t(byte, pio, 4); + pio = XFER_PIO_0 + min_t(u8, pio, 4); t = ata_timing_data(pio); @@ -305,8 +306,8 @@ static void qd6580_tune_drive(struct ata_device *drive, byte pio) static int __init qd_testreg(int port) { - byte savereg; - byte readreg; + u8 savereg; + u8 readreg; unsigned long flags; save_flags(flags); /* all CPUs */ @@ -333,7 +334,7 @@ static int __init qd_testreg(int port) * called to setup an ata channel : adjusts attributes & links for tuning */ -void __init qd_setup(int unit, int base, int config, unsigned int data0, unsigned int data1, void (*tuneproc) (struct ata_device *, byte pio)) +void __init qd_setup(int unit, int base, int config, unsigned int data0, unsigned int data1, void (*tuneproc) (struct ata_device *, u8 pio)) { struct ata_channel *hwif = &ide_hwifs[unit]; @@ -354,7 +355,7 @@ void __init qd_setup(int unit, int base, int config, unsigned int data0, unsigne */ void __init qd_unsetup(int unit) { struct ata_channel *hwif = &ide_hwifs[unit]; - byte config = hwif->config_data; + u8 config = hwif->config_data; int base = hwif->select_data; void *tuneproc = (void *) hwif->tuneproc; @@ -390,7 +391,7 @@ void __init qd_unsetup(int unit) { int __init qd_probe(int base) { - byte config; + u8 config; int unit; config = qd_read_reg(QD_CONFIG_PORT); @@ -417,7 +418,7 @@ int __init qd_probe(int base) } if (((config & 0xf0) == QD_CONFIG_QD6580_A) || ((config & 0xf0) == QD_CONFIG_QD6580_B)) { - byte control; + u8 control; if (qd_testreg(base) || qd_testreg(base+0x02)) return 1; /* bad registers */ diff --git a/drivers/ide/qd65xx.h b/drivers/ide/qd65xx.h index 73a7d76bbf6e..e0136907954c 100644 --- a/drivers/ide/qd65xx.h +++ b/drivers/ide/qd65xx.h @@ -34,8 +34,8 @@ #define QD_CONFIG(hwif) ((hwif)->config_data & 0x00ff) #define QD_CONTROL(hwif) (((hwif)->config_data & 0xff00) >> 8) -#define QD_TIMING(drive) (byte)(((drive)->drive_data) & 0x00ff) -#define QD_TIMREG(drive) (byte)((((drive)->drive_data) & 0xff00) >> 8) +#define QD_TIMING(drive) (u8)(((drive)->drive_data) & 0x00ff) +#define QD_TIMREG(drive) (u8)((((drive)->drive_data) & 0xff00) >> 8) #define QD6500_DEF_DATA ((QD_TIM1_PORT<<8) | (QD_ID3 ? 0x0c : 0x08)) #define QD6580_DEF_DATA ((QD_TIM1_PORT<<8) | (QD_ID3 ? 0x0a : 0x00)) diff --git a/drivers/ide/quirks.c b/drivers/ide/quirks.c index d4cd05578193..740cfe5632fe 100644 --- a/drivers/ide/quirks.c +++ b/drivers/ide/quirks.c @@ -24,8 +24,9 @@ #include #include #include -#include #include +#include +#include #include #include @@ -153,14 +154,14 @@ int check_drive_lists(struct ata_device *drive, int good_bad) /* Consult the list of known "good" drives */ list = good_dma_drives; while (*list) { - if (!strcmp(*list++,id->model)) + if (!strcmp(*list++, id->model)) return 1; } } else { /* Consult the list of known "bad" drives */ list = bad_dma_drives; while (*list) { - if (!strcmp(*list++,id->model)) { + if (!strcmp(*list++, id->model)) { printk("%s: Disabling (U)DMA for %s\n", drive->name, id->model); return 1; diff --git a/drivers/ide/serverworks.c b/drivers/ide/serverworks.c index ff8e39ef3b9f..1aa9c7199d71 100644 --- a/drivers/ide/serverworks.c +++ b/drivers/ide/serverworks.c @@ -85,14 +85,14 @@ #include #include #include -#include #include #include +#include #include #include -#include "ata-timing.h" +#include "timing.h" #include "pcihost.h" #undef SVWKS_DEBUG_DRIVE_INFO diff --git a/drivers/ide/sis5513.c b/drivers/ide/sis5513.c index fb1a56cd0140..efe3d4a882ad 100644 --- a/drivers/ide/sis5513.c +++ b/drivers/ide/sis5513.c @@ -44,13 +44,13 @@ #include #include #include -#include #include +#include #include #include -#include "ata-timing.h" +#include "timing.h" #include "pcihost.h" /* When DEBUG is defined it outputs initial PCI config register @@ -84,7 +84,7 @@ static unsigned char chipset_family; Fewer might be used depending on the actual chipset */ static unsigned char ide_regs_copy[0x58]; -static byte sis5513_max_config_register(void) { +static u8 sis5513_max_config_register(void) { switch(chipset_family) { case ATA_00: case ATA_16: return 0x4f; @@ -100,9 +100,9 @@ static byte sis5513_max_config_register(void) { /* Read config registers, print differences from previous read */ static void sis5513_load_verify_registers(struct pci_dev* dev, char* info) { int i; - byte reg_val; - byte changed=0; - byte max = sis5513_max_config_register(); + u8 reg_val; + u8 changed = 0; + u8 max = sis5513_max_config_register(); printk("SIS5513: %s, changed registers:\n", info); for(i=0; i<=max; i++) { @@ -121,9 +121,10 @@ static void sis5513_load_verify_registers(struct pci_dev* dev, char* info) { } /* Load config registers, no printing */ -static void sis5513_load_registers(struct pci_dev* dev) { +static void sis5513_load_registers(struct pci_dev* dev) +{ int i; - byte max = sis5513_max_config_register(); + u8 max = sis5513_max_config_register(); for(i=0; i<=max; i++) { pci_read_config_byte(dev, i, &(ide_regs_copy[i])); @@ -131,14 +132,15 @@ static void sis5513_load_registers(struct pci_dev* dev) { } /* Print a register */ -static void sis5513_print_register(int reg) { +static void sis5513_print_register(int reg) +{ printk(" %0#x:%0#x", reg, ide_regs_copy[reg]); } /* Print valuable registers */ static void sis5513_print_registers(struct pci_dev* dev, char* marker) { int i; - byte max = sis5513_max_config_register(); + u8 max = sis5513_max_config_register(); sis5513_load_registers(dev); printk("SIS5513 %s\n", marker); @@ -193,9 +195,9 @@ static const struct { /* Cycle time bits and values vary accross chip dma capabilities These three arrays hold the register layout and the values to set. Indexed by chipset_family and (dma_mode - XFER_UDMA_0) */ -static byte cycle_time_offset[] = {0,0,5,4,4,0,0}; -static byte cycle_time_range[] = {0,0,2,3,3,4,4}; -static byte cycle_time_value[][XFER_UDMA_5 - XFER_UDMA_0 + 1] = { +static u8 cycle_time_offset[] = {0,0,5,4,4,0,0}; +static u8 cycle_time_range[] = {0,0,2,3,3,4,4}; +static u8 cycle_time_value[][XFER_UDMA_5 - XFER_UDMA_0 + 1] = { {0,0,0,0,0,0}, /* no udma */ {0,0,0,0,0,0}, /* no udma */ {3,2,1,0,0,0}, @@ -317,7 +319,7 @@ static int sis5513_tune_chipset(struct ata_device *drive, u8 speed) struct ata_channel *hwif = drive->channel; struct pci_dev *dev = hwif->pci_dev; - byte drive_pci, reg; + u8 drive_pci, reg; #ifdef DEBUG sis5513_load_verify_registers(dev, "sis5513_tune_chipset start"); @@ -418,7 +420,7 @@ static unsigned int __init pci_init_sis5513(struct pci_dev *dev) #endif if (SiSHostChipInfo[i].flags & SIS5513_LATENCY) { - byte latency = (chipset_family == ATA_100)? 0x80 : 0x10; /* Lacking specs */ + u8 latency = (chipset_family == ATA_100)? 0x80 : 0x10; /* Lacking specs */ pci_write_config_byte(dev, PCI_LATENCY_TIMER, latency); } } @@ -427,7 +429,7 @@ static unsigned int __init pci_init_sis5513(struct pci_dev *dev) 1/ tell IDE channels to operate in Compabitility mode only 2/ tell old chips to allow per drive IDE timings */ if (host_dev) { - byte reg; + u8 reg; switch(chipset_family) { case ATA_133: case ATA_100: diff --git a/drivers/ide/sl82c105.c b/drivers/ide/sl82c105.c index 488b0018bb43..d348331d2006 100644 --- a/drivers/ide/sl82c105.c +++ b/drivers/ide/sl82c105.c @@ -19,14 +19,14 @@ #include #include #include -#include #include +#include #include #include #include -#include "ata-timing.h" +#include "timing.h" #include "pcihost.h" /* @@ -82,7 +82,7 @@ static void config_for_pio(struct ata_device *drive, int pio, int report) if (pio == 255) xfer_mode = ata_timing_mode(drive, XFER_PIO | XFER_EPIO); else - xfer_mode = XFER_PIO_0 + min_t(byte, pio, 4); + xfer_mode = XFER_PIO_0 + min_t(u8, pio, 4); t = ata_timing_data(xfer_mode); @@ -258,7 +258,7 @@ static void sl82c105_lostirq(struct ata_device *drive) * We only deal with PIO mode here - DMA mode 'using_dma' is not * initialised at the point that this function is called. */ -static void tune_sl82c105(struct ata_device *drive, byte pio) +static void tune_sl82c105(struct ata_device *drive, u8 pio) { config_for_pio(drive, pio, 1); @@ -320,7 +320,7 @@ static unsigned int __init sl82c105_init_chipset(struct pci_dev *dev) static void __init sl82c105_init_dma(struct ata_channel *ch, unsigned long dma_base) { unsigned int bridge_rev; - byte dma_state; + u8 dma_state; dma_state = inb(dma_base + 2); bridge_rev = sl82c105_bridge_revision(ch->pci_dev); diff --git a/drivers/ide/tcq.c b/drivers/ide/tcq.c index 83c63ff13f7d..f6ce02e194e2 100644 --- a/drivers/ide/tcq.c +++ b/drivers/ide/tcq.c @@ -25,6 +25,7 @@ #include #include #include +#include #include #include diff --git a/drivers/ide/timing.h b/drivers/ide/timing.h new file mode 100644 index 000000000000..f413a85723d0 --- /dev/null +++ b/drivers/ide/timing.h @@ -0,0 +1,83 @@ +/* + * Copyright (C) 1996 Linus Torvalds, Igor Abramov, and Mark Lord + * Copyright (C) 1999-2001 Vojtech Pavlik + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +#define XFER_PIO_5 0x0d +#define XFER_UDMA_SLOW 0x4f + +struct ata_timing { + short mode; + short setup; /* t1 */ + short act8b; /* t2 for 8-bit io */ + short rec8b; /* t2i for 8-bit io */ + short cyc8b; /* t0 for 8-bit io */ + short active; /* t2 or tD */ + short recover; /* t2i or tK */ + short cycle; /* t0 */ + short udma; /* t2CYCTYP/2 */ +}; + +extern struct ata_timing ata_timing[]; + +#define IDE_TIMING_SETUP 0x01 +#define IDE_TIMING_ACT8B 0x02 +#define IDE_TIMING_REC8B 0x04 +#define IDE_TIMING_CYC8B 0x08 +#define IDE_TIMING_8BIT 0x0e +#define IDE_TIMING_ACTIVE 0x10 +#define IDE_TIMING_RECOVER 0x20 +#define IDE_TIMING_CYCLE 0x40 +#define IDE_TIMING_UDMA 0x80 +#define IDE_TIMING_ALL 0xff + +#define FIT(v,x,y) max_t(int,min_t(int,v,y),x) +#define ENOUGH(v,unit) (((v)-1)/(unit)+1) +#define EZ(v,unit) ((v)?ENOUGH(v,unit):0) + +/* see hpt366.c for details */ +#define XFER_UDMA_66_3 0x100 +#define XFER_UDMA_66_4 0x200 + +#define XFER_MODE 0xff0 +#define XFER_UDMA_133 0x800 +#define XFER_UDMA_100 0x400 +#define XFER_UDMA_66 0x300 +#define XFER_UDMA 0x040 +#define XFER_MWDMA 0x020 +#define XFER_SWDMA 0x010 +#define XFER_EPIO 0x001 +#define XFER_PIO 0x000 + +#define XFER_UDMA_ALL 0xf40 +#define XFER_UDMA_80W 0xf00 + +/* External interface to host chips channel timing setup. + * + * It's a bit elaborate due to the legacy we have to bear. + */ + +extern short ata_timing_mode(struct ata_device *drive, int map); +extern void ata_timing_quantize(struct ata_timing *t, struct ata_timing *q, + int T, int UT); +extern void ata_timing_merge(struct ata_timing *a, struct ata_timing *b, + struct ata_timing *m, unsigned int what); +void ata_timing_merge_8bit(struct ata_timing *t); +extern struct ata_timing* ata_timing_data(short speed); +extern int ata_timing_compute(struct ata_device *drive, + short speed, struct ata_timing *t, int T, int UT); +extern u8 ata_best_pio_mode(struct ata_device *drive); diff --git a/drivers/ide/trm290.c b/drivers/ide/trm290.c index 4e1995b62a47..d37b405e4759 100644 --- a/drivers/ide/trm290.c +++ b/drivers/ide/trm290.c @@ -251,7 +251,7 @@ static void __init trm290_init_channel(struct ata_channel *hwif) { unsigned int cfgbase = 0; unsigned long flags; - byte reg; + u8 reg; struct pci_dev *dev = hwif->pci_dev; hwif->chipset = ide_trm290; diff --git a/drivers/ide/umc8672.c b/drivers/ide/umc8672.c index fb7f1a6116b9..61c986d226b3 100644 --- a/drivers/ide/umc8672.c +++ b/drivers/ide/umc8672.c @@ -46,13 +46,13 @@ #include #include #include +#include #include #include -#include #include -#include "ata-timing.h" +#include "timing.h" /* * Default speeds. These can be changed with "auto-tune" and/or hdparm. @@ -62,11 +62,11 @@ #define UMC_DRIVE2 1 /* 11 = Fastest Speed */ #define UMC_DRIVE3 1 /* In case of crash reduce speed */ -static byte current_speeds[4] = {UMC_DRIVE0, UMC_DRIVE1, UMC_DRIVE2, UMC_DRIVE3}; -static const byte pio_to_umc [5] = {0,3,7,10,11}; /* rough guesses */ +static u8 current_speeds[4] = {UMC_DRIVE0, UMC_DRIVE1, UMC_DRIVE2, UMC_DRIVE3}; +static const u8 pio_to_umc[5] = {0,3,7,10,11}; /* rough guesses */ /* 0 1 2 3 4 5 6 7 8 9 10 11 */ -static const byte speedtab [3][12] = { +static const u8 speedtab[3][12] = { {0xf, 0xb, 0x2, 0x2, 0x2, 0x1, 0x1, 0x1, 0x1, 0x1, 0x1, 0x1 }, {0x3, 0x2, 0x2, 0x2, 0x2, 0x2, 0x1, 0x1, 0x1, 0x1, 0x1, 0x1 }, {0xff,0xcb,0xc0,0x58,0x36,0x33,0x23,0x22,0x21,0x11,0x10,0x0}}; @@ -77,13 +77,13 @@ static void out_umc (char port,char wert) outb_p (wert,0x109); } -static inline byte in_umc (char port) +static inline u8 in_umc (char port) { outb_p (port,0x108); return inb_p (0x109); } -static void umc_set_speeds (byte speeds[]) +static void umc_set_speeds(u8 speeds[]) { int i, tmp; @@ -106,14 +106,14 @@ static void umc_set_speeds (byte speeds[]) speeds[0], speeds[1], speeds[2], speeds[3]); } -static void tune_umc(struct ata_device *drive, byte pio) +static void tune_umc(struct ata_device *drive, u8 pio) { unsigned long flags; if (pio == 255) pio = ata_timing_mode(drive, XFER_PIO | XFER_EPIO) - XFER_PIO_0; else - pio = min_t(byte, pio, 4); + pio = min_t(u8, pio, 4); printk("%s: setting umc8672 to PIO mode%d (speed %d)\n", drive->name, pio, pio_to_umc[pio]); save_flags(flags); /* all CPUs */ diff --git a/drivers/ide/via82cxxx.c b/drivers/ide/via82cxxx.c index 54838f9a8975..45cc8fd3fa80 100644 --- a/drivers/ide/via82cxxx.c +++ b/drivers/ide/via82cxxx.c @@ -65,11 +65,12 @@ #include #include #include +#include #include #include -#include "ata-timing.h" +#include "timing.h" #include "pcihost.h" #define VIA_IDE_ENABLE 0x40 @@ -217,7 +218,7 @@ static void via82cxxx_tune_drive(struct ata_device *drive, unsigned char pio) return; } - via_set_drive(drive, XFER_PIO_0 + min_t(byte, pio, 5)); + via_set_drive(drive, XFER_PIO_0 + min_t(u8, pio, 5)); } #ifdef CONFIG_BLK_DEV_IDEDMA diff --git a/fs/partitions/msdos.c b/fs/partitions/msdos.c index f06e68e07cce..5d0bb6074fe4 100644 --- a/fs/partitions/msdos.c +++ b/fs/partitions/msdos.c @@ -23,6 +23,7 @@ #include /* for invalidate_bdev() */ #ifdef CONFIG_BLK_DEV_IDE +#include #include /* IDE xlate */ #elif defined(CONFIG_BLK_DEV_IDE_MODULE) #include diff --git a/include/linux/ide.h b/include/linux/ide.h index 7b9c5cce01cf..8a41b3b2e74a 100644 --- a/include/linux/ide.h +++ b/include/linux/ide.h @@ -285,8 +285,8 @@ struct ata_device { unsigned long sleep; /* sleep until this time */ - byte retry_pio; /* retrying dma capable host in pio */ - byte state; /* retry state */ + u8 retry_pio; /* retrying dma capable host in pio */ + u8 state; /* retry state */ unsigned using_dma : 1; /* disk is using dma for read/write */ unsigned using_tcq : 1; /* disk is using queueing */ @@ -307,20 +307,20 @@ struct ata_device { unsigned remap_0_to_1 : 2; /* 0=remap if ezdrive, 1=remap, 2=noremap */ unsigned ata_flash : 1; /* 1=present, 0=default */ unsigned addressing; /* : 2; 0=28-bit, 1=48-bit, 2=64-bit */ - byte scsi; /* 0=default, 1=skip current ide-subdriver for ide-scsi emulation */ + u8 scsi; /* 0=default, 1=skip current ide-subdriver for ide-scsi emulation */ select_t select; /* basic drive/head select reg value */ u8 status; /* last retrived status value for device */ - byte ready_stat; /* min status value for drive ready */ - byte mult_count; /* current multiple sector setting */ - byte bad_wstat; /* used for ignoring WRERR_STAT */ - byte nowerr; /* used for ignoring WRERR_STAT */ - byte sect0; /* offset of first sector for DM6:DDO */ - byte head; /* "real" number of heads */ - byte sect; /* "real" sectors per track */ - byte bios_head; /* BIOS/fdisk/LILO number of heads */ - byte bios_sect; /* BIOS/fdisk/LILO sectors per track */ + u8 ready_stat; /* min status value for drive ready */ + u8 mult_count; /* current multiple sector setting */ + u8 bad_wstat; /* used for ignoring WRERR_STAT */ + u8 nowerr; /* used for ignoring WRERR_STAT */ + u8 sect0; /* offset of first sector for DM6:DDO */ + u8 head; /* "real" number of heads */ + u8 sect; /* "real" sectors per track */ + u8 bios_head; /* BIOS/fdisk/LILO number of heads */ + u8 bios_sect; /* BIOS/fdisk/LILO sectors per track */ unsigned int bios_cyl; /* BIOS/fdisk/LILO number of cyls */ unsigned int cyl; /* "real" number of cyls */ u64 capacity; /* total number of sectors */ @@ -343,13 +343,12 @@ struct ata_device { int lun; /* logical unit */ int crc_count; /* crc counter to reduce drive speed */ - byte quirk_list; /* drive is considered quirky if set for a specific host */ - byte suspend_reset; /* drive suspend mode flag, soft-reset recovers */ - byte current_speed; /* current transfer rate set */ - byte dn; /* now wide spread use */ - byte wcache; /* status of write cache */ - byte acoustic; /* acoustic management */ - byte queue_depth; /* max queue depth */ + int quirk_list; /* drive is considered quirky if set for a specific host */ + u8 current_speed; /* current transfer rate set */ + u8 dn; /* now wide spread use */ + u8 wcache; /* status of write cache */ + u8 acoustic; /* acoustic management */ + unsigned int queue_depth; /* max queue depth */ unsigned int failures; /* current failure count */ unsigned int max_failures; /* maximum allowed failure count */ struct device dev; /* global device tree handle */ @@ -370,7 +369,7 @@ typedef enum { ATA_OP_FINISHED, /* no drive operation was started */ ATA_OP_CONTINUES, /* a drive operation was started, and a handler was set */ ATA_OP_RELEASED, /* started and released bus */ - ATA_OP_READY, /* indicate status poll finished fine */ + ATA_OP_READY /* indicate status poll finished fine */ } ide_startstop_t; /* @@ -428,10 +427,10 @@ struct ata_channel { */ /* setup disk on a channel for a particular PIO transfer mode */ - void (*tuneproc) (struct ata_device *, byte pio); + void (*tuneproc) (struct ata_device *, u8 pio); /* setup the chipset timing for a particular transfer mode */ - int (*speedproc) (struct ata_device *, byte pio); + int (*speedproc) (struct ata_device *, u8 pio); /* tweaks hardware to select drive */ void (*selectproc) (struct ata_device *); @@ -640,10 +639,8 @@ extern void ata_read(struct ata_device *, void *, unsigned int); extern void ata_write(struct ata_device *, void *, unsigned int); extern int ide_raw_taskfile(struct ata_device *, struct ata_taskfile *, char *); -extern int ide_config_drive_speed(struct ata_device *, byte); -extern byte eighty_ninty_three(struct ata_device *); - -extern void ide_stall_queue(struct ata_device *, unsigned long); +extern int ide_config_drive_speed(struct ata_device *, u8); +extern int eighty_ninty_three(struct ata_device *); extern int system_bus_speed; @@ -656,11 +653,11 @@ extern int system_bus_speed; extern int drive_is_flashcard(struct ata_device *); -int ide_spin_wait_hwgroup(struct ata_device *); -void ide_timer_expiry (unsigned long data); +extern int ide_spin_wait_hwgroup(struct ata_device *); +extern void ide_timer_expiry(unsigned long data); extern void ata_irq_request(int irq, void *data, struct pt_regs *regs); -void do_ide_request (request_queue_t * q); -void ide_init_subdrivers (void); +extern void do_ide_request(request_queue_t * q); +extern void ide_init_subdrivers(void); extern struct block_device_operations ide_fops[]; @@ -742,12 +739,12 @@ static inline int udma_irq_status(struct ata_device *drive) static inline void udma_timeout(struct ata_device *drive) { - return drive->channel->udma_timeout(drive); + drive->channel->udma_timeout(drive); } static inline void udma_irq_lost(struct ata_device *drive) { - return drive->channel->udma_irq_lost(drive); + drive->channel->udma_irq_lost(drive); } #ifdef CONFIG_BLK_DEV_IDEDMA -- cgit v1.2.3 From c5e062079a7090891ea5cd1b23a7eab52b156b2a Mon Sep 17 00:00:00 2001 From: Rusty Russell Date: Fri, 26 Jul 2002 01:28:07 -0700 Subject: [PATCH] Hot-plug CPU Boot Changes This patch alters the boot sequence to "plug in" each CPU, one at a time. You need the patch for each architecture, as well. The interface used to be "smp_boot_cpus()", "smp_commence()", and each arch implemented the "maxcpus" boot arg itself. With this patch, it is: smp_prepare_cpus(maxcpus): probe for cpus and set up cpu_possible(cpu). __cpu_up(cpu): called *after* initcalls, for each cpu where cpu_possible(cpu) is true. smp_cpus_done(maxcpus): called after every cpu has been brought up --- include/linux/notifier.h | 2 ++ include/linux/sched.h | 1 - include/linux/smp.h | 23 +++++++++++++----- init/main.c | 61 ++++++++++++++++++++++++++++++++++++++++-------- kernel/Makefile | 1 + kernel/cpu.c | 54 ++++++++++++++++++++++++++++++++++++++++++ kernel/sched.c | 58 ++++++++++++++++++++++----------------------- kernel/softirq.c | 37 +++++++++++++++++++---------- 8 files changed, 178 insertions(+), 59 deletions(-) create mode 100644 kernel/cpu.c (limited to 'include/linux') diff --git a/include/linux/notifier.h b/include/linux/notifier.h index 0db9736c1166..05d2e7968646 100644 --- a/include/linux/notifier.h +++ b/include/linux/notifier.h @@ -60,5 +60,7 @@ extern int notifier_call_chain(struct notifier_block **n, unsigned long val, voi #define NETLINK_URELEASE 0x0001 /* Unicast netlink socket released */ +#define CPU_ONLINE 0x0002 /* CPU (unsigned)v coming up */ + #endif /* __KERNEL__ */ #endif /* _LINUX_NOTIFIER_H */ diff --git a/include/linux/sched.h b/include/linux/sched.h index 6dd4746e58cd..1ee746b656cf 100644 --- a/include/linux/sched.h +++ b/include/linux/sched.h @@ -150,7 +150,6 @@ extern void update_process_times(int user); extern void update_one_process(struct task_struct *p, unsigned long user, unsigned long system, int cpu); extern void scheduler_tick(int user_tick, int system); -extern void migration_init(void); extern unsigned long cache_decay_ticks; diff --git a/include/linux/smp.h b/include/linux/smp.h index d6857a229d5d..454fdcdf14d2 100644 --- a/include/linux/smp.h +++ b/include/linux/smp.h @@ -32,19 +32,19 @@ extern void FASTCALL(smp_send_reschedule(int cpu)); /* - * Boot processor call to load the other CPU's + * Prepare machine for booting other CPUs. */ -extern void smp_boot_cpus(void); +extern void smp_prepare_cpus(unsigned int max_cpus); /* - * Processor call in. Must hold processors until .. + * Bring a CPU up */ -extern void smp_callin(void); +extern int __cpu_up(unsigned int cpunum); /* - * Multiprocessors may now schedule + * Final polishing of CPUs */ -extern void smp_commence(void); +extern void smp_cpus_done(unsigned int max_cpus); /* * Call a function on all other processors @@ -71,6 +71,13 @@ extern volatile int smp_msg_id; #define MSG_RESCHEDULE 0x0003 /* Reschedule request from master CPU*/ #define MSG_CALL_FUNCTION 0x0004 /* Call function on all other CPUs */ +struct notifier_block; + +/* Need to know about CPUs going up/down? */ +extern int register_cpu_notifier(struct notifier_block *nb); +extern void unregister_cpu_notifier(struct notifier_block *nb); + +int cpu_up(unsigned int cpu); #else /* !SMP */ /* @@ -93,6 +100,10 @@ static inline void smp_send_reschedule_all(void) { } #define per_cpu(var, cpu) var #define this_cpu(var) var +/* Need to know about CPUs going up/down? */ +#define register_cpu_notifier(nb) 0 +#define unregister_cpu_notifier(nb) do { } while(0) + #endif /* !SMP */ #define get_cpu() ({ preempt_disable(); smp_processor_id(); }) diff --git a/init/main.c b/init/main.c index 3a50b7b197a6..ab46d162736d 100644 --- a/init/main.c +++ b/init/main.c @@ -95,6 +95,35 @@ int rows, cols; char *execute_command; +/* Setup configured maximum number of CPUs to activate */ +static unsigned int max_cpus = UINT_MAX; + +/* + * Setup routine for controlling SMP activation + * + * Command-line option of "nosmp" or "maxcpus=0" will disable SMP + * activation entirely (the MPS table probe still happens, though). + * + * Command-line option of "maxcpus=", where is an integer + * greater than 0, limits the maximum number of CPUs activated in + * SMP mode to . + */ +static int __init nosmp(char *str) +{ + max_cpus = 0; + return 1; +} + +__setup("nosmp", nosmp); + +static int __init maxcpus(char *str) +{ + get_option(&str, &max_cpus); + return 1; +} + +__setup("maxcpus=", maxcpus); + static char * argv_init[MAX_INIT_ARGS+2] = { "init", NULL, }; char * envp_init[MAX_INIT_ENVS+2] = { "HOME=/", "TERM=linux", NULL, }; @@ -275,6 +304,7 @@ static void __init smp_init(void) #endif static inline void setup_per_cpu_areas(void) { } +static inline void smp_prepare_cpus(unsigned int maxcpus) { } #else @@ -305,11 +335,27 @@ static void __init setup_per_cpu_areas(void) /* Called by boot processor to activate the rest. */ static void __init smp_init(void) { + unsigned int i; + + /* FIXME: This should be done in userspace --RR */ + for (i = 0; i < NR_CPUS; i++) { + if (num_online_cpus() >= max_cpus) + break; + if (cpu_possible(i) && !cpu_online(i)) { + printk("Bringing up %i\n", i); + cpu_up(i); + } + } + + /* Any cleanup work */ + printk("CPUS done %u\n", max_cpus); + smp_cpus_done(max_cpus); +#if 0 /* Get other processors into their bootup holding patterns. */ - smp_boot_cpus(); smp_threads_ready=1; smp_commence(); +#endif } #endif @@ -405,14 +451,12 @@ asmlinkage void __init start_kernel(void) check_bugs(); printk("POSIX conformance testing by UNIFIX\n"); - init_idle(current, smp_processor_id()); - /* * We count on the initial thread going ok * Like idlers init is an unlocked kernel thread, which will * make syscalls (and thus be locked). */ - smp_init(); + init_idle(current, smp_processor_id()); /* Do the rest non-__init'ed, we're now alive */ rest_init(); @@ -443,12 +487,6 @@ static void __init do_initcalls(void) */ static void __init do_basic_setup(void) { - /* - * Let the per-CPU migration threads start up: - */ -#if CONFIG_SMP - migration_init(); -#endif /* * Tell the world that we're going to be the grim * reaper of innocent orphaned children. @@ -493,7 +531,10 @@ static int init(void * unused) static char * argv_sh[] = { "sh", NULL, }; lock_kernel(); + /* Sets up cpus_possible() */ + smp_prepare_cpus(max_cpus); do_basic_setup(); + smp_init(); prepare_namespace(); diff --git a/kernel/Makefile b/kernel/Makefile index d0cad7d5115c..4834fc454271 100644 --- a/kernel/Makefile +++ b/kernel/Makefile @@ -17,6 +17,7 @@ obj-y = sched.o dma.o fork.o exec_domain.o panic.o printk.o \ sysctl.o capability.o ptrace.o timer.o user.o \ signal.o sys.o kmod.o context.o futex.o platform.o +obj-$(CONFIG_SMP) += cpu.o obj-$(CONFIG_UID16) += uid16.o obj-$(CONFIG_MODULES) += ksyms.o obj-$(CONFIG_PM) += pm.o diff --git a/kernel/cpu.c b/kernel/cpu.c new file mode 100644 index 000000000000..b1820a5536d6 --- /dev/null +++ b/kernel/cpu.c @@ -0,0 +1,54 @@ +/* CPU control. + * (C) 2001 Rusty Russell + * This code is licenced under the GPL. + */ +#include +#include +#include +#include +#include +#include +#include + +/* This protects CPUs going up and down... */ +DECLARE_MUTEX(cpucontrol); + +static struct notifier_block *cpu_chain = NULL; + +/* Need to know about CPUs going up/down? */ +int register_cpu_notifier(struct notifier_block *nb) +{ + return notifier_chain_register(&cpu_chain, nb); +} + +void unregister_cpu_notifier(struct notifier_block *nb) +{ + notifier_chain_unregister(&cpu_chain,nb); +} + +int __devinit cpu_up(unsigned int cpu) +{ + int ret; + + if ((ret = down_interruptible(&cpucontrol)) != 0) + return ret; + + if (cpu_online(cpu)) { + ret = -EINVAL; + goto out; + } + + /* Arch-specific enabling code. */ + ret = __cpu_up(cpu); + if (ret != 0) goto out; + if (!cpu_online(cpu)) + BUG(); + + /* Now call notifier in preparation. */ + printk("CPU %u IS NOW UP!\n", cpu); + notifier_call_chain(&cpu_chain, CPU_ONLINE, (void *)cpu); + + out: + up(&cpucontrol); + return ret; +} diff --git a/kernel/sched.c b/kernel/sched.c index a54ee5a0356c..67ac32a24c1f 100644 --- a/kernel/sched.c +++ b/kernel/sched.c @@ -27,6 +27,8 @@ #include #include #include +#include +#include /* * Convert user-nice values [ -20 ... 0 ... 19 ] @@ -1777,9 +1779,11 @@ void set_cpus_allowed(task_t *p, unsigned long new_mask) migration_req_t req; runqueue_t *rq; +#if 0 /* FIXME: Grab cpu_lock, return error on this case. --RR */ new_mask &= cpu_online_map; if (!new_mask) BUG(); +#endif preempt_disable(); rq = task_rq_lock(p, &flags); @@ -1812,8 +1816,6 @@ out: preempt_enable(); } -static __initdata int master_migration_thread; - static int migration_thread(void * bind_cpu) { int cpu = (int) (long) bind_cpu; @@ -1825,15 +1827,7 @@ static int migration_thread(void * bind_cpu) sigfillset(¤t->blocked); set_fs(KERNEL_DS); - /* - * The first migration thread is started on the boot CPU, it - * migrates the other migration threads to their destination CPUs. - */ - if (cpu != master_migration_thread) { - while (!cpu_rq(master_migration_thread)->migration_thread) - yield(); - set_cpus_allowed(current, 1UL << cpu); - } + set_cpus_allowed(current, 1UL << cpu); printk("migration_task %d on cpu=%d\n", cpu, smp_processor_id()); ret = setscheduler(0, SCHED_FIFO, ¶m); @@ -1890,29 +1884,33 @@ repeat: } } -void __init migration_init(void) +static int migration_call(struct notifier_block *nfb, + unsigned long action, + void *hcpu) { - int cpu; - - master_migration_thread = smp_processor_id(); - current->cpus_allowed = 1UL << master_migration_thread; - - for (cpu = 0; cpu < NR_CPUS; cpu++) { - if (!cpu_online(cpu)) - continue; - if (kernel_thread(migration_thread, (void *) (long) cpu, - CLONE_FS | CLONE_FILES | CLONE_SIGNAL) < 0) - BUG(); + switch (action) { + case CPU_ONLINE: + printk("Starting migration thread for cpu %li\n", + (long)hcpu); + kernel_thread(migration_thread, hcpu, + CLONE_FS | CLONE_FILES | CLONE_SIGNAL); + break; } - current->cpus_allowed = -1L; + return NOTIFY_OK; +} - for (cpu = 0; cpu < NR_CPUS; cpu++) { - if (!cpu_online(cpu)) - continue; - while (!cpu_rq(cpu)->migration_thread) - schedule_timeout(2); - } +static struct notifier_block migration_notifier = { &migration_call, NULL, 0 }; + +int __init migration_init(void) +{ + /* Start one for boot CPU. */ + migration_call(&migration_notifier, CPU_ONLINE, + (void *)smp_processor_id()); + register_cpu_notifier(&migration_notifier); + return 0; } + +__initcall(migration_init); #endif extern void init_timervecs(void); diff --git a/kernel/softirq.c b/kernel/softirq.c index 135106c390c4..38ae82b344c0 100644 --- a/kernel/softirq.c +++ b/kernel/softirq.c @@ -17,6 +17,7 @@ #include #include #include +#include /* - No shared variables, all the data are CPU local. @@ -387,20 +388,32 @@ static int ksoftirqd(void * __bind_cpu) } } -static __init int spawn_ksoftirqd(void) +static int __devinit cpu_callback(struct notifier_block *nfb, + unsigned long action, + void *hcpu) { - int cpu; + int hotcpu = (unsigned long)hcpu; - for (cpu = 0; cpu < NR_CPUS; cpu++) { - if (!cpu_online(cpu)) - continue; - if (kernel_thread(ksoftirqd, (void *) (long) cpu, - CLONE_FS | CLONE_FILES | CLONE_SIGNAL) < 0) - printk("spawn_ksoftirqd() failed for cpu %d\n", cpu); - else - while (!ksoftirqd_task(cpu)) - yield(); - } + if (action == CPU_ONLINE) { + if (kernel_thread(ksoftirqd, hcpu, + CLONE_FS | CLONE_FILES | CLONE_SIGNAL) < 0) { + printk("ksoftirqd for %i failed\n", hotcpu); + return NOTIFY_BAD; + } + + while (!ksoftirqd_task(hotcpu)) + yield(); + return NOTIFY_OK; + } + return NOTIFY_BAD; +} + +static struct notifier_block cpu_nfb = { &cpu_callback, NULL, 0 }; + +static __init int spawn_ksoftirqd(void) +{ + cpu_callback(&cpu_nfb, CPU_ONLINE, (void *)smp_processor_id()); + register_cpu_notifier(&cpu_nfb); return 0; } -- cgit v1.2.3