From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from frasgout.his.huawei.com (frasgout.his.huawei.com [185.176.79.56]) (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 51B0C22FDEC; Mon, 10 Nov 2025 16:11:05 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=185.176.79.56 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1762791067; cv=none; b=UvNteOdHf5WX9PxPf76ja2IefPkxHqAWZVZI1pNQXuLoINM4kKZ8bplaV76yUyGKWLXeD0gVPAO02XpbxBoKGcEVobcs/VtEUKvjPeQbgVGAEgNTW3qBvWHS81HBgJHakwV5/iYXuXJRtG6Cq0N6ze8xJzuUf2grloj8Rt5806A= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1762791067; c=relaxed/simple; bh=WzOv8NXNcifmk9Zr6KwL2Xm62FjbQz/VGh1p1ppXMwc=; h=Date:From:To:CC:Subject:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=el+8aPopV39D0Gb55CAxELVJjxNq2JbtXvcQWNpKwIw4NAMBbXmX1wvXqlcFu5aeHQwtcb97N1QW9NYgSdDDS02i2T7yVYXsl1EmPD015VYZLM2pQQ4Sui+YAk/opWZBxaZZr+BOXvuX6P1KEa+rT/3chD5kWDhXw236KeVOW/E= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=huawei.com; spf=pass smtp.mailfrom=huawei.com; arc=none smtp.client-ip=185.176.79.56 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=huawei.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=huawei.com Received: from mail.maildlp.com (unknown [172.18.186.231]) by frasgout.his.huawei.com (SkyGuard) with ESMTPS id 4d4vlY4rJ8zJ46Bd; Tue, 11 Nov 2025 00:10:33 +0800 (CST) Received: from dubpeml100005.china.huawei.com (unknown [7.214.146.113]) by mail.maildlp.com (Postfix) with ESMTPS id 27CB114033C; Tue, 11 Nov 2025 00:11:03 +0800 (CST) Received: from localhost (10.203.177.15) by dubpeml100005.china.huawei.com (7.214.146.113) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1544.36; Mon, 10 Nov 2025 16:11:01 +0000 Date: Mon, 10 Nov 2025 16:11:00 +0000 From: Jonathan Cameron To: Ben Horgan CC: , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , Subject: Re: [PATCH 08/33] ACPI: Define acpi_put_table cleanup handler and acpi_get_table_ret() helper Message-ID: <20251110161100.000039f3@huawei.com> In-Reply-To: <20251107123450.664001-9-ben.horgan@arm.com> References: <20251107123450.664001-1-ben.horgan@arm.com> <20251107123450.664001-9-ben.horgan@arm.com> X-Mailer: Claws Mail 4.3.0 (GTK 3.24.42; x86_64-w64-mingw32) Precedence: bulk X-Mailing-List: linux-acpi@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="US-ASCII" Content-Transfer-Encoding: 7bit X-ClientProxiedBy: lhrpeml100010.china.huawei.com (7.191.174.197) To dubpeml100005.china.huawei.com (7.214.146.113) On Fri, 7 Nov 2025 12:34:25 +0000 Ben Horgan wrote: > Define a cleanup helper for use with __free to release the acpi table when > the pointer goes out of scope. Also, introduce the helper > acpi_get_table_ret() to simplify a commonly used pattern involving > acpi_get_table(). > > These are first used in a subsequent commit. > > Signed-off-by: Ben Horgan Seems useful enough to be to be worth having. Needs input from Rafael. Reviewed-by: Jonathan Cameron > --- > include/linux/acpi.h | 12 ++++++++++++ > 1 file changed, 12 insertions(+) > > diff --git a/include/linux/acpi.h b/include/linux/acpi.h > index a9dbacabdf89..1124b7dc79fd 100644 > --- a/include/linux/acpi.h > +++ b/include/linux/acpi.h > @@ -8,6 +8,7 @@ > #ifndef _LINUX_ACPI_H > #define _LINUX_ACPI_H > > +#include > #include > #include /* for struct resource */ > #include > @@ -221,6 +222,17 @@ void acpi_reserve_initial_tables (void); > void acpi_table_init_complete (void); > int acpi_table_init (void); > > +static inline struct acpi_table_header *acpi_get_table_ret(char *signature, u32 instance) > +{ > + struct acpi_table_header *table; > + int status = acpi_get_table(signature, instance, &table); > + > + if (ACPI_FAILURE(status)) > + return ERR_PTR(-ENOENT); > + return table; > +} > +DEFINE_FREE(acpi_put_table, struct acpi_table_header *, if (!IS_ERR_OR_NULL(_T)) acpi_put_table(_T)) > + > int acpi_table_parse(char *id, acpi_tbl_table_handler handler); > int __init_or_acpilib acpi_table_parse_entries(char *id, > unsigned long table_size, int entry_id,