Re: [PATCH v1 1/3] scsi_cmnd: Introduce scsi_transfer_length helper

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

 



On Tue, Jun 10, 2014 at 10:02 PM, Martin K. Petersen
<martin.petersen@xxxxxxxxxx> wrote:
>>>>>> "Sagi" == Sagi Grimberg <sagig@xxxxxxxxxxxx> writes:
>
> +static inline unsigned scsi_prot_length(unsigned data_length,
> +                                       unsigned sector_size)
> +{
> +       switch (sector_size) {
> +       case 512:
> +               return (data_length >> 9) * 8;
> +       case 1024:
> +               return (data_length >> 10) * 8;
> +       case 2048:
> +               return (data_length >> 11) * 8;
> +       case 4096:
> +               return (data_length >> 12) * 8;
> +       default:
> +               return (data_length >> ilog2(sector_size)) * 8;
> +       }
> +}
> +
> +static inline unsigned scsi_transfer_length(struct scsi_cmnd *cmd)
> +{
> +       unsigned data_length;
> +
> +       if (cmd->sc_data_direction == DMA_FROM_DEVICE) {
> +               data_length = scsi_in(cmd)->length;
> +               if (scsi_get_prot_op(cmd) ==  SCSI_PROT_NORMAL ||
> +                   scsi_get_prot_op(cmd) ==  SCSI_PROT_READ_INSERT)
> +                       return data_length;
> +       } else {
> +               data_length = scsi_out(cmd)->length;
> +               if (scsi_get_prot_op(cmd) ==  SCSI_PROT_NORMAL ||
> +                   scsi_get_prot_op(cmd) ==  SCSI_PROT_WRITE_STRIP)
> +                       return data_length;
> +       }
> +
> +       /* Protection information exists on the wire */
> +       return data_length + scsi_prot_length(data_length,
> +                                             cmd->device->sector_size);
> +}
>
> Let's do this for 3.16:

Just to make sure, by 3.16 you also mean 3.15.y, right?
--
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