On Wed, Jun 15, 2011 at 01:27:03PM +1000, David Gwynne wrote:
> ie, check if the VPD bit is set when an inquiry is issued and stop
> if it is. adds a free check for the cdblen there too.
> 
> i cant even ping my x60 atm, so i cant test. anyone else want to
> give it a spin?

I have several sdmmc devices. What would I look for? i.e. what problem
does this fix?

.... Ken

> 
> Index: sdmmc_scsi.c
> ===================================================================
> RCS file: /cvs/src/sys/dev/sdmmc/sdmmc_scsi.c,v
> retrieving revision 1.26
> diff -u -p -r1.26 sdmmc_scsi.c
> --- sdmmc_scsi.c      25 Oct 2010 10:36:49 -0000      1.26
> +++ sdmmc_scsi.c      15 Jun 2011 03:25:28 -0000
> @@ -80,6 +80,7 @@ void        *sdmmc_ccb_alloc(void *);
>  void sdmmc_ccb_free(void *, void *);
>  
>  void sdmmc_scsi_cmd(struct scsi_xfer *);
> +void sdmmc_inquiry(struct scsi_xfer *);
>  void sdmmc_start_xs(struct sdmmc_softc *, struct sdmmc_ccb *);
>  void sdmmc_complete_xs(void *);
>  void sdmmc_done_xs(struct sdmmc_ccb *);
> @@ -296,7 +297,6 @@ sdmmc_scsi_cmd(struct scsi_xfer *xs)
>       struct sdmmc_softc *sc = link->adapter_softc;
>       struct sdmmc_scsi_softc *scbus = sc->sc_scsibus;
>       struct sdmmc_scsi_target *tgt = &scbus->sc_tgt[link->target];
> -     struct scsi_inquiry_data inq;
>       struct scsi_read_cap_data rcd;
>       u_int32_t blockno;
>       u_int32_t blockcnt;
> @@ -327,17 +327,7 @@ sdmmc_scsi_cmd(struct scsi_xfer *xs)
>               break;
>  
>       case INQUIRY:
> -             bzero(&inq, sizeof inq);
> -             inq.device = T_DIRECT;
> -             inq.version = 2;
> -             inq.response_format = 2;
> -             inq.additional_length = 32;
> -             strlcpy(inq.vendor, "SD/MMC ", sizeof(inq.vendor));
> -             snprintf(inq.product, sizeof(inq.product),
> -                 "Drive #%02d", link->target);
> -             strlcpy(inq.revision, "   ", sizeof(inq.revision));
> -             bcopy(&inq, xs->data, MIN(xs->datalen, sizeof inq));
> -             scsi_done(xs);
> +             sdmmc_inquiry(xs);
>               return;
>  
>       case TEST_UNIT_READY:
> @@ -381,6 +371,39 @@ sdmmc_scsi_cmd(struct scsi_xfer *xs)
>       ccb->ccb_blockno = blockno;
>  
>       sdmmc_start_xs(sc, ccb);
> +}
> +
> +void
> +sdmmc_inquiry(struct scsi_xfer *xs)
> +{
> +     struct scsi_link *link = xs->sc_link;
> +     struct scsi_inquiry_data inq;
> +     struct scsi_inquiry *cdb = (struct scsi_inquiry *)xs->cmd;
> +
> +        if (xs->cmdlen != sizeof(*cdb)) {
> +             xs->error = XS_DRIVER_STUFFUP;
> +             goto done;
> +     }
> +
> +     if (ISSET(cdb->flags, SI_EVPD)) {
> +             xs->error = XS_DRIVER_STUFFUP;
> +             goto done;
> +     }
> +
> +     bzero(&inq, sizeof inq);
> +     inq.device = T_DIRECT;
> +     inq.version = 2;
> +     inq.response_format = 2;
> +     inq.additional_length = 32;
> +     strlcpy(inq.vendor, "SD/MMC ", sizeof(inq.vendor));
> +     snprintf(inq.product, sizeof(inq.product),
> +         "Drive #%02d", link->target);
> +     strlcpy(inq.revision, "   ", sizeof(inq.revision));
> +
> +     bcopy(&inq, xs->data, MIN(xs->datalen, sizeof(inq)));
> +
> +done:
> +     scsi_done(xs);
>  }
>  
>  void

Reply via email to