Re: [PATCH v8 3/4] scsi: ufs: L2P map management for HPB read
From: Bart Van Assche
Date: Sat Aug 08 2020 - 20:37:26 EST
On 2020-08-06 02:15, Daejun Park wrote:
> + req->end_io_data = (void *)map_req;
Please leave the (void *) cast out since explicit casts from a non-void
to a void pointer are not necessary in C.
> +static inline struct
> +ufshpb_rsp_field *ufshpb_get_hpb_rsp(struct ufshcd_lrb *lrbp)
> +{
> + return (struct ufshpb_rsp_field *)&lrbp->ucd_rsp_ptr->sr.sense_data_len;
> +}
Please introduce a union in struct utp_cmd_rsp instead of using casts
to reinterpret a part of a data structure.
> +/* routine : isr (ufs) */
The above comment looks very cryptic. Should it perhaps be expanded?
> +struct ufshpb_active_field {
> + __be16 active_rgn;
> + __be16 active_srgn;
> +} __packed;
Since "__packed" is not necessary for the above data structure, please
remove it. Note: a typical approach in the Linux kernel to verify that
the compiler has not inserted any padding bytes is to add a BUILD_BUG_ON()
statement in an initialization function that verifies the size of ABI data
structures. See also the output of the following command:
git grep -nH 'BUILD_BUG_ON.sizeof.*!='
> +struct ufshpb_rsp_field {
> + __be16 sense_data_len;
> + u8 desc_type;
> + u8 additional_len;
> + u8 hpb_type;
> + u8 reserved;
> + u8 active_rgn_cnt;
> + u8 inactive_rgn_cnt;
> + struct ufshpb_active_field hpb_active_field[2];
> + __be16 hpb_inactive_field[2];
> +} __packed;
I think the above __packed statement should also be left out.
Thanks,
Bart.