--- initial
+++ final
@@ -1,116 +1,116 @@
 static int c_can_plat_probe(struct platform_device *pdev) {
   int ret;
   void __iomem *addr;
   struct net_device *dev;
   struct c_can_priv *priv;
   const struct of_device_id *match;
   const struct platform_device_id *id;
   struct pinctrl *pinctrl;
   struct resource *mem, *res;
   int irq;
   struct clk *clk;
   if (pdev->dev.of_node) {
     match = of_match_device(c_can_of_table, &pdev->dev);
     if (!match) {
       dev_err(&pdev->dev, "Failed to find matching dt id\n");
       ret = -EINVAL;
       goto exit;
     }
     id = match->data;
   } else {
     id = platform_get_device_id(pdev);
   }
   pinctrl = devm_pinctrl_get_select_default(&pdev->dev);
   if (IS_ERR(pinctrl)) dev_warn(&pdev->dev, "failed to configure pins from driver\n");
   /* get the appropriate clk */
   clk = clk_get(&pdev->dev, NULL);
   if (IS_ERR(clk)) {
     dev_err(&pdev->dev, "no clock defined\n");
     ret = -ENODEV;
     goto exit;
   }
   /* get the platform data */
   mem = platform_get_resource(pdev, IORESOURCE_MEM, 0);
   irq = platform_get_irq(pdev, 0);
   if (!mem || irq <= 0) {
     ret = -ENODEV;
     goto exit_free_clk;
   }
   if (!request_mem_region(mem->start, resource_size(mem), KBUILD_MODNAME)) {
     dev_err(&pdev->dev, "resource unavailable\n");
     ret = -ENODEV;
     goto exit_free_clk;
   }
   addr = ioremap(mem->start, resource_size(mem));
   if (!addr) {
     dev_err(&pdev->dev, "failed to map can port\n");
     ret = -ENOMEM;
     goto exit_release_mem;
   }
   /* allocate the c_can device */
   dev = alloc_c_can_dev();
   if (!dev) {
     ret = -ENOMEM;
     goto exit_iounmap;
   }
   priv = netdev_priv(dev);
   switch (id->driver_data) {
   case BOSCH_C_CAN:
     priv->regs = reg_map_c_can;
     switch (mem->flags & IORESOURCE_MEM_TYPE_MASK) {
     case IORESOURCE_MEM_32BIT:
       priv->read_reg = c_can_plat_read_reg_aligned_to_32bit;
       priv->write_reg = c_can_plat_write_reg_aligned_to_32bit;
       break;
     case IORESOURCE_MEM_16BIT:
     default:
       priv->read_reg = c_can_plat_read_reg_aligned_to_16bit;
       priv->write_reg = c_can_plat_write_reg_aligned_to_16bit;
       break;
     }
     break;
   case BOSCH_D_CAN:
     priv->regs = reg_map_d_can;
     priv->can.ctrlmode_supported |= CAN_CTRLMODE_3_SAMPLES;
     priv->read_reg = c_can_plat_read_reg_aligned_to_16bit;
     priv->write_reg = c_can_plat_write_reg_aligned_to_16bit;
     if (pdev->dev.of_node)
       priv->instance = of_alias_get_id(pdev->dev.of_node, "d_can");
     else
       priv->instance = pdev->id;
     res = platform_get_resource(pdev, IORESOURCE_MEM, 1);
-    priv->raminit_ctrlreg = devm_request_and_ioremap(&pdev->dev, res);
-    if (!priv->raminit_ctrlreg || priv->instance < 0)
+    priv->raminit_ctrlreg = devm_ioremap_resource(&pdev->dev, res);
+    if (IS_ERR(priv->raminit_ctrlreg) || priv->instance < 0)
       dev_info(&pdev->dev, "control memory is not used for raminit\n");
     else
       priv->raminit = c_can_hw_raminit;
     break;
   default: ret = -EINVAL; goto exit_free_device;
   }
   dev->irq = irq;
   priv->base = addr;
   priv->device = &pdev->dev;
   priv->can.clock.freq = clk_get_rate(clk);
   priv->priv = clk;
   priv->type = id->driver_data;
   platform_set_drvdata(pdev, dev);
   SET_NETDEV_DEV(dev, &pdev->dev);
   ret = register_c_can_dev(dev);
   if (ret) {
     dev_err(&pdev->dev, "registering %s failed (err=%d)\n", KBUILD_MODNAME, ret);
     goto exit_free_device;
   }
   dev_info(&pdev->dev, "%s device registered (regs=%p, irq=%d)\n", KBUILD_MODNAME, priv->base, dev->irq);
   return 0;
 exit_free_device:
   free_c_can_dev(dev);
 exit_iounmap:
   iounmap(addr);
 exit_release_mem:
   release_mem_region(mem->start, resource_size(mem));
 exit_free_clk:
   clk_put(clk);
 exit:
   dev_err(&pdev->dev, "probe failed\n");
   return ret;
 }<sep>@@
expression e,d,res;
statement S1,S2; 
@@

-	e = devm_request_and_ioremap(d, res);
+	e = devm_ioremap_resource(d, res);
	if (
-	    e == NULL
+	    IS_ERR(e)
	    || ...)
	S1 else S2