imamnurby/smpl_train_seed8 huggingface dataset:
--- initial
+++ final
@@ -1,38 +1,38 @@
 static void reset_back_end_for_pipe(struct dc *dc, struct pipe_ctx *pipe_ctx, struct dc_state *context) {
   int i;
   if (pipe_ctx->stream_res.stream_enc == NULL) {
     pipe_ctx->stream = NULL;
     return;
   }
   if (!IS_FPGA_MAXIMUS_DC(dc->ctx->dce_environment)) {
     /* DPMS may already disable */
     if (!pipe_ctx->stream->dpms_off)
       core_link_disable_stream(pipe_ctx, FREE_ACQUIRED_RESOURCE);
     else if (pipe_ctx->stream_res.audio) {
       /*
        * if stream is already disabled outside of commit streams path,
        * audio disable was skipped. Need to do it here
        */
       pipe_ctx->stream_res.audio->funcs->az_disable(pipe_ctx->stream_res.audio);
       if (dc->caps.dynamic_audio == true) {
         /*we have to dynamic arbitrate the audio endpoints*/
         pipe_ctx->stream_res.audio = NULL;
         /*we free the resource, need reset is_audio_acquired*/
         update_audio_usage(&dc->current_state->res_ctx, dc->res_pool, pipe_ctx->stream_res.audio, false);
       }
     }
   }
   /* by upper caller loop, parent pipe: pipe0, will be reset last.
    * back end share by all pipes and will be disable only when disable
    * parent pipe.
    */
   if (pipe_ctx->top_pipe == NULL) {
     pipe_ctx->stream_res.tg->funcs->disable_crtc(pipe_ctx->stream_res.tg);
     pipe_ctx->stream_res.tg->funcs->enable_optc_clock(pipe_ctx->stream_res.tg, false);
   }
   for (i = 0; i < dc->res_pool->pipe_count; i++)
     if (&dc->current_state->res_ctx.pipe_ctx[i] == pipe_ctx) break;
   if (i == dc->res_pool->pipe_count) return;
   pipe_ctx->stream = NULL;
-  dm_logger_write(dc->ctx->logger, LOG_DEBUG, "Reset back end for pipe %d, tg:%d\n", pipe_ctx->pipe_idx, pipe_ctx->stream_res.tg->inst);
+  DC_LOG_DEBUG(dc->ctx->logger, "Reset back end for pipe %d, tg:%d\n", pipe_ctx->pipe_idx, pipe_ctx->stream_res.tg->inst);
 }<sep>@@
expression e1;
@@

