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

Commit 2ce069e3 authored by qctecmdr's avatar qctecmdr Committed by Gerrit - the friendly Code Review server
Browse files

Merge "qbt: Add ioctls to acquire and release wakelock"

parents b1c2e169 a1b7d276
Loading
Loading
Loading
Loading
+27 −1
Original line number Diff line number Diff line
/* Copyright (c) 2016-2018, The Linux Foundation. All rights reserved.
/* Copyright (c) 2016-2019, The Linux Foundation. All rights reserved.
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License version 2 and
@@ -117,6 +117,7 @@ struct qbt1000_drvdata {
	enum fd_indication_mode fd_ind_mode;
	bool ipc_is_stale;
	bool gestures_enabled;
	atomic_t wakelock_acquired;
};

/*
@@ -311,6 +312,11 @@ static int qbt1000_release(struct inode *inode, struct file *file)
	}
	drvdata = file->private_data;
	atomic_inc(&drvdata->available);
	if (atomic_read(&drvdata->wakelock_acquired) != 0) {
		pr_debug("Releasing wakelock\n");
		pm_relax(drvdata->dev);
		atomic_set(&drvdata->wakelock_acquired, 0);
	}
	return 0;
}

@@ -589,6 +595,25 @@ static long qbt1000_ioctl(
		}
		break;
	}
	case QBT1000_ACQUIRE_WAKELOCK:
	{
		if (atomic_read(&drvdata->wakelock_acquired) == 0) {
			pr_debug("Acquiring wakelock\n");
			pm_stay_awake(drvdata->dev);
		}
		atomic_inc(&drvdata->wakelock_acquired);
		break;
	}
	case QBT1000_RELEASE_WAKELOCK:
	{
		if (atomic_read(&drvdata->wakelock_acquired) == 0)
			break;
		if (atomic_dec_and_test(&drvdata->wakelock_acquired)) {
			pr_debug("Releasing wakelock\n");
			pm_relax(drvdata->dev);
		}
		break;
	}
	default:
		pr_err("invalid cmd %d\n", cmd);
		rc = -ENOIOCTLCMD;
@@ -1234,6 +1259,7 @@ static int qbt1000_probe(struct platform_device *pdev)
		goto end;

	atomic_set(&drvdata->available, 1);
	atomic_set(&drvdata->wakelock_acquired, 0);

	mutex_init(&drvdata->mutex);
	mutex_init(&drvdata->fw_events_mutex);
+2 −0
Original line number Diff line number Diff line
@@ -21,6 +21,8 @@ enum qbt1000_commands {
	QBT1000_CONFIGURE_POWER_KEY = 104
};
#define QBT1000_ENABLE_GESTURES 105
#define QBT1000_ACQUIRE_WAKELOCK 106
#define QBT1000_RELEASE_WAKELOCK 107

/*
 * enum qbt1000_fw_event -