From patchwork Fri Jun 9 18:32:52 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Rob Herring X-Patchwork-Id: 105769 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:994d:0:b0:3d9:f83d:47d9 with SMTP id k13csp1110809vqr; Fri, 9 Jun 2023 11:42:19 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ7eFzlknUZkrivQaKsE8peUYFUp2RjyN4j91RSITXp+UvNo3MqOmTXWceq3PZEHk7kb00sY X-Received: by 2002:a17:903:32ca:b0:1ae:50cc:455 with SMTP id i10-20020a17090332ca00b001ae50cc0455mr1866407plr.39.1686336139019; Fri, 09 Jun 2023 11:42:19 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1686336139; cv=none; d=google.com; s=arc-20160816; b=dTmb+0QSa08r2wyDJvLZ+YZ3qT9bjNOiqGw0bDP51kjb/2ndvQYHaMTsjpAzCg4UDW OM8ztfeDDLwfhUWOgoymF4wSlD94MWZMuXnMTALzKywvXaYygnhPQASFxucBsDQm+Qfa 2b8fpvqnp+ysXpxljSMbLSDphz541IvHYiN7YQjZyxAzqRKljQMlgBuiHEffzi9OdbPr +jfOSzP+elCzKcZA/fD8bt8OKwWbf9uQoDYOp01BxIxpx3BjrXQ4X2NayGYCjh263X7D EhCSIL0Gr9q3mC+6eTGo9SNAb4mDK/OAF70Zbp14sxmJ38uRfXdl6rQXYdwRm4zZeHr/ 2htw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from; bh=AGqPwyg/tCD/J3bWMKGMkc2zAlUcbkmqtQu/P2N7szY=; b=Z2L0a0L+vrV/kffGCAr+AaJftZFRuxxUT/YSnrmofJPH8yinqqh5C2lTopNZmcmkV2 CFfvO1sWcGZFgqP1+42A1WHtpEx4yriwvG3HDCnBjQkeHcvxIsso97elo58f57jKbJpP 1F9m6tZ8JnIupg7jBoVQl66zQzY+ESqX2bEt/MIfupvPK7O3RiShldkeRvaegPATSpC4 64caIXUH69yD/+AF5DfgTinEVEvflZVWrwFaB7U2Ml5S4yy6JGA9nFFMErvYxw9Ty056 kVsYRjpz1XQx902+IiWDnzPS0GccXIC5U6/JEgafUpU/W/jruf72Xv6F/dJKlrRJIC6p k4ng== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id y15-20020a17090322cf00b001b055bd62f6si3148331plg.431.2023.06.09.11.42.05; Fri, 09 Jun 2023 11:42:19 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231580AbjFISde (ORCPT + 99 others); Fri, 9 Jun 2023 14:33:34 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46992 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231193AbjFISd1 (ORCPT ); Fri, 9 Jun 2023 14:33:27 -0400 Received: from mail-il1-f179.google.com (mail-il1-f179.google.com [209.85.166.179]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 424A13AAD; Fri, 9 Jun 2023 11:33:02 -0700 (PDT) Received: by mail-il1-f179.google.com with SMTP id e9e14a558f8ab-33e53672aa6so8864945ab.1; Fri, 09 Jun 2023 11:33:02 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1686335581; x=1688927581; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=AGqPwyg/tCD/J3bWMKGMkc2zAlUcbkmqtQu/P2N7szY=; b=WTHqAbnLUxyBGV+5fdmv72hFow6j5lAPFihN2WPIDmhpeWUB5p2qtWsEMrP6UtgUzy HOyx00qgfUw1ecu2BKeXpJe/4b6PFNQ4S67CU9CH+pRtBm1jrCqEdd33FFshmewKm2UQ azFeU61i8LJCPLCr8lugll3/65F6dJqUz8Pw5tOfKzzxreccVp5e786ZHbh96YVL/SBz rLtXbOzOh3ok7qj7008+k0LEW+A9cLRAE7dtjEvesZgIr4UpJfgJyM57klZT1chvc/VA quFeHVR8n3M+cA9P6RVmxeKS88hNTRsk4ozw1JJCbIvsjN8v+GNMhpO7uMxIYj1tNGeJ ZPNw== X-Gm-Message-State: AC+VfDxEwOOQFFPbDzeGnv38MU7O+2CRyqJHTEiZZo0oXgvXe8Rmdc0z lK1dafcvL6fiVSq6q2yyZw== X-Received: by 2002:a92:ce11:0:b0:33a:56d6:d9a4 with SMTP id b17-20020a92ce11000000b0033a56d6d9a4mr2619749ilo.10.1686335581349; Fri, 09 Jun 2023 11:33:01 -0700 (PDT) Received: from robh_at_kernel.org ([64.188.179.250]) by smtp.gmail.com with ESMTPSA id p10-20020a92c10a000000b0033b27117120sm1220618ile.13.2023.06.09.11.33.00 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 09 Jun 2023 11:33:00 -0700 (PDT) Received: (nullmailer pid 1767637 invoked by uid 1000); Fri, 09 Jun 2023 18:32:59 -0000 From: Rob Herring To: =?utf-8?q?Beno=C3=AEt_Cousson?= , Paul Walmsley , Tony Lindgren , Russell King Cc: linux-omap@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org Subject: [PATCH] ARM: omap2: Use of_range_to_resource() for "ranges" parsing Date: Fri, 9 Jun 2023 12:32:52 -0600 Message-Id: <20230609183252.1767487-1-robh@kernel.org> X-Mailer: git-send-email 2.39.2 MIME-Version: 1.0 X-Spam-Status: No, score=-1.2 required=5.0 tests=BAYES_00, FREEMAIL_ENVFROM_END_DIGIT,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H2, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1768251603243080150?= X-GMAIL-MSGID: =?utf-8?q?1768251603243080150?= "ranges" is a standard property with common parsing functions. Users shouldn't be implementing their own parsing of it. Use the recently added of_range_to_resource() function instead for OMAP hwmod. Signed-off-by: Rob Herring --- arch/arm/mach-omap2/omap_hwmod.c | 45 +++++--------------------------- 1 file changed, 6 insertions(+), 39 deletions(-) diff --git a/arch/arm/mach-omap2/omap_hwmod.c b/arch/arm/mach-omap2/omap_hwmod.c index aac4c4ee2528..1e17b5f77588 100644 --- a/arch/arm/mach-omap2/omap_hwmod.c +++ b/arch/arm/mach-omap2/omap_hwmod.c @@ -2194,23 +2194,8 @@ int omap_hwmod_parse_module_range(struct omap_hwmod *oh, struct resource *res) { struct property *prop; - const __be32 *ranges; const char *name; - u32 nr_addr, nr_size; - u64 base, size; - int len, error; - - if (!res) - return -EINVAL; - - ranges = of_get_property(np, "ranges", &len); - if (!ranges) - return -ENOENT; - - len /= sizeof(*ranges); - - if (len < 3) - return -EINVAL; + int err; of_property_for_each_string(np, "compatible", prop, name) if (!strncmp("ti,sysc-", name, 8)) @@ -2219,26 +2204,12 @@ int omap_hwmod_parse_module_range(struct omap_hwmod *oh, if (!name) return -ENOENT; - error = of_property_read_u32(np, "#address-cells", &nr_addr); - if (error) - return -ENOENT; + err = of_range_to_resource(np, 0, res); + if (err) + return err; - error = of_property_read_u32(np, "#size-cells", &nr_size); - if (error) - return -ENOENT; - - if (nr_addr != 1 || nr_size != 1) { - pr_err("%s: invalid range for %s->%pOFn\n", __func__, - oh->name, np); - return -EINVAL; - } - - ranges++; - base = of_translate_address(np, ranges++); - size = be32_to_cpup(ranges); - - pr_debug("omap_hwmod: %s %pOFn at 0x%llx size 0x%llx\n", - oh->name, np, base, size); + pr_debug("omap_hwmod: %s %pOFn at %pR\n", + oh->name, np, &res); if (oh && oh->mpu_rt_idx) { omap_hwmod_fix_mpu_rt_idx(oh, np, res); @@ -2246,10 +2217,6 @@ int omap_hwmod_parse_module_range(struct omap_hwmod *oh, return 0; } - res->start = base; - res->end = base + size - 1; - res->flags = IORESOURCE_MEM; - return 0; }