imamnurby/smpl_train_seed8 huggingface dataset:
--- initial
+++ final
@@ -1,49 +1,49 @@
 static int pci_frontend_enable_msix(struct pci_dev *dev, int vector[], int nvec) {
   int err;
   int i;
   struct xen_pci_op op = {
       .cmd = XEN_PCI_OP_enable_msix,
       .domain = pci_domain_nr(dev->bus),
       .bus = dev->bus->number,
       .devfn = dev->devfn,
       .value = nvec,
   };
   struct pcifront_sd *sd = dev->bus->sysdata;
   struct pcifront_device *pdev = pcifront_get_pdev(sd);
   struct msi_desc *entry;
   if (nvec > SH_INFO_MAX_VEC) {
-    dev_err(&dev->dev,
+    pci_err(dev,
             "too much vector for pci frontend: %x."
             " Increase SH_INFO_MAX_VEC.\n",
             nvec);
     return -EINVAL;
   }
   i = 0;
   for_each_pci_msi_entry(entry, dev) {
     op.msix_entries[i].entry = entry->msi_attrib.entry_nr;
     /* Vector is useless at this point. */
     op.msix_entries[i].vector = -1;
     i++;
   }
   err = do_pci_op(pdev, &op);
   if (likely(!err)) {
     if (likely(!op.value)) {
       /* we get the result */
       for (i = 0; i < nvec; i++) {
         if (op.msix_entries[i].vector <= 0) {
-          dev_warn(&dev->dev, "MSI-X entry %d is invalid: %d!\n", i, op.msix_entries[i].vector);
+          pci_warn(dev, "MSI-X entry %d is invalid: %d!\n", i, op.msix_entries[i].vector);
           err = -EINVAL;
           vector[i] = -1;
           continue;
         }
         vector[i] = op.msix_entries[i].vector;
       }
     } else {
       printk(KERN_DEBUG "enable msix get value %x\n", op.value);
       err = op.value;
     }
   } else {
-    dev_err(&dev->dev, "enable msix get err %x\n", err);
+    pci_err(dev, "enable msix get err %x\n", err);
   }
   return err;
 }<sep>@@
struct pci_dev *dv;
@@

-dev_err(&dv->dev,
+pci_err(dv,
	...)

@@
struct pci_dev *dv;
@@

-dev_warn(&dv->dev,
+pci_warn(dv,
	...)
--- initial
+++ final
@@ -1,51 +1,51 @@
 static void quirk_e100_interrupt(struct pci_dev *dev) {
   u16 command, pmcsr;
   u8 __iomem *csr;
   u8 cmd_hi;
   switch (dev->device) {
   /* PCI IDs taken from drivers/net/e100.c */
   case 0x1029:
   case 0x1030 ... 0x1034:
   case 0x1038 ... 0x103E:
   case 0x1050 ... 0x1057:
   case 0x1059:
   case 0x1064 ... 0x106B:
   case 0x1091 ... 0x1095:
   case 0x1209:
   case 0x1229:
   case 0x2449:
   case 0x2459:
   case 0x245D:
   case 0x27DC: break;
   default: return;
   }
   /*
    * Some firmware hands off the e100 with interrupts enabled,
    * which can cause a flood of interrupts if packets are
    * received before the driver attaches to the device.  So
    * disable all e100 interrupts here.  The driver will
    * re-enable them when it's ready.
    */
   pci_read_config_word(dev, PCI_COMMAND, &command);
   if (!(command & PCI_COMMAND_MEMORY) || !pci_resource_start(dev, 0)) return;
   /*
    * Check that the device is in the D0 power state. If it's not,
    * there is no point to look any further.
    */
   if (dev->pm_cap) {
     pci_read_config_word(dev, dev->pm_cap + PCI_PM_CTRL, &pmcsr);
     if ((pmcsr & PCI_PM_CTRL_STATE_MASK) != PCI_D0) return;
   }
   /* Convert from PCI bus to resource space.  */
   csr = ioremap(pci_resource_start(dev, 0), 8);
   if (!csr) {
-    dev_warn(&dev->dev, "Can't map e100 registers\n");
+    pci_warn(dev, "Can't map e100 registers\n");
     return;
   }
   cmd_hi = readb(csr + 3);
   if (cmd_hi == 0) {
-    dev_warn(&dev->dev, "Firmware left e100 interrupts enabled; disabling\n");
+    pci_warn(dev, "Firmware left e100 interrupts enabled; disabling\n");
     writeb(1, csr + 3);
   }
   iounmap(csr);
 }<sep>@@
struct pci_dev *dv;
@@

-dev_warn(&dv->dev,
+pci_warn(dv,
	...)
--- initial
+++ final
@@ -1,9 +1,9 @@
 void pci_allocate_vc_save_buffers(struct pci_dev *dev) {
   int i;
   for (i = 0; i < ARRAY_SIZE(vc_caps); i++) {
     int len, pos = pci_find_ext_capability(dev, vc_caps[i].id);
     if (!pos) continue;
     len = pci_vc_do_save_buffer(dev, pos, NULL, false);
-    if (pci_add_ext_cap_save_buffer(dev, vc_caps[i].id, len)) dev_err(&dev->dev, "unable to preallocate %s save buffer\n", vc_caps[i].name);
+    if (pci_add_ext_cap_save_buffer(dev, vc_caps[i].id, len)) pci_err(dev, "unable to preallocate %s save buffer\n", vc_caps[i].name);
   }
 }<sep>@@
struct pci_dev *dv;
@@

-dev_err(&dv->dev,
+pci_err(dv,
	...)
--- initial
+++ final
@@ -1,29 +1,29 @@
 static int reset_ivb_igd(struct pci_dev *dev, int probe) {
   void __iomem *mmio_base;
   unsigned long timeout;
   u32 val;
   if (probe) return 0;
   mmio_base = pci_iomap(dev, 0, 0);
   if (!mmio_base) return -ENOMEM;
   iowrite32(0x00000002, mmio_base + MSG_CTL);
   /*
    * Clobbering SOUTH_CHICKEN2 register is fine only if the next
    * driver loaded sets the right bits. However, this's a reset and
    * the bits have been set by i915 previously, so we clobber
    * SOUTH_CHICKEN2 register directly here.
    */
   iowrite32(0x00000005, mmio_base + SOUTH_CHICKEN2);
   val = ioread32(mmio_base + PCH_PP_CONTROL) & 0xfffffffe;
   iowrite32(val, mmio_base + PCH_PP_CONTROL);
   timeout = jiffies + msecs_to_jiffies(IGD_OPERATION_TIMEOUT);
   do {
     val = ioread32(mmio_base + PCH_PP_STATUS);
     if ((val & 0xb0000000) == 0) goto reset_complete;
     msleep(10);
   } while (time_before(jiffies, timeout));
-  dev_warn(&dev->dev, "timeout during reset\n");
+  pci_warn(dev, "timeout during reset\n");
 reset_complete:
   iowrite32(0x00000002, mmio_base + NSDE_PWR_STATE);
   pci_iounmap(dev, mmio_base);
   return 0;
 }<sep>@@
struct pci_dev *dv;
@@

-dev_warn(&dv->dev,
+pci_warn(dv,
	...)
--- initial
+++ final
@@ -1,9 +1,9 @@
 static void quirk_disable_root_port_attributes(struct pci_dev *pdev) {
   struct pci_dev *root_port = pci_find_pcie_root_port(pdev);
   if (!root_port) {
-    dev_warn(&pdev->dev, "PCIe Completion erratum may cause device errors\n");
+    pci_warn(pdev, "PCIe Completion erratum may cause device errors\n");
     return;
   }
-  dev_info(&root_port->dev, "Disabling No Snoop/Relaxed Ordering Attributes to avoid PCIe Completion erratum in %s\n", dev_name(&pdev->dev));
+  pci_info(root_port, "Disabling No Snoop/Relaxed Ordering Attributes to avoid PCIe Completion erratum in %s\n", dev_name(&pdev->dev));
   pcie_capability_clear_and_set_word(root_port, PCI_EXP_DEVCTL, PCI_EXP_DEVCTL_RELAX_EN | PCI_EXP_DEVCTL_NOSNOOP_EN, 0);
 }<sep>@@
struct pci_dev *dv;
@@

-dev_warn(&dv->dev,
+pci_warn(dv,
	...)

@@
struct pci_dev *dv;
@@

-dev_info(&dv->dev,
+pci_info(dv,
	...)
--- initial
+++ final
@@ -1,24 +1,24 @@
 int pci_hp_add_bridge(struct pci_dev *dev) {
   struct pci_bus *parent = dev->bus;
   int busnr, start = parent->busn_res.start;
   unsigned int available_buses = 0;
   int end = parent->busn_res.end;
   for (busnr = start; busnr <= end; busnr++) {
     if (!pci_find_bus(pci_domain_nr(parent), busnr)) break;
   }
   if (busnr-- > end) {
-    dev_err(&dev->dev, "No bus number available for hot-added bridge\n");
+    pci_err(dev, "No bus number available for hot-added bridge\n");
     return -1;
   }
   /* Scan bridges that are already configured */
   busnr = pci_scan_bridge(parent, dev, busnr, 0);
   /*
    * Distribute the available bus numbers between hotplug-capable
    * bridges to make extending the chain later possible.
    */
   available_buses = end - busnr;
   /* Scan bridges that need to be reconfigured */
   pci_scan_bridge_extend(parent, dev, busnr, available_buses, 1);
   if (!dev->subordinate) return -1;
   return 0;
 }<sep>@@
struct pci_dev *dv;
@@

-dev_err(&dv->dev,
+pci_err(dv,
	...)
--- initial
+++ final
@@ -1,43 +1,43 @@
 static void mellanox_check_broken_intx_masking(struct pci_dev *pdev) {
   __be32 __iomem *fw_ver;
   u16 fw_major;
   u16 fw_minor;
   u16 fw_subminor;
   u32 fw_maj_min;
   u32 fw_sub_min;
   int i;
   for (i = 0; i < ARRAY_SIZE(mellanox_broken_intx_devs); i++) {
     if (pdev->device == mellanox_broken_intx_devs[i]) {
       pdev->broken_intx_masking = 1;
       return;
     }
   }
   /* Getting here means Connect-IB cards and up. Connect-IB has no INTx
    * support so shouldn't be checked further
    */
   if (pdev->device == PCI_DEVICE_ID_MELLANOX_CONNECTIB) return;
   if (pdev->device != PCI_DEVICE_ID_MELLANOX_CONNECTX4 && pdev->device != PCI_DEVICE_ID_MELLANOX_CONNECTX4_LX) return;
   /* For ConnectX-4 and ConnectX-4LX, need to check FW support */
   if (pci_enable_device_mem(pdev)) {
-    dev_warn(&pdev->dev, "Can't enable device memory\n");
+    pci_warn(pdev, "Can't enable device memory\n");
     return;
   }
   fw_ver = ioremap(pci_resource_start(pdev, 0), 4);
   if (!fw_ver) {
-    dev_warn(&pdev->dev, "Can't map ConnectX-4 initialization segment\n");
+    pci_warn(pdev, "Can't map ConnectX-4 initialization segment\n");
     goto out;
   }
   /* Reading from resource space should be 32b aligned */
   fw_maj_min = ioread32be(fw_ver);
   fw_sub_min = ioread32be(fw_ver + 1);
   fw_major = fw_maj_min & 0xffff;
   fw_minor = fw_maj_min >> 16;
   fw_subminor = fw_sub_min & 0xffff;
   if (fw_minor > CONNECTX_4_CURR_MAX_MINOR || fw_minor < CONNECTX_4_INTX_SUPPORT_MINOR) {
-    dev_warn(&pdev->dev, "ConnectX-4: FW %u.%u.%u doesn't support INTx masking, disabling. Please upgrade FW to %d.14.1100 and up for INTx support\n", fw_major, fw_minor, fw_subminor, pdev->device == PCI_DEVICE_ID_MELLANOX_CONNECTX4 ? 12 : 14);
+    pci_warn(pdev, "ConnectX-4: FW %u.%u.%u doesn't support INTx masking, disabling. Please upgrade FW to %d.14.1100 and up for INTx support\n", fw_major, fw_minor, fw_subminor, pdev->device == PCI_DEVICE_ID_MELLANOX_CONNECTX4 ? 12 : 14);
     pdev->broken_intx_masking = 1;
   }
   iounmap(fw_ver);
 out:
   pci_disable_device(pdev);
 }<sep>@@
struct pci_dev *dv;
@@

-dev_warn(&dv->dev,
+pci_warn(dv,
	...)
--- initial
+++ final
@@ -1,9 +1,9 @@
 static u32 calc_l1ss_pwron(struct pci_dev *pdev, u32 scale, u32 val) {
   switch (scale) {
   case 0: return val * 2;
   case 1: return val * 10;
   case 2: return val * 100;
   }
-  dev_err(&pdev->dev, "%s: Invalid T_PwrOn scale: %u\n", __func__, scale);
+  pci_err(pdev, "%s: Invalid T_PwrOn scale: %u\n", __func__, scale);
   return 0;
 }<sep>@@
struct pci_dev *dv;
@@

-dev_err(&dv->dev,
+pci_err(dv,
	...)
--- initial
+++ final
@@ -1,46 +1,45 @@
 static int w5300_hw_probe(struct platform_device *pdev) {
   struct wiznet_platform_data *data = dev_get_platdata(&pdev->dev);
   struct net_device *ndev = platform_get_drvdata(pdev);
   struct w5300_priv *priv = netdev_priv(ndev);
   const char *name = netdev_name(ndev);
   struct resource *mem;
   int mem_size;
   int irq;
   int ret;
   if (data && is_valid_ether_addr(data->mac_addr)) {
     memcpy(ndev->dev_addr, data->mac_addr, ETH_ALEN);
   } else {
     eth_hw_addr_random(ndev);
   }
   mem = platform_get_resource(pdev, IORESOURCE_MEM, 0);
-  if (!mem) return -ENXIO;
-  mem_size = resource_size(mem);
   priv->base = devm_ioremap_resource(&pdev->dev, mem);
   if (IS_ERR(priv->base)) return PTR_ERR(priv->base);
+  mem_size = resource_size(mem);
   spin_lock_init(&priv->reg_lock);
   priv->indirect = mem_size < W5300_BUS_DIRECT_SIZE;
   if (priv->indirect) {
     priv->read = w5300_read_indirect;
     priv->write = w5300_write_indirect;
   } else {
     priv->read = w5300_read_direct;
     priv->write = w5300_write_direct;
   }
   w5300_hw_reset(priv);
   if (w5300_read(priv, W5300_IDR) != IDR_W5300) return -ENODEV;
   irq = platform_get_irq(pdev, 0);
   if (irq < 0) return irq;
   ret = request_irq(irq, w5300_interrupt, IRQ_TYPE_LEVEL_LOW, name, ndev);
   if (ret < 0) return ret;
   priv->irq = irq;
   priv->link_gpio = data ? data->link_gpio : -EINVAL;
   if (gpio_is_valid(priv->link_gpio)) {
     char *link_name = devm_kzalloc(&pdev->dev, 16, GFP_KERNEL);
     if (!link_name) return -ENOMEM;
     snprintf(link_name, 16, "%s-link", name);
     priv->link_irq = gpio_to_irq(priv->link_gpio);
     if (request_any_context_irq(priv->link_irq, w5300_detect_link, IRQF_TRIGGER_RISING | IRQF_TRIGGER_FALLING, link_name, priv->ndev) < 0) priv->link_gpio = -EINVAL;
   }
   netdev_info(ndev, "at 0x%llx irq %d\n", (u64)mem->start, irq);
   return 0;
 }<sep>@@
expression e1,e2,e3,e4,e6,pdev;
statement S1,S2;
@@

-	e1 = platform_get_resource(pdev, IORESOURCE_MEM, e3);
-	if (e1 == NULL)
-		S1
	... when any
            when != e1
-	e6 = resource_size(e1);
	... when any
            when != e1
+	e1 = platform_get_resource(pdev, IORESOURCE_MEM, e3);
 	e2 = devm_ioremap_resource(e4, e1);
	if (...) S2
+	e6 = resource_size(e1);
--- initial
+++ final
@@ -1,39 +1,38 @@
 static int usb_hcd_da8xx_probe(const struct hc_driver *driver, struct platform_device *pdev) {
   struct da8xx_ohci_root_hub *hub = dev_get_platdata(&pdev->dev);
   struct usb_hcd *hcd;
   struct resource *mem;
   int error, irq;
   if (hub == NULL) return -ENODEV;
   usb11_clk = devm_clk_get(&pdev->dev, "usb11");
   if (IS_ERR(usb11_clk)) return PTR_ERR(usb11_clk);
   usb20_clk = devm_clk_get(&pdev->dev, "usb20");
   if (IS_ERR(usb20_clk)) return PTR_ERR(usb20_clk);
   hcd = usb_create_hcd(driver, &pdev->dev, dev_name(&pdev->dev));
   if (!hcd) return -ENOMEM;
   mem = platform_get_resource(pdev, IORESOURCE_MEM, 0);
-  if (!mem) return -ENODEV;
-  hcd->rsrc_start = mem->start;
-  hcd->rsrc_len = resource_size(mem);
   hcd->regs = devm_ioremap_resource(&pdev->dev, mem);
   if (IS_ERR(hcd->regs)) {
     error = PTR_ERR(hcd->regs);
     goto err;
   }
+  hcd->rsrc_start = mem->start;
+  hcd->rsrc_len = resource_size(mem);
   ohci_hcd_init(hcd_to_ohci(hcd));
   irq = platform_get_irq(pdev, 0);
   if (irq < 0) {
     error = -ENODEV;
     goto err;
   }
   error = usb_add_hcd(hcd, irq, 0);
   if (error) goto err;
   device_wakeup_enable(hcd->self.controller);
   if (hub->ocic_notify) {
     error = hub->ocic_notify(ohci_da8xx_ocic_handler);
     if (!error) return 0;
   }
   usb_remove_hcd(hcd);
 err:
   usb_put_hcd(hcd);
   return error;
 }<sep>@@
expression e1,e2,e3,e4,e5,e6,pdev;
statement S1,S2;
@@

-	e1 = platform_get_resource(pdev, IORESOURCE_MEM, e3);
-	if (e1 == NULL)
-		S1
	... when any
            when != e1
-	e5 = e1->start;
-	e6 = resource_size(e1);
	... when any
            when != e1
+	e1 = platform_get_resource(pdev, IORESOURCE_MEM, e3);
 	e2 = devm_ioremap_resource(e4, e1);
	if (...) S2
+	e5 = e1->start;
+	e6 = resource_size(e1);
--- initial
+++ final
@@ -1,56 +1,52 @@
 static int jz4740_ohci_probe(struct platform_device *pdev) {
   int ret;
   struct usb_hcd *hcd;
   struct jz4740_ohci_hcd *jz4740_ohci;
   struct resource *res;
   int irq;
-  res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
-  if (!res) {
-    dev_err(&pdev->dev, "Failed to get platform resource\n");
-    return -ENOENT;
-  }
   irq = platform_get_irq(pdev, 0);
   if (irq < 0) {
     dev_err(&pdev->dev, "Failed to get platform irq\n");
     return irq;
   }
   hcd = usb_create_hcd(&ohci_jz4740_hc_driver, &pdev->dev, "jz4740");
   if (!hcd) {
     dev_err(&pdev->dev, "Failed to create hcd.\n");
     return -ENOMEM;
   }
   jz4740_ohci = hcd_to_jz4740_hcd(hcd);
-  hcd->rsrc_start = res->start;
-  hcd->rsrc_len = resource_size(res);
+  res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
   hcd->regs = devm_ioremap_resource(&pdev->dev, res);
   if (IS_ERR(hcd->regs)) {
     ret = PTR_ERR(hcd->regs);
     goto err_free;
   }
+  hcd->rsrc_start = res->start;
+  hcd->rsrc_len = resource_size(res);
   jz4740_ohci->clk = devm_clk_get(&pdev->dev, "uhc");
   if (IS_ERR(jz4740_ohci->clk)) {
     ret = PTR_ERR(jz4740_ohci->clk);
     dev_err(&pdev->dev, "Failed to get clock: %d\n", ret);
     goto err_free;
   }
   jz4740_ohci->vbus = devm_regulator_get(&pdev->dev, "vbus");
   if (IS_ERR(jz4740_ohci->vbus)) jz4740_ohci->vbus = NULL;
   clk_set_rate(jz4740_ohci->clk, 48000000);
   clk_enable(jz4740_ohci->clk);
   if (jz4740_ohci->vbus) ohci_jz4740_set_vbus_power(jz4740_ohci, true);
   platform_set_drvdata(pdev, hcd);
   ohci_hcd_init(hcd_to_ohci(hcd));
   ret = usb_add_hcd(hcd, irq, 0);
   if (ret) {
     dev_err(&pdev->dev, "Failed to add hcd: %d\n", ret);
     goto err_disable;
   }
   device_wakeup_enable(hcd->self.controller);
   return 0;
 err_disable:
   if (jz4740_ohci->vbus) regulator_disable(jz4740_ohci->vbus);
   clk_disable(jz4740_ohci->clk);
 err_free:
   usb_put_hcd(hcd);
   return ret;
 }<sep>@@
expression e1,e2,e3,e4,e5,e6,pdev;
statement S1,S2;
@@

-	e1 = platform_get_resource(pdev, IORESOURCE_MEM, e3);
-	if (e1 == NULL)
-		S1
	... when any
            when != e1
-	e5 = e1->start;
-	e6 = resource_size(e1);
	... when any
            when != e1
+	e1 = platform_get_resource(pdev, IORESOURCE_MEM, e3);
 	e2 = devm_ioremap_resource(e4, e1);
	if (...) S2
+	e5 = e1->start;
+	e6 = resource_size(e1);
--- initial
+++ final
@@ -1,6 +1,5 @@
 static int __maybe_unused hid_sensor_suspend(struct device *dev) {
-  struct platform_device *pdev = to_platform_device(dev);
-  struct iio_dev *indio_dev = platform_get_drvdata(pdev);
+  struct iio_dev *indio_dev = dev_get_drvdata(dev);
   struct hid_sensor_common *attrb = iio_device_get_drvdata(indio_dev);
   return _hid_sensor_power_state(attrb, false);
 }<sep>@@
identifier e1;
expression e2;
type T;
@@

(
- T e1 = to_platform_device(e2);
  ...
- platform_get_drvdata(e1)
+ dev_get_drvdata(e2)
  ... when any
&
  T e1 = to_platform_device(e2);
  <... when != e1
(
  platform_get_drvdata(e1)
|
- &e1->dev
+ e2
)
  ...>
)
--- initial
+++ final
@@ -1,21 +1,20 @@
 static int ds1216_rtc_read_time(struct device *dev, struct rtc_time *tm) {
-  struct platform_device *pdev = to_platform_device(dev);
-  struct ds1216_priv *priv = platform_get_drvdata(pdev);
+  struct ds1216_priv *priv = dev_get_drvdata(dev);
   struct ds1216_regs regs;
   ds1216_switch_ds_to_clock(priv->ioaddr);
   ds1216_read(priv->ioaddr, (u8 *)&regs);
   tm->tm_sec = bcd2bin(regs.sec);
   tm->tm_min = bcd2bin(regs.min);
   if (regs.hour & DS1216_HOUR_1224) {
     /* AM/PM mode */
     tm->tm_hour = bcd2bin(regs.hour & 0x1f);
     if (regs.hour & DS1216_HOUR_AMPM) tm->tm_hour += 12;
   } else
     tm->tm_hour = bcd2bin(regs.hour & 0x3f);
   tm->tm_wday = (regs.wday & 7) - 1;
   tm->tm_mday = bcd2bin(regs.mday & 0x3f);
   tm->tm_mon = bcd2bin(regs.month & 0x1f);
   tm->tm_year = bcd2bin(regs.year);
   if (tm->tm_year < 70) tm->tm_year += 100;
   return 0;
 }<sep>@@
identifier e1;
expression e2;
type T;
@@

(
- T e1 = to_platform_device(e2);
  ...
- platform_get_drvdata(e1)
+ dev_get_drvdata(e2)
  ... when any
&
  T e1 = to_platform_device(e2);
  <... when != e1
(
  platform_get_drvdata(e1)
|
- &e1->dev
+ e2
)
  ...>
)
--- initial
+++ final
@@ -1,6 +1,5 @@
 static int __maybe_unused xwdt_suspend(struct device *dev) {
-  struct platform_device *pdev = to_platform_device(dev);
-  struct xwdt_device *xdev = platform_get_drvdata(pdev);
+  struct xwdt_device *xdev = dev_get_drvdata(dev);
   if (watchdog_active(&xdev->xilinx_wdt_wdd)) xilinx_wdt_stop(&xdev->xilinx_wdt_wdd);
   return 0;
 }<sep>@@
identifier e1;
expression e2;
type T;
@@

(
- T e1 = to_platform_device(e2);
  ...
- platform_get_drvdata(e1)
+ dev_get_drvdata(e2)
  ... when any
&
  T e1 = to_platform_device(e2);
  <... when != e1
(
  platform_get_drvdata(e1)
|
- &e1->dev
+ e2
)
  ...>
)
--- initial
+++ final
@@ -1,32 +1,31 @@
 static int sdhci_arasan_resume(struct device *dev) {
-  struct platform_device *pdev = to_platform_device(dev);
-  struct sdhci_host *host = platform_get_drvdata(pdev);
+  struct sdhci_host *host = dev_get_drvdata(dev);
   struct sdhci_pltfm_host *pltfm_host = sdhci_priv(host);
   struct sdhci_arasan_data *sdhci_arasan = sdhci_pltfm_priv(pltfm_host);
   int ret;
   ret = clk_enable(sdhci_arasan->clk_ahb);
   if (ret) {
     dev_err(dev, "Cannot enable AHB clock.\n");
     return ret;
   }
   ret = clk_enable(pltfm_host->clk);
   if (ret) {
     dev_err(dev, "Cannot enable SD clock.\n");
     return ret;
   }
   if (!IS_ERR(sdhci_arasan->phy) && host->mmc->actual_clock) {
     ret = phy_power_on(sdhci_arasan->phy);
     if (ret) {
       dev_err(dev, "Cannot power on phy.\n");
       return ret;
     }
     sdhci_arasan->is_phy_on = true;
   }
   ret = sdhci_resume_host(host);
   if (ret) {
     dev_err(dev, "Cannot resume host.\n");
     return ret;
   }
   if (sdhci_arasan->has_cqe) return cqhci_resume(host->mmc);
   return 0;
 }<sep>@@
identifier e1;
expression e2;
type T;
@@

(
- T e1 = to_platform_device(e2);
  ...
- platform_get_drvdata(e1)
+ dev_get_drvdata(e2)
  ... when any
&
  T e1 = to_platform_device(e2);
  <... when != e1
(
  platform_get_drvdata(e1)
|
- &e1->dev
+ e2
)
  ...>
)
--- initial
+++ final
@@ -1,6 +1,5 @@
 static int lpc32xx_rtc_resume(struct device *dev) {
-  struct platform_device *pdev = to_platform_device(dev);
-  struct lpc32xx_rtc *rtc = platform_get_drvdata(pdev);
-  if (rtc->irq >= 0 && device_may_wakeup(&pdev->dev)) disable_irq_wake(rtc->irq);
+  struct lpc32xx_rtc *rtc = dev_get_drvdata(dev);
+  if (rtc->irq >= 0 && device_may_wakeup(dev)) disable_irq_wake(rtc->irq);
   return 0;
 }<sep>@@
identifier e1;
expression e2;
type T;
@@

(
- T e1 = to_platform_device(e2);
  ...
- platform_get_drvdata(e1)
+ dev_get_drvdata(e2)
  ... when any
&
  T e1 = to_platform_device(e2);
  <... when != e1
(
  platform_get_drvdata(e1)
|
- &e1->dev
+ e2
)
  ...>
)
--- initial
+++ final
@@ -1,18 +1,17 @@
 static int __maybe_unused cros_ec_sensors_prepare(struct device *dev) {
-  struct platform_device *pdev = to_platform_device(dev);
-  struct iio_dev *indio_dev = platform_get_drvdata(pdev);
+  struct iio_dev *indio_dev = dev_get_drvdata(dev);
   struct cros_ec_sensors_core_state *st = iio_priv(indio_dev);
   if (st->curr_sampl_freq == 0) return 0;
   /*
    * If the sensors are sampled at high frequency, we will not be able to
    * sleep. Set sampling to a long period if necessary.
    */
   if (st->curr_sampl_freq < CROS_EC_MIN_SUSPEND_SAMPLING_FREQUENCY) {
     mutex_lock(&st->cmd_lock);
     st->param.cmd = MOTIONSENSE_CMD_EC_RATE;
     st->param.ec_rate.data = CROS_EC_MIN_SUSPEND_SAMPLING_FREQUENCY;
     cros_ec_motion_send_host_cmd(st, 0);
     mutex_unlock(&st->cmd_lock);
   }
   return 0;
 }<sep>@@
identifier e1;
expression e2;
type T;
@@

(
- T e1 = to_platform_device(e2);
  ...
- platform_get_drvdata(e1)
+ dev_get_drvdata(e2)
  ... when any
&
  T e1 = to_platform_device(e2);
  <... when != e1
(
  platform_get_drvdata(e1)
|
- &e1->dev
+ e2
)
  ...>
)
--- initial
+++ final
@@ -1,12 +1,11 @@
 static int imx_uart_suspend(struct device *dev) {
-  struct platform_device *pdev = to_platform_device(dev);
-  struct imx_port *sport = platform_get_drvdata(pdev);
+  struct imx_port *sport = dev_get_drvdata(dev);
   int ret;
   uart_suspend_port(&imx_uart_uart_driver, &sport->port);
   disable_irq(sport->port.irq);
   ret = clk_prepare_enable(sport->clk_ipg);
   if (ret) return ret;
   /* enable wakeup from i.MX UART */
   imx_uart_enable_wakeup(sport, true);
   return 0;
 }<sep>@@
identifier e1;
expression e2;
type T;
@@

(
- T e1 = to_platform_device(e2);
  ...
- platform_get_drvdata(e1)
+ dev_get_drvdata(e2)
  ... when any
&
  T e1 = to_platform_device(e2);
  <... when != e1
(
  platform_get_drvdata(e1)
|
- &e1->dev
+ e2
)
  ...>
)
--- initial
+++ final
@@ -1,7 +1,6 @@
 static int sh_mobile_lcdc_runtime_suspend(struct device *dev) {
-  struct platform_device *pdev = to_platform_device(dev);
-  struct sh_mobile_lcdc_priv *priv = platform_get_drvdata(pdev);
+  struct sh_mobile_lcdc_priv *priv = dev_get_drvdata(dev);
   /* turn off LCDC hardware */
   lcdc_write(priv, _LDCNT1R, 0);
   return 0;
 }<sep>@@
identifier e1;
expression e2;
type T;
@@

(
- T e1 = to_platform_device(e2);
  ...
- platform_get_drvdata(e1)
+ dev_get_drvdata(e2)
  ... when any
&
  T e1 = to_platform_device(e2);
  <... when != e1
(
  platform_get_drvdata(e1)
|
- &e1->dev
+ e2
)
  ...>
)