Re: Question about scsi_host_alloc

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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."
-
To unsubscribe from this list: send the line "unsubscribe linux-scsi" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [SCSI Target Devel]     [Linux SCSI Target Infrastructure]     [Kernel Newbies]     [IDE]     [Security]     [Git]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux ATA RAID]     [Linux IIO]     [Samba]     [Device Mapper]
  Powered by Linux