Re: [PATCH v3 07/18] scsi: sd: detect support for command duration limits

Bart Van Assche
2023-01-24T19:40:47Z

On 1/24/23 11:02, Niklas Cassel wrote:
> +static const char *sd_cdl_perf_name(u8 val)
> +{
> + switch (val) {
> + case 0x00:
> + return "0";
> + case 0x01:
> + return "0.5";
> + case 0x02:
> + return "1.0";
> + case 0x03:
> + return "1.5";
> + case 0x04:
> + return "2.0";
> + case 0x05:
> + return "2.5";
> + case 0x06:
> + return "3";
> + case 0x07:
> + return "4";
> + case 0x08:
> + return "5";
> + case 0x09:
> + return "8";
> + case 0x0A:
> + return "10";
> + case 0x0B:
> + return "15";
> + case 0x0C:
> + return "20";
> + default:
> + return "?";
> + }
> +}
> +
> +static const char *sd_cdl_policy_name(u8 policy)
> +{
> + switch (policy) {
> + case 0x00:
> + return "complete-earliest";
> + case 0x01:
> + return "continue-next-limit";
> + case 0x02:
> + return "continue-no-limit";
> + case 0x0d:
> + return "complete-unavailable";
> + case 0x0e:
> + return "abort-recovery";
> + case 0x0f:
> + return "abort";
> + default:
> + return "?";
> + }
> +}

I think that the above two functions can be made shorter by using
look-up arrays and designated initialzers.

Thanks,

Bart.