[PATCH v3] driver core: Explicitly initialize struct member @data.have_async in __device_attach()
From: Zijun Hu
Date: Fri Sep 13 2024 - 10:07:17 EST
From: Zijun Hu <quic_zijuhu@xxxxxxxxxxx>
__device_attach() defines struct device_attach_data @data as auto
variable and needs to use both @data.want_async and @data.have_async
but it explicitly initializes the former and leaves compiler implicitly
initialize the later, that does not have an elegant look, solved by
explicitly initializing the later member as well that also makes @data
have full initialization.
Signed-off-by: Zijun Hu <quic_zijuhu@xxxxxxxxxxx>
---
IMO, this change still has a little bit of value as explained below:
- Looks at below similar commit:
Commit: 8f45f5071ad2 ("gpu: host1x: Explicitly initialize host1x_info structures")
- This change's initialization way is obvious better than
struct device_attach_data data = {
.dev = dev,
.check_async = allow_async,
};
which is better than current
struct device_attach_data data = {
.dev = dev,
.check_async = allow_async,
.want_async = false,
};
---
Changes in v3:
- Correct commit message.
- Link to v2: https://lore.kernel.org/r/20240823-fix_have_async-v2-1-ed1039527365@xxxxxxxxxxx
Changes in v2:
- Remove both fix and stable tag
- Correct both title and commit messages
- Link to v1: https://lore.kernel.org/r/20240823-fix_have_async-v1-1-43a354b6614b@xxxxxxxxxxx
---
drivers/base/dd.c | 1 +
1 file changed, 1 insertion(+)
diff --git a/drivers/base/dd.c b/drivers/base/dd.c
index a7cc7ff0923b..9e8596773e7f 100644
--- a/drivers/base/dd.c
+++ b/drivers/base/dd.c
@@ -1021,6 +1021,7 @@ static int __device_attach(struct device *dev, bool allow_async)
.dev = dev,
.check_async = allow_async,
.want_async = false,
+ .have_async = false,
};
if (dev->parent)
---
base-commit: efb0b309fa0d8a92f9b303d292944cda08349eed
change-id: 20240823-fix_have_async-3a135618d91b
Best regards,
--
Zijun Hu <quic_zijuhu@xxxxxxxxxxx>