imamnurby/smpl_train_seed8 huggingface dataset:
--- initial
+++ final
@@ -1,42 +1,37 @@
 static int ixj_build_filter_cadence(IXJ *j, IXJ_FILTER_CADENCE __user *cp) {
   IXJ_FILTER_CADENCE *lcp;
-  lcp = kmalloc(sizeof(IXJ_FILTER_CADENCE), GFP_KERNEL);
-  if (lcp == NULL) {
-    if (ixjdebug & 0x0001) { printk(KERN_INFO "Could not allocate memory for cadence\n"); }
-    return -ENOMEM;
-  }
-  if (copy_from_user(lcp, cp, sizeof(IXJ_FILTER_CADENCE))) {
+  lcp = memdup_user(cp, sizeof(IXJ_FILTER_CADENCE));
+  if (IS_ERR(lcp)) {
     if (ixjdebug & 0x0001) { printk(KERN_INFO "Could not copy cadence to kernel\n"); }
-    kfree(lcp);
-    return -EFAULT;
+    return PTR_ERR(lcp);
   }
   if (lcp->filter > 5) {
     if (ixjdebug & 0x0001) { printk(KERN_INFO "Cadence out of range\n"); }
     kfree(lcp);
     return -1;
   }
   j->cadence_f[lcp->filter].state = 0;
   j->cadence_f[lcp->filter].enable = lcp->enable;
   j->filter_en[lcp->filter] = j->cadence_f[lcp->filter].en_filter = lcp->en_filter;
   j->cadence_f[lcp->filter].on1 = lcp->on1;
   j->cadence_f[lcp->filter].on1min = 0;
   j->cadence_f[lcp->filter].on1max = 0;
   j->cadence_f[lcp->filter].off1 = lcp->off1;
   j->cadence_f[lcp->filter].off1min = 0;
   j->cadence_f[lcp->filter].off1max = 0;
   j->cadence_f[lcp->filter].on2 = lcp->on2;
   j->cadence_f[lcp->filter].on2min = 0;
   j->cadence_f[lcp->filter].on2max = 0;
   j->cadence_f[lcp->filter].off2 = lcp->off2;
   j->cadence_f[lcp->filter].off2min = 0;
   j->cadence_f[lcp->filter].off2max = 0;
   j->cadence_f[lcp->filter].on3 = lcp->on3;
   j->cadence_f[lcp->filter].on3min = 0;
   j->cadence_f[lcp->filter].on3max = 0;
   j->cadence_f[lcp->filter].off3 = lcp->off3;
   j->cadence_f[lcp->filter].off3min = 0;
   j->cadence_f[lcp->filter].off3max = 0;
   if (ixjdebug & 0x0002) { printk(KERN_INFO "Cadence %d loaded\n", lcp->filter); }
   kfree(lcp);
   return 0;
 }<sep>@@
expression e1,e2,e3,r;
statement S;
constant GFP_KERNEL;
@@

-	e1 = kmalloc(e3, GFP_KERNEL);
-	if (e1 == NULL)
-		S

-	if (copy_from_user(e1, e2, e3))
+	e1 = memdup_user(e2, e3);
+	if (IS_ERR(e1))
        {
		...
-		kfree(e1);
		...
-		return r;
+		return PTR_ERR(e1);
	}
--- initial
+++ final
@@ -1,43 +1,39 @@
 int qeth_snmp_command(struct qeth_card *card, char __user *udata) {
   struct qeth_cmd_buffer *iob;
   struct qeth_ipa_cmd *cmd;
   struct qeth_snmp_ureq *ureq;
   int req_len;
   struct qeth_arp_query_info qinfo = {
       0,
   };
   int rc = 0;
   QETH_CARD_TEXT(card, 3, "snmpcmd");
   if (card->info.guestlan) return -EOPNOTSUPP;
   if ((!qeth_adp_supported(card, IPA_SETADP_SET_SNMP_CONTROL)) && (!card->options.layer2)) { return -EOPNOTSUPP; }
   /* skip 4 bytes (data_len struct member) to get req_len */
   if (copy_from_user(&req_len, udata + sizeof(int), sizeof(int))) return -EFAULT;
-  ureq = kmalloc(req_len + sizeof(struct qeth_snmp_ureq_hdr), GFP_KERNEL);
-  if (!ureq) {
+  ureq = memdup_user(udata, req_len + sizeof(struct qeth_snmp_ureq_hdr));
+  if (IS_ERR(ureq)) {
     QETH_CARD_TEXT(card, 2, "snmpnome");
-    return -ENOMEM;
-  }
-  if (copy_from_user(ureq, udata, req_len + sizeof(struct qeth_snmp_ureq_hdr))) {
-    kfree(ureq);
-    return -EFAULT;
+    return PTR_ERR(ureq);
   }
   qinfo.udata_len = ureq->hdr.data_len;
   qinfo.udata = kzalloc(qinfo.udata_len, GFP_KERNEL);
   if (!qinfo.udata) {
     kfree(ureq);
     return -ENOMEM;
   }
   qinfo.udata_offset = sizeof(struct qeth_snmp_ureq_hdr);
   iob = qeth_get_adapter_cmd(card, IPA_SETADP_SET_SNMP_CONTROL, QETH_SNMP_SETADP_CMDLENGTH + req_len);
   cmd = (struct qeth_ipa_cmd *)(iob->data + IPA_PDU_HEADER_SIZE);
   memcpy(&cmd->data.setadapterparms.data.snmp, &ureq->cmd, req_len);
   rc = qeth_send_ipa_snmp_cmd(card, iob, QETH_SETADP_BASE_LEN + req_len, qeth_snmp_command_cb, (void *)&qinfo);
   if (rc)
     QETH_DBF_MESSAGE(2, "SNMP command failed on %s: (0x%x)\n", QETH_CARD_IFNAME(card), rc);
   else {
     if (copy_to_user(udata, qinfo.udata, qinfo.udata_len)) rc = -EFAULT;
   }
   kfree(ureq);
   kfree(qinfo.udata);
   return rc;
 }<sep>@@
expression e1,e2,e3,r;
constant GFP_KERNEL;
@@

+	e1 = memdup_user(e2, e3);
+	if (IS_ERR(e1)) {
-	e1 = kmalloc(e3, GFP_KERNEL);
-	if (e1 == NULL) {
		...
-		return ...;
-	}

-	if (copy_from_user(e1, e2, e3))
-       {
-		kfree(e1);

-		return r;
+		return PTR_ERR(e1);
	}
--- initial
+++ final
@@ -1,15 +1,11 @@
 char *strndup_user(const char __user *s, long n) {
   char *p;
   long length;
   length = strnlen_user(s, n);
   if (!length) return ERR_PTR(-EFAULT);
   if (length > n) return ERR_PTR(-EINVAL);
-  p = kmalloc(length, GFP_KERNEL);
-  if (!p) return ERR_PTR(-ENOMEM);
-  if (copy_from_user(p, s, length)) {
-    kfree(p);
-    return ERR_PTR(-EFAULT);
-  }
+  p = memdup_user(s, length);
+  if (IS_ERR(p)) return PTR_ERR(p);
   p[length - 1] = '\0';
   return p;
 }<sep>@@
expression e1,e2,e3,r;
statement S;
constant GFP_KERNEL;
@@

-	e1 = kmalloc(e3, GFP_KERNEL);
-	if (e1 == NULL)
-		S

-	if (copy_from_user(e1, e2, e3))
+	e1 = memdup_user(e2, e3);
+	if (IS_ERR(e1))
-       {
-		kfree(e1);
-		return r;
+		return PTR_ERR(e1);
-	}
--- initial
+++ final
@@ -1,72 +1,68 @@
 static int sg_start_req(Sg_request *srp, unsigned char *cmd) {
   int res;
   struct request *rq;
   Sg_fd *sfp = srp->parentfp;
   sg_io_hdr_t *hp = &srp->header;
   int dxfer_len = (int)hp->dxfer_len;
   int dxfer_dir = hp->dxfer_direction;
   unsigned int iov_count = hp->iovec_count;
   Sg_scatter_hold *req_schp = &srp->data;
   Sg_scatter_hold *rsv_schp = &sfp->reserve;
   struct request_queue *q = sfp->parentdp->device->request_queue;
   struct rq_map_data *md, map_data;
   int rw = hp->dxfer_direction == SG_DXFER_TO_DEV ? WRITE : READ;
   SCSI_LOG_TIMEOUT(4, printk(KERN_INFO "sg_start_req: dxfer_len=%d\n", dxfer_len));
   rq = blk_get_request(q, rw, GFP_ATOMIC);
   if (!rq) return -ENOMEM;
   memcpy(rq->cmd, cmd, hp->cmd_len);
   rq->cmd_len = hp->cmd_len;
   rq->cmd_type = REQ_TYPE_BLOCK_PC;
   srp->rq = rq;
   rq->end_io_data = srp;
   rq->sense = srp->sense_b;
   rq->retries = SG_DEFAULT_RETRIES;
   if ((dxfer_len <= 0) || (dxfer_dir == SG_DXFER_NONE)) return 0;
   if (sg_allow_dio && hp->flags & SG_FLAG_DIRECT_IO && dxfer_dir != SG_DXFER_UNKNOWN && !iov_count && !sfp->parentdp->device->host->unchecked_isa_dma && blk_rq_aligned(q, hp->dxferp, dxfer_len))
     md = NULL;
   else
     md = &map_data;
   if (md) {
     if (!sg_res_in_use(sfp) && dxfer_len <= rsv_schp->bufflen)
       sg_link_reserve(sfp, srp, dxfer_len);
     else {
       res = sg_build_indirect(req_schp, sfp, dxfer_len);
       if (res) return res;
     }
     md->pages = req_schp->pages;
     md->page_order = req_schp->page_order;
     md->nr_entries = req_schp->k_use_sg;
     md->offset = 0;
     md->null_mapped = hp->dxferp ? 0 : 1;
     if (dxfer_dir == SG_DXFER_TO_FROM_DEV)
       md->from_user = 1;
     else
       md->from_user = 0;
   }
   if (iov_count) {
     int len, size = sizeof(struct sg_iovec) * iov_count;
     struct iovec *iov;
-    iov = kmalloc(size, GFP_ATOMIC);
-    if (!iov) return -ENOMEM;
-    if (copy_from_user(iov, hp->dxferp, size)) {
-      kfree(iov);
-      return -EFAULT;
-    }
+    iov = memdup_user(hp->dxferp, size);
+    if (IS_ERR(iov)) return PTR_ERR(iov);
     len = iov_length(iov, iov_count);
     if (hp->dxfer_len < len) {
       iov_count = iov_shorten(iov, iov_count, hp->dxfer_len);
       len = hp->dxfer_len;
     }
     res = blk_rq_map_user_iov(q, rq, md, (struct sg_iovec *)iov, iov_count, len, GFP_ATOMIC);
     kfree(iov);
   } else
     res = blk_rq_map_user(q, rq, md, hp->dxferp, hp->dxfer_len, GFP_ATOMIC);
   if (!res) {
     srp->bio = rq->bio;
     if (!md) {
       req_schp->dio_in_use = 1;
       hp->info |= SG_INFO_DIRECT_IO;
     }
   }
   return res;
 }<sep>@@
expression e1,e2,e3,r;
statement S;
constant GFP_KERNEL;
@@

-	e1 = kmalloc(e3, GFP_KERNEL);
-	if (e1 == NULL)
-		S

-	if (copy_from_user(e1, e2, e3))
+	e1 = memdup_user(e2, e3);
+	if (IS_ERR(e1))
-       {
-		kfree(e1);
-		return r;
+		return PTR_ERR(e1);
-	}
--- initial
+++ final
@@ -1,59 +1,55 @@
 static noinline int i2cdev_ioctl_rdrw(struct i2c_client *client, unsigned long arg) {
   struct i2c_rdwr_ioctl_data rdwr_arg;
   struct i2c_msg *rdwr_pa;
   u8 __user **data_ptrs;
   int i, res;
   if (copy_from_user(&rdwr_arg, (struct i2c_rdwr_ioctl_data __user *)arg, sizeof(rdwr_arg))) return -EFAULT;
   /* Put an arbitrary limit on the number of messages that can
    * be sent at once */
   if (rdwr_arg.nmsgs > I2C_RDRW_IOCTL_MAX_MSGS) return -EINVAL;
-  rdwr_pa = kmalloc(rdwr_arg.nmsgs * sizeof(struct i2c_msg), GFP_KERNEL);
-  if (!rdwr_pa) return -ENOMEM;
-  if (copy_from_user(rdwr_pa, rdwr_arg.msgs, rdwr_arg.nmsgs * sizeof(struct i2c_msg))) {
-    kfree(rdwr_pa);
-    return -EFAULT;
-  }
+  rdwr_pa = memdup_user(rdwr_arg.msgs, rdwr_arg.nmsgs * sizeof(struct i2c_msg));
+  if (IS_ERR(rdwr_pa)) return PTR_ERR(rdwr_pa);
   data_ptrs = kmalloc(rdwr_arg.nmsgs * sizeof(u8 __user *), GFP_KERNEL);
   if (data_ptrs == NULL) {
     kfree(rdwr_pa);
     return -ENOMEM;
   }
   res = 0;
   for (i = 0; i < rdwr_arg.nmsgs; i++) {
     /* Limit the size of the message to a sane amount;
      * and don't let length change either. */
     if ((rdwr_pa[i].len > 8192) || (rdwr_pa[i].flags & I2C_M_RECV_LEN)) {
       res = -EINVAL;
       break;
     }
     data_ptrs[i] = (u8 __user *)rdwr_pa[i].buf;
     rdwr_pa[i].buf = kmalloc(rdwr_pa[i].len, GFP_KERNEL);
     if (rdwr_pa[i].buf == NULL) {
       res = -ENOMEM;
       break;
     }
     if (copy_from_user(rdwr_pa[i].buf, data_ptrs[i], rdwr_pa[i].len)) {
       ++i; /* Needs to be kfreed too */
       res = -EFAULT;
       break;
     }
   }
   if (res < 0) {
     int j;
     for (j = 0; j < i; ++j)
       kfree(rdwr_pa[j].buf);
     kfree(data_ptrs);
     kfree(rdwr_pa);
     return res;
   }
   res = i2c_transfer(client->adapter, rdwr_pa, rdwr_arg.nmsgs);
   while (i-- > 0) {
     if (res >= 0 && (rdwr_pa[i].flags & I2C_M_RD)) {
       if (copy_to_user(data_ptrs[i], rdwr_pa[i].buf, rdwr_pa[i].len)) res = -EFAULT;
     }
     kfree(rdwr_pa[i].buf);
   }
   kfree(data_ptrs);
   kfree(rdwr_pa);
   return res;
 }<sep>@@
expression e1,e2,e3,r;
statement S;
constant GFP_KERNEL;
@@

-	e1 = kmalloc(e3, GFP_KERNEL);
-	if (e1 == NULL)
-		S

-	if (copy_from_user(e1, e2, e3))
+	e1 = memdup_user(e2, e3);
+	if (IS_ERR(e1))
-       {
-		kfree(e1);
-		return r;
+		return PTR_ERR(e1);
-	}
--- initial
+++ final
@@ -1,16 +1,12 @@
 static ssize_t i2cdev_write(struct file *file, const char __user *buf, size_t count, loff_t *offset) {
   int ret;
   char *tmp;
   struct i2c_client *client = file->private_data;
   if (count > 8192) count = 8192;
-  tmp = kmalloc(count, GFP_KERNEL);
-  if (tmp == NULL) return -ENOMEM;
-  if (copy_from_user(tmp, buf, count)) {
-    kfree(tmp);
-    return -EFAULT;
-  }
+  tmp = memdup_user(buf, count);
+  if (IS_ERR(tmp)) return PTR_ERR(tmp);
   pr_debug("i2c-dev: i2c-%d writing %zu bytes.\n", iminor(file->f_path.dentry->d_inode), count);
   ret = i2c_master_send(client, tmp, count);
   kfree(tmp);
   return ret;
 }<sep>@@
expression e1,e2,e3,r;
statement S;
constant GFP_KERNEL;
@@

-	e1 = kmalloc(e3, GFP_KERNEL);
-	if (e1 == NULL)
-		S

-	if (copy_from_user(e1, e2, e3))
+	e1 = memdup_user(e2, e3);
+	if (IS_ERR(e1))
-       {
-		kfree(e1);
-		return r;
+		return PTR_ERR(e1);
-	}
--- initial
+++ final
@@ -1,18 +1,14 @@
 static noinline int btrfs_ioctl_ino_lookup(struct file *file, void __user *argp) {
   struct btrfs_ioctl_ino_lookup_args *args;
   struct inode *inode;
   int ret;
   if (!capable(CAP_SYS_ADMIN)) return -EPERM;
-  args = kmalloc(sizeof(*args), GFP_KERNEL);
-  if (!args) return -ENOMEM;
-  if (copy_from_user(args, argp, sizeof(*args))) {
-    kfree(args);
-    return -EFAULT;
-  }
+  args = memdup_user(argp, sizeof(*args));
+  if (IS_ERR(args)) return PTR_ERR(args);
   inode = fdentry(file)->d_inode;
   if (args->treeid == 0) args->treeid = BTRFS_I(inode)->root->root_key.objectid;
   ret = btrfs_search_path_in_tree(BTRFS_I(inode)->root->fs_info, args->treeid, args->objectid, args->name);
   if (ret == 0 && copy_to_user(argp, args, sizeof(*args))) ret = -EFAULT;
   kfree(args);
   return ret;
 }<sep>@@
expression e1,e2,e3,r;
statement S;
constant GFP_KERNEL;
@@

-	e1 = kmalloc(e3, GFP_KERNEL);
-	if (e1 == NULL)
-		S

-	if (copy_from_user(e1, e2, e3))
+	e1 = memdup_user(e2, e3);
+	if (IS_ERR(e1))
-       {
-		kfree(e1);
-		return r;
+		return PTR_ERR(e1);
-	}
--- initial
+++ final
@@ -1,17 +1,13 @@
 static noinline int btrfs_ioctl_tree_search(struct file *file, void __user *argp) {
   struct btrfs_ioctl_search_args *args;
   struct inode *inode;
   int ret;
   if (!capable(CAP_SYS_ADMIN)) return -EPERM;
-  args = kmalloc(sizeof(*args), GFP_KERNEL);
-  if (!args) return -ENOMEM;
-  if (copy_from_user(args, argp, sizeof(*args))) {
-    kfree(args);
-    return -EFAULT;
-  }
+  args = memdup_user(argp, sizeof(*args));
+  if (IS_ERR(args)) return PTR_ERR(args);
   inode = fdentry(file)->d_inode;
   ret = search_ioctl(inode, args);
   if (ret == 0 && copy_to_user(argp, args, sizeof(*args))) ret = -EFAULT;
   kfree(args);
   return ret;
 }<sep>@@
expression e1,e2,e3,r;
statement S;
constant GFP_KERNEL;
@@

-	e1 = kmalloc(e3, GFP_KERNEL);
-	if (e1 == NULL)
-		S

-	if (copy_from_user(e1, e2, e3))
+	e1 = memdup_user(e2, e3);
+	if (IS_ERR(e1))
-       {
-		kfree(e1);
-		return r;
+		return PTR_ERR(e1);
-	}
--- initial
+++ final
@@ -1,53 +1,54 @@
 static int gsta_probe(struct platform_device *dev) {
   int i, err;
   struct pci_dev *pdev;
   struct sta2x11_gpio_pdata *gpio_pdata;
   struct gsta_gpio *chip;
   struct resource *res;
   pdev = *(struct pci_dev **)(dev->dev.platform_data);
   gpio_pdata = dev_get_platdata(&pdev->dev);
   if (gpio_pdata == NULL) dev_err(&dev->dev, "no gpio config\n");
   pr_debug("gpio config: %p\n", gpio_pdata);
   res = platform_get_resource(dev, IORESOURCE_MEM, 0);
   chip = devm_kzalloc(&dev->dev, sizeof(*chip), GFP_KERNEL);
   if (!chip) return -ENOMEM;
   chip->dev = &dev->dev;
-  chip->reg_base = devm_request_and_ioremap(&dev->dev, res);
+  chip->reg_base = devm_ioremap_resource(&dev->dev, res);
+  if (IS_ERR(chip->reg_base)) return PTR_ERR(chip->reg_base);
   for (i = 0; i < GSTA_NR_BLOCKS; i++) {
     chip->regs[i] = chip->reg_base + i * 4096;
     /* disable all irqs */
     writel(0, &chip->regs[i]->rimsc);
     writel(0, &chip->regs[i]->fimsc);
     writel(~0, &chip->regs[i]->ic);
   }
   spin_lock_init(&chip->lock);
   gsta_gpio_setup(chip);
   if (gpio_pdata)
     for (i = 0; i < GSTA_NR_GPIO; i++)
       gsta_set_config(chip, i, gpio_pdata->pinconfig[i]);
   /* 384 was used in previous code: be compatible for other drivers */
   err = irq_alloc_descs(-1, 384, GSTA_NR_GPIO, NUMA_NO_NODE);
   if (err < 0) {
     dev_warn(&dev->dev, "sta2x11 gpio: Can't get irq base (%i)\n", -err);
     return err;
   }
   chip->irq_base = err;
   gsta_alloc_irq_chip(chip);
   err = request_irq(pdev->irq, gsta_gpio_handler, IRQF_SHARED, KBUILD_MODNAME, chip);
   if (err < 0) {
     dev_err(&dev->dev, "sta2x11 gpio: Can't request irq (%i)\n", -err);
     goto err_free_descs;
   }
   err = gpiochip_add(&chip->gpio);
   if (err < 0) {
     dev_err(&dev->dev, "sta2x11 gpio: Can't register (%i)\n", -err);
     goto err_free_irq;
   }
   platform_set_drvdata(dev, chip);
   return 0;
 err_free_irq:
   free_irq(pdev->irq, chip);
 err_free_descs:
   irq_free_descs(chip->irq_base, GSTA_NR_GPIO);
   return err;
 }<sep>@@
expression e,d,res; 
statement S1,S2;
@@

-	e = devm_request_and_ioremap(d, res);
+	e = devm_ioremap_resource(d, res);
+	if (IS_ERR(e)) return PTR_ERR(e);
	... when != if (e == NULL || ...) S1 else S2
            when != if (IS_ERR(e) || ...) S1 else S2
--- initial
+++ final
@@ -1,7 +1,7 @@
 static void __iomem *__init mvebu_pcie_map_registers(struct platform_device *pdev, struct device_node *np, struct mvebu_pcie_port *port) {
   struct resource regs;
   int ret = 0;
   ret = of_address_to_resource(np, 0, &regs);
   if (ret) return NULL;
-  return devm_request_and_ioremap(&pdev->dev, &regs);
+  return devm_ioremap_resource(&pdev->dev, &regs);
 }<sep>@@
expression d,res;
@@

	return
-		devm_request_and_ioremap(d, res);
+		devm_ioremap_resource(d, res);
--- initial
+++ final
@@ -1,77 +1,74 @@
 static int pxa3xx_gcu_probe(struct platform_device *pdev) {
   int i, ret, irq;
   struct resource *r;
   struct pxa3xx_gcu_priv *priv;
   struct device *dev = &pdev->dev;
   priv = devm_kzalloc(dev, sizeof(struct pxa3xx_gcu_priv), GFP_KERNEL);
   if (!priv) return -ENOMEM;
   init_waitqueue_head(&priv->wait_idle);
   init_waitqueue_head(&priv->wait_free);
   spin_lock_init(&priv->spinlock);
   /* we allocate the misc device structure as part of our own allocation,
    * so we can get a pointer to our priv structure later on with
    * container_of(). This isn't really necessary as we have a fixed minor
    * number anyway, but this is to avoid statics. */
   priv->misc_dev.minor = MISCDEV_MINOR, priv->misc_dev.name = DRV_NAME, priv->misc_dev.fops = &pxa3xx_gcu_miscdev_fops;
   /* handle IO resources */
   r = platform_get_resource(pdev, IORESOURCE_MEM, 0);
-  priv->mmio_base = devm_request_and_ioremap(dev, r);
-  if (IS_ERR(priv->mmio_base)) {
-    dev_err(dev, "failed to map I/O memory\n");
-    return PTR_ERR(priv->mmio_base);
-  }
+  priv->mmio_base = devm_ioremap_resource(dev, r);
+  if (IS_ERR(priv->mmio_base)) return PTR_ERR(priv->mmio_base);
   /* enable the clock */
   priv->clk = devm_clk_get(dev, NULL);
   if (IS_ERR(priv->clk)) {
     dev_err(dev, "failed to get clock\n");
     return PTR_ERR(priv->clk);
   }
   /* request the IRQ */
   irq = platform_get_irq(pdev, 0);
   if (irq < 0) {
     dev_err(dev, "no IRQ defined\n");
     return -ENODEV;
   }
   ret = devm_request_irq(dev, irq, pxa3xx_gcu_handle_irq, 0, DRV_NAME, priv);
   if (ret < 0) {
     dev_err(dev, "request_irq failed\n");
     return ret;
   }
   /* allocate dma memory */
   priv->shared = dma_alloc_coherent(dev, SHARED_SIZE, &priv->shared_phys, GFP_KERNEL);
   if (!priv->shared) {
     dev_err(dev, "failed to allocate DMA memory\n");
     return -ENOMEM;
   }
   /* register misc device */
   ret = misc_register(&priv->misc_dev);
   if (ret < 0) {
     dev_err(dev, "misc_register() for minor %d failed\n", MISCDEV_MINOR);
     goto err_free_dma;
   }
   ret = clk_enable(priv->clk);
   if (ret < 0) {
     dev_err(dev, "failed to enable clock\n");
     goto err_misc_deregister;
   }
   for (i = 0; i < 8; i++) {
     ret = pxa3xx_gcu_add_buffer(dev, priv);
     if (ret) {
       dev_err(dev, "failed to allocate DMA memory\n");
       goto err_disable_clk;
     }
   }
   platform_set_drvdata(pdev, priv);
   priv->resource_mem = r;
   pxa3xx_gcu_reset(priv);
   pxa3xx_gcu_init_debug_timer();
   dev_info(dev, "registered @0x%p, DMA 0x%p (%d bytes), IRQ %d\n", (void *)r->start, (void *)priv->shared_phys, SHARED_SIZE, irq);
   return 0;
 err_free_dma:
   dma_free_coherent(dev, SHARED_SIZE, priv->shared, priv->shared_phys);
 err_misc_deregister:
   misc_deregister(&priv->misc_dev);
 err_disable_clk:
   clk_disable(priv->clk);
   return ret;
 }<sep>@@
expression e,d,res;
statement S,S1;
@@

-	e = devm_request_and_ioremap(d, res);
+	e = devm_ioremap_resource(d, res);
	if (IS_ERR(e))
-	{
- 		dev_err(...);
		S
-	}
	else S1
--- initial
+++ final
@@ -1,46 +1,43 @@
 static int nbu2ss_drv_probe(struct platform_device *pdev) {
   int status = -ENODEV;
   struct nbu2ss_udc *udc;
   struct resource *r;
   int irq;
   void __iomem *mmio_base;
   udc = &udc_controller;
   memset(udc, 0, sizeof(struct nbu2ss_udc));
   platform_set_drvdata(pdev, udc);
   /* require I/O memory and IRQ to be provided as resources */
   r = platform_get_resource(pdev, IORESOURCE_MEM, 0);
-  mmio_base = devm_request_and_ioremap(&pdev->dev, r);
-  if (IS_ERR(mmio_base)) {
-    dev_err(&pdev->dev, "failed to map I/O memory\n");
-    return PTR_ERR(mmio_base);
-  }
+  mmio_base = devm_ioremap_resource(&pdev->dev, r);
+  if (IS_ERR(mmio_base)) return PTR_ERR(mmio_base);
   irq = platform_get_irq(pdev, 0);
   if (irq < 0) {
     dev_err(&pdev->dev, "failed to get IRQ\n");
     return irq;
   }
   status = devm_request_irq(&pdev->dev, irq, _nbu2ss_udc_irq, 0, driver_name, udc);
   /* IO Memory */
   udc->p_regs = (PT_FC_REGS)mmio_base;
   /* USB Function Controller Interrupt */
   if (status != 0) {
     ERR("request_irq(USB_UDC_IRQ_1) failed\n");
     goto cleanup1;
   }
   /* Driver Initialization */
   status = nbu2ss_drv_contest_init(pdev, udc);
   if (status < 0) {
     /* Error */
     goto cleanup1;
   }
   /* VBUS Interrupt */
   irq_set_irq_type(INT_VBUS, IRQ_TYPE_EDGE_BOTH);
   status = request_irq(INT_VBUS, _nbu2ss_vbus_irq, IRQF_SHARED, driver_name, udc);
   if (status != 0) {
     ERR("request_irq(INT_VBUS) failed\n");
     goto cleanup1;
   }
   return status;
 cleanup1:
   return status;
 }<sep>@@
expression e,d,res;
statement S,S1;
@@

-	e = devm_request_and_ioremap(d, res);
+	e = devm_ioremap_resource(d, res);
	if (IS_ERR(e))
-	{
- 		dev_err(...);
		S
-	}
	else S1
--- initial
+++ final
@@ -1,64 +1,64 @@
 int xfs_attr_rmtval_remove(struct xfs_da_args *args) {
   struct xfs_mount *mp = args->dp->i_mount;
   xfs_dablk_t lblkno;
   int blkcnt;
   int error;
   int done;
   trace_xfs_attr_rmtval_remove(args);
   /*
    * Roll through the "value", invalidating the attribute value's blocks.
    */
   lblkno = args->rmtblkno;
   blkcnt = args->rmtblkcnt;
   while (blkcnt > 0) {
     struct xfs_bmbt_irec map;
     struct xfs_buf *bp;
     xfs_daddr_t dblkno;
     int dblkcnt;
     int nmap;
     /*
      * Try to remember where we decided to put the value.
      */
     nmap = 1;
     error = xfs_bmapi_read(args->dp, (xfs_fileoff_t)lblkno, blkcnt, &map, &nmap, XFS_BMAPI_ATTRFORK);
     if (error) return error;
     ASSERT(nmap == 1);
     ASSERT((map.br_startblock != DELAYSTARTBLOCK) && (map.br_startblock != HOLESTARTBLOCK));
     dblkno = XFS_FSB_TO_DADDR(mp, map.br_startblock), dblkcnt = XFS_FSB_TO_BB(mp, map.br_blockcount);
     /*
      * If the "remote" value is in the cache, remove it.
      */
     bp = xfs_buf_incore(mp->m_ddev_targp, dblkno, dblkcnt, XBF_TRYLOCK);
     if (bp) {
       xfs_buf_stale(bp);
       xfs_buf_relse(bp);
       bp = NULL;
     }
     lblkno += map.br_blockcount;
     blkcnt -= map.br_blockcount;
   }
   /*
    * Keep de-allocating extents until the remote-value region is gone.
    */
   lblkno = args->rmtblkno;
   blkcnt = args->rmtblkcnt;
   done = 0;
   while (!done) {
-    xfs_defer_init(args->trans->t_dfops, args->firstblock);
+    xfs_defer_init(NULL, args->trans->t_dfops, args->firstblock);
     error = xfs_bunmapi(args->trans, args->dp, lblkno, blkcnt, XFS_BMAPI_ATTRFORK, 1, args->firstblock, &done);
     if (error) goto out_defer_cancel;
     xfs_defer_ijoin(args->trans->t_dfops, args->dp);
     error = xfs_defer_finish(&args->trans, args->trans->t_dfops);
     if (error) goto out_defer_cancel;
     /*
      * Close out trans and start the next one in the chain.
      */
     error = xfs_trans_roll_inode(&args->trans, args->dp);
     if (error) return error;
   }
   return 0;
 out_defer_cancel:
   xfs_defer_cancel(args->trans->t_dfops);
   args->trans = NULL;
   return error;
 }<sep>@@
expression e1,e2,tp;
@@

-		xfs_defer_init(e1, e2);
+		xfs_defer_init(NULL, e1, e2);