linux-pm.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Elliot Berman <eberman@codeaurora.org>
To: Sebastian Reichel <sre@kernel.org>,
	Andy Yan <andy.yan@rock-chips.com>,
	Bjorn Andersson <bjorn.andersson@linaro.org>
Cc: Elliot Berman <eberman@codeaurora.org>,
	linux-pm@vger.kernel.org, linux-arm-msm@vger.kernel.org,
	Trilok Soni <tsoni@codeaurora.org>,
	Prasad Sodagudi <psodagud@codeaurora.org>
Subject: [PATCH 3/4] power: reset: Add support for reboot mode alternate properties
Date: Fri, 31 Jul 2020 14:14:19 -0700	[thread overview]
Message-ID: <1596230060-6065-4-git-send-email-eberman@codeaurora.org> (raw)
In-Reply-To: <1596230060-6065-1-git-send-email-eberman@codeaurora.org>

Reboot mode driver does not currently support reboot commands with
spaces in them [1]. Add an optional new node "reboot-mode-names" and
"reboot-mode-magic" which add an array of strings and u32s, respectively
which would permit any string in this framework.

Signed-off-by: Elliot Berman <eberman@codeaurora.org>
---
 drivers/power/reset/reboot-mode.c | 42 ++++++++++++++++++++++++++++++++++++++-
 1 file changed, 41 insertions(+), 1 deletion(-)

diff --git a/drivers/power/reset/reboot-mode.c b/drivers/power/reset/reboot-mode.c
index b4076b1..363734d 100644
--- a/drivers/power/reset/reboot-mode.c
+++ b/drivers/power/reset/reboot-mode.c
@@ -64,8 +64,9 @@ int reboot_mode_register(struct reboot_mode_driver *reboot)
 	struct mode_info *info;
 	struct property *prop;
 	struct device_node *np = reboot->dev->of_node;
+	const char *mode_name;
 	size_t len = strlen(PREFIX);
-	int ret;
+	int ret, count, i;
 
 	INIT_LIST_HEAD(&reboot->head);
 
@@ -101,6 +102,45 @@ int reboot_mode_register(struct reboot_mode_driver *reboot)
 		list_add_tail(&info->list, &reboot->head);
 	}
 
+	count = of_property_count_u32_elems(np, "reboot-mode-magic");
+	for (i = 0; i < count; i++) {
+		info = devm_kzalloc(reboot->dev, sizeof(*info), GFP_KERNEL);
+		if (!info) {
+			ret = -ENOMEM;
+			goto error;
+		}
+
+		if (of_property_read_string_index(np, "reboot-mode-names", i,
+						  &mode_name)) {
+			dev_err(reboot->dev, "unable to read reboot-mode-names[%d]\n",
+				i);
+			ret = -EINVAL;
+			goto error;
+		}
+		info->mode = kstrdup_const(mode_name, GFP_KERNEL);
+		if (!info->mode) {
+			ret = -ENOMEM;
+			goto error;
+		} else if (info->mode[0] == '\0') {
+			dev_err(reboot->dev, "invalid reboot-mode-names[%d]: too short!\n",
+				i);
+			kfree_const(info->mode);
+			ret = -EINVAL;
+			goto error;
+		}
+
+		if (of_property_read_u32_index(np, "reboot-mode-magic", i,
+					       &info->magic)) {
+			dev_err(reboot->dev, "unable to read reboot-mode-magic[%d]\n",
+				i);
+			kfree_const(info->mode);
+			ret = -EINVAL;
+			goto error;
+		}
+
+		list_add_tail(&info->list, &reboot->head);
+	}
+
 	reboot->reboot_notifier.notifier_call = reboot_mode_notify;
 	register_reboot_notifier(&reboot->reboot_notifier);
 
-- 
The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum,
a Linux Foundation Collaborative Project


  parent reply	other threads:[~2020-07-31 21:14 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-07-31 21:14 [PATCH 0/4] Add restart commands for PM8150 Elliot Berman
2020-07-31 21:14 ` [PATCH 1/4] dt-bindings: power: reset: Convert reboot-mode to YAML Elliot Berman
2020-07-31 21:14 ` [PATCH 2/4] dt-bindings: power: reset: Add alternate reboot mode format Elliot Berman
2020-07-31 21:14 ` Elliot Berman [this message]
2020-07-31 21:14 ` [PATCH 4/4] arm64: dts: qcom: pm8150: Add reboot magic Elliot Berman

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1596230060-6065-4-git-send-email-eberman@codeaurora.org \
    --to=eberman@codeaurora.org \
    --cc=andy.yan@rock-chips.com \
    --cc=bjorn.andersson@linaro.org \
    --cc=linux-arm-msm@vger.kernel.org \
    --cc=linux-pm@vger.kernel.org \
    --cc=psodagud@codeaurora.org \
    --cc=sre@kernel.org \
    --cc=tsoni@codeaurora.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).