From patchwork Mon Feb 12 16:28:30 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrew Davis X-Patchwork-Id: 199908 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:bc8a:b0:106:860b:bbdd with SMTP id dn10csp32008dyb; Mon, 12 Feb 2024 08:37:12 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCXS5SAKzkNpJkxdR+u0G71g1jfQ1tjgV1N9JrDUXJLa9+pJw56lBH8dKUQfCTCycmpFiKc1U4c/pOZfHwg4Bl52VzziFw== X-Google-Smtp-Source: AGHT+IGMXAP1yD57TggnL6Z5eZxE8ypQVJSVaRepiM905/8R9gryoxziz7GGwMlLdU9UdvwRWsIx X-Received: by 2002:a17:902:ec8e:b0:1d9:efc7:1c4e with SMTP id x14-20020a170902ec8e00b001d9efc71c4emr32022plg.6.1707755831904; Mon, 12 Feb 2024 08:37:11 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1707755831; cv=pass; d=google.com; s=arc-20160816; b=eg/sGnI5bB6ew4faWb4Rjd/uboFVtfqRCxMdTEiKLAi3M+Sb0w6Gjje7jn0XOyfbzE +er0/+TIy0vlQ2RgkDsCLs3q9P6s981f6EmWNLhm6ublWVPBDH66uT73nEmHeZq0ZBPd 1jtEg0/795HEzSeu1OTzTrmYGLoqCgbL978fPhYwksmpNRtPPvjJD8rzwzgP+Ngs1VZc +hrV3oLBVDkmJaXiB0f7doL27VNCXOQKFa01qYC0mHgd9uUJLxE4R3l3+sWFLU4i581Z WY0egIgstEgnNpt/H4JhaCMaY4c2RgBN2DoyC76SLcCPf4w4OSoh6YH0wcZxnjZD7Wh5 1KAQ== 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=Kv9JczQeQR+ifDe2YtY2D7JV7A0GaYQwadF3KmYeaVc=; fh=gqQaRvzBX/lCwVJbw1EzLi1VseCiyeiujtoavtj1oo0=; b=K92aOknGUKYSdB6+xb5pNr+WzliGE7HrQfXQ8jbzT+OplZgZ7usLmMEqV5wahIoBTK WYt5l4itilMwse/mLXiskMeCU3mmEQARnPVPZJnkYCCIXFCnXjYCOw/l30usHidr7gq6 eCMMLjBsyPoZwnQ27stFeqqUJ+XrKUeAnLRPY/VPfyIFztyocOoK2+jAX8YF/iKFngws FI1JI8/AQHdmFDl6c1refun41mBovz4eyBHxRowkA2alkzrVzMSNTjkorWMNcwcNJ6Vx Cice9oB1l5dOpSAUVgL1gJxwz6IBycCaiSTIDjl4QmuvXGDdxdCCURuk+4NqOFF3vvj0 rNYg==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@ti.com header.s=ti-com-17Q1 header.b=kuV50zaN; 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-61973-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-61973-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=QUARANTINE sp=NONE dis=NONE) header.from=ti.com X-Forwarded-Encrypted: i=2; AJvYcCWLgjvkEQVAx4aRkGjFff7j1pS3ULIMMFAV4P+HSm96rqFuGG6+vpvyMz9O3u15V/BaoeaHrBfJNia/Khpq5aI8vE/8oA== Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [147.75.48.161]) by mx.google.com with ESMTPS id q6-20020a170902eb8600b001d973ab7bd3si475046plg.48.2024.02.12.08.37.11 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 12 Feb 2024 08:37:11 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-61973-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) client-ip=147.75.48.161; Authentication-Results: mx.google.com; dkim=pass header.i=@ti.com header.s=ti-com-17Q1 header.b=kuV50zaN; 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-61973-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-61973-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 sy.mirrors.kernel.org (Postfix) with ESMTPS id 5832EB229CD for ; Mon, 12 Feb 2024 16:34:36 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 969CB4DA16; Mon, 12 Feb 2024 16:29:00 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=ti.com header.i=@ti.com header.b="kuV50zaN" Received: from lelv0142.ext.ti.com (lelv0142.ext.ti.com [198.47.23.249]) (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 D0D7847A5D; Mon, 12 Feb 2024 16:28:55 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=198.47.23.249 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707755337; cv=none; b=CcWaNKD8gtvt6g9GMviuTFZ15qoinIlzPWPom49IUcuwqRQqX2U7xzpgMXWRG93RFbL4lFOAudfIaEANj4dtnOX4v8pTXKSC+Zx1JtTiZVMWXBbhIGvoYBBdpd32D8eAmC2Mt5fEtfxT+UILc1zYKbSYrYvTICKSrv92w6zUnf0= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707755337; c=relaxed/simple; bh=RxXJw64OwJAtdWJLJWPIzMTgt8BfdaiVjURfYs0Yq3k=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=Beo4GE+98R61XlwXyuGDxX94MtMnV0lN4r6dbyhuYH3REEDO3LtA17X0OWR/uixjJmMiSrApzu5RXg6c+zFuaFNeSop3eJvqwhbiMkz8A83bGRBTh5E/fIJ3pKPDEMzdz7dbdFANmefGaxWu0NLL6Sw+nM5mygcF8nYu9BDBP40= 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=kuV50zaN; arc=none smtp.client-ip=198.47.23.249 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 fllv0035.itg.ti.com ([10.64.41.0]) by lelv0142.ext.ti.com (8.15.2/8.15.2) with ESMTP id 41CGSiiF004180; Mon, 12 Feb 2024 10:28:44 -0600 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ti.com; s=ti-com-17Q1; t=1707755324; bh=Kv9JczQeQR+ifDe2YtY2D7JV7A0GaYQwadF3KmYeaVc=; h=From:To:CC:Subject:Date:In-Reply-To:References; b=kuV50zaNhFmvV87ZrvdHIO4lkV6nZ0/ikkX3WKcyT3ePHjBQBVJ6OjF3vaqmEvfFI xB25hPpyNLfeVYwmNdv5t5PPpkKsZLcU20PsWFrzDyohAtfsYvgZ/AR9mJaavVVX2M LLrPpxH4MquVAIuynWxccSb2B/NNe1d66+i7//cA= Received: from DFLE111.ent.ti.com (dfle111.ent.ti.com [10.64.6.32]) by fllv0035.itg.ti.com (8.15.2/8.15.2) with ESMTPS id 41CGSicq047017 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=FAIL); Mon, 12 Feb 2024 10:28:44 -0600 Received: from DFLE108.ent.ti.com (10.64.6.29) by DFLE111.ent.ti.com (10.64.6.32) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.2507.23; Mon, 12 Feb 2024 10:28:44 -0600 Received: from lelvsmtp6.itg.ti.com (10.180.75.249) by DFLE108.ent.ti.com (10.64.6.29) 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; Mon, 12 Feb 2024 10:28:44 -0600 Received: from lelvsmtp5.itg.ti.com ([10.249.42.149]) by lelvsmtp6.itg.ti.com (8.15.2/8.15.2) with ESMTP id 41CGSWRE090688; Mon, 12 Feb 2024 10:28:43 -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 v4 18/19] power: reset: syscon-poweroff: Move device data into a struct Date: Mon, 12 Feb 2024 10:28:30 -0600 Message-ID: <20240212162831.67838-19-afd@ti.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240212162831.67838-1-afd@ti.com> References: <20240212162831.67838-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: 1790711779206276601 X-GMAIL-MSGID: 1790711779206276601 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 Reviewed-by: AngeloGioacchino Del Regno --- drivers/power/reset/syscon-poweroff.c | 40 ++++++++++++++++----------- 1 file changed, 24 insertions(+), 16 deletions(-) diff --git a/drivers/power/reset/syscon-poweroff.c b/drivers/power/reset/syscon-poweroff.c index 1b2ce7734260c..19c8da997b4c8 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,26 @@ 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 = devm_kzalloc(dev, sizeof(*data), GFP_KERNEL); + if (!data) + return -ENOMEM; + + 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 +66,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) {