[PATCH 1/2] driver core: platform: turn pdev->id_auto into pdev->flags

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]



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@xxxxxxxxxxxxxxx>
Signed-off-by: Théo Lebrun <theo.lebrun@xxxxxxxxxxx>
---
 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





[Index of Archives]     [Pulseaudio]     [Linux Audio Users]     [ALSA Devel]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]

  Powered by Linux