RDMA/core: Correct some coding-style issues
v2 cover RDMA/core: Correct some coding-style issues
Do some cleanups according to the coding-style of kernel.
Changes since v1:
- Remove a BUG_ON in #3 and put the changes into a new patch.
- Drop the parts about spaces around xx_for_each_xx() from #4 because some
clang formatter prefer current style.
- Link: https://patchwork.kernel.org/project/linux-rdma/cover/[email protected]/
Weihang Li (1):
RDMA/core: Remove redundant BUG_ON
Wenpeng Liang (6):
RDMA/core: Print the function name by __func__ instead of an fixed
string
RDMA/core: Remove the redundant return statements RDMA/core: Add necessary spaces
RDMA/core: Remove redundant spaces
RDMA/core: Correct format of braces
RDMA/core: Correct format of block comments
drivers/infiniband/core/cache.c | 3 ++- drivers/infiniband/core/cm.c | 39 ++++++++++++++++---------------- drivers/infiniband/core/cm_msgs.h | 4 ++-- drivers/infiniband/core/cma.c | 21 ++++++++++-------- drivers/infiniband/core/iwcm.c | 1 - drivers/infiniband/core/iwpm_msg.c | 3 ++- drivers/infiniband/core/mad.c | 43 ++++++++++++++++-------------------- drivers/infiniband/core/mad_rmpp.c | 10 ++++----- drivers/infiniband/core/sysfs.c | 13 +++++------ drivers/infiniband/core/ucma.c | 8 +++---- drivers/infiniband/core/umem.c | 4 ++-- drivers/infiniband/core/user_mad.c | 30 +++++++++++-------------- drivers/infiniband/core/uverbs_cmd.c | 22 +++++++++--------- drivers/infiniband/core/verbs.c | 3 ++- 14 files changed, 98 insertions(+), 106 deletions(-)
Signature · 1 line
2.8.1
PATCH v2 1/7 RDMA/core: Print the function name by __func__ instead of an fixed string
From: Wenpeng Liang <[email protected]>
It's better to use __func__ than a fixed string to print a function's name.
--- drivers/infiniband/core/ucma.c | 4 ++-- drivers/infiniband/core/umem.c | 4 ++-- drivers/infiniband/core/user_mad.c | 26 +++++++++++--------------- 3 files changed, 15 insertions(+), 19 deletions(-)
drivers/infiniband/core/ucma.c +2 -2
@@ -1708,8 +1708,8 @@ static ssize_t ucma_write(struct file *filp, const char __user *buf,ssize_t ret;if (!ib_safe_file_access (filp)) { -pr_err_once ("ucma_write: process %d (%s) changed security contexts after opening file descriptor, this is not allowed.\n" , -task_tgid_vnr (current), current->comm); +pr_err_once ("%s: process %d (%s) changed security contexts after opening file descriptor, this is not allowed.\n" , + __func__,task_tgid_vnr (current), current->comm);return -EACCES ; }
drivers/infiniband/core/umem.c +2 -2
@@ -305,8 +305,8 @@ int ib_umem_copy_from(void *dst, struct ib_umem *umem, size_t offset,int ret;if (offset > umem->length || length > umem->length - offset) { -pr_err ("ib_umem_copy_from not in range. offset: %zd umem length: %zd end: %zd\n" , - offset, umem->length, end); +pr_err ("%s not in range. offset: %zd umem length: %zd end: %zd\n" , + __func__, offset, umem->length, end);return -EINVAL ; }
drivers/infiniband/core/user_mad.c +11 -15
@@ -688,8 +688,7 @@ static int ib_umad_reg_agent(struct ib_umad_file *file, void __user *arg,mutex_lock (&file->mutex);if (!file->port->ib_dev) { -dev_notice (&file->port->dev, -"ib_umad_reg_agent: invalid device\n" ); +dev_notice (&file->port->dev,"%s: invalid device\n" , __func__); ret = -EPIPE ; goto out; }
@@ -701,7 +700,7 @@ static int ib_umad_reg_agent(struct ib_umad_file *file, void __user *arg,if (ureq.qpn !=0 && ureq.qpn !=1 ) {dev_notice (&file->port->dev, -"ib_umad_reg_agent: invalid QPN %d specified\n" , +"%s: invalid QPN %d specified\n" , __func__, ureq.qpn); ret = -EINVAL ; goto out;
@@ -711,9 +710,9 @@ static int ib_umad_reg_agent(struct ib_umad_file *file, void __user *arg,if (!__get_agent (file, agent_id)) goto found; -dev_notice (&file->port->dev, -"ib_umad_reg_agent: Max Agents (%u) reached\n" , +dev_notice (&file->port->dev,"%s: Max Agents (%u) reached\n" , __func__,IB_UMAD_MAX_AGENTS ); + ret = -ENOMEM ; goto out;
@@ -790,8 +789,7 @@ static int ib_umad_reg_agent2(struct ib_umad_file *file, void __user *arg)mutex_lock (&file->mutex);if (!file->port->ib_dev) { -dev_notice (&file->port->dev, -"ib_umad_reg_agent2: invalid device\n" ); +dev_notice (&file->port->dev,"%s: invalid device\n" , __func__); ret = -EPIPE ; goto out; }
@@ -802,17 +800,16 @@ static int ib_umad_reg_agent2(struct ib_umad_file *file, void __user *arg) }if (ureq.qpn !=0 && ureq.qpn !=1 ) { -dev_notice (&file->port->dev, -"ib_umad_reg_agent2: invalid QPN %d specified\n" , - ureq.qpn); +dev_notice (&file->port->dev,"%s: invalid QPN %d specified\n" , + __func__, ureq.qpn); ret = -EINVAL ; goto out; }if (ureq.flags & ~IB_USER_MAD_REG_FLAGS_CAP ) {dev_notice (&file->port->dev, -"ib_umad_reg_agent2 failed: invalid registration flags specified 0x%x; supported 0x%x\n" , - ureq.flags,IB_USER_MAD_REG_FLAGS_CAP ); +"%s failed: invalid registration flags specified 0x%x; supported 0x%x\n" , + __func__, ureq.flags,IB_USER_MAD_REG_FLAGS_CAP ); ret = -EINVAL ; if (put_user((u32)IB_USER_MAD_REG_FLAGS_CAP,
@@ -827,8 +824,7 @@ static int ib_umad_reg_agent2(struct ib_umad_file *file, void __user *arg)if (!__get_agent (file, agent_id)) goto found; -dev_notice (&file->port->dev, -"ib_umad_reg_agent2: Max Agents (%u) reached\n" , +dev_notice (&file->port->dev,"%s: Max Agents (%u) reached\n" , __func__,IB_UMAD_MAX_AGENTS ); ret = -ENOMEM ; goto out;
@@ -840,7 +836,7 @@ static int ib_umad_reg_agent2(struct ib_umad_file *file, void __user *arg) req.mgmt_class_version = ureq.mgmt_class_version;if (ureq.oui &0xff000000 ) {dev_notice (&file->port->dev, -"ib_umad_reg_agent2 failed: oui invalid 0x%08x\n" , +"%s failed: oui invalid 0x%08x\n" , __func__, ureq.oui); ret = -EINVAL ; goto out;
Signature · 1 line
2.8.1
PATCH v2 2/7 RDMA/core: Remove the redundant return statements
In reply to Weihang LiFrom: Wenpeng Liang <[email protected]>
The return statements at the end of a void function is meaningless.
--- drivers/infiniband/core/mad.c | 2 -- drivers/infiniband/core/sysfs.c | 1 - 2 files changed, 3 deletions(-)
drivers/infiniband/core/mad.c +0 -2
@@ -1860,8 +1860,6 @@ static void ib_mad_complete_recv(struct ib_mad_agent_private *mad_agent_priv, mad_recv_wc);deref_mad_agent (mad_agent_priv); } - -return ; } static enum smi_action handle_ib_smi(const struct ib_mad_port_private *port_priv,
drivers/infiniband/core/sysfs.c +0 -1
@@ -1049,7 +1049,6 @@ static void setup_hw_stats(struct ib_device *device, struct ib_port *port,kfree (hsag); err_free_stats:kfree (stats); -return ; }static int add_port (struct ib_core_device *coredev,int port_num)
Signature · 1 line
2.8.1
PATCH v2 3/7 RDMA/core: Add necessary spaces
In reply to Weihang LiFrom: Wenpeng Liang <[email protected]>
Space is required before '(' of switch statements and around '='.
--- drivers/infiniband/core/cm.c | 2 +- drivers/infiniband/core/cm_msgs.h | 4 ++-- drivers/infiniband/core/ucma.c | 4 ++-- 3 files changed, 5 insertions(+), 5 deletions(-)
drivers/infiniband/core/cm.c +1 -1
@@ -3099,7 +3099,7 @@ int ib_send_cm_mra(struct ib_cm_id *cm_id, cm_id_priv = container_of(cm_id, struct cm_id_private, id);spin_lock_irqsave (&cm_id_priv->lock, flags); -switch (cm_id_priv->id.state) { +switch (cm_id_priv->id.state) {case IB_CM_REQ_RCVD : cm_state =IB_CM_MRA_REQ_SENT ; lap_state = cm_id->lap_state;
drivers/infiniband/core/cm_msgs.h +2 -2
@@ -22,7 +22,7 @@static inline enum ib_qp_type cm_req_get_qp_type (struct cm_req_msg *req_msg) {u8 transport_type =IBA_GET (CM_REQ_TRANSPORT_SERVICE_TYPE , req_msg); -switch (transport_type) { +switch (transport_type) {case 0 :return IB_QPT_RC ;case 1 :return IB_QPT_UC ;case 3 :
@@ -37,7 +37,7 @@ static inline enum ib_qp_type cm_req_get_qp_type(struct cm_req_msg *req_msg)static inline void cm_req_set_qp_type (struct cm_req_msg *req_msg,enum ib_qp_type qp_type) { -switch (qp_type) { +switch (qp_type) {case IB_QPT_UC :IBA_SET (CM_REQ_TRANSPORT_SERVICE_TYPE , req_msg,1 );break ;
drivers/infiniband/core/ucma.c +2 -2
@@ -231,7 +231,7 @@ static void ucma_copy_conn_event(struct rdma_ucm_conn_param *dst,memcpy (dst->private_data, src->private_data, src->private_data_len); dst->private_data_len = src->private_data_len; - dst->responder_resources =src->responder_resources; + dst->responder_resources = src->responder_resources; dst->initiator_depth = src->initiator_depth; dst->flow_control = src->flow_control; dst->retry_count = src->retry_count;
@@ -1034,7 +1034,7 @@ static void ucma_copy_conn_param(struct rdma_cm_id *id, { dst->private_data = src->private_data; dst->private_data_len = src->private_data_len; - dst->responder_resources =src->responder_resources; + dst->responder_resources = src->responder_resources; dst->initiator_depth = src->initiator_depth; dst->flow_control = src->flow_control; dst->retry_count = src->retry_count;
Signature · 1 line
2.8.1
PATCH v2 4/7 RDMA/core: Remove redundant spaces
In reply to Weihang LiFrom: Wenpeng Liang <[email protected]>
Space is not required after '(', before ')', before ',' and between '*' and symbol name of a definition.
--- drivers/infiniband/core/cm.c | 31 +++++++++++++++---------------- drivers/infiniband/core/mad.c | 18 +++++++++--------- drivers/infiniband/core/mad_rmpp.c | 10 +++++----- drivers/infiniband/core/sysfs.c | 6 +++--- drivers/infiniband/core/user_mad.c | 4 ++-- drivers/infiniband/core/uverbs_cmd.c | 22 +++++++++++----------- 6 files changed, 45 insertions(+), 46 deletions(-)
drivers/infiniband/core/cm.c +15 -16
@@ -420,8 +420,7 @@ static int cm_alloc_response_msg(struct cm_port *port,return 0 ; } -static void *cm_copy_private_data (const void *private_data, -u8 private_data_len) +static void *cm_copy_private_data (const void *private_data,u8 private_data_len) {void *data;
@@ -680,8 +679,8 @@ static struct cm_id_private *cm_insert_listen(struct cm_id_private *cm_id_priv,return cm_id_priv; } -static struct cm_id_private *cm_find_listen (struct ib_device *device, -__be64 service_id) +static struct cm_id_private *cm_find_listen (struct ib_device *device, +__be64 service_id) {struct rb_node *node = cm.listen_service_table.rb_node;struct cm_id_private *cm_id_priv;
@@ -708,8 +707,8 @@ static struct cm_id_private * cm_find_listen(struct ib_device *device,return NULL ; } -static struct cm_timewait_info *cm_insert_remote_id (struct cm_timewait_info - *timewait_info) +static struct cm_timewait_info *cm_insert_remote_id (struct cm_timewait_info + *timewait_info) {struct rb_node **link = &cm.remote_id_table.rb_node;struct rb_node *parent =NULL ;
@@ -767,8 +766,8 @@ static struct cm_id_private *cm_find_remote_id(__be64 remote_ca_guid,return res; } -static struct cm_timewait_info *cm_insert_remote_qpn (struct cm_timewait_info - *timewait_info) +static struct cm_timewait_info *cm_insert_remote_qpn (struct cm_timewait_info + *timewait_info) {struct rb_node **link = &cm.remote_qp_table.rb_node;struct rb_node *parent =NULL ;
@@ -797,8 +796,8 @@ static struct cm_timewait_info * cm_insert_remote_qpn(struct cm_timewait_inforeturn NULL ; } -static struct cm_id_private *cm_insert_remote_sidr (struct cm_id_private - *cm_id_priv) +static struct cm_id_private *cm_insert_remote_sidr (struct cm_id_private + *cm_id_priv) {struct rb_node **link = &cm.remote_sidr_table.rb_node;struct rb_node *parent =NULL ;
@@ -897,7 +896,7 @@ struct ib_cm_id *ib_create_cm_id(struct ib_device *device, }EXPORT_SYMBOL (ib_create_cm_id); -static struct cm_work *cm_dequeue_work (struct cm_id_private *cm_id_priv) +static struct cm_work *cm_dequeue_work (struct cm_id_private *cm_id_priv) {struct cm_work *work;
@@ -986,7 +985,7 @@ static void cm_remove_remote(struct cm_id_private *cm_id_priv) } } -static struct cm_timewait_info *cm_create_timewait_info (__be32 local_id) +static struct cm_timewait_info *cm_create_timewait_info (__be32 local_id) {struct cm_timewait_info *timewait_info;
@@ -1977,8 +1976,8 @@ unlock: spin_unlock_irq(&cm_id_priv->lock); free:cm_free_msg (msg); } -static struct cm_id_private *cm_match_req (struct cm_work *work, -struct cm_id_private *cm_id_priv) +static struct cm_id_private *cm_match_req (struct cm_work *work, +struct cm_id_private *cm_id_priv) {struct cm_id_private *listen_cm_id_priv, *cur_cm_id_priv;struct cm_timewait_info *timewait_info;
@@ -2994,7 +2993,7 @@ static void cm_format_rej_event(struct cm_work *work)IBA_GET_MEM_PTR (CM_REJ_PRIVATE_DATA , rej_msg); } -static struct cm_id_private *cm_acquire_rejected_id (struct cm_rej_msg *rej_msg) +static struct cm_id_private *cm_acquire_rejected_id (struct cm_rej_msg *rej_msg) {struct cm_id_private *cm_id_priv;__be32 remote_id;
@@ -3156,7 +3155,7 @@ error2: spin_unlock_irqrestore(&cm_id_priv->lock, flags); }EXPORT_SYMBOL (ib_send_cm_mra); -static struct cm_id_private *cm_acquire_mraed_id (struct cm_mra_msg *mra_msg) +static struct cm_id_private *cm_acquire_mraed_id (struct cm_mra_msg *mra_msg) {switch (IBA_GET (CM_MRA_MESSAGE_MRAED , mra_msg)) {case CM_MSG_RESPONSE_REQ :
drivers/infiniband/core/mad.c +9 -9
@@ -807,7 +807,7 @@ static int alloc_send_rmpp_list(struct ib_mad_send_wr_private *send_wr,/* Allocate data segments. */ for (left = send_buf->data_len + pad; left >0 ; left -= seg_size) { - seg =kmalloc (sizeof (*seg) + seg_size, gfp_mask); + seg =kmalloc (sizeof (*seg) + seg_size, gfp_mask);if (!seg) {free_send_rmpp_list (send_wr);return -ENOMEM ;
@@ -837,12 +837,12 @@ int ib_mad_kernel_rmpp_agent(const struct ib_mad_agent *agent) }EXPORT_SYMBOL (ib_mad_kernel_rmpp_agent); -struct ib_mad_send_buf *ib_create_send_mad (struct ib_mad_agent *mad_agent, -u32 remote_qpn,u16 pkey_index, -int rmpp_active, -int hdr_len,int data_len, -gfp_t gfp_mask, -u8 base_version) +struct ib_mad_send_buf *ib_create_send_mad (struct ib_mad_agent *mad_agent, +u32 remote_qpn,u16 pkey_index, +int rmpp_active, +int hdr_len,int data_len, +gfp_t gfp_mask, +u8 base_version) {struct ib_mad_agent_private *mad_agent_priv;struct ib_mad_send_wr_private *mad_send_wr;
@@ -1679,7 +1679,7 @@ static inline int rcv_has_same_class(const struct ib_mad_send_wr_private *wr,static inline int rcv_has_same_gid (const struct ib_mad_agent_private *mad_agent_priv,const struct ib_mad_send_wr_private *wr, -const struct ib_mad_recv_wc *rwc ) +const struct ib_mad_recv_wc *rwc) {struct rdma_ah_attr attr;u8 send_resp, rcv_resp;
@@ -2256,7 +2256,7 @@ void ib_mad_complete_send_wr(struct ib_mad_send_wr_private *mad_send_wr,adjust_timeout (mad_agent_priv);spin_unlock_irqrestore (&mad_agent_priv->lock, flags); -if (mad_send_wr->status !=IB_WC_SUCCESS ) +if (mad_send_wr->status !=IB_WC_SUCCESS ) mad_send_wc->status = mad_send_wr->status;if (ret ==IB_RMPP_RESULT_INTERNAL )ib_rmpp_send_handler (mad_send_wc);
drivers/infiniband/core/mad_rmpp.c +5 -5
@@ -382,8 +382,8 @@ static inline int get_seg_num(struct ib_mad_recv_buf *seg)return be32_to_cpu (rmpp_mad->rmpp_hdr.seg_num); } -static inline struct ib_mad_recv_buf *get_next_seg (struct list_head *rmpp_list, -struct ib_mad_recv_buf *seg) +static inline struct ib_mad_recv_buf *get_next_seg (struct list_head *rmpp_list, +struct ib_mad_recv_buf *seg) {if (seg->list.next == rmpp_list)return NULL ;
@@ -396,8 +396,8 @@ static inline int window_size(struct ib_mad_agent_private *agent)return max (agent->qp_info->recv_queue.max_active >>3 ,1 ); } -static struct ib_mad_recv_buf *find_seg_location (struct list_head *rmpp_list, -int seg_num) +static struct ib_mad_recv_buf *find_seg_location (struct list_head *rmpp_list, +int seg_num) {struct ib_mad_recv_buf *seg_buf;int cur_seg_num;
@@ -449,7 +449,7 @@ static inline int get_mad_len(struct mad_rmpp_recv *rmpp_recv)return hdr_size + rmpp_recv->seg_num * data_size - pad; } -static struct ib_mad_recv_wc *complete_rmpp (struct mad_rmpp_recv *rmpp_recv) +static struct ib_mad_recv_wc *complete_rmpp (struct mad_rmpp_recv *rmpp_recv) {struct ib_mad_recv_wc *rmpp_wc;
drivers/infiniband/core/sysfs.c +3 -3
@@ -297,7 +297,7 @@ static ssize_t rate_show(struct ib_port *p, struct port_attribute *unused,static const char *phys_state_to_str (enum ib_port_phys_state phys_state) { -static const char * phys_state_str[] = { +static const char *phys_state_str[] = {"<unknown>" ,"Sleep" ,"Polling" ,
@@ -470,14 +470,14 @@ static ssize_t show_port_pkey(struct ib_port *p, struct port_attribute *attr, struct port_table_attribute port_pma_attr_##_name = { \ .attr =__ATTR (_name,S_IRUGO , show_pma_counter,NULL ), \ .index = (_offset) | ((_width) <<16 ) | ((_counter) <<24 ), \ - .attr_id =IB_PMA_PORT_COUNTERS , \ + .attr_id =IB_PMA_PORT_COUNTERS , \ }#define PORT_PMA_ATTR_EXT (_name, _width, _offset) \ struct port_table_attribute port_pma_attr_ext_##_name = { \ .attr = __ATTR(_name, S_IRUGO, show_pma_counter, NULL), \ .index = (_offset) | ((_width) << 16), \ - .attr_id = IB_PMA_PORT_COUNTERS_EXT , \ + .attr_id = IB_PMA_PORT_COUNTERS_EXT, \ }/*
drivers/infiniband/core/user_mad.c +2 -2
@@ -165,8 +165,8 @@ static void ib_umad_dev_put(struct ib_umad_device *dev)static int hdr_size (struct ib_umad_file *file) { -return file->use_pkey_index ?sizeof (struct ib_user_mad_hdr ) : -sizeof (struct ib_user_mad_hdr_old ); +return file->use_pkey_index ?sizeof (struct ib_user_mad_hdr ) : +sizeof (struct ib_user_mad_hdr_old ); }/* caller must hold file->mutex */
drivers/infiniband/core/uverbs_cmd.c +11 -11
@@ -2002,12 +2002,12 @@ static int ib_uverbs_destroy_qp(struct uverbs_attr_bundle *attrs)static void *alloc_wr (size_t wr_size,__u32 num_sge) { -if (num_sge >= (U32_MAX -ALIGN (wr_size,sizeof (struct ib_sge ))) / -sizeof (struct ib_sge )) +if (num_sge >= (U32_MAX -ALIGN (wr_size,sizeof (struct ib_sge ))) / +sizeof (struct ib_sge ))return NULL ; -return kmalloc (ALIGN (wr_size,sizeof (struct ib_sge )) + - num_sge *sizeof (struct ib_sge ),GFP_KERNEL ); +return kmalloc (ALIGN (wr_size,sizeof (struct ib_sge )) + + num_sge *sizeof (struct ib_sge ),GFP_KERNEL ); }static int ib_uverbs_post_send (struct uverbs_attr_bundle *attrs)
@@ -2216,7 +2216,7 @@ ib_uverbs_unmarshall_recv(struct uverbs_req_iter *iter, u32 wr_count,const struct ib_sge __user *sgls;const void __user *wqes; -if (wqe_size <sizeof (struct ib_uverbs_recv_wr )) +if (wqe_size <sizeof (struct ib_uverbs_recv_wr ))return ERR_PTR (-EINVAL ); wqes =uverbs_request_next_ptr (iter, wqe_size * wr_count);
@@ -2249,14 +2249,14 @@ ib_uverbs_unmarshall_recv(struct uverbs_req_iter *iter, u32 wr_count, }if (user_wr->num_sge >= - (U32_MAX -ALIGN (sizeof *next,sizeof (struct ib_sge ))) / -sizeof (struct ib_sge )) { + (U32_MAX -ALIGN (sizeof (*next),sizeof (struct ib_sge ))) / +sizeof (struct ib_sge )) { ret = -EINVAL ; goto err; } - next =kmalloc (ALIGN (sizeof *next,sizeof (struct ib_sge )) + - user_wr->num_sge *sizeof (struct ib_sge ), + next =kmalloc (ALIGN (sizeof (*next),sizeof (struct ib_sge )) + + user_wr->num_sge *sizeof (struct ib_sge ),GFP_KERNEL );if (!next) { ret = -ENOMEM ;
@@ -2274,8 +2274,8 @@ ib_uverbs_unmarshall_recv(struct uverbs_req_iter *iter, u32 wr_count, next->num_sge = user_wr->num_sge;if (next->num_sge) { - next->sg_list = (void *) next + -ALIGN (sizeof *next,sizeof (struct ib_sge )); + next->sg_list = (void *)next + +ALIGN (sizeof (*next),sizeof (struct ib_sge ));if (copy_from_user (next->sg_list, sgls + sg_ind, next->num_sge *sizeof (struct ib_sge ))) {
Signature · 1 line
2.8.1
PATCH v2 5/7 RDMA/core: Correct format of braces
In reply to Weihang LiFrom: Wenpeng Liang <[email protected]>
Do following cleanups about braces:
- Add the necessary braces to maintain context alignment.
- Fix the open '{' that is not on the same line as "switch".
- Remove braces that are not necessary for single statement blocks.
- Fix "else" that doesn't follow close brace '}'.
--- drivers/infiniband/core/cache.c | 3 ++- drivers/infiniband/core/cm.c | 3 +-- drivers/infiniband/core/cma.c | 21 ++++++++++++--------- drivers/infiniband/core/mad.c | 20 ++++++++------------ drivers/infiniband/core/sysfs.c | 6 ++---- 5 files changed, 25 insertions(+), 28 deletions(-)
drivers/infiniband/core/cache.c +2 -1
@@ -1113,8 +1113,9 @@ int ib_find_cached_pkey(struct ib_device *device, u32 port_num, *index = i; ret =0 ;break ; - }else + }else { partial_ix = i; + } }if (ret && partial_ix >=0 ) {
drivers/infiniband/core/cm.c +1 -2
@@ -3917,8 +3917,7 @@ static int cm_establish(struct ib_cm_id *cm_id) cm_id_priv = container_of(cm_id, struct cm_id_private, id);spin_lock_irqsave (&cm_id_priv->lock, flags); -switch (cm_id->state) - { +switch (cm_id->state) {case IB_CM_REP_SENT :case IB_CM_MRA_REP_RCVD : cm_id->state =IB_CM_ESTABLISHED ;
drivers/infiniband/core/cma.c +12 -9
@@ -1126,8 +1126,9 @@ int rdma_init_qp_attr(struct rdma_cm_id *id, struct ib_qp_attr *qp_attr, qp_attr_mask); qp_attr->port_num = id_priv->id.port_num; *qp_attr_mask |=IB_QP_PORT ; - }else + }else { ret = -ENOSYS ; + }if ((*qp_attr_mask &IB_QP_TIMEOUT ) && id_priv->timeout_set) qp_attr->timeout = id_priv->timeout;
@@ -4116,10 +4117,11 @@ int rdma_connect_locked(struct rdma_cm_id *id, ret =cma_resolve_ib_udp (id_priv, conn_param); else ret =cma_connect_ib (id_priv, conn_param); - }else if (rdma_cap_iw_cm (id->device, id->port_num)) + }else if (rdma_cap_iw_cm (id->device, id->port_num)) { ret =cma_connect_iw (id_priv, conn_param); -else + }else { ret = -ENOSYS ; + }if (ret) goto err_state;return 0 ;
@@ -4226,9 +4228,9 @@ static int cma_accept_iw(struct rdma_id_private *id_priv, iw_param.ird = conn_param->responder_resources; iw_param.private_data = conn_param->private_data; iw_param.private_data_len = conn_param->private_data_len; -if (id_priv->id.qp) { +if (id_priv->id.qp) iw_param.qpn = id_priv->qp_num; - }else +else iw_param.qpn = conn_param->qp_num;return iw_cm_accept (id_priv->cm_id.iw, &iw_param);
@@ -4311,11 +4313,11 @@ int rdma_accept(struct rdma_cm_id *id, struct rdma_conn_param *conn_param)else ret =cma_rep_recv (id_priv); } - }else if (rdma_cap_iw_cm (id->device, id->port_num)) + }else if (rdma_cap_iw_cm (id->device, id->port_num)) { ret =cma_accept_iw (id_priv, conn_param); -else + }else { ret = -ENOSYS ; - + }if (ret) goto reject;
@@ -4401,8 +4403,9 @@ int rdma_reject(struct rdma_cm_id *id, const void *private_data, }else if (rdma_cap_iw_cm (id->device, id->port_num)) { ret =iw_cm_reject (id_priv->cm_id.iw, private_data, private_data_len); - }else + }else { ret = -ENOSYS ; + }return ret; }
drivers/infiniband/core/mad.c +8 -12
@@ -155,8 +155,7 @@ static inline u8 convert_mgmt_class(u8 mgmt_class)static int get_spl_qp_index (enum ib_qp_type qp_type) { -switch (qp_type) - { +switch (qp_type) {case IB_QPT_SMI :return 0 ;case IB_QPT_GSI :
@@ -707,8 +706,7 @@ static int handle_outgoing_dr_smp(struct ib_mad_agent_private *mad_agent_priv, (const struct ib_mad *)smp, (struct ib_mad *)mad_priv->mad, &mad_size, &out_mad_pkey_index); -switch (ret) - { +switch (ret) {case IB_MAD_RESULT_SUCCESS |IB_MAD_RESULT_REPLY :if (ib_response_mad ((const struct ib_mad_hdr *)mad_priv->mad) && mad_agent_priv->agent.recv_handler) {
@@ -1275,11 +1273,9 @@ static void remove_methods_mad_agent(struct ib_mad_mgmt_method_table *method,int i;/* Remove any methods for this mad agent */ -for (i =0 ; i <IB_MGMT_MAX_METHODS ; i++) { -if (method->agent[i] == agent) { +for (i =0 ; i <IB_MGMT_MAX_METHODS ; i++) +if (method->agent[i] == agent) method->agent[i] =NULL ; - } - } } static int add_nonoui_reg_req(struct ib_mad_reg_req *mad_reg_req,
@@ -1454,9 +1450,8 @@ static void remove_mad_reg_req(struct ib_mad_agent_private *agent_priv)* Was MAD registration request supplied * with original registration ? */ -if (!agent_priv->reg_req) { +if (!agent_priv->reg_req) goto out; - } port_priv = agent_priv->qp_info->port_priv; mgmt_class =convert_mgmt_class (agent_priv->reg_req->mgmt_class);
@@ -2200,9 +2195,10 @@ static void wait_for_response(struct ib_mad_send_wr_private *mad_send_wr) temp_mad_send_wr->timeout))break ; } - } -else + }else { list_item = &mad_agent_priv->wait_list; + } +list_add (&mad_send_wr->agent_list, list_item);/* Reschedule a work item if we have a shorter timeout */
drivers/infiniband/core/sysfs.c +2 -4
@@ -1074,9 +1074,8 @@ static int add_port(struct ib_core_device *coredev, int port_num) ret =kobject_init_and_add (&p->kobj, &port_type, coredev->ports_kobj,"%d" , port_num); -if (ret) { +if (ret) goto err_put; - } p->gid_attr_group =kzalloc (sizeof (*p->gid_attr_group),GFP_KERNEL );if (!p->gid_attr_group) {
@@ -1087,9 +1086,8 @@ static int add_port(struct ib_core_device *coredev, int port_num) p->gid_attr_group->port = p; ret =kobject_init_and_add (&p->gid_attr_group->kobj, &gid_attr_type, &p->kobj,"gid_attrs" ); -if (ret) { +if (ret) goto err_put_gid_attrs; - }if (device->ops.process_mad && is_full_dev) { p->pma_table =get_counter_table (device, port_num);
Signature · 1 line
2.8.1
PATCH v2 6/7 RDMA/core: Correct format of block comments
In reply to Weihang LiFrom: Wenpeng Liang <[email protected]>
Block comments should not use a trailing */ on a separate line and every line of a block comment should start with an '*'.
--- drivers/infiniband/core/cm.c | 3 ++- drivers/infiniband/core/iwpm_msg.c | 3 ++- drivers/infiniband/core/mad.c | 3 ++- drivers/infiniband/core/verbs.c | 3 ++- 4 files changed, 8 insertions(+), 4 deletions(-)
drivers/infiniband/core/cm.c +2 -1
@@ -255,7 +255,8 @@ struct cm_id_private {struct completion comp;refcount_t refcount;/* Number of clients sharing this ib_cm_id. Only valid for listeners. -* Protected by the cm.lock spinlock. */ +* Protected by the cm.lock spinlock. +*/ int listen_sharecount;struct rcu_head rcu;
drivers/infiniband/core/iwpm_msg.c +2 -1
@@ -528,7 +528,8 @@ int iwpm_add_mapping_cb(struct sk_buff *skb, struct netlink_callback *cb) }/* netlink attribute policy for the response to add and query mapping request -* and response with remote address info */ +* and response with remote address info +*/ static const struct nla_policy resp_query_policy[IWPM_NLA_RQUERY_MAPPING_MAX ] = { [IWPM_NLA_RQUERY_MAPPING_SEQ ] = { .type =NLA_U32 }, [IWPM_NLA_RQUERY_LOCAL_ADDR ] = {
drivers/infiniband/core/mad.c +2 -1
@@ -1829,7 +1829,8 @@ static void ib_mad_complete_recv(struct ib_mad_agent_private *mad_agent_priv,deref_mad_agent (mad_agent_priv); }else {/* not user rmpp, revert to normal behavior and -* drop the mad */ +* drop the mad +*/ ib_free_recv_mad (mad_recv_wc);deref_mad_agent (mad_agent_priv);return ;
drivers/infiniband/core/verbs.c +2 -1
@@ -342,7 +342,8 @@ int ib_dealloc_pd_user(struct ib_pd *pd, struct ib_udata *udata) }/* uverbs manipulates usecnt with proper locking, while the kabi -requires the caller to guarantee we can't race here. */ +* requires the caller to guarantee we can't race here. +*/ WARN_ON (atomic_read (&pd->usecnt)); ret = pd->device->ops.dealloc_pd (pd, udata);
Signature · 1 line
2.8.1
PATCH v2 7/7 RDMA/core: Remove redundant BUG_ON
In reply to Weihang LiIt's ok if the refcount of cm_id is zero when release the reference of it, there is no need to call BUG_ON.
--- drivers/infiniband/core/iwcm.c | 1 - 1 file changed, 1 deletion(-)
drivers/infiniband/core/iwcm.c +0 -1
@@ -211,7 +211,6 @@ static void free_cm_id(struct iwcm_id_private *cm_id_priv)*/ static int iwcm_deref_id (struct iwcm_id_private *cm_id_priv) { -BUG_ON (atomic_read (&cm_id_priv->refcount)==0 );if (atomic_dec_and_test (&cm_id_priv->refcount)) {BUG_ON (!list_empty (&cm_id_priv->work_list));free_cm_id (cm_id_priv);
Signature · 1 line
2.8.1
Jason Gunthorpe
maintainerRe: [PATCH v2 for-next 7/7] RDMA/core: Remove redundant BUG_ON
Quoted 2 lines · Weihang Li
It's ok if the refcount of
cm_idis zero when release the reference of it, there is no need to callBUG_ON.
Huh? No it isn't.
If you want to remove this BUG_ON then convert this to a refcount_t and rely on refcount debugging instead.
Jason
Re: [PATCH v2 for-next 7/7] RDMA/core: Remove redundant BUG_ON
Quoted 11 lines · Jason Gunthorpe
Quoted 2 lines · Weihang Li
It's ok if the refcount of
cm_idis zero when release the reference of it, there is no need to callBUG_ON.Huh? No it isn't.
If you want to remove this
BUG_ONthen convert this to arefcount_tand rely on refcount debugging instead.Jason
I see. I will try using refcount_t instead.
Thank you
Weihang
Quoted 11 lines · Weihang Li
Do some cleanups according to the coding-style of kernel.
Changes since v1:
- Remove aBUG_ONin #3 and put the changes into a new patch.
- Drop the parts about spaces aroundxx_for_each_xx()from #4 because some
clang formatter prefer current style.
- Link: https://patchwork.kernel.org/project/linux-rdma/cover/[email protected]/Weihang Li (1):
RDMA/core: Remove redundantBUG_ON
Quoted 9 lines
Wenpeng Liang (6):
RDMA/core: Print the function name by__func__instead of an fixed
string
RDMA/core: Remove the redundant return statements RDMA/core: Add necessary spaces
RDMA/core: Remove redundant spaces
RDMA/core: Correct format of braces
RDMA/core: Correct format of block comments
Thanks,
Quoted 7 lines · Weihang Li
Do some cleanups according to the coding-style of kernel.
Changes since v1:
- Remove aBUG_ONin #3 and put the changes into a new patch.
- Drop the parts about spaces aroundxx_for_each_xx()from #4 because some
clang formatter prefer current style.
- Link: https://patchwork.kernel.org/project/linux-rdma/cover/[email protected]/
Let's not make a habit of sending patches like this, but I will take this one
Quoted 6 lines
Wenpeng Liang (6):
RDMA/core: Print the function name by__func__instead of an fixed
string
RDMA/core: Remove the redundant return statements RDMA/core: Add necessary spaces
RDMA/core: Remove redundant spaces
I fixed the layout of most of the lines this patch touched as they were still not close enough to the canonical format.
Applied to for-next, thanks
Jason
Quoted 12 lines · Jason Gunthorpe
Quoted 7 lines · Weihang Li
Do some cleanups according to the coding-style of kernel.
Changes since v1:
- Remove aBUG_ONin #3 and put the changes into a new patch.
- Drop the parts about spaces aroundxx_for_each_xx()from #4 because some
clang formatter prefer current style.
- Link: https://patchwork.kernel.org/project/linux-rdma/cover/[email protected]/Let's not make a habit of sending patches like this, but I will take this one
Sure.
Quoted 10 lines
Quoted 6 lines
Wenpeng Liang (6):
RDMA/core: Print the function name by__func__instead of an fixed
string
RDMA/core: Remove the redundant return statements RDMA/core: Add necessary spaces
RDMA/core: Remove redundant spacesI fixed the layout of most of the lines this patch touched as they were still not close enough to the canonical format.
OK, thank you.
Weihang
Quoted 4 lines
Applied to for-next, thanks
Jason