/**
 * pil_get() - Load a peripheral into memory and take it out of reset
 * @name: pointer to a string containing the name of the peripheral to load
 *
 * This function returns a pointer if it succeeds. If an error occurs an
 * ERR_PTR is returned.
 *
 * If PIL is not enabled in the kernel, the value %NULL will be returned.
 */
void *pil_get(const char *name)
{
	int ret;
	struct pil_device *pil;
	struct pil_device *pil_d;
	void *retval;

	if (!name)
		return NULL;

	pil = retval = find_peripheral(name);
	if (!pil)
		return ERR_PTR(-ENODEV);
	if (!try_module_get(pil->owner)) {
		put_device(&pil->dev);
		return ERR_PTR(-ENODEV);
	}

	pil_d = pil_get(pil->desc->depends_on);
	if (IS_ERR(pil_d)) {
		retval = pil_d;
		goto err_depends;
	}

	mutex_lock(&pil->lock);
	if (!pil->count) {
		ret = load_image(pil);
		if (ret) {
			retval = ERR_PTR(ret);
			goto err_load;
		}
	}
	pil->count++;
	pil_set_state(pil, PIL_ONLINE);
	mutex_unlock(&pil->lock);
out:
	return retval;
err_load:
	mutex_unlock(&pil->lock);
	pil_put(pil_d);
err_depends:
	put_device(&pil->dev);
	module_put(pil->owner);
	goto out;
}
Esempio n. 2
0
int pil_force_boot(const char *name)
{
	int ret = -EINVAL;
	struct pil_device *pil;

	pil = find_peripheral(name);
	if (!pil) {
		pr_err("%s: Couldn't find %s\n", __func__, name);
		return -EINVAL;
	}

	mutex_lock(&pil->lock);
	if (!WARN(!pil->count, "%s: Reference count mismatch\n", __func__))
		ret = load_image(pil);
	if (!ret)
		pil_set_state(pil, PIL_ONLINE);
	mutex_unlock(&pil->lock);
	put_device(&pil->dev);

	return ret;
}
Esempio n. 3
0
static void pil_shutdown(struct pil_device *pil)
{
	pil->desc->ops->shutdown(pil->desc);
	flush_delayed_work(&pil->proxy);
	pil_set_state(pil, PIL_OFFLINE);
}
void *pil_get(const char *name)
{
	int ret;
	struct pil_device *pil;
	struct pil_device *pil_d;
	void *retval;
#ifdef CONFIG_MSM8960_ONLY
	static int modem_initialized = 0;
	int loop_count = 0;
#endif

	if (!name)
		return NULL;

	pil = retval = find_peripheral(name);
	if (!pil)
		return ERR_PTR(-ENODEV);
	if (!try_module_get(pil->owner)) {
		put_device(&pil->dev);
		return ERR_PTR(-ENODEV);
	}

	pil_d = pil_get(pil->desc->depends_on);
	if (IS_ERR(pil_d)) {
		retval = pil_d;
		goto err_depends;
	}

#ifdef CONFIG_MSM8960_ONLY
	if (!strcmp("modem", name)) {
		while (unlikely(!modem_initialized && strcmp("rmt_storage", current->comm) && loop_count++ < 10)) {
			
			printk("%s: %s(%d) waiting for rmt_storage %d\n", __func__, current->comm, current->pid, loop_count);
			msleep(500);
		}
	}
#endif
	mutex_lock(&pil->lock);
	if (!pil->count) {
		if (!strcmp("modem", name)) {
			printk("%s: %s(%d) for %s\n", __func__, current->comm, current->pid, name);
#ifdef CONFIG_MSM8960_ONLY
			modem_initialized = 1;
#endif
		}
		ret = load_image(pil);
		if (ret) {
			retval = ERR_PTR(ret);
			goto err_load;
		}
	}
	pil->count++;
	pil_set_state(pil, PIL_ONLINE);
	mutex_unlock(&pil->lock);
#if defined(CONFIG_MSM8930_ONLY)
	if (!strcmp("modem", name)) {
		complete_all(&pil_work_finished);
	}
#elif defined(CONFIG_ARCH_APQ8064)
		complete_all(&pil_work_finished);
#endif
out:
	return retval;
err_load:
	mutex_unlock(&pil->lock);
	pil_put(pil_d);
err_depends:
	put_device(&pil->dev);
	module_put(pil->owner);
	goto out;
}
void *pil_get(const char *name)
{
	int ret;
	struct pil_device *pil;
	struct pil_device *pil_d;
	void *retval;
	static int modem_initialized = 0;
	int loop_count = 0;

	if (!name)
		return NULL;
	
	printk("%s: %s(%d) for %s\n", __func__, current->comm, current->pid, name);

	pil = retval = find_peripheral(name);
	if (!pil)
		return ERR_PTR(-ENODEV);
	if (!try_module_get(pil->owner)) {
		put_device(&pil->dev);
		return ERR_PTR(-ENODEV);
	}

	pil_d = pil_get(pil->desc->depends_on);
	if (IS_ERR(pil_d)) {
		retval = pil_d;
		goto err_depends;
	}

	
	printk("%s: pil_get %s sucessfully, pil->count:%d\n", __func__, name, pil->count);

	if (!strcmp("modem", name)) {
		while (unlikely(!modem_initialized && strcmp("rmt_storage", current->comm) && loop_count++ < 10)) {
			
			printk("%s: %s(%d) waiting for rmt_storage %d\n", __func__, current->comm, current->pid, loop_count);
			msleep(500);
		}
	}
	mutex_lock(&pil->lock);
	if (!pil->count) {
		if (!strcmp("modem", name)) {
			printk("%s: %s(%d) for %s\n", __func__, current->comm, current->pid, name);
			modem_initialized = 1;
		}
		ret = load_image(pil);
		if (ret) {
			retval = ERR_PTR(ret);
			goto err_load;
		}
	}
	pil->count++;
	pil_set_state(pil, PIL_ONLINE);
	mutex_unlock(&pil->lock);
out:
	return retval;
err_load:
	mutex_unlock(&pil->lock);
	pil_put(pil_d);
err_depends:
	put_device(&pil->dev);
	module_put(pil->owner);
	goto out;
}