After commit 515db266a9da ("driver core: Remove device link creation limitation"), if PM-runtime flags are passed to device_link_add(), it will fail (returning NULL) due to an overly restrictive flags check introduced by that commit. Fix this issue by extending the check in question to cover the PM-runtime flags too.
Unified · Split
| @@ -213,6 +213,9 @@ void device_pm_move_to_tail(struct device *dev) · 212 unmodified lines | |||
| 213 | DL_FLAG_AUTOREMOVE_SUPPLIER | \ | 213 | DL_FLAG_AUTOREMOVE_SUPPLIER | \ |
| 214 | DL_FLAG_AUTOPROBE_CONSUMER) | 214 | DL_FLAG_AUTOPROBE_CONSUMER) |
| 215 | 215 | ||
| 216 | #define DL_ADD_VALID_FLAGS (DL_MANAGED_LINK_FLAGS | DL_FLAG_STATELESS | \ | ||
| 217 | DL_FLAG_PM_RUNTIME | DL_FLAG_RPM_ACTIVE) | ||
| 218 | |||
| 216 | /** | 219 | /** |
| 217 | * device_link_add - Create a link between two devices. | 220 | * device_link_add - Create a link between two devices. |
| 218 | * @consumer: Consumer end of the link. | 221 | * @consumer: Consumer end of the link. |
| @@ -274,8 +277,7 @@ struct device_link *device_link_add(struct device *consumer, · 55 unmodified lines | |||
| 274 | { | 277 | { |
| 275 | struct device_link *link; | 278 | struct device_link *link; |
| 276 | 279 | ||
| 277 | if (!consumer || !supplier || | 280 | if (!consumer || !supplier || flags & ~DL_ADD_VALID_FLAGS || |
| 278 | (flags & ~(DL_FLAG_STATELESS | DL_MANAGED_LINK_FLAGS)) || | ||
| 279 | (flags & DL_FLAG_STATELESS && flags & DL_MANAGED_LINK_FLAGS) || | 281 | (flags & DL_FLAG_STATELESS && flags & DL_MANAGED_LINK_FLAGS) || |
| 280 | (flags & DL_FLAG_AUTOPROBE_CONSUMER && | 282 | (flags & DL_FLAG_AUTOPROBE_CONSUMER && |
| 281 | flags & (DL_FLAG_AUTOREMOVE_CONSUMER | | 283 | flags & (DL_FLAG_AUTOREMOVE_CONSUMER | |