From: Matthew Wilcox <matthew@wil.cx>
To: jidong xiao <jidong.xiao@gmail.com>
Cc: linux-scsi@vger.kernel.org
Subject: Re: Question about scsi_host_alloc
Date: Wed, 18 Jul 2007 05:26:29 -0600 [thread overview]
Message-ID: <20070718112628.GM14791@parisc-linux.org> (raw)
In-Reply-To: <4104961b0707180400l62a7eda7p5ec0770ddb69651b@mail.gmail.com>
On Wed, Jul 18, 2007 at 07:00:01PM +0800, jidong xiao wrote:
> I see this function,struct Scsi_Host *scsi_host_alloc(struct
> scsi_host_template *, int), I am wondering what does the second
> parameter used for?Say,
>
> I mean the privsize, i.e. extra bytes, why do we need such extra
> bytes?Who will use it?
It's for the use of the driver. Many drivers have a struct containing
additional information, such as:
struct scsi_qla_host {
/* Linux adapter configuration data */
struct Scsi_Host *host; /* pointer to host data */
struct scsi_qla_host *next;
struct device_reg __iomem *iobase; /* Base Memory-mapped I/O addres
s */
[....]
struct nvram nvram;
int nvram_valid;
};
...
struct scsi_qla_host *ha;
host = scsi_host_alloc(&qla1280_driver_template, sizeof(*ha));
ha = (struct scsi_qla_host *)host->hostdata;
It means the driver doesn't need to allocate the private data separately,
so it's a little more efficient. You also don't need to worry about
reference counting it; it will be freed when the Scsi_Host is freed.
--
"Bill, look, we understand that you're interested in selling us this
operating system, but compare it to ours. We can't possibly take such
a retrograde step."
prev parent reply other threads:[~2007-07-18 11:26 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2007-07-18 11:00 Question about scsi_host_alloc jidong xiao
2007-07-18 11:26 ` Matthew Wilcox [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20070718112628.GM14791@parisc-linux.org \
--to=matthew@wil.cx \
--cc=jidong.xiao@gmail.com \
--cc=linux-scsi@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.