> + if (pname_count > max_count)
> + pname_count = max_count;
Use min/min_t here?
> + for (i = 0; i < pname_count; i++) {
> + wwpn = be64_to_cpu(li_desc->pname_list[i]);
> + rport = fc_find_rport_by_wwpn(shost, wwpn);
> + if (rport &&
> + (rport->roles & FC_PORT_ROLE_FCP_TARGET ||
> + rport->roles & FC_PORT_ROLE_NVME_TARGET)) {
> + if (rport == attach_rport)
> + continue;
> + fc_li_stats_update(event_type,
> + &rport->fpin_stats);
> }
> + pname_count = be32_to_cpu(pc_desc->pname_count);
> + desc_len = be32_to_cpu(pc_desc->desc_len);
> + if (desc_len < sizeof(*pc_desc) - FC_TLV_DESC_HDR_SZ)
> + max_count = 0;
> + else
> + max_count = (desc_len -
> + (sizeof(*pc_desc) - FC_TLV_DESC_HDR_SZ)) /
> + sizeof(pc_desc->pname_list[0]);
> + if (pname_count > max_count)
> + pname_count = max_count;
> +
> + for (i = 0; i < pname_count; i++) {
> + wwpn = be64_to_cpu(pc_desc->pname_list[i]);
> + rport = fc_find_rport_by_wwpn(shost, wwpn);
> + if (rport &&
> + (rport->roles & FC_PORT_ROLE_FCP_TARGET ||
> + rport->roles & FC_PORT_ROLE_NVME_TARGET)) {
> + if (rport == attach_rport)
> + continue;
> + fc_cn_stats_update(event_type,
> + &rport->fpin_stats);
> }
> }
Am I missing something or is this code entirely duplicate except
for the different stats updates helper? Maybe use the chance
to factor it into a common helper in a follow on patch?