Received: by 2002:a05:6a10:a0d1:0:0:0:0 with SMTP id j17csp3315375pxa; Tue, 18 Aug 2020 11:58:42 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyyxpXVFuQDo2ppixVq8NDIiLAR+VszHDHDWmZOCEtcqFKdF9xlxfqw0pMeuw7EsJcRiwN7 X-Received: by 2002:a05:6402:31b5:: with SMTP id dj21mr20642559edb.154.1597777121843; Tue, 18 Aug 2020 11:58:41 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1597777121; cv=none; d=google.com; s=arc-20160816; b=E8cJ3304NHLTpM/8ZLjvHlGQSfP4dXbOT6OKtqY8nkWv6plgMLQ7NBo9IzkAhB527I M4iz+6whkOAkBK2mGVgsGgSxKBOf3amSXDlFk+BwZlsP5c1h7z9maj7L+5L9OKJFx7Yq quQ9EGJUUPRqH7r9vpK2LWHO8uq7t2QFoHL0C9pBXLJdf7raikyftp+VeC0qLt20WGIa xLrbbcillBJ6/DRpjnuhrCPXzpl+mytAcaBbyJ55Ih6Z7SLvRPZqoLwzmJBjxtUvtJYH j6uB3TqIk5/KRABrykLh4MDsVNjVG3BrP74fHCphE9L57k3tXNXYcWEuQYWWJiLBziOQ Hxhw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dmarc-filter:dkim-signature; bh=nh+RSm6RsPXE+qcY152AR0CU4QrxqI5oIYGuVIflNG4=; b=oDXThVtzsBns3FE5JpmXWKylZ6fiv7cMbdXuzq4uy6u37Uocp8YhoqarMRf0EWg5RK afhSa8Kh/W7P943zdhMTBuQceIwb96ct+cjMHTf5I0GJQ7CJV0PVpjjrUoQuydNMX7VH AO8/CsAeObz0LMNMPMjDShEEo4tGyJaYgRV2woDm11TBYp6h20SI96tgLIk9tulERRM+ tBgdYiw8bdlyTq/2vIR/KzEzFn+FCrOGLmlXAbzH/hAb/8BqX18bNyzMxA3H4k+qJOMN W46rC5AxVXrZuGne2DPQ6wCNMGdsiW56qL+rdAxZLuTlUSIjuPL/Zgj/8oQmsAafClnF oGbg== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@mg.codeaurora.org header.s=smtp header.b=k3gXHMbs; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id a17si13613814ejt.20.2020.08.18.11.58.18; Tue, 18 Aug 2020 11:58:41 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=fail header.i=@mg.codeaurora.org header.s=smtp header.b=k3gXHMbs; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726670AbgHRSzI (ORCPT + 99 others); Tue, 18 Aug 2020 14:55:08 -0400 Received: from mail29.static.mailgun.info ([104.130.122.29]:53045 "EHLO mail29.static.mailgun.info" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726746AbgHRSzB (ORCPT ); Tue, 18 Aug 2020 14:55:01 -0400 DKIM-Signature: a=rsa-sha256; v=1; c=relaxed/relaxed; d=mg.codeaurora.org; q=dns/txt; s=smtp; t=1597776900; h=References: In-Reply-To: Message-Id: Date: Subject: Cc: To: From: Sender; bh=nh+RSm6RsPXE+qcY152AR0CU4QrxqI5oIYGuVIflNG4=; b=k3gXHMbsj/aLWvdA8ILzOQJc7TQFAAlr6Mjquwsb/Ioi2DMDSq262bcjX8nh395CGhALfuOg eUHS1SB97eJEbCLDnI9vADYC+bFgYOuwrOtn9GWKyn3eaF7XPD2Kbw3t/RSTrPJZ4KayWlRG zNFdfo2DVPIWlLTjH6qQbIFniy4= X-Mailgun-Sending-Ip: 104.130.122.29 X-Mailgun-Sid: WyI0MWYwYSIsICJsaW51eC1rZXJuZWxAdmdlci5rZXJuZWwub3JnIiwgImJlOWU0YSJd Received: from smtp.codeaurora.org (ec2-35-166-182-171.us-west-2.compute.amazonaws.com [35.166.182.171]) by smtp-out-n03.prod.us-east-1.postgun.com with SMTP id 5f3c23e2cbcd42bdeed534c9 (version=TLS1.2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256); Tue, 18 Aug 2020 18:54:26 GMT Received: by smtp.codeaurora.org (Postfix, from userid 1001) id C8660C433CB; Tue, 18 Aug 2020 18:54:25 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-caf-mail-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-1.0 required=2.0 tests=ALL_TRUSTED,SPF_NONE, URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.0 Received: from eberman-linux.qualcomm.com (i-global254.qualcomm.com [199.106.103.254]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-SHA256 (128/128 bits)) (No client certificate requested) (Authenticated sender: eberman) by smtp.codeaurora.org (Postfix) with ESMTPSA id 00BC9C433AD; Tue, 18 Aug 2020 18:54:24 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 smtp.codeaurora.org 00BC9C433AD Authentication-Results: aws-us-west-2-caf-mail-1.web.codeaurora.org; dmarc=none (p=none dis=none) header.from=codeaurora.org Authentication-Results: aws-us-west-2-caf-mail-1.web.codeaurora.org; spf=none smtp.mailfrom=eberman@codeaurora.org From: Elliot Berman To: Sebastian Reichel , Andy Yan , Bjorn Andersson , Andy Gross , Rob Herring Cc: Elliot Berman , linux-pm@vger.kernel.org, linux-arm-msm@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, Trilok Soni , Prasad Sodagudi Subject: [RESEND PATCH v1 3/4] power: reset: Add support for reboot mode alternate properties Date: Tue, 18 Aug 2020 11:54:15 -0700 Message-Id: <1597776856-12014-4-git-send-email-eberman@codeaurora.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1597776856-12014-1-git-send-email-eberman@codeaurora.org> References: <1597776856-12014-1-git-send-email-eberman@codeaurora.org> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.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 --- 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