Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit da3d93c3 authored by Linux Build Service Account's avatar Linux Build Service Account Committed by Gerrit - the friendly Code Review server
Browse files

Merge "icnss: Add support for suspend/resume"

parents 5551ac50 e45a0a68
Loading
Loading
Loading
Loading
+54 −0
Original line number Diff line number Diff line
@@ -133,6 +133,7 @@ enum icnss_driver_state {
	ICNSS_FW_READY,
	ICNSS_DRIVER_PROBED,
	ICNSS_FW_TEST_MODE,
	ICNSS_SUSPEND,
};

struct ce_irq_list {
@@ -2002,6 +2003,9 @@ static int icnss_stats_show_state(struct seq_file *s, struct icnss_data *priv)
		case ICNSS_FW_TEST_MODE:
			seq_puts(s, "FW TEST MODE");
			continue;
		case ICNSS_SUSPEND:
			seq_puts(s, "DRIVER SUSPENDED");
			continue;
		}

		seq_printf(s, "UNKNOWN-%d", i);
@@ -2362,6 +2366,54 @@ static int icnss_remove(struct platform_device *pdev)
	return 0;
}

static int icnss_suspend(struct platform_device *pdev,
			 pm_message_t state)
{
	int ret = 0;

	if (!penv) {
		ret = -ENODEV;
		goto out;
	}

	icnss_pr_dbg("Driver suspending, state: 0x%lx\n",
		     penv->state);

	if (!penv->ops)
		goto out;

	if (penv->ops->suspend)
		ret = penv->ops->suspend(&pdev->dev, state);

out:
	if (ret == 0)
		set_bit(ICNSS_SUSPEND, &penv->state);
	return ret;
}

static int icnss_resume(struct platform_device *pdev)
{
	int ret = 0;

	if (!penv) {
		ret = -ENODEV;
		goto out;
	}

	icnss_pr_dbg("Driver resuming, state: 0x%lx\n",
		     penv->state);

	if (!penv->ops)
		goto out;

	if (penv->ops->resume)
		ret = penv->ops->resume(&pdev->dev);

out:
	if (ret == 0)
		clear_bit(ICNSS_SUSPEND, &penv->state);
	return ret;
}

static const struct of_device_id icnss_dt_match[] = {
	{.compatible = "qcom,icnss"},
@@ -2373,6 +2425,8 @@ MODULE_DEVICE_TABLE(of, icnss_dt_match);
static struct platform_driver icnss_driver = {
	.probe  = icnss_probe,
	.remove = icnss_remove,
	.suspend = icnss_suspend,
	.resume = icnss_resume,
	.driver = {
		.name = "icnss",
		.owner = THIS_MODULE,