void wil_pm_runtime_allow(struct wil6210_priv *wil) { struct device *dev = wil_to_dev(wil); pm_runtime_put_noidle(dev); pm_runtime_set_autosuspend_delay(dev, WIL6210_AUTOSUSPEND_DELAY_MS); pm_runtime_use_autosuspend(dev); pm_runtime_allow(dev); }
/** * 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 omap2430_musb_init(struct musb *musb) { u32 l; int status = 0; struct device *dev = musb->controller; struct musb_hdrc_platform_data *plat = dev->platform_data; struct omap_musb_board_data *data = plat->board_data; musb->xceiv = usb_get_transceiver(); if (!musb->xceiv) { pr_err("HS USB OTG: no transceiver configured\n"); return -ENODEV; } INIT_WORK(&musb->otg_notifier_work, musb_otg_notifier_work); status = pm_runtime_get_sync(dev); if (status < 0) { dev_err(dev, "pm_runtime_get_sync FAILED %d\n", status); goto err1; } l = musb_readl(musb->mregs, OTG_INTERFSEL); if (data->interface_type == MUSB_INTERFACE_UTMI) { l &= ~ULPI_12PIN; l |= UTMI_8BIT; } else { l |= ULPI_12PIN; } musb_writel(musb->mregs, OTG_INTERFSEL, l); pr_debug("HS USB OTG: revision 0x%x, sysconfig 0x%02x, " "sysstatus 0x%x, intrfsel 0x%x, simenable 0x%x\n", musb_readl(musb->mregs, OTG_REVISION), musb_readl(musb->mregs, OTG_SYSCONFIG), musb_readl(musb->mregs, OTG_SYSSTATUS), musb_readl(musb->mregs, OTG_INTERFSEL), musb_readl(musb->mregs, OTG_SIMENABLE)); musb->nb.notifier_call = musb_otg_notifications; status = usb_register_notifier(musb->xceiv, &musb->nb); if (status) dev_dbg(musb->controller, "notification register failed\n"); setup_timer(&musb_idle_timer, musb_do_idle, (unsigned long) musb); pm_runtime_put_noidle(musb->controller); return 0; err1: return status; }
static int amba_remove(struct device *dev) { struct amba_device *pcdev = to_amba_device(dev); struct amba_driver *drv = to_amba_driver(dev->driver); int ret; pm_runtime_get_sync(dev); ret = drv->remove(pcdev); pm_runtime_put_noidle(dev); /* Undo the runtime PM settings in amba_probe() */ pm_runtime_disable(dev); pm_runtime_set_suspended(dev); pm_runtime_put_noidle(dev); amba_put_disable_pclk(pcdev); return ret; }
static int exynos_ohci_bus_suspend(struct usb_hcd *hcd) { int ret; ret = ohci_bus_suspend(hcd); /* Decrease pm_count that was increased at s5p_ehci_resume func. */ pm_runtime_put_noidle(hcd->self.controller); return ret; }
static int replicator_probe(struct platform_device *pdev) { int ret; struct device *dev = &pdev->dev; struct coresight_platform_data *pdata = NULL; struct replicator_drvdata *drvdata; struct coresight_desc desc = { 0 }; struct device_node *np = pdev->dev.of_node; if (np) { pdata = of_get_coresight_platform_data(dev, np); if (IS_ERR(pdata)) return PTR_ERR(pdata); pdev->dev.platform_data = pdata; } drvdata = devm_kzalloc(dev, sizeof(*drvdata), GFP_KERNEL); if (!drvdata) return -ENOMEM; drvdata->dev = &pdev->dev; drvdata->atclk = devm_clk_get(&pdev->dev, "atclk"); /* optional */ if (!IS_ERR(drvdata->atclk)) { ret = clk_prepare_enable(drvdata->atclk); if (ret) return ret; } pm_runtime_get_noresume(&pdev->dev); pm_runtime_set_active(&pdev->dev); pm_runtime_enable(&pdev->dev); platform_set_drvdata(pdev, drvdata); desc.type = CORESIGHT_DEV_TYPE_LINK; desc.subtype.link_subtype = CORESIGHT_DEV_SUBTYPE_LINK_SPLIT; desc.ops = &replicator_cs_ops; desc.pdata = pdev->dev.platform_data; desc.dev = &pdev->dev; drvdata->csdev = coresight_register(&desc); if (IS_ERR(drvdata->csdev)) { ret = PTR_ERR(drvdata->csdev); goto out_disable_pm; } pm_runtime_put(&pdev->dev); return 0; out_disable_pm: if (!IS_ERR(drvdata->atclk)) clk_disable_unprepare(drvdata->atclk); pm_runtime_put_noidle(&pdev->dev); pm_runtime_disable(&pdev->dev); return ret; }
int s5p_ehci_bus_suspend(struct usb_hcd *hcd) { int ret; ret = ehci_bus_suspend(hcd); /* Decrease pm_count that was increased at s5p_ehci_resume func. */ if (hcd->self.controller->power.runtime_auto) pm_runtime_put_noidle(hcd->self.controller); return ret; }
/** * usb_autopm_put_interface_no_suspend - decrement a USB interface's PM-usage counter * @intf: the usb_interface whose counter should be decremented * * This routine decrements @intf's usage counter but does not carry out an * autosuspend. * * This routine can run in atomic context. */ void usb_autopm_put_interface_no_suspend(struct usb_interface *intf) { struct usb_device *udev = interface_to_usbdev(intf); usb_mark_last_busy(udev); #if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,32)) atomic_dec(&intf->pm_usage_cnt); #else intf->pm_usage_cnt--; #endif pm_runtime_put_noidle(&intf->dev); }
static int cyttsp5_spi_read_default_nosize(struct cyttsp5_adapter *adap, void *buf, int max) { struct cyttsp5_spi *ts = dev_get_drvdata(adap->dev); int rc; pm_runtime_get_noresume(adap->dev); mutex_lock(&ts->lock); rc = cyttsp5_spi_read_default_nosize_(adap, buf, max); mutex_unlock(&ts->lock); pm_runtime_put_noidle(adap->dev); return rc; }
static int iommu_enable(struct omap_iommu *obj) { int ret; if (!arch_iommu) return -ENODEV; ret = pm_runtime_get_sync(obj->dev); if (ret < 0) pm_runtime_put_noidle(obj->dev); return ret < 0 ? ret : 0; }
static int cyttsp5_spi_write_read_specific(struct cyttsp5_adapter *adap, u8 write_len, u8 *write_buf, u8 *read_buf) { struct cyttsp5_spi *ts = dev_get_drvdata(adap->dev); int rc; pm_runtime_get_noresume(adap->dev); mutex_lock(&ts->lock); rc = cyttsp5_spi_write_read_specific_(adap, write_len, write_buf, read_buf); mutex_unlock(&ts->lock); pm_runtime_put_noidle(adap->dev); return rc; }
static int omap_rng_probe(struct platform_device *pdev) { struct omap_rng_dev *priv; struct resource *res; struct device *dev = &pdev->dev; int ret; priv = devm_kzalloc(dev, sizeof(struct omap_rng_dev), GFP_KERNEL); if (!priv) return -ENOMEM; omap_rng_ops.priv = (unsigned long)priv; platform_set_drvdata(pdev, priv); priv->dev = dev; res = platform_get_resource(pdev, IORESOURCE_MEM, 0); priv->base = devm_ioremap_resource(dev, res); if (IS_ERR(priv->base)) { ret = PTR_ERR(priv->base); goto err_ioremap; } pm_runtime_enable(&pdev->dev); ret = pm_runtime_get_sync(&pdev->dev); if (ret) { dev_err(&pdev->dev, "Failed to runtime_get device: %d\n", ret); pm_runtime_put_noidle(&pdev->dev); goto err_ioremap; } ret = (dev->of_node) ? of_get_omap_rng_device_details(priv, pdev) : get_omap_rng_device_details(priv); if (ret) goto err_ioremap; ret = hwrng_register(&omap_rng_ops); if (ret) goto err_register; dev_info(&pdev->dev, "OMAP Random Number Generator ver. %02x\n", omap_rng_read(priv, RNG_REV_REG)); return 0; err_register: priv->base = NULL; pm_runtime_disable(&pdev->dev); err_ioremap: dev_err(dev, "initialization failed.\n"); return ret; }
static int cyttsp4_i2c_write(struct cyttsp4_adapter *adap, u8 addr, const void *buf, int size) { struct cyttsp4_i2c *ts = dev_get_drvdata(adap->dev); int rc; pm_runtime_get_noresume(adap->dev); mutex_lock(&ts->lock); rc = cyttsp4_i2c_write_block_data(ts, addr, size, buf); mutex_unlock(&ts->lock); pm_runtime_put_noidle(adap->dev); return rc; }
static int pa12203001_set_power_state(struct pa12203001_data *data, bool on, u8 mask) { #ifdef CONFIG_PM int ret; if (on && (mask & PA12203001_ALS_EN_MASK)) { mutex_lock(&data->lock); if (data->px_enabled) { ret = pa12203001_als_enable(data, PA12203001_ALS_EN_MASK); if (ret < 0) goto err; } else { data->als_needs_enable = true; } mutex_unlock(&data->lock); } if (on && (mask & PA12203001_PX_EN_MASK)) { mutex_lock(&data->lock); if (data->als_enabled) { ret = pa12203001_px_enable(data, PA12203001_PX_EN_MASK); if (ret < 0) goto err; } else { data->px_needs_enable = true; } mutex_unlock(&data->lock); } if (on) { ret = pm_runtime_get_sync(&data->client->dev); if (ret < 0) pm_runtime_put_noidle(&data->client->dev); } else { pm_runtime_mark_last_busy(&data->client->dev); ret = pm_runtime_put_autosuspend(&data->client->dev); } return ret; err: mutex_unlock(&data->lock); return ret; #endif return 0; }
static int cyttsp4_spi_read(struct cyttsp4_adapter *adap, u16 addr, void *buf, int size, int max_xfer) { struct cyttsp4_spi *ts = dev_get_drvdata(adap->dev); int rc; pm_runtime_get_noresume(adap->dev); mutex_lock(&ts->lock); rc = cyttsp4_spi_read_block_data(ts, addr, size, buf, max_xfer); mutex_unlock(&ts->lock); pm_runtime_put_noidle(adap->dev); return rc; }
int wil_pm_runtime_get(struct wil6210_priv *wil) { int rc; struct device *dev = wil_to_dev(wil); rc = pm_runtime_get_sync(dev); if (rc < 0) { wil_err(wil, "pm_runtime_get_sync() failed, rc = %d\n", rc); pm_runtime_put_noidle(dev); return rc; } return 0; }
/** * irq_chip_pm_get - Enable power for an IRQ chip * @data: Pointer to interrupt specific data * * Enable the power to the IRQ chip referenced by the interrupt data * structure. */ int irq_chip_pm_get(struct irq_data *data) { int retval; if (IS_ENABLED(CONFIG_PM) && data->chip->parent_device) { retval = pm_runtime_get_sync(data->chip->parent_device); if (retval < 0) { pm_runtime_put_noidle(data->chip->parent_device); return retval; } } return 0; }
void kbase_device_runtime_put_sync(struct device *dev) { struct kbase_device *kbdev; kbdev = dev_get_drvdata(dev); if(delayed_work_pending(&kbdev->runtime_pm_workqueue)) { cancel_delayed_work_sync(&kbdev->runtime_pm_workqueue); } pm_runtime_put_noidle(kbdev->osdev.dev); schedule_delayed_work_on(0, &kbdev->runtime_pm_workqueue, RUNTIME_PM_DELAY_TIME/(1000/HZ)); #if MALI_RTPM_DEBUG printk( "---kbase_device_runtime_put_sync, usage_count=%d\n", atomic_read(&kbdev->osdev.dev->power.usage_count)); #endif }
static void st_tty_close(struct tty_struct *tty) { unsigned char i = ST_MAX_CHANNELS; unsigned long flags = 0; struct st_data_s *st_gdata = tty->disc_data; pr_info("%s ", __func__); /* TODO: * if a protocol has been registered & line discipline * un-installed for some reason - what should be done ? */ spin_lock_irqsave(&st_gdata->lock, flags); for (i = 0; i < ST_MAX_CHANNELS; i++) { if (st_gdata->is_registered[i] == true) pr_err("%d not un-registered", i); st_gdata->list[i] = NULL; st_gdata->is_registered[i] = false; } st_gdata->protos_registered = 0; spin_unlock_irqrestore(&st_gdata->lock, flags); /* * signal to UIM via KIM that - * N_TI_WL ldisc is un-installed */ st_kim_complete(st_gdata->kim_data); st_gdata->tty = NULL; /* Flush any pending characters in the driver and discipline. */ tty_ldisc_flush(tty); tty_driver_flush_buffer(tty); spin_lock_irqsave(&st_gdata->lock, flags); /* empty out txq and tx_waitq */ skb_queue_purge(&st_gdata->txq); skb_queue_purge(&st_gdata->tx_waitq); /* reset the TTY Rx states of ST */ st_gdata->rx_count = 0; st_gdata->rx_state = ST_W4_PACKET_TYPE; kfree_skb(st_gdata->rx_skb); st_gdata->rx_skb = NULL; spin_unlock_irqrestore(&st_gdata->lock, flags); pm_runtime_put_noidle(st_gdata->tty_dev); if (!pm_runtime_suspended(st_gdata->tty_dev)) __pm_runtime_idle(st_gdata->tty_dev, 0); pr_debug("%s: done ", __func__); }
static int __devexit apds9802als_remove(struct i2c_client *client) { struct als_data *data = i2c_get_clientdata(client); pm_runtime_get_sync(&client->dev); als_set_power_state(client, false); sysfs_remove_group(&client->dev.kobj, &m_als_gr); pm_runtime_disable(&client->dev); pm_runtime_set_suspended(&client->dev); pm_runtime_put_noidle(&client->dev); kfree(data); return 0; }
static int cyttsp4_i2c_write(struct cyttsp4_adapter *adap, u8 addr, const void *buf, int size) { struct cyttsp4_i2c *ts = dev_get_drvdata(adap->dev); int rc; lmdebug_dump_buf(buf, size, "cyttsp4_i2c_write"); pm_runtime_get_noresume(adap->dev); mutex_lock(&ts->lock); rc = cyttsp4_i2c_write_block_data(ts, addr, size, buf); mutex_unlock(&ts->lock); pm_runtime_put_noidle(adap->dev); //dev_dbg("%s: Done\n", __func__); return rc; }
static int dw8250_remove(struct platform_device *pdev) { struct dw8250_data *data = platform_get_drvdata(pdev); pm_runtime_get_sync(&pdev->dev); serial8250_unregister_port(data->line); if (!IS_ERR(data->clk)) clk_disable_unprepare(data->clk); pm_runtime_disable(&pdev->dev); pm_runtime_put_noidle(&pdev->dev); return 0; }
static int __maybe_unused omap_rng_resume(struct device *dev) { struct omap_rng_dev *priv = dev_get_drvdata(dev); int ret; ret = pm_runtime_get_sync(dev); if (ret) { dev_err(dev, "Failed to runtime_get device: %d\n", ret); pm_runtime_put_noidle(dev); return ret; } priv->pdata->init(priv); return 0; }
static int cyttsp4_i2c_read(struct cyttsp4_adapter *adap, u8 addr, void *buf, int size) { struct cyttsp4_i2c *ts = dev_get_drvdata(adap->dev); int rc; //pr_info("%s: Enter\n", __func__); pm_runtime_get_noresume(adap->dev); mutex_lock(&ts->lock); rc = cyttsp4_i2c_read_block_data(ts, addr, size, buf); mutex_unlock(&ts->lock); pm_runtime_put_noidle(adap->dev); return rc; }
/* Sysfs stuff */ static void lis3lv02d_sysfs_poweron(struct lis3lv02d *lis3) { /* * SYSFS functions are fast visitors so put-call * immediately after the get-call. However, keep * chip running for a while and schedule delayed * suspend. This way periodic sysfs calls doesn't * suffer from relatively long power up time. */ if (lis3->pm_dev) { pm_runtime_get_sync(lis3->pm_dev); pm_runtime_put_noidle(lis3->pm_dev); pm_schedule_suspend(lis3->pm_dev, LIS3_SYSFS_POWERDOWN_DELAY); } }
static int mma8452_remove(struct i2c_client *client) { struct iio_dev *indio_dev = i2c_get_clientdata(client); iio_device_unregister(indio_dev); pm_runtime_disable(&client->dev); pm_runtime_set_suspended(&client->dev); pm_runtime_put_noidle(&client->dev); iio_triggered_buffer_cleanup(indio_dev); mma8452_trigger_cleanup(indio_dev); mma8452_standby(iio_priv(indio_dev)); return 0; }
int mpu3050_common_remove(struct device *dev) { struct iio_dev *indio_dev = dev_get_drvdata(dev); struct mpu3050 *mpu3050 = iio_priv(indio_dev); pm_runtime_get_sync(dev); pm_runtime_put_noidle(dev); pm_runtime_disable(dev); iio_triggered_buffer_cleanup(indio_dev); if (mpu3050->irq) free_irq(mpu3050->irq, mpu3050); iio_device_unregister(indio_dev); mpu3050_power_down(mpu3050); return 0; }
static int sprd_i2c_remove(struct platform_device *pdev) { struct sprd_i2c *i2c_dev = platform_get_drvdata(pdev); int ret; ret = pm_runtime_get_sync(i2c_dev->dev); if (ret < 0) return ret; i2c_del_adapter(&i2c_dev->adap); clk_disable_unprepare(i2c_dev->clk); pm_runtime_put_noidle(i2c_dev->dev); pm_runtime_disable(i2c_dev->dev); return 0; }
static int sdhci_acpi_remove(struct platform_device *pdev) { struct sdhci_acpi_host *c = platform_get_drvdata(pdev); struct device *dev = &pdev->dev; int dead; if (c->use_runtime_pm) { pm_runtime_get_sync(dev); pm_runtime_disable(dev); pm_runtime_put_noidle(dev); } dead = (sdhci_readl(c->host, SDHCI_INT_STATUS) == ~0); sdhci_remove_host(c->host, dead); sdhci_free_host(c->host); return 0; }
static int us5182d_set_power_state(struct us5182d_data *data, bool on) { int ret; if (data->power_mode == US5182D_ONESHOT) return 0; if (on) { ret = pm_runtime_get_sync(&data->client->dev); if (ret < 0) pm_runtime_put_noidle(&data->client->dev); } else { pm_runtime_mark_last_busy(&data->client->dev); ret = pm_runtime_put_autosuspend(&data->client->dev); } return ret; }