- dm_logger_write(e1,LOG_DEBUG,
+ DC_LOG_DEBUG(e1,
	...)
--- initial
+++ final
@@ -1,10 +1,10 @@
 void dce_aud_az_enable(struct audio *audio) {
   struct dce_audio *aud = DCE_AUD(audio);
   uint32_t value = AZ_REG_READ(AZALIA_F0_CODEC_PIN_CONTROL_HOT_PLUG_CONTROL);
   set_reg_field_value(value, 1, AZALIA_F0_CODEC_PIN_CONTROL_HOT_PLUG_CONTROL, CLOCK_GATING_DISABLE);
   set_reg_field_value(value, 1, AZALIA_F0_CODEC_PIN_CONTROL_HOT_PLUG_CONTROL, AUDIO_ENABLED);
   AZ_REG_WRITE(AZALIA_F0_CODEC_PIN_CONTROL_HOT_PLUG_CONTROL, value);
   set_reg_field_value(value, 0, AZALIA_F0_CODEC_PIN_CONTROL_HOT_PLUG_CONTROL, CLOCK_GATING_DISABLE);
   AZ_REG_WRITE(AZALIA_F0_CODEC_PIN_CONTROL_HOT_PLUG_CONTROL, value);
-  dm_logger_write(CTX->logger, LOG_HW_AUDIO, "\n\t========= AUDIO:dce_aud_az_enable: index: %u  data: 0x%x\n", audio->inst, value);
+  DC_LOG_HW_AUDIO(CTX->logger, "\n\t========= AUDIO:dce_aud_az_enable: index: %u  data: 0x%x\n", audio->inst, value);
 }<sep>@@
expression e1;
@@

- dm_logger_write(e1,LOG_HW_AUDIO,
+ DC_LOG_HW_AUDIO(e1,
	...)
--- initial
+++ final
@@ -1,16 +1,16 @@
 static void wait_for_fbc_state_changed(struct dce110_compressor *cp110, bool enabled) {
   uint8_t counter = 0;
   uint32_t addr = mmFBC_STATUS;
   uint32_t value;
   while (counter < 10) {
     value = dm_read_reg(cp110->base.ctx, addr);
     if (get_reg_field_value(value, FBC_STATUS, FBC_ENABLE_STATUS) == enabled) break;
     msleep(10);
     counter++;
   }
   if (counter == 10) {
-    dm_logger_write(cp110->base.ctx->logger, LOG_WARNING, "%s: wait counter exceeded, changes to HW not applied", __func__);
+    DC_LOG_WARNING(cp110->base.ctx->logger, "%s: wait counter exceeded, changes to HW not applied", __func__);
   } else {
-    dm_logger_write(cp110->base.ctx->logger, LOG_SYNC, "FBC status changed to %d", enabled);
+    DC_LOG_SYNC(cp110->base.ctx->logger, "FBC status changed to %d", enabled);
   }
 }<sep>@@
expression e1;
@@

- dm_logger_write(e1,LOG_SYNC,
+ DC_LOG_SYNC(e1,
	...)

@@
expression e1;
@@

- dm_logger_write(e1,LOG_WARNING,
+ DC_LOG_WARNING(e1,
	...)
--- initial
+++ final
@@ -1,20 +1,20 @@
 static enum bp_result transmitter_control_v1_6(struct bios_parser *bp, struct bp_transmitter_control *cntl) {
   enum bp_result result = BP_RESULT_FAILURE;
   const struct command_table_helper *cmd = bp->cmd_helper;
   struct dig_transmitter_control_ps_allocation_v1_6 ps = {{0}};
   ps.param.phyid = cmd->phy_id_to_atom(cntl->transmitter);
   ps.param.action = (uint8_t)cntl->action;
   if (cntl->action == TRANSMITTER_CONTROL_SET_VOLTAGE_AND_PREEMPASIS)
     ps.param.mode_laneset.dplaneset = (uint8_t)cntl->lane_settings;
   else
     ps.param.mode_laneset.digmode = cmd->signal_type_to_atom_dig_mode(cntl->signal);
   ps.param.lanenum = (uint8_t)cntl->lanes_number;
   ps.param.hpdsel = cmd->hpd_sel_to_atom(cntl->hpd_sel);
   ps.param.digfe_sel = cmd->dig_encoder_sel_to_atom(cntl->engine_id);
   ps.param.connobj_id = (uint8_t)cntl->connector_obj_id.id;
   ps.param.symclk_10khz = cntl->pixel_clock / 10;
-  if (cntl->action == TRANSMITTER_CONTROL_ENABLE || cntl->action == TRANSMITTER_CONTROL_ACTIAVATE || cntl->action == TRANSMITTER_CONTROL_DEACTIVATE) { dm_logger_write(bp->base.ctx->logger, LOG_BIOS, "%s:ps.param.symclk_10khz = %d\n", __func__, ps.param.symclk_10khz); }
+  if (cntl->action == TRANSMITTER_CONTROL_ENABLE || cntl->action == TRANSMITTER_CONTROL_ACTIAVATE || cntl->action == TRANSMITTER_CONTROL_DEACTIVATE) { DC_LOG_BIOS(bp->base.ctx->logger, "%s:ps.param.symclk_10khz = %d\n", __func__, ps.param.symclk_10khz); }
   /*color_depth not used any more, driver has deep color factor in the Phyclk*/
   if (EXEC_BIOS_CMD_TABLE(dig1transmittercontrol, ps)) result = BP_RESULT_OK;
   return result;
 }<sep>@@
expression e1;
@@

- dm_logger_write(e1,LOG_BIOS,
+ DC_LOG_BIOS(e1,
	...)
--- initial
+++ final
@@ -1,9 +1,9 @@
 static int core_scsi3_lunacl_depend_item(struct se_dev_entry *se_deve) {
   struct se_lun_acl *lun_acl;
   /*
    * For nacl->dynamic_node_acl=1
    */
-  lun_acl = rcu_dereference_check(se_deve->se_lun_acl, atomic_read(&se_deve->pr_kref.refcount) != 0);
+  lun_acl = rcu_dereference_check(se_deve->se_lun_acl, kref_read(&se_deve->pr_kref) != 0);
   if (!lun_acl) return 0;
   return target_depend_item(&lun_acl->se_lun_group.cg_item);
 }<sep>@@
expression e; 
@@
-               atomic_read(&e.refcount)
+               kref_read(&e)
--- initial
+++ final
@@ -1,40 +1,40 @@
 static void chan_close_cb(struct l2cap_chan *chan) {
   struct lowpan_btle_dev *entry;
   struct lowpan_btle_dev *dev = NULL;
   struct lowpan_peer *peer;
   int err = -ENOENT;
   bool last = false, remove = true;
   BT_DBG("chan %p conn %p", chan, chan->conn);
   if (chan->conn && chan->conn->hcon) {
     if (!is_bt_6lowpan(chan->conn->hcon)) return;
     /* If conn is set, then the netdev is also there and we should
      * not remove it.
      */
     remove = false;
   }
   spin_lock(&devices_lock);
   list_for_each_entry_rcu(entry, &bt_6lowpan_devices, list) {
     dev = lowpan_btle_dev(entry->netdev);
     peer = __peer_lookup_chan(dev, chan);
     if (peer) {
       last = peer_del(dev, peer);
       err = 0;
       BT_DBG("dev %p removing %speer %p", dev, last ? "last " : "1 ", peer);
-      BT_DBG("chan %p orig refcnt %d", chan, atomic_read(&chan->kref.refcount));
+      BT_DBG("chan %p orig refcnt %d", chan, kref_read(&chan->kref));
       l2cap_chan_put(chan);
       break;
     }
   }
   if (!err && last && dev && !atomic_read(&dev->peer_count)) {
     spin_unlock(&devices_lock);
     cancel_delayed_work_sync(&dev->notify_peers);
     ifdown(dev->netdev);
     if (remove) {
       INIT_WORK(&entry->delete_netdev, delete_netdev);
       schedule_work(&entry->delete_netdev);
     }
   } else {
     spin_unlock(&devices_lock);
   }
   return;
 }<sep>@@
expression e; 
@@
-               atomic_read(&e.refcount)
+               kref_read(&e)
--- initial
+++ final
@@ -1,11 +1,11 @@
 static void pnv_php_detach_device_nodes(struct device_node *parent) {
   struct device_node *dn;
   int refcount;
   for_each_child_of_node(parent, dn) {
     pnv_php_detach_device_nodes(dn);
     of_node_put(dn);
-    refcount = atomic_read(&dn->kobj.kref.refcount);
+    refcount = kref_read(&dn->kobj.kref);
     if (refcount != 1) pr_warn("Invalid refcount %d on <%s>\n", refcount, of_node_full_name(dn));
     of_detach_node(dn);
   }
 }<sep>@@
expression e; 
@@
-               atomic_read(&e.refcount)
+               kref_read(&e)
--- initial
+++ final
@@ -1,33 +1,33 @@
 static ssize_t mei_dbgfs_read_meclients(struct file *fp, char __user *ubuf, size_t cnt, loff_t *ppos) {
   struct mei_device *dev = fp->private_data;
   struct mei_me_client *me_cl;
   size_t bufsz = 1;
   char *buf;
   int i = 0;
   int pos = 0;
   int ret;
 #define HDR "  |id|fix|         UUID                       |con|msg len|sb|refc|\n"
   down_read(&dev->me_clients_rwsem);
   list_for_each_entry(me_cl, &dev->me_clients, list) bufsz++;
   bufsz *= sizeof(HDR) + 1;
   buf = kzalloc(bufsz, GFP_KERNEL);
   if (!buf) {
     up_read(&dev->me_clients_rwsem);
     return -ENOMEM;
   }
   pos += scnprintf(buf + pos, bufsz - pos, HDR);
 #undef HDR
   /*  if the driver is not enabled the list won't be consistent */
   if (dev->dev_state != MEI_DEV_ENABLED) goto out;
   list_for_each_entry(me_cl, &dev->me_clients, list) {
     if (mei_me_cl_get(me_cl)) {
-      pos += scnprintf(buf + pos, bufsz - pos, "%2d|%2d|%3d|%pUl|%3d|%7d|%2d|%4d|\n", i++, me_cl->client_id, me_cl->props.fixed_address, &me_cl->props.protocol_name, me_cl->props.max_number_of_connections, me_cl->props.max_msg_length, me_cl->props.single_recv_buf, atomic_read(&me_cl->refcnt.refcount));
+      pos += scnprintf(buf + pos, bufsz - pos, "%2d|%2d|%3d|%pUl|%3d|%7d|%2d|%4d|\n", i++, me_cl->client_id, me_cl->props.fixed_address, &me_cl->props.protocol_name, me_cl->props.max_number_of_connections, me_cl->props.max_msg_length, me_cl->props.single_recv_buf, kref_read(&me_cl->refcnt));
       mei_me_cl_put(me_cl);
     }
   }
 out:
   up_read(&dev->me_clients_rwsem);
   ret = simple_read_from_buffer(ubuf, cnt, ppos, buf, pos);
   kfree(buf);
   return ret;
 }<sep>@@
expression e; 
@@
-               atomic_read(&e.refcount)
+               kref_read(&e)
--- initial
+++ final
@@ -1,23 +1,23 @@
 int genwqe_device_remove(struct genwqe_dev *cd) {
   int rc;
   struct pci_dev *pci_dev = cd->pci_dev;
   if (!genwqe_device_initialized(cd)) return 1;
   genwqe_inform_and_stop_processes(cd);
   /*
    * We currently do wait until all filedescriptors are
    * closed. This leads to a problem when we abort the
    * application which will decrease this reference from
    * 1/unused to 0/illegal and not from 2/used 1/empty.
    */
-  rc = atomic_read(&cd->cdev_genwqe.kobj.kref.refcount);
+  rc = kref_read(&cd->cdev_genwqe.kobj.kref);
   if (rc != 1) {
     dev_err(&pci_dev->dev, "[%s] err: cdev_genwqe...refcount=%d\n", __func__, rc);
     panic("Fatal err: cannot free resources with pending references!");
   }
   genqwe_exit_debugfs(cd);
   device_destroy(cd->class_genwqe, cd->devnum_genwqe);
   cdev_del(&cd->cdev_genwqe);
   unregister_chrdev_region(cd->devnum_genwqe, GENWQE_MAX_MINOR);
   cd->dev = NULL;
   return 0;
 }<sep>@@
expression e; 
@@
-               atomic_read(&e.refcount)
+               kref_read(&e)
--- initial
+++ final
@@ -1,26 +1,26 @@
 static int dump_mle(struct dlm_master_list_entry *mle, char *buf, int len) {
   int out = 0;
   char *mle_type;
   if (mle->type == DLM_MLE_BLOCK)
     mle_type = "BLK";
   else if (mle->type == DLM_MLE_MASTER)
     mle_type = "MAS";
   else
     mle_type = "MIG";
   out += stringify_lockname(mle->mname, mle->mnamelen, buf + out, len - out);
-  out += snprintf(buf + out, len - out, "\t%3s\tmas=%3u\tnew=%3u\tevt=%1d\tuse=%1d\tref=%3d\n", mle_type, mle->master, mle->new_master, !list_empty(&mle->hb_events), !!mle->inuse, atomic_read(&mle->mle_refs.refcount));
+  out += snprintf(buf + out, len - out, "\t%3s\tmas=%3u\tnew=%3u\tevt=%1d\tuse=%1d\tref=%3d\n", mle_type, mle->master, mle->new_master, !list_empty(&mle->hb_events), !!mle->inuse, kref_read(&mle->mle_refs));
   out += snprintf(buf + out, len - out, "Maybe=");
   out += stringify_nodemap(mle->maybe_map, O2NM_MAX_NODES, buf + out, len - out);
   out += snprintf(buf + out, len - out, "\n");
   out += snprintf(buf + out, len - out, "Vote=");
   out += stringify_nodemap(mle->vote_map, O2NM_MAX_NODES, buf + out, len - out);
   out += snprintf(buf + out, len - out, "\n");
   out += snprintf(buf + out, len - out, "Response=");
   out += stringify_nodemap(mle->response_map, O2NM_MAX_NODES, buf + out, len - out);
   out += snprintf(buf + out, len - out, "\n");
   out += snprintf(buf + out, len - out, "Node=");
   out += stringify_nodemap(mle->node_map, O2NM_MAX_NODES, buf + out, len - out);
   out += snprintf(buf + out, len - out, "\n");
   out += snprintf(buf + out, len - out, "\n");
   return out;
 }<sep>@@
expression e; 
@@
-               atomic_read(&e.refcount)
+               kref_read(&e)
--- initial
+++ final
@@ -1,4 +1,4 @@
 int amp_ctrl_put(struct amp_ctrl *ctrl) {
-  BT_DBG("ctrl %p orig refcnt %d", ctrl, atomic_read(&ctrl->kref.refcount));
+  BT_DBG("ctrl %p orig refcnt %d", ctrl, kref_read(&ctrl->kref));
   return kref_put(&ctrl->kref, &amp_ctrl_destroy);
 }<sep>@@
expression e; 
@@
-               atomic_read(&e.refcount)
+               kref_read(&e)
--- initial
+++ final
@@ -1,45 +1,45 @@
 static void __svc_rdma_free(struct work_struct *work) {
   struct svcxprt_rdma *rdma = container_of(work, struct svcxprt_rdma, sc_work);
   struct svc_xprt *xprt = &rdma->sc_xprt;
   dprintk("svcrdma: %s(%p)\n", __func__, rdma);
   if (rdma->sc_qp && !IS_ERR(rdma->sc_qp)) ib_drain_qp(rdma->sc_qp);
   /* We should only be called from kref_put */
-  if (atomic_read(&xprt->xpt_ref.refcount) != 0) pr_err("svcrdma: sc_xprt still in use? (%d)\n", atomic_read(&xprt->xpt_ref.refcount));
+  if (kref_read(&xprt->xpt_ref) != 0) pr_err("svcrdma: sc_xprt still in use? (%d)\n", kref_read(&xprt->xpt_ref));
   /*
    * Destroy queued, but not processed read completions. Note
    * that this cleanup has to be done before destroying the
    * cm_id because the device ptr is needed to unmap the dma in
    * svc_rdma_put_context.
    */
   while (!list_empty(&rdma->sc_read_complete_q)) {
     struct svc_rdma_op_ctxt *ctxt;
     ctxt = list_entry(rdma->sc_read_complete_q.next, struct svc_rdma_op_ctxt, dto_q);
     list_del_init(&ctxt->dto_q);
     svc_rdma_put_context(ctxt, 1);
   }
   /* Destroy queued, but not processed recv completions */
   while (!list_empty(&rdma->sc_rq_dto_q)) {
     struct svc_rdma_op_ctxt *ctxt;
     ctxt = list_entry(rdma->sc_rq_dto_q.next, struct svc_rdma_op_ctxt, dto_q);
     list_del_init(&ctxt->dto_q);
     svc_rdma_put_context(ctxt, 1);
   }
   /* Warn if we leaked a resource or under-referenced */
   if (rdma->sc_ctxt_used != 0) pr_err("svcrdma: ctxt still in use? (%d)\n", rdma->sc_ctxt_used);
   /* Final put of backchannel client transport */
   if (xprt->xpt_bc_xprt) {
     xprt_put(xprt->xpt_bc_xprt);
     xprt->xpt_bc_xprt = NULL;
   }
   rdma_dealloc_frmr_q(rdma);
   svc_rdma_destroy_ctxts(rdma);
   svc_rdma_destroy_maps(rdma);
   /* Destroy the QP if present (not a listener) */
   if (rdma->sc_qp && !IS_ERR(rdma->sc_qp)) ib_destroy_qp(rdma->sc_qp);
   if (rdma->sc_sq_cq && !IS_ERR(rdma->sc_sq_cq)) ib_free_cq(rdma->sc_sq_cq);
   if (rdma->sc_rq_cq && !IS_ERR(rdma->sc_rq_cq)) ib_free_cq(rdma->sc_rq_cq);
   if (rdma->sc_pd && !IS_ERR(rdma->sc_pd)) ib_dealloc_pd(rdma->sc_pd);
   /* Destroy the CM ID */
   rdma_destroy_id(rdma->sc_cm_id);
   kfree(rdma);
 }<sep>@@
expression e; 
@@
-               atomic_read(&e.refcount)
+               kref_read(&e)
--- initial
+++ final
@@ -1,33 +1,33 @@
 void lpfc_mbx_cmpl_reg_login(struct lpfc_hba *phba, LPFC_MBOXQ_t *pmb) {
   struct lpfc_vport *vport = pmb->vport;
   struct lpfc_dmabuf *mp = (struct lpfc_dmabuf *)(pmb->context1);
   struct lpfc_nodelist *ndlp = (struct lpfc_nodelist *)pmb->context2;
   struct Scsi_Host *shost = lpfc_shost_from_vport(vport);
   pmb->context1 = NULL;
   pmb->context2 = NULL;
-  lpfc_printf_vlog(vport, KERN_INFO, LOG_SLI, "0002 rpi:%x DID:%x flg:%x %d map:%x %p\n", ndlp->nlp_rpi, ndlp->nlp_DID, ndlp->nlp_flag, atomic_read(&ndlp->kref.refcount), ndlp->nlp_usg_map, ndlp);
+  lpfc_printf_vlog(vport, KERN_INFO, LOG_SLI, "0002 rpi:%x DID:%x flg:%x %d map:%x %p\n", ndlp->nlp_rpi, ndlp->nlp_DID, ndlp->nlp_flag, kref_read(&ndlp->kref), ndlp->nlp_usg_map, ndlp);
   if (ndlp->nlp_flag & NLP_REG_LOGIN_SEND) ndlp->nlp_flag &= ~NLP_REG_LOGIN_SEND;
   if (ndlp->nlp_flag & NLP_IGNR_REG_CMPL || ndlp->nlp_state != NLP_STE_REG_LOGIN_ISSUE) {
     /* We rcvd a rscn after issuing this
      * mbox reg login, we may have cycled
      * back through the state and be
      * back at reg login state so this
      * mbox needs to be ignored becase
      * there is another reg login in
      * process.
      */
     spin_lock_irq(shost->host_lock);
     ndlp->nlp_flag &= ~NLP_IGNR_REG_CMPL;
     spin_unlock_irq(shost->host_lock);
   }
   /* Call state machine */
   lpfc_disc_state_machine(vport, ndlp, pmb, NLP_EVT_CMPL_REG_LOGIN);
   lpfc_mbuf_free(phba, mp->virt, mp->phys);
   kfree(mp);
   mempool_free(pmb, phba->mbox_mem_pool);
   /* decrement the node reference count held for this callback
    * function.
    */
   lpfc_nlp_put(ndlp);
   return;
 }<sep>@@
expression e; 
@@
-               atomic_read(&e.refcount)
+               kref_read(&e)
--- initial
+++ final
@@ -1,49 +1,49 @@
 int lpfc_unreg_rpi(struct lpfc_vport *vport, struct lpfc_nodelist *ndlp) {
   struct lpfc_hba *phba = vport->phba;
   LPFC_MBOXQ_t *mbox;
   int rc, acc_plogi = 1;
   uint16_t rpi;
   if (ndlp->nlp_flag & NLP_RPI_REGISTERED || ndlp->nlp_flag & NLP_REG_LOGIN_SEND) {
     if (ndlp->nlp_flag & NLP_REG_LOGIN_SEND)
       lpfc_printf_vlog(vport, KERN_INFO, LOG_SLI,
                        "3366 RPI x%x needs to be "
                        "unregistered nlp_flag x%x "
                        "did x%x\n",
                        ndlp->nlp_rpi, ndlp->nlp_flag, ndlp->nlp_DID);
     mbox = mempool_alloc(phba->mbox_mem_pool, GFP_KERNEL);
     if (mbox) {
       /* SLI4 ports require the physical rpi value. */
       rpi = ndlp->nlp_rpi;
       if (phba->sli_rev == LPFC_SLI_REV4) rpi = phba->sli4_hba.rpi_ids[ndlp->nlp_rpi];
       lpfc_unreg_login(phba, vport->vpi, rpi, mbox);
       mbox->vport = vport;
       if (ndlp->nlp_flag & NLP_ISSUE_LOGO) {
         mbox->context1 = ndlp;
         mbox->mbox_cmpl = lpfc_nlp_logo_unreg;
       } else {
-        if (phba->sli_rev == LPFC_SLI_REV4 && (!(vport->load_flag & FC_UNLOADING)) && (bf_get(lpfc_sli_intf_if_type, &phba->sli4_hba.sli_intf) == LPFC_SLI_INTF_IF_TYPE_2) && (atomic_read(&ndlp->kref.refcount) > 0)) {
+        if (phba->sli_rev == LPFC_SLI_REV4 && (!(vport->load_flag & FC_UNLOADING)) && (bf_get(lpfc_sli_intf_if_type, &phba->sli4_hba.sli_intf) == LPFC_SLI_INTF_IF_TYPE_2) && (kref_read(&ndlp->kref) > 0)) {
           mbox->context1 = lpfc_nlp_get(ndlp);
           mbox->mbox_cmpl = lpfc_sli4_unreg_rpi_cmpl_clr;
           /*
            * accept PLOGIs after unreg_rpi_cmpl
            */
           acc_plogi = 0;
         } else
           mbox->mbox_cmpl = lpfc_sli_def_mbox_cmpl;
       }
       rc = lpfc_sli_issue_mbox(phba, mbox, MBX_NOWAIT);
       if (rc == MBX_NOT_FINISHED) {
         mempool_free(mbox, phba->mbox_mem_pool);
         acc_plogi = 1;
       }
     }
     lpfc_no_rpi(phba, ndlp);
     if (phba->sli_rev != LPFC_SLI_REV4) ndlp->nlp_rpi = 0;
     ndlp->nlp_flag &= ~NLP_RPI_REGISTERED;
     ndlp->nlp_flag &= ~NLP_NPR_ADISC;
     if (acc_plogi) ndlp->nlp_flag &= ~NLP_LOGO_ACC;
     return 1;
   }
   ndlp->nlp_flag &= ~NLP_LOGO_ACC;
   return 0;
 }<sep>@@
expression e; 
@@
-               atomic_read(&e.refcount)
+               kref_read(&e)
--- initial
+++ final
@@ -1,23 +1,23 @@
 void lpfc_mbx_cmpl_dflt_rpi(struct lpfc_hba *phba, LPFC_MBOXQ_t *pmb) {
   struct lpfc_dmabuf *mp = (struct lpfc_dmabuf *)(pmb->context1);
   struct lpfc_nodelist *ndlp = (struct lpfc_nodelist *)pmb->context2;
   pmb->context1 = NULL;
   pmb->context2 = NULL;
   lpfc_mbuf_free(phba, mp->virt, mp->phys);
   kfree(mp);
   mempool_free(pmb, phba->mbox_mem_pool);
   if (ndlp) {
-    lpfc_printf_vlog(ndlp->vport, KERN_INFO, LOG_NODE, "0006 rpi%x DID:%x flg:%x %d map:%x %p\n", ndlp->nlp_rpi, ndlp->nlp_DID, ndlp->nlp_flag, atomic_read(&ndlp->kref.refcount), ndlp->nlp_usg_map, ndlp);
+    lpfc_printf_vlog(ndlp->vport, KERN_INFO, LOG_NODE, "0006 rpi%x DID:%x flg:%x %d map:%x %p\n", ndlp->nlp_rpi, ndlp->nlp_DID, ndlp->nlp_flag, kref_read(&ndlp->kref), ndlp->nlp_usg_map, ndlp);
     if (NLP_CHK_NODE_ACT(ndlp)) {
       lpfc_nlp_put(ndlp);
       /* This is the end of the default RPI cleanup logic for
        * this ndlp. If no other discovery threads are using
        * this ndlp, free all resources associated with it.
        */
       lpfc_nlp_not_used(ndlp);
     } else {
       lpfc_drop_node(ndlp->vport, ndlp);
     }
   }
   return;
 }<sep>@@
expression e; 
@@
-               atomic_read(&e.refcount)
+               kref_read(&e)
--- initial
+++ final
@@ -1,5 +1,5 @@
 static ssize_t usnic_ib_show_max_vf(struct device *device, struct device_attribute *attr, char *buf) {
   struct usnic_ib_dev *us_ibdev;
   us_ibdev = container_of(device, struct usnic_ib_dev, ib_dev.dev);
-  return scnprintf(buf, PAGE_SIZE, "%u\n", atomic_read(&us_ibdev->vf_cnt.refcount));
+  return scnprintf(buf, PAGE_SIZE, "%u\n", kref_read(&us_ibdev->vf_cnt));
 }<sep>@@
expression e; 
@@
-               atomic_read(&e.refcount)
+               kref_read(&e)
--- initial
+++ final
@@ -1,4 +1,4 @@
 void ceph_osdc_get_request(struct ceph_osd_request *req) {
-  dout("%s %p (was %d)\n", __func__, req, atomic_read(&req->r_kref.refcount));
+  dout("%s %p (was %d)\n", __func__, req, kref_read(&req->r_kref));
   kref_get(&req->r_kref);
 }<sep>@@
expression e; 
@@
-               atomic_read(&e.refcount)
+               kref_read(&e)
--- initial
+++ final
@@ -1,16 +1,16 @@
 void omap_gem_describe(struct drm_gem_object *obj, struct seq_file *m) {
   struct omap_gem_object *omap_obj = to_omap_bo(obj);
   uint64_t off;
   off = drm_vma_node_start(&obj->vma_node);
-  seq_printf(m, "%08x: %2d (%2d) %08llx %pad (%2d) %p %4d", omap_obj->flags, obj->name, obj->refcount.refcount.counter, off, &omap_obj->paddr, omap_obj->paddr_cnt, omap_obj->vaddr, omap_obj->roll);
+  seq_printf(m, "%08x: %2d (%2d) %08llx %pad (%2d) %p %4d", omap_obj->flags, obj->name, kref_read(&obj->refcount), off, &omap_obj->paddr, omap_obj->paddr_cnt, omap_obj->vaddr, omap_obj->roll);
   if (omap_obj->flags & OMAP_BO_TILED) {
     seq_printf(m, " %dx%d", omap_obj->width, omap_obj->height);
     if (omap_obj->block) {
       struct tcm_area *area = &omap_obj->block->area;
       seq_printf(m, " (%dx%d, %dx%d)", area->p0.x, area->p0.y, area->p1.x, area->p1.y);
     }
   } else {
     seq_printf(m, " %d", obj->size);
   }
   seq_printf(m, "\n");
 }<sep>@@
expression e;
@@
-		e.refcount.counter
+		kref_read(&e)
--- initial
+++ final
@@ -1,4 +1,4 @@
 void l2cap_chan_put(struct l2cap_chan *c) {
-  BT_DBG("chan %p orig refcnt %d", c, atomic_read(&c->kref.refcount));
+  BT_DBG("chan %p orig refcnt %d", c, kref_read(&c->kref));
   kref_put(&c->kref, l2cap_chan_destroy);
 }<sep>@@
expression e; 
@@
-               atomic_read(&e.refcount)
+               kref_read(&e)