2002-01-03 21:35:15

by Michael Zhu

[permalink] [raw]
Subject: The CURRENT macro

In Alessandro Rubini's book Linux Device Driver(Second
Edition), Chatper 12, he said that "By accessing the
fields in the request structure, usually by way of
CURRENT" and "CURRENT is just a pointer into
blk_dev[MAJOR_NR].request_queue". I know CURRENT is
just a macro. Where can I find the definition of this
macro?
I just don't know how to get the struct request from
the request_queue(a request_queue_t struct). CURRENT
points to which field in the
blk_dev[MAJOR_NR].request_queue? Thank you very much.

Michael

______________________________________________________
Send your holiday cheer with http://greetings.yahoo.ca


2002-01-03 21:49:00

by Jonathan Corbet

[permalink] [raw]
Subject: Re: The CURRENT macro

> In Alessandro Rubini's book Linux Device Driver(Second
> Edition), Chatper 12

Alessandro and...um...some other guy...:)

> he said that "By accessing the
> fields in the request structure, usually by way of
> CURRENT" and "CURRENT is just a pointer into
> blk_dev[MAJOR_NR].request_queue". I know CURRENT is
> just a macro. Where can I find the definition of this
> macro?

A little grepping in the source would give you the answer there. It's in
.../include/linux/blk.h.

> I just don't know how to get the struct request from
> the request_queue(a request_queue_t struct). CURRENT
> points to which field in the
> blk_dev[MAJOR_NR].request_queue? Thank you very much.

CURRENT is one way. There's also functions like blkdev_entry_next_request
(also described in that chapter) that will pull a request off the queue for
you, if that's what you need.

Note that all this stuff has changed quite a bit in 2.5.

jon

Jonathan Corbet
Executive editor, LWN.net
[email protected]

2002-01-03 22:01:32

by Richard B. Johnson

[permalink] [raw]
Subject: Re: The CURRENT macro

On Thu, 3 Jan 2002, Michael Zhu wrote:

> In Alessandro Rubini's book Linux Device Driver(Second
> Edition), Chatper 12, he said that "By accessing the
> fields in the request structure, usually by way of
> CURRENT" and "CURRENT is just a pointer into
> blk_dev[MAJOR_NR].request_queue". I know CURRENT is
> just a macro. Where can I find the definition of this
> macro?
> I just don't know how to get the struct request from
> the request_queue(a request_queue_t struct). CURRENT
> points to which field in the
> blk_dev[MAJOR_NR].request_queue? Thank you very much.
>
> Michael

If symlinks are set up:

/usr/include/linux/blk.h

#ifndef _BLK_H
#define _BLK_H

[SNIPPED...]

#ifndef CURRENT
#define CURRENT blkdev_entry_next_request(&blk_dev[MAJOR_NR].request_queue.queue_head)
#endif

#endif /* _BLK_H */

Otherwise:

../linux-n.n.n/include/linux/blk.h


FYI. To find things in the future, do:
cd /usr/include/linux
grep WHAT_TO_FIND *.h | more
cd ../asm
grep WHAT_TO_FIND *.h | more


Cheers,
Dick Johnson

Penguin : Linux version 2.4.1 on an i686 machine (797.90 BogoMips).

I was going to compile a list of innovations that could be
attributed to Microsoft. Once I realized that Ctrl-Alt-Del
was handled in the BIOS, I found that there aren't any.


2002-01-03 22:03:12

by Tom Gall

[permalink] [raw]
Subject: Re: The CURRENT macro

Michael Zhu wrote:
>
> In Alessandro Rubini's book Linux Device Driver(Second
> Edition), Chatper 12, he said that "By accessing the
> fields in the request structure, usually by way of
> CURRENT" and "CURRENT is just a pointer into
> blk_dev[MAJOR_NR].request_queue". I know CURRENT is
> just a macro. Where can I find the definition of this
> macro?
> I just don't know how to get the struct request from
> the request_queue(a request_queue_t struct). CURRENT
> points to which field in the
> blk_dev[MAJOR_NR].request_queue? Thank you very much.

Look in include/asm-[your-arch]/current.h

