[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20250218-pdev-uaf-v1-1-5ea1a0d3aba0@bootlin.com>
Date: Tue, 18 Feb 2025 12:00:12 +0100
From: Théo Lebrun <theo.lebrun@...tlin.com>
To: Greg Kroah-Hartman <gregkh@...uxfoundation.org>,
"Rafael J. Wysocki" <rafael@...nel.org>, Danilo Krummrich <dakr@...nel.org>,
Rob Herring <robh@...nel.org>, Saravana Kannan <saravanak@...gle.com>,
"David S. Miller" <davem@...emloft.net>,
Grant Likely <grant.likely@...retlab.ca>
Cc: linux-kernel@...r.kernel.org, devicetree@...r.kernel.org,
Liam Girdwood <lgirdwood@...il.com>, Mark Brown <broonie@...nel.org>,
Jaroslav Kysela <perex@...ex.cz>, Takashi Iwai <tiwai@...e.com>,
Binbin Zhou <zhoubinbin@...ngson.cn>, linux-sound@...r.kernel.org,
Vladimir Kondratiev <vladimir.kondratiev@...ileye.com>,
Grégory Clement <gregory.clement@...tlin.com>,
Thomas Petazzoni <thomas.petazzoni@...tlin.com>,
Tawfik Bayouk <tawfik.bayouk@...ileye.com>,
Théo Lebrun <theo.lebrun@...tlin.com>,
stable@...r.kernel.org
Subject: [PATCH 1/2] driver core: platform: turn pdev->id_auto into
pdev->flags
struct platform_device->id_auto is the only boolean stored inside the
structure. Remove it and add an u8 flags field. The goal is to allow
more flags (without using more memory).
Cc: <stable@...r.kernel.org>
Signed-off-by: Théo Lebrun <theo.lebrun@...tlin.com>
---
drivers/base/platform.c | 6 +++---
include/linux/platform_device.h | 3 ++-
2 files changed, 5 insertions(+), 4 deletions(-)
diff --git a/drivers/base/platform.c b/drivers/base/platform.c
index 6f2a33722c5203ac196a6e36e153648d0fe6c6d4..e2284482c7ba7c12fe2ab3c715e7d1daa3f65021 100644
--- a/drivers/base/platform.c
+++ b/drivers/base/platform.c
@@ -682,7 +682,7 @@ int platform_device_add(struct platform_device *pdev)
if (ret < 0)
return ret;
pdev->id = ret;
- pdev->id_auto = true;
+ pdev->flags |= PLATFORM_DEVICE_FLAG_ID_AUTO;
dev_set_name(dev, "%s.%d.auto", pdev->name, pdev->id);
break;
}
@@ -720,7 +720,7 @@ int platform_device_add(struct platform_device *pdev)
return 0;
failed:
- if (pdev->id_auto) {
+ if (pdev->flags & PLATFORM_DEVICE_FLAG_ID_AUTO) {
ida_free(&platform_devid_ida, pdev->id);
pdev->id = PLATFORM_DEVID_AUTO;
}
@@ -750,7 +750,7 @@ void platform_device_del(struct platform_device *pdev)
if (!IS_ERR_OR_NULL(pdev)) {
device_del(&pdev->dev);
- if (pdev->id_auto) {
+ if (pdev->flags & PLATFORM_DEVICE_FLAG_ID_AUTO) {
ida_free(&platform_devid_ida, pdev->id);
pdev->id = PLATFORM_DEVID_AUTO;
}
diff --git a/include/linux/platform_device.h b/include/linux/platform_device.h
index 074754c23d330c9a099e20eecfeb6cbd5025e04f..d842b21ba3791f974fa62f52bd160ef5820261c1 100644
--- a/include/linux/platform_device.h
+++ b/include/linux/platform_device.h
@@ -23,7 +23,8 @@ struct platform_device_id;
struct platform_device {
const char *name;
int id;
- bool id_auto;
+ u8 flags;
+#define PLATFORM_DEVICE_FLAG_ID_AUTO BIT(0)
struct device dev;
u64 platform_dma_mask;
struct device_dma_parameters dma_parms;
--
2.48.1
Powered by blists - more mailing lists