static int ux500_pd_amba_resume_noirq(struct device *dev) { struct pm_runtime_data *prd = __to_prd(dev); int (*callback)(struct device *) = NULL; int ret = 0; bool is_suspended = pm_runtime_status_suspended(dev); dev_vdbg(dev, "%s()\n", __func__); /* * Do not bypass AMBA bus pm functions by calling generic * pm directly. A future fix could be to implement a * "pm_bus_generic_*" API which we can use instead. */ if (dev->bus && dev->bus->pm) callback = dev->bus->pm->resume_noirq; if (callback) ret = callback(dev); else ret = pm_generic_resume_noirq(dev); if (!ret && !is_suspended) ux500_pd_enable(prd); return ret; }
static void mali_dvfs_event_proc(struct work_struct *w) { #ifdef CONFIG_MALI_DEVFREQ if (mali_devfreq) { mutex_lock(&mali_devfreq->lock); update_devfreq(mali_devfreq); mutex_unlock(&mali_devfreq->lock); } return 0; #else mali_dvfs_status *dvfs_status; mutex_lock(&mali_enable_clock_lock); dvfs_status = &mali_dvfs_status_current; mali_dvfs_decide_next_level(dvfs_status); if (dvfs_status->step >= dvfs_step_max) dvfs_status->step = dvfs_step_max-1; if (dvfs_status->step < dvfs_step_min) dvfs_status->step = dvfs_step_min; if (!pm_runtime_status_suspended(dvfs_status->kbdev->osdev.dev)) kbase_platform_dvfs_set_level(dvfs_status->kbdev, dvfs_status->step); mutex_unlock(&mali_enable_clock_lock); #endif }
static int pm_callback_power_on(struct kbase_device *kbdev) { int result; int ret_val; struct device *dev = kbdev->dev; #if (HARD_RESET_AT_POWER_OFF != 1) if (!pm_runtime_status_suspended(dev)) ret_val = 0; else #endif ret_val = 1; if (unlikely(dev->power.disable_depth > 0)) { kbase_platform_on(kbdev); } else { result = pm_runtime_resume(dev); if (result < 0 && result == -EAGAIN) kbase_platform_on(kbdev); else if (result < 0) printk("[mali-midgard] pm_runtime_resume failed (%d)\n", result); } return ret_val; }
static int _od_suspend_noirq(struct device *dev) { struct platform_device *pdev = to_platform_device(dev); struct omap_device *od = to_omap_device(pdev); int ret; /* Don't attempt late suspend on a driver that is not bound */ if (od->_driver_status != BUS_NOTIFY_BOUND_DRIVER) return 0; ret = pm_generic_suspend_noirq(dev); if (!ret && !pm_runtime_status_suspended(dev)) { if (pm_generic_runtime_suspend(dev) == 0) { if (!pm_runtime_suspended(dev)) { /* NOTE: *might* indicate driver race */ dev_dbg(dev, "%s: Force suspending\n", __func__); pm_runtime_set_suspended(dev); od->flags |= OMAP_DEVICE_SUSPEND_FORCED; } omap_device_idle(pdev); od->flags |= OMAP_DEVICE_SUSPENDED; } } return ret; }
static inline void pm_callback_resume(struct kbase_device *kbdev) { if (!pm_runtime_status_suspended(kbdev->dev)) pm_callback_runtime_on(kbdev); else pm_callback_power_on(kbdev); }
static int pm_callback_power_on(kbase_device *kbdev) { int result; int ret_val; struct kbase_os_device *osdev = &kbdev->osdev; struct exynos_context *platform; platform = (struct exynos_context *) kbdev->platform_context; if (pm_runtime_status_suspended(osdev->dev)) ret_val = 1; else ret_val = 0; if(osdev->dev->power.disable_depth > 0) { if(platform->cmu_pmu_status == 0) kbase_platform_cmu_pmu_control(kbdev, 1); return ret_val; } result = pm_runtime_resume(osdev->dev); if(result < 0 && result == -EAGAIN) kbase_platform_cmu_pmu_control(kbdev, 1); else if(result < 0) OSK_PRINT_ERROR(OSK_BASE_PM, "pm_runtime_get_sync failed (%d)\n", result); return ret_val; }
static int img_i2s_out_dev_remove(struct platform_device *pdev) { pm_runtime_disable(&pdev->dev); if (!pm_runtime_status_suspended(&pdev->dev)) img_i2s_out_runtime_suspend(&pdev->dev); return 0; }
static int mt6797_afe_pcm_dev_remove(struct platform_device *pdev) { pm_runtime_disable(&pdev->dev); if (!pm_runtime_status_suspended(&pdev->dev)) mt6797_afe_runtime_suspend(&pdev->dev); pm_runtime_put_sync(&pdev->dev); return 0; }
/** * exynos_drd_switch_start_host - helper function for starting/stoping the host * controller driver. * * @otg: Pointer to the usb_otg structure. * @on: start / stop the host controller driver. * * Returns 0 on success otherwise negative errno. */ static int exynos_drd_switch_start_host(struct usb_otg *otg, int on) { struct exynos_drd_switch *drd_switch = container_of(otg, struct exynos_drd_switch, otg); struct usb_hcd *hcd; struct device *xhci_dev; int ret = 0; if (!otg->host) return -EINVAL; dev_dbg(otg->phy->dev, "Turn %s host %s\n", on ? "on" : "off", otg->host->bus_name); hcd = bus_to_hcd(otg->host); xhci_dev = hcd->self.controller; if (on) { #if !defined(CONFIG_USB_HOST_NOTIFY) wake_lock(&drd_switch->wakelock); #endif /* * Clear runtime_error flag. The flag could be * set when user space accessed the host while DRD * was in B-Dev mode. */ pm_runtime_disable(xhci_dev); if (pm_runtime_status_suspended(xhci_dev)) pm_runtime_set_suspended(xhci_dev); else pm_runtime_set_active(xhci_dev); pm_runtime_enable(xhci_dev); ret = pm_runtime_get_sync(xhci_dev); if (ret < 0 && ret != -EINPROGRESS) { pm_runtime_put_noidle(xhci_dev); goto err; } exynos_drd_switch_ases_vbus_ctrl(drd_switch, 1); } else { exynos_drd_switch_ases_vbus_ctrl(drd_switch, 0); ret = pm_runtime_put_sync(xhci_dev); if (ret == -EAGAIN) pm_runtime_get_noresume(xhci_dev); #if !defined(CONFIG_USB_HOST_NOTIFY) else wake_unlock(&drd_switch->wakelock); #endif } err: /* ret can be 1 after pm_runtime_get_sync */ return (ret < 0) ? ret : 0; }
static int tegra20_spdif_platform_remove(struct platform_device *pdev) { pm_runtime_disable(&pdev->dev); if (!pm_runtime_status_suspended(&pdev->dev)) tegra20_spdif_runtime_suspend(&pdev->dev); tegra_pcm_platform_unregister(&pdev->dev); snd_soc_unregister_component(&pdev->dev); return 0; }
static int sirf_usp_pcm_suspend(struct device *dev) { struct sirf_usp *usp = dev_get_drvdata(dev); if (!pm_runtime_status_suspended(dev)) { regmap_read(usp->regmap, USP_MODE1, &usp->mode1_reg); regmap_read(usp->regmap, USP_MODE2, &usp->mode2_reg); sirf_usp_pcm_runtime_suspend(dev); } return 0; }
static int tegra30_ahub_remove(struct platform_device *pdev) { if (!ahub) return -ENODEV; pm_runtime_disable(&pdev->dev); if (!pm_runtime_status_suspended(&pdev->dev)) tegra30_ahub_runtime_suspend(&pdev->dev); return 0; }
/** * dwc3_ext_event_notify - callback to handle events from external transceiver * @otg: Pointer to the otg transceiver structure * @event: Event reported by transceiver * * Returns 0 on success */ static void dwc3_ext_event_notify(struct usb_otg *otg, enum dwc3_ext_events event) { static bool init; struct dwc3_otg *dotg = container_of(otg, struct dwc3_otg, otg); struct dwc3_ext_xceiv *ext_xceiv = dotg->ext_xceiv; struct usb_phy *phy = dotg->otg.phy; int ret = 0; if (event == DWC3_EVENT_PHY_RESUME) { if (!pm_runtime_status_suspended(phy->dev)) { dev_warn(phy->dev, "PHY_RESUME event out of LPM!!!!\n"); } else { dev_dbg(phy->dev, "ext PHY_RESUME event received\n"); /* ext_xceiver would have taken h/w out of LPM by now */ ret = pm_runtime_get(phy->dev); if (ret == -EACCES) { /* pm_runtime_get may fail during system resume with -EACCES error */ pm_runtime_disable(phy->dev); pm_runtime_set_active(phy->dev); pm_runtime_enable(phy->dev); } else if (ret < 0) { dev_warn(phy->dev, "pm_runtime_get failed!\n"); } } } else if (event == DWC3_EVENT_XCEIV_STATE) { if (ext_xceiv->id == DWC3_ID_FLOAT) { dev_dbg(phy->dev, "XCVR: ID set\n"); set_bit(ID, &dotg->inputs); } else { dev_dbg(phy->dev, "XCVR: ID clear\n"); clear_bit(ID, &dotg->inputs); } if (ext_xceiv->bsv) { dev_dbg(phy->dev, "XCVR: BSV set\n"); set_bit(B_SESS_VLD, &dotg->inputs); } else { dev_dbg(phy->dev, "XCVR: BSV clear\n"); clear_bit(B_SESS_VLD, &dotg->inputs); } if (!init) { init = true; complete(&dotg->dwc3_xcvr_vbus_init); dev_dbg(phy->dev, "XCVR: BSV init complete\n"); return; } schedule_work(&dotg->sm_work); } }
static int img_spdif_out_dev_remove(struct platform_device *pdev) { struct img_spdif_out *spdif = platform_get_drvdata(pdev); pm_runtime_disable(&pdev->dev); if (!pm_runtime_status_suspended(&pdev->dev)) img_spdif_out_suspend(&pdev->dev); clk_disable_unprepare(spdif->clk_sys); return 0; }
static int rockchip_i2s_remove(struct platform_device *pdev) { struct rk_i2s_dev *i2s = dev_get_drvdata(&pdev->dev); pm_runtime_disable(&pdev->dev); if (!pm_runtime_status_suspended(&pdev->dev)) i2s_runtime_suspend(&pdev->dev); clk_disable_unprepare(i2s->mclk); clk_disable_unprepare(i2s->hclk); return 0; }
/** * dev_pm_disarm_wake_irq - Disarm device wake-up * @wirq: Device wake-up interrupt * * Clears up the wake-up event conditionally based on the * device_may_wake(). */ void dev_pm_disarm_wake_irq(struct wake_irq *wirq) { if (!wirq) return; if (device_may_wakeup(wirq->dev)) { disable_irq_wake(wirq->irq); if (wirq->status & WAKE_IRQ_DEDICATED_ALLOCATED && !pm_runtime_status_suspended(wirq->dev)) disable_irq_nosync(wirq->irq); } }
static int sirf_usp_pcm_resume(struct device *dev) { struct sirf_usp *usp = dev_get_drvdata(dev); int ret; if (!pm_runtime_status_suspended(dev)) { ret = sirf_usp_pcm_runtime_resume(dev); if (ret) return ret; regmap_write(usp->regmap, USP_MODE1, usp->mode1_reg); regmap_write(usp->regmap, USP_MODE2, usp->mode2_reg); } return 0; }
static int gpu_power_on(kbase_device *kbdev) { int ret_val; struct kbase_os_device *osdev = &kbdev->osdev; if (pm_runtime_status_suspended(osdev->dev)) ret_val = 1; else ret_val = 0; pm_runtime_resume(osdev->dev); return ret_val; }
static int tegra20_spdif_platform_remove(struct platform_device *pdev) { struct tegra20_spdif *spdif = dev_get_drvdata(&pdev->dev); pm_runtime_disable(&pdev->dev); if (!pm_runtime_status_suspended(&pdev->dev)) tegra20_spdif_runtime_suspend(&pdev->dev); tegra_pcm_platform_unregister(&pdev->dev); snd_soc_unregister_dai(&pdev->dev); clk_put(spdif->clk_spdif_out); return 0; }
static int tegra30_dam_remove(struct platform_device *pdev) { struct tegra30_dam_context *dam; pm_runtime_disable(&pdev->dev); if (!pm_runtime_status_suspended(&pdev->dev)) tegra30_dam_runtime_suspend(&pdev->dev); dam = platform_get_drvdata(pdev); clk_put(dam->dam_clk); tegra30_dam_debug_remove(dam); dams_cont_info[pdev->id] = NULL; return 0; }
static int rockchip_i2s_remove(struct platform_device *pdev) { struct rk_i2s_dev *i2s = dev_get_drvdata(&pdev->dev); pm_runtime_disable(&pdev->dev); if (!pm_runtime_status_suspended(&pdev->dev)) i2s_runtime_suspend(&pdev->dev); clk_disable_unprepare(i2s->mclk); clk_disable_unprepare(i2s->hclk); snd_dmaengine_pcm_unregister(&pdev->dev); snd_soc_unregister_component(&pdev->dev); return 0; }
static int sun8i_codec_remove(struct platform_device *pdev) { struct snd_soc_card *card = platform_get_drvdata(pdev); struct sun8i_codec *scodec = snd_soc_card_get_drvdata(card); pm_runtime_disable(&pdev->dev); if (!pm_runtime_status_suspended(&pdev->dev)) sun8i_codec_runtime_suspend(&pdev->dev); snd_soc_unregister_codec(&pdev->dev); clk_disable_unprepare(scodec->clk_module); clk_disable_unprepare(scodec->clk_bus); return 0; }
static int _od_resume_noirq(struct device *dev) { struct platform_device *pdev = to_platform_device(dev); struct omap_device *od = to_omap_device(pdev); if ((od->flags & OMAP_DEVICE_SUSPENDED) && !pm_runtime_status_suspended(dev)) { od->flags &= ~OMAP_DEVICE_SUSPENDED; if (!(od->flags & OMAP_DEVICE_NO_IDLE_ON_SUSPEND)) omap_device_enable(pdev); pm_generic_runtime_resume(dev); } return pm_generic_resume_noirq(dev); }
static int tegra20_i2s_platform_remove(struct platform_device *pdev) { struct tegra20_i2s *i2s = dev_get_drvdata(&pdev->dev); pm_runtime_disable(&pdev->dev); if (!pm_runtime_status_suspended(&pdev->dev)) tegra20_i2s_runtime_suspend(&pdev->dev); tegra_pcm_platform_unregister(&pdev->dev); snd_soc_unregister_component(&pdev->dev); clk_put(i2s->clk_i2s); return 0; }
static int mlx90614_remove(struct i2c_client *client) { struct iio_dev *indio_dev = i2c_get_clientdata(client); struct mlx90614_data *data = iio_priv(indio_dev); iio_device_unregister(indio_dev); if (data->wakeup_gpio) { pm_runtime_disable(&client->dev); if (!pm_runtime_status_suspended(&client->dev)) mlx90614_sleep(data); pm_runtime_set_suspended(&client->dev); } return 0; }
static int tegra30_ahub_remove(struct platform_device *pdev) { if (!ahub) return -ENODEV; pm_runtime_disable(&pdev->dev); if (!pm_runtime_status_suspended(&pdev->dev)) tegra30_ahub_runtime_suspend(&pdev->dev); clk_put(ahub->clk_apbif); clk_put(ahub->clk_d_audio); ahub = NULL; return 0; }
static int _od_suspend_noirq(struct device *dev) { struct platform_device *pdev = to_platform_device(dev); struct omap_device *od = to_omap_device(pdev); int ret; ret = pm_generic_suspend_noirq(dev); if (!ret && !pm_runtime_status_suspended(dev)) { if (pm_generic_runtime_suspend(dev) == 0) { if (!(od->flags & OMAP_DEVICE_NO_IDLE_ON_SUSPEND)) omap_device_idle(pdev); od->flags |= OMAP_DEVICE_SUSPENDED; } } return ret; }
static int img_spfi_remove(struct platform_device *pdev) { struct spi_master *master = platform_get_drvdata(pdev); struct img_spfi *spfi = spi_master_get_devdata(master); if (spfi->tx_ch) dma_release_channel(spfi->tx_ch); if (spfi->rx_ch) dma_release_channel(spfi->rx_ch); pm_runtime_disable(spfi->dev); if (!pm_runtime_status_suspended(spfi->dev)) { clk_disable_unprepare(spfi->spfi_clk); clk_disable_unprepare(spfi->sys_clk); } return 0; }
static int _omap_device_notifier_call(struct notifier_block *nb, unsigned long event, void *dev) { struct platform_device *pdev = to_platform_device(dev); struct omap_device *od; int err; switch (event) { case BUS_NOTIFY_REMOVED_DEVICE: if (pdev->archdata.od) omap_device_delete(pdev->archdata.od); break; case BUS_NOTIFY_UNBOUND_DRIVER: od = to_omap_device(pdev); if (od && (od->_state == OMAP_DEVICE_STATE_ENABLED)) { dev_info(dev, "enabled after unload, idling\n"); err = omap_device_idle(pdev); if (err) dev_err(dev, "failed to idle\n"); } break; case BUS_NOTIFY_BIND_DRIVER: od = to_omap_device(pdev); if (od && (od->_state == OMAP_DEVICE_STATE_ENABLED) && pm_runtime_status_suspended(dev)) { od->_driver_status = BUS_NOTIFY_BIND_DRIVER; pm_runtime_set_active(dev); } break; case BUS_NOTIFY_ADD_DEVICE: if (pdev->dev.of_node) omap_device_build_from_dt(pdev); omap_auxdata_legacy_init(dev); /* fall through */ default: od = to_omap_device(pdev); if (od) od->_driver_status = event; } return NOTIFY_DONE; }
static int escore_runtime_resume(struct device *dev) { struct escore_priv *escore = &escore_priv; struct device *p = dev->parent; int ret = 0; pr_info("%s(): @@@@@@ Entry #####\n", __func__); dev_dbg(dev, "%s()\n", __func__); if (p && pm_runtime_status_suspended(p)) { dev_err(dev, "%s() - parent is suspended\n", __func__); pm_runtime_resume(p); } INC_DISABLE_FW_RECOVERY_USE_CNT(escore); /* Resume functions will take care of enabling clock */ if (escore->voice_sense && escore->vs_ops.escore_is_voicesense_sleep_enable(escore)) ret = escore_vs_resume(dev); else ret = escore_non_vs_resume(dev); if (ret) goto escore_wakeup_fail_recovery; pm_runtime_mark_last_busy(escore->dev); dev_dbg(dev, "%s() complete %d\n", __func__, ret); DEC_DISABLE_FW_RECOVERY_USE_CNT(escore); pr_info("%s(): @@@@@@ EXIT #####\n", __func__); return ret; escore_wakeup_fail_recovery: DEC_DISABLE_FW_RECOVERY_USE_CNT(escore); ret = escore_fw_recovery(escore, FORCED_FW_RECOVERY_ON); if (ret < 0) { dev_err(dev, "%s() Firmware recovery failed %d\n", __func__, ret); } return ret; }