Re: [PATCH for-next 3/6] RDMA/hns: Simplify the qp state convert code

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

 



On Mon, Apr 13, 2020 at 02:40:39PM +0800, Weihang Li wrote:
> From: Lang Cheng <chenglang@xxxxxxxxxx>
> 
> Use type map table to reduce the cyclomatic complexity.
> 
> Signed-off-by: Lang Cheng <chenglang@xxxxxxxxxx>
> Signed-off-by: Weihang Li <liweihang@xxxxxxxxxx>
>  drivers/infiniband/hw/hns/hns_roce_hw_v2.c | 27 ++++++++++++++-------------
>  1 file changed, 14 insertions(+), 13 deletions(-)
> 
> diff --git a/drivers/infiniband/hw/hns/hns_roce_hw_v2.c b/drivers/infiniband/hw/hns/hns_roce_hw_v2.c
> index 6816278..e938bd8 100644
> +++ b/drivers/infiniband/hw/hns/hns_roce_hw_v2.c
> @@ -4540,19 +4540,20 @@ static int hns_roce_v2_modify_qp(struct ib_qp *ibqp,
>  	return ret;
>  }
>  
> -static inline enum ib_qp_state to_ib_qp_st(enum hns_roce_v2_qp_state state)
> -{
> -	switch (state) {
> -	case HNS_ROCE_QP_ST_RST:	return IB_QPS_RESET;
> -	case HNS_ROCE_QP_ST_INIT:	return IB_QPS_INIT;
> -	case HNS_ROCE_QP_ST_RTR:	return IB_QPS_RTR;
> -	case HNS_ROCE_QP_ST_RTS:	return IB_QPS_RTS;
> -	case HNS_ROCE_QP_ST_SQ_DRAINING:
> -	case HNS_ROCE_QP_ST_SQD:	return IB_QPS_SQD;
> -	case HNS_ROCE_QP_ST_SQER:	return IB_QPS_SQE;
> -	case HNS_ROCE_QP_ST_ERR:	return IB_QPS_ERR;
> -	default:			return -1;
> -	}
> +static int to_ib_qp_st(enum hns_roce_v2_qp_state state)
> +{
> +	const enum ib_qp_state map[] = {

Should be static

Jason



[Index of Archives]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Photo]     [Yosemite News]     [Yosemite Photos]     [Linux Kernel]     [Linux SCSI]     [XFree86]

  Powered by Linux