It's architecture dependant. For instance on PPC64 we keep current in a
register.

Regards,

Tom

--
Tom Gall - [embedded] [PPC64 | PPC32] Code Monkey
Peace, Love & "Where's the ka-boom? There was
Linux Technology Center supposed to be an earth
http://www.ibm.com/linux/ltc/ shattering ka-boom!"
(w) [email protected] -- Marvin Martian
(w) 507-253-4558
(h) [email protected]

2002-01-03 22:05:22

by Tom Gall

[permalink] [raw]
Subject: Re: The CURRENT macro

Michael Zhu wrote:
>
> In Alessandro Rubini's book Linux Device Driver(Second
> Edition), Chatper 12, he said that "By accessing the
> fields in the request structure, usually by way of
> CURRENT" and "CURRENT is just a pointer into
> blk_dev[MAJOR_NR].request_queue". I know CURRENT is
> just a macro. Where can I find the definition of this
> macro?
> I just don't know how to get the struct request from
> the request_queue(a request_queue_t struct). CURRENT
> points to which field in the
> blk_dev[MAJOR_NR].request_queue? Thank you very much.

Heh! Ignore that last one ...

Wrong current... you want CURRENT ... duh! look in include/linux/blk.h

grep is your friend.

Regards,

Tom
--
Tom Gall - [embedded] [PPC64 | PPC32] Code Monkey
Peace, Love & "Where's the ka-boom? There was
Linux Technology Center supposed to be an earth
http://www.ibm.com/linux/ltc/ shattering ka-boom!"
(w) [email protected] -- Marvin Martian
(w) 507-253-4558
(h) [email protected]

2002-01-03 22:15:22

by Peter Makholm

[permalink] [raw]
Subject: Re: The CURRENT macro

[email protected] (Michael Zhu) writes:

> blk_dev[MAJOR_NR].request_queue". I know CURRENT is
> just a macro. Where can I find the definition of this
> macro?

Seek, and ye shall find (Matt 7.7):

xyzzy% find -type f | xargs grep "#define CURRENT "
./include/linux/blk.h:#define CURRENT blkdev_entry_next_request(&blk_dev[MAJOR_NR].request_queue.queue_head)
xyzzy%

--
N?r folk sp?rger mig, om jeg er n?rd, bliver jeg altid ilde til mode
og svarer lidt undskyldende: "Nej, jeg bruger RedHat".
-- Allan Olesen p? dk.edb.system.unix

2002-01-03 23:40:30

by Arnaldo Carvalho de Melo

[permalink] [raw]
Subject: Re: The CURRENT macro

Em Thu, Jan 03, 2002 at 02:48:39PM -0700, Jonathan Corbet escreveu:
> > In Alessandro Rubini's book Linux Device Driver(Second
> > Edition), Chatper 12

> Alessandro and...um...some other guy...:)

Yes, I know that other guy, very nice guy indeed 8)

> > he said that "By accessing the
> > fields in the request structure, usually by way of
> > CURRENT" and "CURRENT is just a pointer into
> > blk_dev[MAJOR_NR].request_queue". I know CURRENT is
> > just a macro. Where can I find the definition of this
> > macro?

> A little grepping in the source would give you the answer there. It's in
> .../include/linux/blk.h.

Or:

make tags
vi -t CURRENT

8)

- Arnaldo

2002-01-04 08:02:35

by Terje Eggestad

[permalink] [raw]
Subject: Re: The CURRENT macro

On Thu, 2002-01-03 at 22:55, Arnaldo Carvalho de Melo wrote:

>
> > A little grepping in the source would give you the answer there. It's in
> > .../include/linux/blk.h.
>
> Or:
>
> make tags
> vi -t CURRENT
>

Or
make TAGS
emacs
then in emacs: M-.


In either case make sure you do a make xconfig or another config to
make sure tags are correct for your platform.


> 8)
>
> - Arnaldo
> -
> To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
> the body of a message to [email protected]
> More majordomo info at http://vger.kernel.org/majordomo-info.html
> Please read the FAQ at http://www.tux.org/lkml/


TJ