From patchwork Sun Mar 19 16:32:20 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Rob Herring X-Patchwork-Id: 71822 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:604a:0:0:0:0:0 with SMTP id j10csp788731wrt; Sun, 19 Mar 2023 09:37:30 -0700 (PDT) X-Google-Smtp-Source: AK7set9Nx7hUIJBlZaelLqE0cInlbo/p/QZr/z4sD3cmpVSK3+HIgFXVzT0p3LigVM/hatoWRXlz X-Received: by 2002:a05:6a20:8426:b0:d6:26a3:98d with SMTP id c38-20020a056a20842600b000d626a3098dmr16877215pzd.46.1679243849991; Sun, 19 Mar 2023 09:37:29 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1679243849; cv=none; d=google.com; s=arc-20160816; b=QgrLWdQULP5+YX7ir0+Xw/mQHdPLIcLDU3AV8a6VO22+Lwp3vbcqOgyxvp+jQf2Ocj AqFk/UgAoMhR09+sKX9krhoruOujkaPpk+pth9DMBAw3iW3GYQsYP4hSVZkHEreR5y5e XoaU4lpXYoSJIFmh9EIXdOkVZXNVFWs5mhjJAgdLs7i9lelVQi6s1GM9hqMkDFNzOyF2 56vDV7JnUY9vOMEr9KGQBKNOFUfghdITDiQCOKOEaVihOgf32w1kgGoeyD3nnYQIeSxf UoM7FnE8j8lEG+lwuGeMh5Vl6VSb6/C6h7Fo6WzRZFsYaQmudnSFrrHpIKE8kfGBjc65 3k4g== 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=1cae0i8JaCTjo4rUYT/R3b+i11mfGlF5/Y5DDWylcB0=; b=P/XI0hY5M49dBlQDWpQ6zqQx6aDkGcTFghL1+M98aEmPi9TfrkRHGZwosYUPvetCic +7hAeaubI7ffShsqufzhHL3QAv4/0dHd/0BOyf21JlYUIdz5Lns8hgT37OTEQJMv4ePU yG9iDv4L1stNcvpZufZ86udtg9omvbXpvBVt0XjJBRi9M7Qbs82Nv4fmCX/JAZRPTWBp Ziai8zCeemR++kv7XdexGmZpTlbM0b0azDv4xyrp7HCVcnrGCKrQ4VUFrL0R0thSNYdN 3D9l1bjWwBuWx6CwNpFELJZS6W9SzcpyC89Oism9Ae2nvudig4o7E8KKXSS125irqEUN OUbA== 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 j11-20020a63ec0b000000b0050bd79d02b5si8267207pgh.113.2023.03.19.09.37.15; Sun, 19 Mar 2023 09:37:29 -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 S231159AbjCSQc7 (ORCPT + 99 others); Sun, 19 Mar 2023 12:32:59 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37682 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230518AbjCSQcr (ORCPT ); Sun, 19 Mar 2023 12:32:47 -0400 Received: from mail-il1-f182.google.com (mail-il1-f182.google.com [209.85.166.182]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 445881EFD9 for ; Sun, 19 Mar 2023 09:32:27 -0700 (PDT) Received: by mail-il1-f182.google.com with SMTP id h11so5391599ild.11 for ; Sun, 19 Mar 2023 09:32:27 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1679243544; 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=1cae0i8JaCTjo4rUYT/R3b+i11mfGlF5/Y5DDWylcB0=; b=EuyQ8TXUTrR8JwWIz88gOI6b7c/g7v3bjIS0LqgRtNzh6DAGcHvshgiRuvIbkhBJmN 52OlLAeQ+ZblT82AZ2LkzLtF+uQDnGcLgAE3dclyMaaGkNjL6cwRV+EWMmodXa9PguaL GyHu0cpLT4o/IVi3qt4dx8g3CmCXGjAfVUibx+IdHoYNxG4b7cFy9kCi8M8HqK5QhjOm iN1DxW/mBVt1JOLFNoJ0dBJQdBbXNlhMYNfsiseoqzBeeLKWVQaYO6oG6LNpk7ec1wb5 1UvnnjPkiWRxAo9GXi+JjQw/RoL6aB2bBDcLT6kTURnlhtxU0ggNrUifeTpZjboVDDo1 MMvA== X-Gm-Message-State: AO0yUKWWMeraqtg3qXE6tWRuAFxZGD32ab/aiNku4fLhFgBClyFclAT3 2mMmP2TeY4+fXex7Sh3fm25y4dfYYQ== X-Received: by 2002:a92:d98d:0:b0:315:4793:f7b4 with SMTP id r13-20020a92d98d000000b003154793f7b4mr3403987iln.31.1679243544460; Sun, 19 Mar 2023 09:32:24 -0700 (PDT) Received: from robh_at_kernel.org ([2605:ef80:80c7:2689:137d:d795:47e4:3de1]) by smtp.gmail.com with ESMTPSA id k16-20020a056e02135000b00313f2279f06sm2165966ilr.73.2023.03.19.09.32.23 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 19 Mar 2023 09:32:24 -0700 (PDT) Received: (nullmailer pid 226334 invoked by uid 1000); Sun, 19 Mar 2023 16:32:21 -0000 From: Rob Herring To: Daniel Lezcano , Thomas Gleixner Cc: linux-kernel@vger.kernel.org Subject: [PATCH] clocksource/drivers/timer-ti-dm: Use of_address_to_resource() Date: Sun, 19 Mar 2023 11:32:20 -0500 Message-Id: <20230319163220.226273-1-robh@kernel.org> X-Mailer: git-send-email 2.39.2 MIME-Version: 1.0 X-Spam-Status: No, score=-1.1 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 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?1760814799459125495?= X-GMAIL-MSGID: =?utf-8?q?1760814799459125495?= Replace of_get_address() and of_translate_address() calls with single call to of_address_to_resource(). Signed-off-by: Rob Herring --- drivers/clocksource/timer-ti-dm-systimer.c | 57 ++++++++++------------ 1 file changed, 27 insertions(+), 30 deletions(-) diff --git a/drivers/clocksource/timer-ti-dm-systimer.c b/drivers/clocksource/timer-ti-dm-systimer.c index 632523c1232f..3b98a3c04f87 100644 --- a/drivers/clocksource/timer-ti-dm-systimer.c +++ b/drivers/clocksource/timer-ti-dm-systimer.c @@ -251,24 +251,22 @@ static void __init dmtimer_systimer_assign_alwon(void) counter_32k = -ENODEV; for_each_matching_node(np, dmtimer_match_table) { + struct resource res; if (!dmtimer_is_preferred(np)) continue; - if (of_property_read_bool(np, "ti,timer-alwon")) { - const __be32 *addr; - - addr = of_get_address(np, 0, NULL, NULL); - pa = of_translate_address(np, addr); - if (pa) { - /* Quirky omap3 boards must use dmtimer12 */ - if (quirk_unreliable_oscillator && - pa == 0x48318000) - continue; - - of_node_put(np); - break; - } - } + if (!of_property_read_bool(np, "ti,timer-alwon")) + continue; + + if (of_address_to_resource(np, 0, &res)) + continue; + + /* Quirky omap3 boards must use dmtimer12 */ + if (quirk_unreliable_oscillator && res.start == 0x48318000) + continue; + + of_node_put(np); + break; } /* Usually no need for dmtimer clocksource if we have counter32 */ @@ -285,24 +283,22 @@ static void __init dmtimer_systimer_assign_alwon(void) static u32 __init dmtimer_systimer_find_first_available(void) { struct device_node *np; - const __be32 *addr; u32 pa = 0; for_each_matching_node(np, dmtimer_match_table) { + struct resource res; if (!dmtimer_is_preferred(np)) continue; - addr = of_get_address(np, 0, NULL, NULL); - pa = of_translate_address(np, addr); - if (pa) { - if (pa == clocksource || pa == clockevent) { - pa = 0; - continue; - } - - of_node_put(np); - break; - } + if (of_address_to_resource(np, 0, &res)) + continue; + + if (res.start == clocksource || res.start == clockevent) + continue; + + pa = res.start; + of_node_put(np); + break; } return pa; @@ -812,7 +808,7 @@ static int __init dmtimer_clocksource_init(struct device_node *np) */ static int __init dmtimer_systimer_init(struct device_node *np) { - const __be32 *addr; + struct resource res; u32 pa; /* One time init for the preferred timer configuration */ @@ -826,8 +822,9 @@ static int __init dmtimer_systimer_init(struct device_node *np) return -EINVAL; } - addr = of_get_address(np, 0, NULL, NULL); - pa = of_translate_address(np, addr); + + of_address_to_resource(np, 0, &res); + pa = (u32)res.start; if (!pa) return -EINVAL;