RE: [PATCH 11/12] scsi: ufs: Simplify transfer request header initialization

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

 



>  /**
> @@ -2587,10 +2587,10 @@ static void ufshcd_prepare_req_desc_hdr(struct
> ufshcd_lrb *lrbp, u8 *upiu_flags,
>                                         enum dma_data_direction cmd_dir, int ehs_length)
>  {
>         struct utp_transfer_req_desc *req_desc = lrbp->utr_descriptor_ptr;
> +       struct request_desc_header *h = &req_desc->header;
>         u32 data_direction;
Maybe use the enum type as its strange to assign u32 to a nibble

> -       u32 dword_0;
> -       u32 dword_1 = 0;
> -       u32 dword_3 = 0;
> +
> +       *h = (typeof(*h)){ };
> 
>         if (cmd_dir == DMA_FROM_DEVICE) {
>                 data_direction = UTP_DEVICE_TO_HOST;
> @@ -2603,25 +2603,22 @@ static void ufshcd_prepare_req_desc_hdr(struct
> ufshcd_lrb *lrbp, u8 *upiu_flags,
>                 *upiu_flags = UPIU_CMD_FLAGS_NONE;
>         }
 
> -       dword_0 = data_direction | (lrbp->command_type <<
> UPIU_COMMAND_TYPE_OFFSET) |
> -               ehs_length << 8;
> +       h->command_type = lrbp->command_type;
AFAIK the CT is always 1 in UFSHCI3.0?

> +       h->data_direction = data_direction;
> +       h->ehs_length = ehs_length;
> +
>         if (lrbp->intr_cmd)
> -               dword_0 |= UTP_REQ_DESC_INT_CMD;
> +               h->interrupt = 1;
> 
..............................

> 
> +static void ufshcd_check_header_layout(void)
> +{
> +       BUILD_BUG_ON(((u8 *)&(struct request_desc_header){
> +                               .cci = 3})[0] != 3);
> +
> +       BUILD_BUG_ON(((u8 *)&(struct request_desc_header){
> +                               .ehs_length = 2})[1] != 2);
> +
> +       BUILD_BUG_ON(((u8 *)&(struct request_desc_header){
> +                               .enable_crypto = 1})[2]
> +                    != 0x80);
> +
> +       BUILD_BUG_ON((((u8 *)&(struct request_desc_header){
> +                                       .command_type = 5,
> +                                       .data_direction = 3,
> +                                       .interrupt = 1,
> +                               })[3]) != ((5 << 4) | (3 << 1) | 1));
Isn't this checker assumes endianness hence requires the applicable #ifdef?

Thanks,
Avri

> +
> +       BUILD_BUG_ON(((__le32 *)&(struct request_desc_header){
> +                               .dunl = cpu_to_le32(0xdeadbeef)})[1] !=
> +               cpu_to_le32(0xdeadbeef));
> +
> +       BUILD_BUG_ON(((u8 *)&(struct request_desc_header){
> +                               .ocs = 4})[8] != 4);
> +
> +       BUILD_BUG_ON(((u8 *)&(struct request_desc_header){
> +                               .cds = 5})[9] != 5);
> +
> +       BUILD_BUG_ON(((__le32 *)&(struct request_desc_header){
> +                               .dunu = cpu_to_le32(0xbadcafe)})[3] !=
> +               cpu_to_le32(0xbadcafe));
> +}
> +




[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