Re: PATCH: PMC-Sierra MaxRAID driver to support 6Gb/s SAS RAID controller

James Bottomley
2009-06-11T14:08:14Z

On Thu, 2009-06-11 at 13:47 +0200, Rolf Eike Beer wrote:
> Anil Ravindranath wrote:
> > +static int pmcraid_slave_alloc(struct scsi_device *scsi_dev)
> > +{
> > + struct pmcraid_resource_entry *temp, *res = NULL;
> > + struct pmcraid_instance *pinstance;
> > + u8 target, bus, lun;
> > + unsigned long lock_flags;
> > + int rc = -ENXIO;
> > +
> > + pinstance = (struct pmcraid_instance *)scsi_dev->host->hostdata;
>
> hostdata is void* AFAIR so there is no need to cast. It's C, there is no need
> to cast to or from void* anywhere if the other thing is a pointer.

Then please read the actual source *before* commenting. hostdata is an
unsigned long hostdata[0] in struct Scsi_Host because we elongate the
allocation area by howmuch extra space is requested.

The above statement is technically correct; however, since so many
people get this slightly wrong, we have an inline function shost_priv()
which takes the host and returns a void* pointer to the hostdata area,
so it's much better framed as

pinstance = shost_priv(scsi_dev->host);

James