From patchwork Tue Aug 18 18:54:15 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Elliot Berman X-Patchwork-Id: 11722117 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id E1758109B for ; Tue, 18 Aug 2020 18:54:54 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id C988B221E2 for ; Tue, 18 Aug 2020 18:54:54 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (1024-bit key) header.d=mg.codeaurora.org header.i=@mg.codeaurora.org header.b="EiZbGM5e" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726803AbgHRSyx (ORCPT ); Tue, 18 Aug 2020 14:54:53 -0400 Received: from m43-7.mailgun.net ([69.72.43.7]:27506 "EHLO m43-7.mailgun.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726766AbgHRSyt (ORCPT ); Tue, 18 Aug 2020 14:54:49 -0400 DKIM-Signature: a=rsa-sha256; v=1; c=relaxed/relaxed; d=mg.codeaurora.org; q=dns/txt; s=smtp; t=1597776888; h=References: In-Reply-To: Message-Id: Date: Subject: Cc: To: From: Sender; bh=nh+RSm6RsPXE+qcY152AR0CU4QrxqI5oIYGuVIflNG4=; b=EiZbGM5ewJIck41uAlrlxTD8K63L5lYngvXai5e5kXbioKY5YUqUabOettKfeipA66UdNoSi JDSIf8kvCTu70V4yPT9PtslH81I1AfF4Bw5+zFT6n3zHQHV4kIegvRIbviFS0YsX9rc2zL3a NglotEJsS3lEluQDXM/to7HBBIk= X-Mailgun-Sending-Ip: 69.72.43.7 X-Mailgun-Sid: WyI1MzIzYiIsICJsaW51eC1hcm0tbXNtQHZnZXIua2VybmVsLm9yZyIsICJiZTllNGEiXQ== 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 5f3c23e2cbcd42bdeed534c8 (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-arm-msm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-arm-msm@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);