Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

reset: make device_reset_optional() really optional

Commit bb475230b8e5 ("reset: make optional functions really optional")
converted *_get_optional* functions, but device_reset_optional() was
left behind. Convert it in the same way.

Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>
Signed-off-by: Philipp Zabel <p.zabel@pengutronix.de>

authored by

Masahiro Yamada and committed by
Philipp Zabel
1554bbd4 4fbd8d19

+18 -19
+5 -4
drivers/reset/core.c
··· 566 566 * device_reset - find reset controller associated with the device 567 567 * and perform reset 568 568 * @dev: device to be reset by the controller 569 + * @optional: whether it is optional to reset the device 569 570 * 570 - * Convenience wrapper for reset_control_get() and reset_control_reset(). 571 + * Convenience wrapper for __reset_control_get() and reset_control_reset(). 571 572 * This is useful for the common case of devices with single, dedicated reset 572 573 * lines. 573 574 */ 574 - int device_reset(struct device *dev) 575 + int __device_reset(struct device *dev, bool optional) 575 576 { 576 577 struct reset_control *rstc; 577 578 int ret; 578 579 579 - rstc = reset_control_get(dev, NULL); 580 + rstc = __reset_control_get(dev, NULL, 0, 0, optional); 580 581 if (IS_ERR(rstc)) 581 582 return PTR_ERR(rstc); 582 583 ··· 587 586 588 587 return ret; 589 588 } 590 - EXPORT_SYMBOL_GPL(device_reset); 589 + EXPORT_SYMBOL_GPL(__device_reset); 591 590 592 591 /** 593 592 * APIs to manage an array of reset controls.
+13 -15
include/linux/reset.h
··· 20 20 int index, bool shared, 21 21 bool optional); 22 22 void reset_control_put(struct reset_control *rstc); 23 + int __device_reset(struct device *dev, bool optional); 23 24 struct reset_control *__devm_reset_control_get(struct device *dev, 24 25 const char *id, int index, bool shared, 25 26 bool optional); 26 - 27 - int __must_check device_reset(struct device *dev); 28 27 29 28 struct reset_control *devm_reset_control_array_get(struct device *dev, 30 29 bool shared, bool optional); 31 30 struct reset_control *of_reset_control_array_get(struct device_node *np, 32 31 bool shared, bool optional); 33 - 34 - static inline int device_reset_optional(struct device *dev) 35 - { 36 - return device_reset(dev); 37 - } 38 32 39 33 #else 40 34 ··· 56 62 { 57 63 } 58 64 59 - static inline int __must_check device_reset(struct device *dev) 65 + static inline int __device_reset(struct device *dev, bool optional) 60 66 { 61 - WARN_ON(1); 62 - return -ENOTSUPP; 63 - } 64 - 65 - static inline int device_reset_optional(struct device *dev) 66 - { 67 - return -ENOTSUPP; 67 + return optional ? 0 : -ENOTSUPP; 68 68 } 69 69 70 70 static inline struct reset_control *__of_reset_control_get( ··· 96 108 } 97 109 98 110 #endif /* CONFIG_RESET_CONTROLLER */ 111 + 112 + static inline int __must_check device_reset(struct device *dev) 113 + { 114 + return __device_reset(dev, false); 115 + } 116 + 117 + static inline int device_reset_optional(struct device *dev) 118 + { 119 + return __device_reset(dev, true); 120 + } 99 121 100 122 /** 101 123 * reset_control_get_exclusive - Lookup and obtain an exclusive reference