From patchwork Thu Jun 10 16:39:12 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ioana Ciornei X-Patchwork-Id: 12313549 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-12.8 required=3.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED,DKIM_SIGNED,DKIM_VALID,FREEMAIL_FORGED_FROMDOMAIN, FREEMAIL_FROM,HEADER_FROM_DIFFERENT_DOMAINS,HK_RANDOM_FROM, INCLUDES_CR_TRAILER,INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS, URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 731BDC48BD1 for ; Thu, 10 Jun 2021 16:42:45 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 416E4613E1 for ; Thu, 10 Jun 2021 16:42:45 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 416E4613E1 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=1HiI8dLmPGX9rZDq6j13PmQnqfXO77tnPHOLibTys0Y=; b=VKAzVOwq0aMoIw K0cSqVuZE8Lfa8mjDxfxN+dWNW21liP/Xp+3EAEjTIrqO3Gt4aU1JyahUwvCgUNMwohVO5hdE61tm Hay7nRar+oy6J93Vn/MU7p7AU8aeRdxaS7R7Yw1YmtnE9H2r/iBQzivTAKJA/QHGBXXaj5ebZaXQe MiyecmIMuVce++pzw+KqtO/GkMWJgIuYr4g1d8qgLRBlLNv6IyB4ThwrJSEDZgrFm7am5sumV+J7r EjPGsqQlO5ckKbfICgbrr+/h06BW+RX8vumn8IZAAqq1AH7amSgJObUZTpy0wwha9abujhlan8+8d EIbGK9CpEN75Htp6qsYA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1lrNjp-001iE9-Ob; Thu, 10 Jun 2021 16:41:01 +0000 Received: from mail-ej1-x635.google.com ([2a00:1450:4864:20::635]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1lrNjR-001i7P-PU for linux-arm-kernel@lists.infradead.org; Thu, 10 Jun 2021 16:40:39 +0000 Received: by mail-ej1-x635.google.com with SMTP id ho18so190865ejc.8 for ; Thu, 10 Jun 2021 09:40:37 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=WYaGnISu1YfOE/7UiWGOnu7UNyMRUmG6vqNEYiYQnuw=; b=oOrrc83d8TfIoeXmdiRoiQg6glDODRsfbpbGcLCinVvDPPg4EwsRnclPpJGstuwomD Loe/4iW8ArsQULGi5DaAxbHMvjJ13BPDnbOvZFsEIy2ZPqa51dMbtxYcG4fAawlfR5Jw gKTx7B4SvmEIZY4c0R/PpJdoCQghcoPfzZVhxZ7hdlYVA+oiAlarlUZJGfRfK2IWs1Td UZzn1wJtbaW8kK82d/ly2IcvdtRmbDm2YUKBIz3x6xvsxQcsRVk/ALJGw+GQysJYmabr kg3GsAnLtefhEN7Mwo92YkIbiYiaolH7vbQ77mxVB7Hn9LPpR2OIxhHZvc1a34OC2264 AXQg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=WYaGnISu1YfOE/7UiWGOnu7UNyMRUmG6vqNEYiYQnuw=; b=cJ0UtSx+ySeuNkW1upMgu6JmkZKZr9FcyXCeIIor5JVhdpQfE91EQmMTy00a2eieWD xrZs10ntW37z2I0u7acHE5wfVcDoF0urGwgVW8GiOjB5xuiP+JRWj4smMN/QKTO+gKzI FgwQwE8iA3XaNtFyezDHhliKBwZe8QP3TKAZN3QnwRi78T5MqjrL/jBcNiqV6exsVUXH nIYAVQaoAcJdsFI0BdSQj1zsyDNTSCfWcZ4v3jQj/w9SSsLYQI5p8qVv0kiT7TYzae+W ds7qSN7xoZlXqVEKW387nGEbCQ3rjirdUZCrTTpStX/4jVOgwyGCASMF7dA0jK4HC44w vHyQ== X-Gm-Message-State: AOAM532tXgQw7TLCTDrtXhTav76zQtAEcCwwYSoep6TMpAH/kWP7oLWi wc0haIo39cr9ahodqfsEIlo= X-Google-Smtp-Source: ABdhPJwO+2kntI2vKAnq2EhOGIoStYyq0+AsQrrHaXncx6UCvB7nJNv9I6rRDQY/bNNB9TrVGooJag== X-Received: by 2002:a17:906:714d:: with SMTP id z13mr515845ejj.48.1623343236264; Thu, 10 Jun 2021 09:40:36 -0700 (PDT) Received: from yoga-910.localhost ([188.26.52.84]) by smtp.gmail.com with ESMTPSA id e22sm1657166edv.57.2021.06.10.09.40.34 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 10 Jun 2021 09:40:35 -0700 (PDT) From: Ioana Ciornei To: Grant Likely , "Rafael J . Wysocki" , Jeremy Linton , Andrew Lunn , Andy Shevchenko , Florian Fainelli , Russell King - ARM Linux admin , Heikki Krogerus , Marcin Wojtas , Pieter Jansen Van Vuuren , Jon , Saravana Kannan , Randy Dunlap , calvin.johnson@nxp.com Cc: Cristi Sovaiala , Florin Laurentiu Chiculita , Madalin Bucur , linux-arm-kernel@lists.infradead.org, Diana Madalina Craciun , linux-acpi@vger.kernel.org, linux-kernel@vger.kernel.org, linux.cj@gmail.com, netdev@vger.kernel.org, Laurentiu Tudor , Len Brown , "Rafael J . Wysocki" , Calvin Johnson , Ioana Ciornei Subject: [PATCH net-next v8 10/15] ACPI: utils: Introduce acpi_get_local_address() Date: Thu, 10 Jun 2021 19:39:12 +0300 Message-Id: <20210610163917.4138412-11-ciorneiioana@gmail.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210610163917.4138412-1-ciorneiioana@gmail.com> References: <20210610163917.4138412-1-ciorneiioana@gmail.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210610_094037_853734_3EA4565B X-CRM114-Status: GOOD ( 12.90 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org From: Calvin Johnson Introduce a wrapper around the _ADR evaluation. Signed-off-by: Calvin Johnson Reviewed-by: Andy Shevchenko Signed-off-by: Ioana Ciornei Acked-by: Rafael J. Wysocki --- Changes in v8: None Changes in v7: None Changes in v6: None Changes in v5: - Replace fwnode_get_id() with acpi_get_local_address() Changes in v4: - Improve code structure to handle all cases Changes in v3: - Modified to retrieve reg property value for ACPI as well - Resolved compilation issue with CONFIG_ACPI = n - Added more info into documentation drivers/acpi/utils.c | 14 ++++++++++++++ include/linux/acpi.h | 7 +++++++ 2 files changed, 21 insertions(+) diff --git a/drivers/acpi/utils.c b/drivers/acpi/utils.c index 3b54b8fd7396..e7ddd281afff 100644 --- a/drivers/acpi/utils.c +++ b/drivers/acpi/utils.c @@ -277,6 +277,20 @@ acpi_evaluate_integer(acpi_handle handle, EXPORT_SYMBOL(acpi_evaluate_integer); +int acpi_get_local_address(acpi_handle handle, u32 *addr) +{ + unsigned long long adr; + acpi_status status; + + status = acpi_evaluate_integer(handle, METHOD_NAME__ADR, NULL, &adr); + if (ACPI_FAILURE(status)) + return -ENODATA; + + *addr = (u32)adr; + return 0; +} +EXPORT_SYMBOL(acpi_get_local_address); + acpi_status acpi_evaluate_reference(acpi_handle handle, acpi_string pathname, diff --git a/include/linux/acpi.h b/include/linux/acpi.h index c60745f657e9..6ace3a0f1415 100644 --- a/include/linux/acpi.h +++ b/include/linux/acpi.h @@ -710,6 +710,8 @@ static inline u64 acpi_arch_get_root_pointer(void) } #endif +int acpi_get_local_address(acpi_handle handle, u32 *addr); + #else /* !CONFIG_ACPI */ #define acpi_disabled 1 @@ -965,6 +967,11 @@ static inline struct acpi_device *acpi_resource_consumer(struct resource *res) return NULL; } +static inline int acpi_get_local_address(acpi_handle handle, u32 *addr) +{ + return -ENODEV; +} + #endif /* !CONFIG_ACPI */ #ifdef CONFIG_ACPI_HOTPLUG_IOAPIC