From nobody Fri Dec 19 20:51:09 2025 Received: from fgw22-7.mail.saunalahti.fi (fgw22-7.mail.saunalahti.fi [62.142.5.83]) (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 ADAA016B72D for ; Tue, 28 May 2024 10:27:22 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=62.142.5.83 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1716892044; cv=none; b=JrSbHaKHXae8u7c0V3OzYXT20oe/M8l5/JwwyQR87/Imvyp2D8Pk5s3/lJpGQFWp2jSRjYpRoAT+pV082kqB9EW8nVpiKkm8/M1a2pwXyX3OrAU19SU+quokO0QpmTfkXcv9wJAVDz6b69g4GCgNt8nDQyVC+lGpCuVOS5FB4vM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1716892044; c=relaxed/simple; bh=GZc8x9iHuY9Px/1rUVgjFt08MsDSpXrXnuf9QEySDXM=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=GXVHMZws+2bQbwGo3r3U1KCsyHwU3diQTO6z3lqQvZXp67lB+196wN1BqQGYA2ULuPFAswE2QIuVt9e1Pbfvm9f7C0Te3T9dgd/bNevgw6Ibq17SbjPFNl/6MX+krXShh0uyg3wzrT997cCZXhHNLPn/swnWmUHlqMJP1YdNyPs= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com; spf=fail smtp.mailfrom=gmail.com; arc=none smtp.client-ip=62.142.5.83 Authentication-Results: smtp.subspace.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=fail smtp.mailfrom=gmail.com Received: from localhost (88-113-26-230.elisa-laajakaista.fi [88.113.26.230]) by fgw23.mail.saunalahti.fi (Halon) with ESMTP id dce6d4f4-1cdc-11ef-80c1-005056bdfda7; Tue, 28 May 2024 13:27:19 +0300 (EEST) From: Andy Shevchenko To: Andy Shevchenko , linux-acpi@vger.kernel.org, linux-kernel@vger.kernel.org Cc: "Rafael J. Wysocki" , Guanbing Huang , Guanbing Huang , Christoph Hellwig , Woody Suwalski Subject: [PATCH v2 1/2] PNP: Make dev_is_pnp() to be a function and export it for modules Date: Tue, 28 May 2024 13:25:02 +0300 Message-ID: <20240528102708.1451343-2-andy.shevchenko@gmail.com> X-Mailer: git-send-email 2.45.1 In-Reply-To: <20240528102708.1451343-1-andy.shevchenko@gmail.com> References: <20240528102708.1451343-1-andy.shevchenko@gmail.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Since we have a dev_is_pnp() macro that utilises the address of the pnp_bus_type variable, the users, which can be compiled as modules, will fail to build. Convert the macro to be a function and export it to the modules to prevent build breakage. Reported-by: Woody Suwalski Closes: https://lore.kernel.org/r/cc8a93b2-2504-9754-e26c-5d5c3bd1265c@gmai= l.com Fixes: 2a49b45cd0e7 ("PNP: Add dev_is_pnp() macro") Signed-off-by: Andy Shevchenko Reviewed-by: Christoph Hellwig --- drivers/pnp/driver.c | 6 ++++++ include/linux/pnp.h | 4 ++-- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/drivers/pnp/driver.c b/drivers/pnp/driver.c index 0a5d0d8befa8..3483e52e3a81 100644 --- a/drivers/pnp/driver.c +++ b/drivers/pnp/driver.c @@ -266,6 +266,12 @@ const struct bus_type pnp_bus_type =3D { .dev_groups =3D pnp_dev_groups, }; =20 +bool dev_is_pnp(const struct device *dev) +{ + return dev->bus =3D=3D &pnp_bus_type; +} +EXPORT_SYMBOL_GPL(dev_is_pnp); + int pnp_register_driver(struct pnp_driver *drv) { drv->driver.name =3D drv->name; diff --git a/include/linux/pnp.h b/include/linux/pnp.h index 82561242cda4..a8def1cea32c 100644 --- a/include/linux/pnp.h +++ b/include/linux/pnp.h @@ -469,7 +469,7 @@ int compare_pnp_id(struct pnp_id *pos, const char *id); int pnp_register_driver(struct pnp_driver *drv); void pnp_unregister_driver(struct pnp_driver *drv); =20 -#define dev_is_pnp(d) ((d)->bus =3D=3D &pnp_bus_type) +bool dev_is_pnp(const struct device *dev); =20 #else =20 @@ -502,7 +502,7 @@ static inline int compare_pnp_id(struct pnp_id *pos, co= nst char *id) { return -E static inline int pnp_register_driver(struct pnp_driver *drv) { return -EN= ODEV; } static inline void pnp_unregister_driver(struct pnp_driver *drv) { } =20 -#define dev_is_pnp(d) false +static inline bool dev_is_pnp(const struct device *dev) { return false; } =20 #endif /* CONFIG_PNP */ =20 --=20 2.45.1 From nobody Fri Dec 19 20:51:09 2025 Received: from fgw22-7.mail.saunalahti.fi (fgw22-7.mail.saunalahti.fi [62.142.5.83]) (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 7CB1816B740 for ; Tue, 28 May 2024 10:27:23 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=62.142.5.83 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1716892045; cv=none; b=bATcfAqDRO3ZCEFqc5cGWY+kozKH8r+GlumJWT4Shc3vlNJbmzgG4SnLzgQXnr5mGRl5rlaUsiEppIWIjdqVEV47yTAs7DPfQI9yP9Nlc2obo55CQrpuoluQu8MAEU1sp1ybawVKRizgoBxRa8cGxycsBkPJUxr45vUG2y2c85s= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1716892045; c=relaxed/simple; bh=BNnZ7gYxVPG+zhntrXhysWWcp6Wfp3QG2SUsNPXf5hg=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=fXEyNNfmlZWAYk1xX8OBCCIP5iQZ2sswcg1IOYOxeOqEV5Fuz58FfSoH5bXiYPtLysWOVpHyV6uSEAELXNPpYioW/FGT0SgK5Rm/CCeXMYwsafZ44nyBR6npgmPKfthQt964/Os7D62iHnzBKRQi1dPd4oz5mddQ7rRMOzCgljs= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com; spf=fail smtp.mailfrom=gmail.com; arc=none smtp.client-ip=62.142.5.83 Authentication-Results: smtp.subspace.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=fail smtp.mailfrom=gmail.com Received: from localhost (88-113-26-230.elisa-laajakaista.fi [88.113.26.230]) by fgw21.mail.saunalahti.fi (Halon) with ESMTP id dd9a6722-1cdc-11ef-aaf4-005056bdd08f; Tue, 28 May 2024 13:27:21 +0300 (EEST) From: Andy Shevchenko To: Andy Shevchenko , linux-acpi@vger.kernel.org, linux-kernel@vger.kernel.org Cc: "Rafael J. Wysocki" , Guanbing Huang , Guanbing Huang , Christoph Hellwig Subject: [PATCH v2 2/2] PNP: Hide pnp_bus_type from the non-PNP code Date: Tue, 28 May 2024 13:25:03 +0300 Message-ID: <20240528102708.1451343-3-andy.shevchenko@gmail.com> X-Mailer: git-send-email 2.45.1 In-Reply-To: <20240528102708.1451343-1-andy.shevchenko@gmail.com> References: <20240528102708.1451343-1-andy.shevchenko@gmail.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" The pnp_bus_type is defined only when CONFIG_PNP=3Dy, while being not guarded by ifdeffery in the header. Moreover, it's not used outside of the PNP code. Move it to the internal header to make sure no-one will try to (ab)use it. Signed-off-by: Andy Shevchenko Reviewed-by: Christoph Hellwig --- drivers/pnp/base.h | 1 + include/linux/pnp.h | 2 -- 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/drivers/pnp/base.h b/drivers/pnp/base.h index e74a0f6a3157..4e80273dfb1e 100644 --- a/drivers/pnp/base.h +++ b/drivers/pnp/base.h @@ -6,6 +6,7 @@ =20 extern struct mutex pnp_lock; extern const struct attribute_group *pnp_dev_groups[]; +extern const struct bus_type pnp_bus_type; =20 int pnp_register_protocol(struct pnp_protocol *protocol); void pnp_unregister_protocol(struct pnp_protocol *protocol); diff --git a/include/linux/pnp.h b/include/linux/pnp.h index a8def1cea32c..7f2ff95d2deb 100644 --- a/include/linux/pnp.h +++ b/include/linux/pnp.h @@ -435,8 +435,6 @@ struct pnp_protocol { #define protocol_for_each_dev(protocol, dev) \ list_for_each_entry(dev, &(protocol)->devices, protocol_list) =20 -extern const struct bus_type pnp_bus_type; - #if defined(CONFIG_PNP) =20 /* device management */ --=20 2.45.1