From patchwork Thu Feb 1 18:01:01 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrew Davis X-Patchwork-Id: 195418 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7301:2719:b0:106:209c:c626 with SMTP id hl25csp340103dyb; Thu, 1 Feb 2024 10:04:43 -0800 (PST) X-Google-Smtp-Source: AGHT+IHoRC2VGGUe6GymHBKUgerBm0cncOXZ2aJR823xbCFYI2UEEWSw6HipnLeD0nUh3Pn5A3iT X-Received: by 2002:a05:622a:1111:b0:42b:f6c1:dc1b with SMTP id e17-20020a05622a111100b0042bf6c1dc1bmr2560703qty.31.1706810682927; Thu, 01 Feb 2024 10:04:42 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1706810682; cv=pass; d=google.com; s=arc-20160816; b=zcEX5zd1qaFoVxBCvV1HaZw4AusqkurMaz8xWoNphAl6heuj19ZDjNrPZMrn+3Okm4 Ps6ukspGt76zpbl8fGrX26UA/yqKuKB0csVRNBzs0Lt4/SM04AIj9JyN9ZVDHFMlYSV5 oR1z6coF6CgT2kjrUz76/aUQl/58DR7SMzzb3gx/4pjkCuNGAUIK7FmGOxmaUGdbtaPZ WjYsi32iPj0M3m57yJOZu/ph9ttbQuC6A94Q4DxZi9lTmO0vrWAuFqOWxwaySk0CEHLq bWu9k2Ayui7MExdzZeUXvFIx3ESj5fUK92W3GWhOsaqMu+/z2kFPcSqLsDP3CMbsX4dY wlcA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=rjOs3HQelK8dD7ON+CKELNocYhGYtTpRb3RjtcpZp+M=; fh=3InAWL9eE2MFm/9NMXYDbrcE4pg5t/9WcNQuTzHLiRE=; b=rHKp/0JM4OrZvenQsDj2WqavjX4EHsnm6m19SOQwpUkM9QAB8H38HDp/YjXO3E9DUA BdSFuNLBCwSy2bxQPSrGSJV28Dh/rIr5VgEgq5TGcubmkt80VzkaLOzjM3FWuYprYv9Y D/KCUHG4dDddkeVYL4n9EoFvTlIpIRnoBY4qtC5FvVl5NmNwgp7oAw7ugjcSguwGaMO1 JCxsrBq+vyO6GnehYp/N8ltPzoqa1omTOjHanpikHvVBDBKLpDeYMPSczQtkAaKTfnyo kc2X6IJpTN7oew1GQfeNLqU09EenOnDk+KXgqS4iPhYJRxT0dQG6229m2UShQhRNSggM FoCQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@ti.com header.s=ti-com-17Q1 header.b=alGgElcI; arc=pass (i=1 spf=pass spfdomain=ti.com dkim=pass dkdomain=ti.com dmarc=pass fromdomain=ti.com); spf=pass (google.com: domain of linux-kernel+bounces-48639-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-48639-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=QUARANTINE sp=NONE dis=NONE) header.from=ti.com X-Forwarded-Encrypted: i=1; AJvYcCULPCRqTASX0Rvvn/xe9EYCDlo2U1pMyjNHgy2FOPQJiANF1GGF7sYvEkL3BLByJxzVrt1tG9CIdggNabzNnJv7KV08nQ== Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [2604:1380:45d1:ec00::1]) by mx.google.com with ESMTPS id t15-20020a05622a01cf00b0042a9d4326e6si10481416qtw.357.2024.02.01.10.04.42 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 01 Feb 2024 10:04:42 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-48639-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) client-ip=2604:1380:45d1:ec00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@ti.com header.s=ti-com-17Q1 header.b=alGgElcI; arc=pass (i=1 spf=pass spfdomain=ti.com dkim=pass dkdomain=ti.com dmarc=pass fromdomain=ti.com); spf=pass (google.com: domain of linux-kernel+bounces-48639-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-48639-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=QUARANTINE sp=NONE dis=NONE) header.from=ti.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ny.mirrors.kernel.org (Postfix) with ESMTPS id 496F01C290AA for ; Thu, 1 Feb 2024 18:04:08 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 3F6D812883B; Thu, 1 Feb 2024 18:01:36 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=ti.com header.i=@ti.com header.b="alGgElcI" Received: from fllv0015.ext.ti.com (fllv0015.ext.ti.com [198.47.19.141]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id C0510127B60; Thu, 1 Feb 2024 18:01:31 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=198.47.19.141 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706810493; cv=none; b=W2c44K41sy2yfwvHeAW3n1MbRc1j6pSe1QLmOPMyoM0qhDyX7ChGqHiWiJMWBtoRz7tWJZrepTIYBWXxuoGr9s9j9cohKhOuvI4Nvo0gLHfOAt/Jxz73Z6XmZjvlLoRgnTJBuWyeIWxAOCve7XTrxwUwMz83+MLOIHz1DzhJq34= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706810493; c=relaxed/simple; bh=4I1vc+9qiFHbkF+qYQtdPfpYZxXqQl61oW4rBcSj/cM=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=RzmaMZNDD74xEra4MuI9AOZDNozSKzIWfnV4qsXJqMlzRN3fNidp5nNkcSXkTzwftzUlItPprw6WA4KGxETYy2J5ekekywX4Hrj+w3yPAVn25eSFEyCdX3+ou4g128JPHnKdiMxcPLhPUN70mbiYOUgZhW/vEhA1l+x+WYHiSvk= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=ti.com; spf=pass smtp.mailfrom=ti.com; dkim=pass (1024-bit key) header.d=ti.com header.i=@ti.com header.b=alGgElcI; arc=none smtp.client-ip=198.47.19.141 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=ti.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=ti.com Received: from lelv0265.itg.ti.com ([10.180.67.224]) by fllv0015.ext.ti.com (8.15.2/8.15.2) with ESMTP id 411I1EiX049636; Thu, 1 Feb 2024 12:01:14 -0600 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ti.com; s=ti-com-17Q1; t=1706810474; bh=rjOs3HQelK8dD7ON+CKELNocYhGYtTpRb3RjtcpZp+M=; h=From:To:CC:Subject:Date:In-Reply-To:References; b=alGgElcIFoxueD1e1sbl7KER0iExHsEMJHWdamR5M0QH+QPfnKGNyvhDBrQOFecGG q4tGqqYwHJuILBQ2p7m+Nb9aQ6idMYzD3XqDbK5fLuP7sESOqM50+c4uM4ZhuVTuqL XlckU/hX0u7tdX0M2Hm96ueyrhr8Qd7PoM5Djv08= Received: from DLEE110.ent.ti.com (dlee110.ent.ti.com [157.170.170.21]) by lelv0265.itg.ti.com (8.15.2/8.15.2) with ESMTPS id 411I1Eko004643 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=FAIL); Thu, 1 Feb 2024 12:01:14 -0600 Received: from DLEE105.ent.ti.com (157.170.170.35) by DLEE110.ent.ti.com (157.170.170.21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.2507.23; Thu, 1 Feb 2024 12:01:14 -0600 Received: from lelvsmtp5.itg.ti.com (10.180.75.250) by DLEE105.ent.ti.com (157.170.170.35) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.2507.23 via Frontend Transport; Thu, 1 Feb 2024 12:01:13 -0600 Received: from lelvsmtp6.itg.ti.com ([10.249.42.149]) by lelvsmtp5.itg.ti.com (8.15.2/8.15.2) with ESMTP id 411I12Gv117221; Thu, 1 Feb 2024 12:01:13 -0600 From: Andrew Davis To: Sebastian Reichel , Manivannan Sadhasivam , Cristian Ciocaltea , Florian Fainelli , Ray Jui , Scott Branden , Bjorn Andersson , Konrad Dybcio , Sean Wang , Matthias Brugger , AngeloGioacchino Del Regno CC: , , , , , , Andrew Davis Subject: [PATCH 17/18] power: reset: syscon-poweroff: Move device data into a struct Date: Thu, 1 Feb 2024 12:01:01 -0600 Message-ID: <20240201180102.70395-18-afd@ti.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240201180102.70395-1-afd@ti.com> References: <20240201180102.70395-1-afd@ti.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-EXCLAIMER-MD-CONFIG: e1e8a2fd-e40a-4ac6-ac9b-f7e9cc9ee180 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1789720718811659698 X-GMAIL-MSGID: 1789720718811659698 Currently all these device data elements are top level global variables. Move these into a struct. This will be used in the next patch when the global variable usage is removed. Doing this in two steps makes the patches easier to read. Signed-off-by: Andrew Davis --- drivers/power/reset/syscon-poweroff.c | 36 +++++++++++++++------------ 1 file changed, 20 insertions(+), 16 deletions(-) diff --git a/drivers/power/reset/syscon-poweroff.c b/drivers/power/reset/syscon-poweroff.c index 1b2ce7734260c..4899a019256e8 100644 --- a/drivers/power/reset/syscon-poweroff.c +++ b/drivers/power/reset/syscon-poweroff.c @@ -15,15 +15,19 @@ #include #include -static struct regmap *map; -static u32 offset; -static u32 value; -static u32 mask; +struct syscon_poweroff_data { + struct regmap *map; + u32 offset; + u32 value; + u32 mask; +}; + +static struct syscon_poweroff_data *data; static void syscon_poweroff(void) { /* Issue the poweroff */ - regmap_update_bits(map, offset, mask, value); + regmap_update_bits(data->map, data->offset, data->mask, data->value); mdelay(1000); @@ -35,22 +39,22 @@ static int syscon_poweroff_probe(struct platform_device *pdev) struct device *dev = &pdev->dev; int mask_err, value_err; - map = syscon_regmap_lookup_by_phandle(dev->of_node, "regmap"); - if (IS_ERR(map)) { - map = syscon_node_to_regmap(dev->parent->of_node); - if (IS_ERR(map)) { + data->map = syscon_regmap_lookup_by_phandle(dev->of_node, "regmap"); + if (IS_ERR(data->map)) { + data->map = syscon_node_to_regmap(dev->parent->of_node); + if (IS_ERR(data->map)) { dev_err(dev, "unable to get syscon"); - return PTR_ERR(map); + return PTR_ERR(data->map); } } - if (of_property_read_u32(dev->of_node, "offset", &offset)) { + if (of_property_read_u32(dev->of_node, "offset", &data->offset)) { dev_err(dev, "unable to read 'offset'"); return -EINVAL; } - value_err = of_property_read_u32(dev->of_node, "value", &value); - mask_err = of_property_read_u32(dev->of_node, "mask", &mask); + value_err = of_property_read_u32(dev->of_node, "value", &data->value); + mask_err = of_property_read_u32(dev->of_node, "mask", &data->mask); if (value_err && mask_err) { dev_err(dev, "unable to read 'value' and 'mask'"); return -EINVAL; @@ -58,11 +62,11 @@ static int syscon_poweroff_probe(struct platform_device *pdev) if (value_err) { /* support old binding */ - value = mask; - mask = 0xFFFFFFFF; + data->value = data->mask; + data->mask = 0xFFFFFFFF; } else if (mask_err) { /* support value without mask*/ - mask = 0xFFFFFFFF; + data->mask = 0xFFFFFFFF; } if (pm_power_off) {