From 9a52dbfa8f1da11f9365a49f2631e52b83103b0d Mon Sep 17 00:00:00 2001 From: Ondrej Jirman Date: Mon, 23 Nov 2020 02:42:46 +0100 Subject: [PATCH 273/478] Allow to block userpsace from controlling the modem power driver For p-boot privacy switch. Signed-off-by: Ondrej Jirman --- drivers/misc/modem-power.c | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/drivers/misc/modem-power.c b/drivers/misc/modem-power.c index 1f5bfe104463..9afa64ce0c15 100644 --- a/drivers/misc/modem-power.c +++ b/drivers/misc/modem-power.c @@ -179,6 +179,7 @@ enum { /* config options */ MPWR_F_DUMB_POWERUP, MPWR_F_FASTBOOT_POWERUP, + MPWR_F_BLOCKED, /* file */ MPWR_F_OPEN, MPWR_F_OVERFLOW, @@ -1188,6 +1189,9 @@ static ssize_t powered_store(struct device *dev, bool status; int ret; + if (test_bit(MPWR_F_BLOCKED, mpwr->flags)) + return -EPERM; + ret = kstrtobool(buf, &status); if (ret) return ret; @@ -1205,6 +1209,9 @@ static ssize_t powered_blocking_store(struct device *dev, bool status; int ret; + if (test_bit(MPWR_F_BLOCKED, mpwr->flags)) + return -EPERM; + ret = kstrtobool(buf, &status); if (ret) return ret; @@ -1311,6 +1318,9 @@ static ssize_t hard_reset_store(struct device *dev, bool val; int ret; + if (test_bit(MPWR_F_BLOCKED, mpwr->flags)) + return -EPERM; + ret = kstrtobool(buf, &val); if (ret) return ret; @@ -1400,6 +1410,9 @@ static int mpwr_probe_generic(struct device *dev, struct mpwr_dev **mpwr_out) return -EINVAL; } + if (of_property_read_bool(np, "blocked")) + set_bit(MPWR_F_BLOCKED, mpwr->flags); + mpwr->status_pwrkey_multiplexed = of_property_read_bool(np, "status-pwrkey-multiplexed"); -- 2.35.3