From patchwork Thu May 7 10:49:16 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hans de Goede X-Patchwork-Id: 11533095 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 23BC6139A for ; Thu, 7 May 2020 10:49:28 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 0C65D20870 for ; Thu, 7 May 2020 10:49:28 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="FCfPm5yZ" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726514AbgEGKt1 (ORCPT ); Thu, 7 May 2020 06:49:27 -0400 Received: from us-smtp-1.mimecast.com ([207.211.31.81]:28588 "EHLO us-smtp-delivery-1.mimecast.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1725900AbgEGKt1 (ORCPT ); Thu, 7 May 2020 06:49:27 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1588848565; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding; bh=BEUh2QIFXXLvv2dwamDy5GA1DUcQGCNNDhH7clDR2zQ=; b=FCfPm5yZ8bhotFH2D3EZW/nJYj/q+HXyRGCDFDfghFpLv18IvspBPjFy/6+uTZy/M1Pj4X gx8hmEqw94NuIRVeGBiFAdGEvZD8UGW57UKqrYlaMKwFSAV1NMoA7Y/KtKZM+p4WoAfroF 5Wtr7SvQtLD5fxQ1kscodfVGyoC5pNE= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-379-a2fs5XMLMgOxBCmmrwq2cw-1; Thu, 07 May 2020 06:49:21 -0400 X-MC-Unique: a2fs5XMLMgOxBCmmrwq2cw-1 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 4228D80183C; Thu, 7 May 2020 10:49:20 +0000 (UTC) Received: from x1.localdomain.com (ovpn-115-120.ams2.redhat.com [10.36.115.120]) by smtp.corp.redhat.com (Postfix) with ESMTP id 51C6060C81; Thu, 7 May 2020 10:49:18 +0000 (UTC) From: Hans de Goede To: "Rafael J . Wysocki" , Len Brown , Bjorn Helgaas , Mika Westerberg , Andy Shevchenko , Linus Walleij Cc: Hans de Goede , linux-acpi@vger.kernel.org, linux-pci@vger.kernel.org, linux-gpio@vger.kernel.org Subject: [PATCH v2 1/2] ACPI / utils: Add acpi_evaluate_reg() helper Date: Thu, 7 May 2020 12:49:16 +0200 Message-Id: <20200507104917.116589-1-hdegoede@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 Sender: linux-pci-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pci@vger.kernel.org With a recent fix to the pinctrl-cherryview driver we now have 2 drivers open-coding the parameter building / passing for calling _REG on an ACPI handle. Add a helper for this, so that these 2 drivers can be converted to this helper. Suggested-by: Andy Shevchenko Reviewed-by: Andy Shevchenko Signed-off-by: Hans de Goede --- Changes in v2: - Fix spelling error in commit message - Add Andy's Suggested-by and Reviewed-by --- drivers/acpi/utils.c | 25 +++++++++++++++++++++++++ include/acpi/acpi_bus.h | 1 + 2 files changed, 26 insertions(+) diff --git a/drivers/acpi/utils.c b/drivers/acpi/utils.c index 804ac0df58ec..838b719ec7ce 100644 --- a/drivers/acpi/utils.c +++ b/drivers/acpi/utils.c @@ -605,6 +605,31 @@ acpi_status acpi_evaluate_lck(acpi_handle handle, int lock) return status; } +/** + * acpi_evaluate_reg: Evaluate _REG method to register OpRegion presence + * @handle: ACPI device handle + * @space_id: ACPI address space id to register OpRegion presence for + * @function: Parameter to pass to _REG one of ACPI_REG_CONNECT or + * ACPI_REG_DISCONNECT + * + * Evaluate device's _REG method to register OpRegion presence. + */ +acpi_status acpi_evaluate_reg(acpi_handle handle, u8 space_id, u32 function) +{ + struct acpi_object_list arg_list; + union acpi_object params[2]; + + params[0].type = ACPI_TYPE_INTEGER; + params[0].integer.value = space_id; + params[1].type = ACPI_TYPE_INTEGER; + params[1].integer.value = function; + arg_list.count = 2; + arg_list.pointer = params; + + return acpi_evaluate_object(handle, "_REG", &arg_list, NULL); +} +EXPORT_SYMBOL(acpi_evaluate_reg); + /** * acpi_evaluate_dsm - evaluate device's _DSM method * @handle: ACPI device handle diff --git a/include/acpi/acpi_bus.h b/include/acpi/acpi_bus.h index a92bea7184a8..5afb6ceb284f 100644 --- a/include/acpi/acpi_bus.h +++ b/include/acpi/acpi_bus.h @@ -44,6 +44,7 @@ acpi_status acpi_execute_simple_method(acpi_handle handle, char *method, u64 arg); acpi_status acpi_evaluate_ej0(acpi_handle handle); acpi_status acpi_evaluate_lck(acpi_handle handle, int lock); +acpi_status acpi_evaluate_reg(acpi_handle handle, u8 space_id, u32 function); bool acpi_ata_match(acpi_handle handle); bool acpi_bay_match(acpi_handle handle); bool acpi_dock_match(acpi_handle handle); From patchwork Thu May 7 10:49:17 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hans de Goede X-Patchwork-Id: 11533097 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 119C5139A for ; Thu, 7 May 2020 10:49:30 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id EC8D121582 for ; Thu, 7 May 2020 10:49:29 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="ZZSowXst" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726029AbgEGKt3 (ORCPT ); Thu, 7 May 2020 06:49:29 -0400 Received: from us-smtp-delivery-1.mimecast.com ([207.211.31.120]:59481 "EHLO us-smtp-1.mimecast.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1725900AbgEGKt2 (ORCPT ); Thu, 7 May 2020 06:49:28 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1588848567; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=8d5UnaBrJ94u+C+q660aZhujQBvIyXQp2TJsVImovW0=; b=ZZSowXstbjMaPV/rq6RCHfzW/VyivqVlR3DMzK9RfbJRVWJo294REpvRFXFxx5XaNPDxxl RFSCVtMx9RnHSElwfiy+lwpH2n/73fSp6QetFi3JYYxYCPbkWU0ALc4MKmqY+p+EwHIJeI hGioSFTBH0VXng/E9Y5KYF5lsfxdt88= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-463-lz4kF447Oz2oW5jkCD2Ktg-1; Thu, 07 May 2020 06:49:24 -0400 X-MC-Unique: lz4kF447Oz2oW5jkCD2Ktg-1 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 6C2F51030985; Thu, 7 May 2020 10:49:22 +0000 (UTC) Received: from x1.localdomain.com (ovpn-115-120.ams2.redhat.com [10.36.115.120]) by smtp.corp.redhat.com (Postfix) with ESMTP id 872E960C81; Thu, 7 May 2020 10:49:20 +0000 (UTC) From: Hans de Goede To: "Rafael J . Wysocki" , Len Brown , Bjorn Helgaas , Mika Westerberg , Andy Shevchenko , Linus Walleij Cc: Hans de Goede , linux-acpi@vger.kernel.org, linux-pci@vger.kernel.org, linux-gpio@vger.kernel.org Subject: [PATCH v2 2/2] ACPI / hotplug / PCI: Use the new acpi_evaluate_reg() helper Date: Thu, 7 May 2020 12:49:17 +0200 Message-Id: <20200507104917.116589-2-hdegoede@redhat.com> In-Reply-To: <20200507104917.116589-1-hdegoede@redhat.com> References: <20200507104917.116589-1-hdegoede@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 Sender: linux-pci-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pci@vger.kernel.org Use the new acpi_evaluate_reg() helper in the acpiphp_glue.c code. Acked-by: Bjorn Helgaas Reviewed-by: Andy Shevchenko Signed-off-by: Hans de Goede --- Changes in v2: - Leave comment about not caring about _REG errors in place - Add Bjorn's Acked-by - Add Andy's Reviewed-by --- drivers/pci/hotplug/acpiphp_glue.c | 13 +++---------- 1 file changed, 3 insertions(+), 10 deletions(-) diff --git a/drivers/pci/hotplug/acpiphp_glue.c b/drivers/pci/hotplug/acpiphp_glue.c index b3869951c0eb..b4c92cee13f8 100644 --- a/drivers/pci/hotplug/acpiphp_glue.c +++ b/drivers/pci/hotplug/acpiphp_glue.c @@ -385,19 +385,12 @@ static unsigned char acpiphp_max_busnr(struct pci_bus *bus) static void acpiphp_set_acpi_region(struct acpiphp_slot *slot) { struct acpiphp_func *func; - union acpi_object params[2]; - struct acpi_object_list arg_list; list_for_each_entry(func, &slot->funcs, sibling) { - arg_list.count = 2; - arg_list.pointer = params; - params[0].type = ACPI_TYPE_INTEGER; - params[0].integer.value = ACPI_ADR_SPACE_PCI_CONFIG; - params[1].type = ACPI_TYPE_INTEGER; - params[1].integer.value = 1; /* _REG is optional, we don't care about if there is failure */ - acpi_evaluate_object(func_to_handle(func), "_REG", &arg_list, - NULL); + acpi_evaluate_reg(func_to_handle(func), + ACPI_ADR_SPACE_PCI_CONFIG, + ACPI_REG_CONNECT); } }