void mdm_peripheral_disconnect(struct mdm_modem_drv *mdm_drv) { struct mdm_platform_data *pdata; pr_info("%s\n", __func__); if (!mdm_drv || !mdm_drv->pdata) return; pdata = mdm_drv->pdata; mutex_lock(&hsic_status_lock); if (!hsic_peripheral_status) goto out; /* exynos usb phy contgrol seq * ehci on -> ohci on -> ohci off -> ehci on */ if (pdata->peripheral_platform_device_ohci) platform_device_del(pdata->peripheral_platform_device_ohci); if (pdata->peripheral_platform_device_ehci) platform_device_del(pdata->peripheral_platform_device_ehci); hsic_peripheral_status = 0; out: mutex_unlock(&hsic_status_lock); }
/* * called to clean-up before module exit. */ static void ev3dev_sound_exit (void) { sound_module_exit (); platform_device_del (sound); platform_device_put (sound); }
static int __init test_init(void) { int i, err; if ((err = platform_driver_register(&test_driver))) return err; err = -ENOMEM; for (i = 0; i < MAX_RTC_TEST; i++) { pdev[i] = platform_device_alloc("rtc-test", i); if (!pdev[i]) goto exit_free_mem; } for (i = 0; i < MAX_RTC_TEST; i++) { err = platform_device_add(pdev[i]); if (err) goto exit_device_del; } return 0; exit_device_del: for (; i > 0; i--) platform_device_del(pdev[i - 1]); exit_free_mem: for (i = 0; i < MAX_RTC_TEST; i++) platform_device_put(pdev[i]); platform_driver_unregister(&test_driver); return err; }
static void power_down_mdm(struct mdm_modem_drv *mdm_drv) { int i; for (i = MDM_MODEM_TIMEOUT; i > 0; i -= MDM_MODEM_DELTA) { pet_watchdog(); msleep(MDM_MODEM_DELTA); if (gpio_get_value(mdm_drv->mdm2ap_status_gpio) == 0) break; } if (i <= 0) { pr_err("%s: MDM2AP_STATUS never went low.\n", __func__); gpio_direction_output(mdm_drv->ap2mdm_pmic_reset_n_gpio, 0); for (i = MDM_HOLD_TIME; i > 0; i -= MDM_MODEM_DELTA) { pet_watchdog(); msleep(MDM_MODEM_DELTA); } } /* Also remove the hsic device on 9k power down. */ MDM_DBG("%s: Removing hsic device\n", __func__); if (ifline_status == IFLINE_UP) { platform_device_del(&msm_device_hsic_host); ifline_status = IFLINE_DOWN; } }
static void power_on_mdm(struct mdm_modem_drv *mdm_drv) { /* Remove hsic driver before powering on the modem. */ if (ifline_status == IFLINE_UP) { MDM_DBG("%s: Removing hsic device\n", __func__); platform_device_del(&msm_device_hsic_host); ifline_status = IFLINE_DOWN; } /* Pull both ERR_FATAL and RESET low */ MDM_DBG("Pulling PWR and RESET gpio's low\n"); gpio_direction_output(mdm_drv->ap2mdm_pmic_reset_n_gpio, 0); gpio_direction_output(mdm_drv->ap2mdm_kpdpwr_n_gpio, 0); /* Wait for them to settle. */ usleep(1000); /* Deassert RESET first and wait for ir to settle. */ MDM_DBG("%s: Pulling RESET gpio high\n", __func__); gpio_direction_output(mdm_drv->ap2mdm_pmic_reset_n_gpio, 1); usleep(1000); /* Pull PWR gpio high and wait for it to settle. */ MDM_DBG("%s: Powering on mdm modem\n", __func__); gpio_direction_output(mdm_drv->ap2mdm_kpdpwr_n_gpio, 1); usleep(1000); /* Add back hsic device after modem power up */ MDM_DBG("%s: Adding hsic device\n", __func__); platform_device_add(&msm_device_hsic_host); ifline_status = IFLINE_UP; msleep(200); }
static int __init amhdmitx_init(void) { HDMI_DEBUG(); if(init_flag&INIT_FLAG_NOT_LOAD) return 0; printk("amhdmitx_init\n"); if(hdmi_log_buf_size>0){ hdmi_log_buf=kmalloc(hdmi_log_buf_size, GFP_KERNEL); if(hdmi_log_buf==NULL){ hdmi_log_buf_size=0; } } amhdmi_tx_device = platform_device_alloc(DEVICE_NAME,0); if (!amhdmi_tx_device) { pr_error("failed to alloc amhdmi_tx_device\n"); return -ENOMEM; } if(platform_device_add(amhdmi_tx_device)){ platform_device_put(amhdmi_tx_device); pr_error("failed to add amhdmi_tx_device\n"); return -ENODEV; } if (platform_driver_register(&amhdmitx_driver)) { pr_error("failed to register amhdmitx module\n"); platform_device_del(amhdmi_tx_device); platform_device_put(amhdmi_tx_device); return -ENODEV; } return 0; }
int mc34708_register_regulator(struct mc34708 *mc34708, int reg, struct regulator_init_data *initdata) { struct platform_device *pdev; int ret; if (mc34708->pmic.pdev[reg]) return -EBUSY; pdev = platform_device_alloc("mc34708-regulatr", reg); if (!pdev) return -ENOMEM; mc34708->pmic.pdev[reg] = pdev; initdata->driver_data = mc34708; pdev->dev.platform_data = initdata; pdev->dev.parent = mc34708->dev; ret = platform_device_add(pdev); if (ret != 0) { dev_err(mc34708->dev, "Failed to register regulator %d: %d\n", reg, ret); platform_device_del(pdev); mc34708->pmic.pdev[reg] = NULL; } return ret; }
static int __init osk_soc_init(void) { int err; u32 curRate; struct device *dev; if (!(machine_is_omap_osk())) return -ENODEV; osk_snd_device = platform_device_alloc("soc-audio", -1); if (!osk_snd_device) return -ENOMEM; platform_set_drvdata(osk_snd_device, &osk_snd_devdata); osk_snd_devdata.dev = &osk_snd_device->dev; *(unsigned int *)osk_dai.cpu_dai->private_data = 0; /* McBSP1 */ err = platform_device_add(osk_snd_device); if (err) goto err1; dev = &osk_snd_device->dev; tlv320aic23_mclk = clk_get(dev, "mclk"); if (IS_ERR(tlv320aic23_mclk)) { printk(KERN_ERR "Could not get mclk clock\n"); return -ENODEV; } if (clk_get_usecount(tlv320aic23_mclk) > 0) { /* MCLK is already in use */ printk(KERN_WARNING "MCLK in use at %d Hz. We change it to %d Hz\n", (uint) clk_get_rate(tlv320aic23_mclk), CODEC_CLOCK); } /* * Configure 12 MHz output on MCLK. */ curRate = (uint) clk_get_rate(tlv320aic23_mclk); if (curRate != CODEC_CLOCK) { if (clk_set_rate(tlv320aic23_mclk, CODEC_CLOCK)) { printk(KERN_ERR "Cannot set MCLK for AIC23 CODEC\n"); err = -ECANCELED; goto err1; } } printk(KERN_INFO "MCLK = %d [%d], usecount = %d\n", (uint) clk_get_rate(tlv320aic23_mclk), CODEC_CLOCK, clk_get_usecount(tlv320aic23_mclk)); return 0; err1: clk_put(tlv320aic23_mclk); platform_device_del(osk_snd_device); platform_device_put(osk_snd_device); return err; }
static int __devinit aml_pmu_probe(struct i2c_client *client, const struct i2c_device_id *id) { struct platform_device *pdev; int ret; /* * allocate and regist AML1212 devices, then kernel will probe driver for AML1212 */ #ifdef CONFIG_AML1212 pdev = platform_device_alloc(AML1212_SUPPLY_NAME, AML1212_SUPPLY_ID); if (pdev == NULL) { printk(">> %s, allocate platform device failed\n", __func__); return -ENOMEM; } pdev->dev.parent = &client->dev; pdev->dev.platform_data = client->dev.platform_data; ret = platform_device_add(pdev); if (ret) { printk(">> %s, add platform device failed\n", __func__); platform_device_del(pdev); return -EINVAL; } i2c_set_clientdata(client, pdev); #endif return 0; }
static int test_init(void) { int ret; ret = platform_driver_register(&test_driver); if (ret) return ret; test_pdev = platform_device_alloc("rpm_test", 0); if (!test_pdev) { ret = -EINVAL; goto err_alloc_null; } if (IS_ERR(test_pdev)) { ret = PTR_ERR(test_pdev); goto err_alloc_null; } ret = platform_device_add(test_pdev); if (ret) { platform_device_put(test_pdev); goto err_add; } return 0; err_add: platform_device_del(test_pdev); err_alloc_null: platform_driver_unregister(&test_driver); return ret; }
static int asus_platform_init(struct asus_laptop *asus) { int result; asus->platform_device = platform_device_alloc(ASUS_LAPTOP_FILE, -1); if (!asus->platform_device) return -ENOMEM; platform_set_drvdata(asus->platform_device, asus); result = platform_device_add(asus->platform_device); if (result) goto fail_platform_device; result = sysfs_create_group(&asus->platform_device->dev.kobj, &asus_attr_group); if (result) goto fail_sysfs; return 0; fail_sysfs: platform_device_del(asus->platform_device); fail_platform_device: platform_device_put(asus->platform_device); return result; }
static int asus_platform_init(struct asus_laptop *asus) { int err; asus->platform_device = platform_device_alloc(ASUS_LAPTOP_FILE, -1); if (!asus->platform_device) return -ENOMEM; platform_set_drvdata(asus->platform_device, asus); err = platform_device_add(asus->platform_device); if (err) goto fail_platform_device; err = asus_sysfs_init(asus); if (err) goto fail_sysfs; return 0; fail_sysfs: asus_sysfs_exit(asus); platform_device_del(asus->platform_device); fail_platform_device: platform_device_put(asus->platform_device); return err; }
static void bridge_disconnect(struct usb_interface *intf) { struct data_bridge *dev = usb_get_intfdata(intf); struct list_head *head; struct urb *rx_urb; unsigned long flags; if (!dev) { err("%s: data device not found\n", __func__); return; } ch_id--; ctrl_bridge_disconnect(ch_id); platform_device_del(dev->pdev); usb_set_intfdata(intf, NULL); __dev[ch_id] = NULL; cancel_work_sync(&dev->process_rx_w); cancel_work_sync(&dev->kevent); /*free rx urbs*/ head = &dev->rx_idle; spin_lock_irqsave(&dev->rx_done.lock, flags); while (!list_empty(head)) { rx_urb = list_entry(head->next, struct urb, urb_list); list_del(&rx_urb->urb_list); usb_free_urb(rx_urb); } spin_unlock_irqrestore(&dev->rx_done.lock, flags); usb_put_dev(dev->udev); kfree(dev); }
int wm8350_register_regulator(struct wm8350 *wm8350, int reg, struct regulator_init_data *initdata) { struct platform_device *pdev; int ret; if (wm8350->pmic.pdev[reg]) return -EBUSY; pdev = platform_device_alloc("wm8350-regulator", reg); if (!pdev) return -ENOMEM; wm8350->pmic.pdev[reg] = pdev; initdata->driver_data = wm8350; pdev->dev.platform_data = initdata; pdev->dev.parent = wm8350->dev; platform_set_drvdata(pdev, wm8350); ret = platform_device_add(pdev); if (ret != 0) { dev_err(wm8350->dev, "Failed to register regulator %d: %d\n", reg, ret); platform_device_del(pdev); wm8350->pmic.pdev[reg] = NULL; } return ret; }
static int d2083_register_regulator(struct d2083 *d2083, int reg, struct regulator_init_data *initdata) { struct platform_device *pdev; int ret; if (reg < D2083_BUCK_1 || reg >= D2083_NUMBER_OF_REGULATORS) return -EINVAL; if (d2083->pmic.pdev[reg]) return -EBUSY; pdev = platform_device_alloc(DRIVER_NAME, reg); if (!pdev) return -ENOMEM; d2083->pmic.pdev[reg] = pdev; initdata->driver_data = d2083; pdev->dev.platform_data = initdata; pdev->dev.parent = d2083->dev; platform_set_drvdata(pdev, d2083); ret = platform_device_add(pdev); if (ret != 0) { dev_err(d2083->dev, "Failed to register regulator %d: %d\n", reg, ret); platform_device_del(pdev); d2083->pmic.pdev[reg] = NULL; } return ret; }
static int __init smdk_init(void) { int ret; smdk_snd_wm9713_device = platform_device_alloc("wm9713-codec", -1); if (!smdk_snd_wm9713_device) return -ENOMEM; ret = platform_device_add(smdk_snd_wm9713_device); if (ret) goto err1; smdk_snd_ac97_device = platform_device_alloc("soc-audio", -1); if (!smdk_snd_ac97_device) { ret = -ENOMEM; goto err2; } platform_set_drvdata(smdk_snd_ac97_device, &smdk); ret = platform_device_add(smdk_snd_ac97_device); if (ret) goto err3; return 0; err3: platform_device_put(smdk_snd_ac97_device); err2: platform_device_del(smdk_snd_wm9713_device); err1: platform_device_put(smdk_snd_wm9713_device); return ret; }
static int __exit cpcap_usb_det_remove(struct platform_device *pdev) { struct cpcap_usb_det_data *data = platform_get_drvdata(pdev); cpcap_irq_free(data->cpcap, CPCAP_IRQ_CHRG_DET); cpcap_irq_free(data->cpcap, CPCAP_IRQ_CHRG_CURR1); cpcap_irq_free(data->cpcap, CPCAP_IRQ_SE1); cpcap_irq_free(data->cpcap, CPCAP_IRQ_IDGND); cpcap_irq_free(data->cpcap, CPCAP_IRQ_VBUSVLD); #ifdef CONFIG_TTA_CHARGER cpcap_irq_free(data->cpcap, CPCAP_IRQ_DMI); free_irq(OMAP_GPIO_IRQ(TTU_TTA_CHRG_DET_N_GPIO), 0); gpio_free(TTU_TTA_CHRG_DET_N_GPIO); #endif configure_hardware(data, CPCAP_ACCY_NONE); cancel_delayed_work_sync(&data->work); if ((data->usb_accy != CPCAP_ACCY_NONE) && (data->usb_dev != NULL)) platform_device_del(data->usb_dev); vusb_disable(data); regulator_put(data->regulator); wake_lock_destroy(&data->wake_lock); kfree(data); return 0; }
static int __init tc1100_init(void) { int error; if (!wmi_has_guid(GUID)) return -ENODEV; tc1100_device = platform_device_alloc("tc1100-wmi", -1); if (!tc1100_device) return -ENOMEM; error = platform_device_add(tc1100_device); if (error) goto err_device_put; error = platform_driver_probe(&tc1100_driver, tc1100_probe); if (error) goto err_device_del; pr_info("HP Compaq TC1100 Tablet WMI Extras loaded\n"); return 0; err_device_del: platform_device_del(tc1100_device); err_device_put: platform_device_put(tc1100_device); return error; }
int max17135_register_regulator(struct max17135 *max17135, int reg, struct regulator_init_data *initdata) { struct platform_device *pdev; int ret; struct i2c_client *client = max17135->i2c_client; /* If we can't find PMIC via I2C, we should not register regulators */ if (i2c_smbus_read_byte_data(client, REG_MAX17135_PRODUCT_REV) != 0) { dev_err(max17135->dev, "Max17135 PMIC not found!\n"); return -ENXIO; } if (max17135->pdev[reg]) return -EBUSY; pdev = platform_device_alloc("max17135-reg", reg); if (!pdev) return -ENOMEM; max17135->pdev[reg] = pdev; initdata->driver_data = max17135; pdev->dev.platform_data = initdata; pdev->dev.parent = max17135->dev; platform_set_drvdata(pdev, max17135); ret = platform_device_add(pdev); if (ret != 0) { dev_err(max17135->dev, "Failed to register regulator %d: %d\n", reg, ret); platform_device_del(pdev); max17135->pdev[reg] = NULL; } if (!max17135->init_done) { max17135->pass_num = max17135_pass_num; max17135->vcom_uV = max17135_vcom; /* * Set up PMIC timing values. * Should only be done one time! Timing values may only be * changed a limited number of times according to spec. */ max17135_setup_timings(max17135); max17135->pwrgood_polarity = gpio_get_value(max17135->gpio_pmic_pwrgood); max17135->init_done = true; } return ret; }
static int __devexit aml_pmu_remove(struct i2c_client *client) { struct platform_device *pdev = i2c_get_clientdata(client); platform_device_del(pdev); return 0; }
static int __init osk_soc_init(void) { int err; u32 curRate; struct device *dev; if (!(machine_is_omap_osk())) return -ENODEV; osk_snd_device = platform_device_alloc("soc-audio", -1); if (!osk_snd_device) return -ENOMEM; platform_set_drvdata(osk_snd_device, &snd_soc_card_osk); err = platform_device_add(osk_snd_device); if (err) goto err1; dev = &osk_snd_device->dev; tlv320aic23_mclk = clk_get(dev, "mclk"); if (IS_ERR(tlv320aic23_mclk)) { printk(KERN_ERR "Could not get mclk clock\n"); err = PTR_ERR(tlv320aic23_mclk); goto err2; } /* * Configure 12 MHz output on MCLK. */ curRate = (uint) clk_get_rate(tlv320aic23_mclk); if (curRate != CODEC_CLOCK) { if (clk_set_rate(tlv320aic23_mclk, CODEC_CLOCK)) { printk(KERN_ERR "Cannot set MCLK for AIC23 CODEC\n"); err = -ECANCELED; goto err3; } } #ifdef CONFIG_DEBUG_PRINTK printk(KERN_INFO "MCLK = %d [%d]\n", (uint) clk_get_rate(tlv320aic23_mclk), CODEC_CLOCK); #else ; #endif return 0; err3: clk_put(tlv320aic23_mclk); err2: platform_device_del(osk_snd_device); err1: platform_device_put(osk_snd_device); return err; }
static int __init gpu_init(void) { int ret = 0; #ifndef CONFIG_DOVE_GPU gpu_resources[0].start = gpu_resources[0].end = irqLine; gpu_resources[1].start = registerMemBase; gpu_resources[1].end = registerMemBase + registerMemSize - 1; gpu_resources[2].start = contiguousBase; gpu_resources[2].end = contiguousBase + contiguousSize - 1; /*####modified for marvell-bg2*/ /* Allocate device */ gpu_device = platform_device_alloc(DRV_NAME, -1); /*####end for marvell-bg2*/ if (!gpu_device) { printk(KERN_ERR "galcore: platform_device_alloc failed.\n"); ret = -ENOMEM; goto out; } /* Insert resource */ ret = platform_device_add_resources(gpu_device, gpu_resources, 3); if (ret) { printk(KERN_ERR "galcore: platform_device_add_resources failed.\n"); goto put_dev; } /* Add device */ ret = platform_device_add(gpu_device); if (ret) { printk(KERN_ERR "galcore: platform_device_add failed.\n"); goto put_dev; } #endif ret = platform_driver_register(&gpu_driver); if (!ret) { goto out; } #ifndef CONFIG_DOVE_GPU platform_device_del(gpu_device); put_dev: platform_device_put(gpu_device); #endif out: return ret; }
static void ev3dev_ui_exit(void) { ModuleExit(); sysfs_remove_group(&ui->dev.kobj, &ev3dev_ui_attr_group); platform_device_del( ui ); platform_device_put( ui ); }
static void __exit battery_exit(void) { if (battery_platform_device) { platform_device_del(battery_platform_device); platform_device_put(battery_platform_device); } platform_driver_unregister(&battery_driver); }
static void notify_accy(struct cpcap_usb_det_data *data, enum cpcap_accy accy) { dev_info(&data->cpcap->spi->dev, "notify_accy: accy=%d\n", accy); if ((data->usb_accy != CPCAP_ACCY_NONE) && (data->usb_dev != NULL)) { platform_device_del(data->usb_dev); data->usb_dev = NULL; } configure_hardware(data, accy); data->usb_accy = accy; if (accy != CPCAP_ACCY_NONE) { data->usb_dev = platform_device_alloc(accy_devices[accy], -1); if (data->usb_dev) { data->usb_dev->dev.platform_data = data->cpcap; platform_device_add(data->usb_dev); } } else vusb_disable(data); if ((accy == CPCAP_ACCY_USB) || (accy == CPCAP_ACCY_FACTORY)) { if (!data->usb_connected_dev) { data->usb_connected_dev = platform_device_alloc("cpcap_usb_connected", -1); platform_device_add(data->usb_connected_dev); } } else if (data->usb_connected_dev) { platform_device_del(data->usb_connected_dev); data->usb_connected_dev = NULL; } if (accy == CPCAP_ACCY_CHARGER) { if (!data->charger_connected_dev) { data->charger_connected_dev = platform_device_alloc("cpcap_charger_connected", -1); platform_device_add(data->charger_connected_dev); } } else if (data->charger_connected_dev) { platform_device_del(data->charger_connected_dev); data->charger_connected_dev = NULL; } }
static int __devexit wl1271_remove(struct spi_device *spi) { struct wl12xx_spi_glue *glue = spi_get_drvdata(spi); platform_device_del(glue->core); platform_device_put(glue->core); kfree(glue); return 0; }
static int __devexit omap2430_remove(struct platform_device *pdev) { struct omap2430_glue *glue = platform_get_drvdata(pdev); platform_device_del(glue->musb); platform_device_put(glue->musb); kfree(glue); return 0; }
static void pme2_low_exit(void) { platform_device_del(pdev); platform_device_put(pdev); pdev = NULL; kmem_cache_destroy(slab_fq); kmem_cache_destroy(slab_flow); kmem_cache_destroy(slab_residue); slab_fq = slab_flow = slab_residue = NULL; }
static int __init gpu_init(void) { int ret = 0; #ifndef CONFIG_DOVE_GPU #if !MRVL_USE_GPU_RESERVE_MEM gpu_resources[0].start = gpu_resources[0].end = irqLine; gpu_resources[1].start = registerMemBase; gpu_resources[1].end = registerMemBase + registerMemSize - 1; /* Allocate device */ gpu_device = platform_device_alloc(DEVICE_NAME, -1); if (!gpu_device) { printk(KERN_ERR "galcore: platform_device_alloc failed.\n"); ret = -ENOMEM; goto out; } /* Insert resource */ ret = platform_device_add_resources(gpu_device, gpu_resources, 2); if (ret) { printk(KERN_ERR "galcore: platform_device_add_resources failed.\n"); goto put_dev; } /* Add device */ ret = platform_device_add(gpu_device); if (ret) { printk(KERN_ERR "galcore: platform_device_add failed.\n"); goto put_dev; } #endif #endif ret = platform_driver_register(&gpu_driver); if (!ret) { goto out; } #ifndef CONFIG_DOVE_GPU #if !MRVL_USE_GPU_RESERVE_MEM platform_device_del(gpu_device); put_dev: platform_device_put(gpu_device); #endif #endif out: return ret; }
static int dwc3_pci_register_phys(struct dwc3_pci *glue) { struct usb_phy_generic_platform_data pdata; struct platform_device *pdev; int ret; memset(&pdata, 0x00, sizeof(pdata)); pdev = platform_device_alloc("usb_phy_generic", 0); if (!pdev) return -ENOMEM; glue->usb2_phy = pdev; pdata.type = USB_PHY_TYPE_USB2; pdata.gpio_reset = -1; ret = platform_device_add_data(glue->usb2_phy, &pdata, sizeof(pdata)); if (ret) goto err1; pdev = platform_device_alloc("usb_phy_generic", 1); if (!pdev) { ret = -ENOMEM; goto err1; } glue->usb3_phy = pdev; pdata.type = USB_PHY_TYPE_USB3; ret = platform_device_add_data(glue->usb3_phy, &pdata, sizeof(pdata)); if (ret) goto err2; ret = platform_device_add(glue->usb2_phy); if (ret) goto err2; ret = platform_device_add(glue->usb3_phy); if (ret) goto err3; return 0; err3: platform_device_del(glue->usb2_phy); err2: platform_device_put(glue->usb3_phy); err1: platform_device_put(glue->usb2_phy); return ret; }