Skip to content

Commit 94bd9ce

Browse files
andy-shevBartosz Golaszewski
authored andcommitted
gpiolib: Update the kernel documentation - add Return sections
$ scripts/kernel-doc -v -none -Wall drivers/gpio/gpiolib* 2>&1 | grep -w warning | wc -l 67 Fix these by adding Return sections. While at it, make sure all of Return sections use the same style. Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com> Reviewed-by: Randy Dunlap <rdunlap@infradead.org> Tested-by: Randy Dunlap <rdunlap@infradead.org> Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com> Link: https://lore.kernel.org/r/20240828164449.2777666-1-andriy.shevchenko@linux.intel.com Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
1 parent 1e3d42f commit 94bd9ce

8 files changed

Lines changed: 226 additions & 58 deletions

File tree

drivers/gpio/gpiolib-acpi.c

Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -153,8 +153,12 @@ static int acpi_gpiochip_find(struct gpio_chip *gc, const void *data)
153153
* @path: ACPI GPIO controller full path name, (e.g. "\\_SB.GPO1")
154154
* @pin: ACPI GPIO pin number (0-based, controller-relative)
155155
*
156-
* Return: GPIO descriptor to use with Linux generic GPIO API, or ERR_PTR
157-
* error value. Specifically returns %-EPROBE_DEFER if the referenced GPIO
156+
* Returns:
157+
* GPIO descriptor to use with Linux generic GPIO API.
158+
* If the GPIO cannot be translated or there is an error an ERR_PTR is
159+
* returned.
160+
*
161+
* Specifically returns %-EPROBE_DEFER if the referenced GPIO
158162
* controller does not have GPIO chip registered at the moment. This is to
159163
* support probe deferral.
160164
*/
@@ -224,6 +228,9 @@ EXPORT_SYMBOL_GPL(acpi_gpio_get_irq_resource);
224228
* I/O resource or return False if not.
225229
* @ares: Pointer to the ACPI resource to fetch
226230
* @agpio: Pointer to a &struct acpi_resource_gpio to store the output pointer
231+
*
232+
* Returns:
233+
* %true if GpioIo resource is found, %false otherwise.
227234
*/
228235
bool acpi_gpio_get_io_resource(struct acpi_resource *ares,
229236
struct acpi_resource_gpio **agpio)
@@ -876,7 +883,9 @@ static int acpi_gpio_property_lookup(struct fwnode_handle *fwnode,
876883
* that case @index is used to select the GPIO entry in the property value
877884
* (in case of multiple).
878885
*
879-
* If the GPIO cannot be translated or there is an error, an ERR_PTR is
886+
* Returns:
887+
* GPIO descriptor to use with Linux generic GPIO API.
888+
* If the GPIO cannot be translated or there is an error an ERR_PTR is
880889
* returned.
881890
*
882891
* Note: if the GPIO resource has multiple entries in the pin list, this
@@ -924,6 +933,8 @@ static struct gpio_desc *acpi_get_gpiod_by_index(struct acpi_device *adev,
924933
* resource with the relevant information from a data-only ACPI firmware node
925934
* and uses that to obtain the GPIO descriptor to return.
926935
*
936+
* Returns:
937+
* GPIO descriptor to use with Linux generic GPIO API.
927938
* If the GPIO cannot be translated or there is an error an ERR_PTR is
928939
* returned.
929940
*/
@@ -1042,7 +1053,8 @@ struct gpio_desc *acpi_find_gpio(struct fwnode_handle *fwnode,
10421053
* The GPIO is considered wake capable if the GpioInt resource specifies
10431054
* SharedAndWake or ExclusiveAndWake.
10441055
*
1045-
* Return: Linux IRQ number (> %0) on success, negative errno on failure.
1056+
* Returns:
1057+
* Linux IRQ number (> 0) on success, negative errno on failure.
10461058
*/
10471059
int acpi_dev_gpio_irq_wake_get_by(struct acpi_device *adev, const char *con_id, int index,
10481060
bool *wake_capable)
@@ -1429,7 +1441,7 @@ static int acpi_find_gpio_count(struct acpi_resource *ares, void *data)
14291441
* @fwnode: firmware node of the GPIO consumer
14301442
* @con_id: function within the GPIO consumer
14311443
*
1432-
* Return:
1444+
* Returns:
14331445
* The number of GPIOs associated with a firmware node / function or %-ENOENT,
14341446
* if no GPIO has been assigned to the requested function.
14351447
*/

drivers/gpio/gpiolib-cdev.c

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2748,7 +2748,9 @@ static ssize_t lineinfo_watch_read(struct file *file, char __user *buf,
27482748
* gpio_chrdev_open() - open the chardev for ioctl operations
27492749
* @inode: inode for this chardev
27502750
* @file: file struct for storing private data
2751-
* Returns 0 on success
2751+
*
2752+
* Returns:
2753+
* 0 on success, or negative errno on failure.
27522754
*/
27532755
static int gpio_chrdev_open(struct inode *inode, struct file *file)
27542756
{
@@ -2814,7 +2816,9 @@ static int gpio_chrdev_open(struct inode *inode, struct file *file)
28142816
* gpio_chrdev_release() - close chardev after ioctl operations
28152817
* @inode: inode for this chardev
28162818
* @file: file struct for storing private data
2817-
* Returns 0 on success
2819+
*
2820+
* Returns:
2821+
* 0 on success, or negative errno on failure.
28182822
*/
28192823
static int gpio_chrdev_release(struct inode *inode, struct file *file)
28202824
{

drivers/gpio/gpiolib-devres.c

Lines changed: 36 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,11 @@ static int devm_gpiod_match_array(struct device *dev, void *res, void *data)
5252
* Managed gpiod_get(). GPIO descriptors returned from this function are
5353
* automatically disposed on driver detach. See gpiod_get() for detailed
5454
* information about behavior and return values.
55+
*
56+
* Returns:
57+
* The GPIO descriptor corresponding to the function @con_id of device
58+
* dev, %-ENOENT if no GPIO has been assigned to the requested function, or
59+
* another IS_ERR() code if an error occurred while trying to acquire the GPIO.
5560
*/
5661
struct gpio_desc *__must_check devm_gpiod_get(struct device *dev,
5762
const char *con_id,
@@ -70,6 +75,11 @@ EXPORT_SYMBOL_GPL(devm_gpiod_get);
7075
* Managed gpiod_get_optional(). GPIO descriptors returned from this function
7176
* are automatically disposed on driver detach. See gpiod_get_optional() for
7277
* detailed information about behavior and return values.
78+
*
79+
* Returns:
80+
* The GPIO descriptor corresponding to the function @con_id of device
81+
* dev, NULL if no GPIO has been assigned to the requested function, or
82+
* another IS_ERR() code if an error occurred while trying to acquire the GPIO.
7383
*/
7484
struct gpio_desc *__must_check devm_gpiod_get_optional(struct device *dev,
7585
const char *con_id,
@@ -89,6 +99,11 @@ EXPORT_SYMBOL_GPL(devm_gpiod_get_optional);
8999
* Managed gpiod_get_index(). GPIO descriptors returned from this function are
90100
* automatically disposed on driver detach. See gpiod_get_index() for detailed
91101
* information about behavior and return values.
102+
*
103+
* Returns:
104+
* The GPIO descriptor corresponding to the function @con_id of device
105+
* dev, %-ENOENT if no GPIO has been assigned to the requested function, or
106+
* another IS_ERR() code if an error occurred while trying to acquire the GPIO.
92107
*/
93108
struct gpio_desc *__must_check devm_gpiod_get_index(struct device *dev,
94109
const char *con_id,
@@ -141,8 +156,10 @@ EXPORT_SYMBOL_GPL(devm_gpiod_get_index);
141156
* GPIO descriptors returned from this function are automatically disposed on
142157
* driver detach.
143158
*
144-
* On successful request the GPIO pin is configured in accordance with
145-
* provided @flags.
159+
* Returns:
160+
* The GPIO descriptor corresponding to the function @con_id of device
161+
* dev, %-ENOENT if no GPIO has been assigned to the requested function, or
162+
* another IS_ERR() code if an error occurred while trying to acquire the GPIO.
146163
*/
147164
struct gpio_desc *devm_fwnode_gpiod_get_index(struct device *dev,
148165
struct fwnode_handle *fwnode,
@@ -182,6 +199,11 @@ EXPORT_SYMBOL_GPL(devm_fwnode_gpiod_get_index);
182199
* function are automatically disposed on driver detach. See
183200
* gpiod_get_index_optional() for detailed information about behavior and
184201
* return values.
202+
*
203+
* Returns:
204+
* The GPIO descriptor corresponding to the function @con_id of device
205+
* dev, %NULL if no GPIO has been assigned to the requested function, or
206+
* another IS_ERR() code if an error occurred while trying to acquire the GPIO.
185207
*/
186208
struct gpio_desc *__must_check devm_gpiod_get_index_optional(struct device *dev,
187209
const char *con_id,
@@ -207,6 +229,12 @@ EXPORT_SYMBOL_GPL(devm_gpiod_get_index_optional);
207229
* Managed gpiod_get_array(). GPIO descriptors returned from this function are
208230
* automatically disposed on driver detach. See gpiod_get_array() for detailed
209231
* information about behavior and return values.
232+
*
233+
* Returns:
234+
* The GPIO descriptors corresponding to the function @con_id of device
235+
* dev, %-ENOENT if no GPIO has been assigned to the requested function,
236+
* or another IS_ERR() code if an error occurred while trying to acquire
237+
* the GPIOs.
210238
*/
211239
struct gpio_descs *__must_check devm_gpiod_get_array(struct device *dev,
212240
const char *con_id,
@@ -243,6 +271,12 @@ EXPORT_SYMBOL_GPL(devm_gpiod_get_array);
243271
* function are automatically disposed on driver detach.
244272
* See gpiod_get_array_optional() for detailed information about behavior and
245273
* return values.
274+
*
275+
* Returns:
276+
* The GPIO descriptors corresponding to the function @con_id of device
277+
* dev, %NULL if no GPIO has been assigned to the requested function,
278+
* or another IS_ERR() code if an error occurred while trying to acquire
279+
* the GPIOs.
246280
*/
247281
struct gpio_descs *__must_check
248282
devm_gpiod_get_array_optional(struct device *dev, const char *con_id,

drivers/gpio/gpiolib-legacy.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,9 @@ EXPORT_SYMBOL_GPL(gpio_free);
2222
* @label: a literal description string of this GPIO
2323
*
2424
* **DEPRECATED** This function is deprecated and must not be used in new code.
25+
*
26+
* Returns:
27+
* 0 on success, or negative errno on failure.
2528
*/
2629
int gpio_request_one(unsigned gpio, unsigned long flags, const char *label)
2730
{

drivers/gpio/gpiolib-of.c

Lines changed: 34 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -46,16 +46,19 @@ enum of_gpio_flags {
4646
* @propname: property name containing gpio specifier(s)
4747
*
4848
* The function returns the count of GPIOs specified for a node.
49-
* Note that the empty GPIO specifiers count too. Returns either
50-
* Number of gpios defined in property,
51-
* -EINVAL for an incorrectly formed gpios property, or
52-
* -ENOENT for a missing gpios property
49+
* NOTE: The empty GPIO specifiers count too.
5350
*
54-
* Example:
55-
* gpios = <0
56-
* &gpio1 1 2
57-
* 0
58-
* &gpio2 3 4>;
51+
* Returns:
52+
* Either number of GPIOs defined in the property, or
53+
* * %-EINVAL for an incorrectly formed "gpios" property, or
54+
* * %-ENOENT for a missing "gpios" property.
55+
*
56+
* Example::
57+
*
58+
* gpios = <0
59+
* &gpio1 1 2
60+
* 0
61+
* &gpio2 3 4>;
5962
*
6063
* The above example defines four GPIOs, two of which are not specified.
6164
* This function will return '4'
@@ -77,6 +80,11 @@ static int of_gpio_named_count(const struct device_node *np,
7780
* "gpios" for the chip select lines. If we detect this, we redirect
7881
* the counting of "cs-gpios" to count "gpios" transparent to the
7982
* driver.
83+
*
84+
* Returns:
85+
* Either number of GPIOs defined in the property, or
86+
* * %-EINVAL for an incorrectly formed "gpios" property, or
87+
* * %-ENOENT for a missing "gpios" property.
8088
*/
8189
static int of_gpio_spi_cs_get_count(const struct device_node *np,
8290
const char *con_id)
@@ -373,7 +381,8 @@ static void of_gpio_flags_quirks(const struct device_node *np,
373381
* @index: index of the GPIO
374382
* @flags: a flags pointer to fill in
375383
*
376-
* Returns GPIO descriptor to use with Linux GPIO API, or one of the errno
384+
* Returns:
385+
* GPIO descriptor to use with Linux GPIO API, or one of the errno
377386
* value on the error condition. If @flags is not NULL the function also fills
378387
* in flags for the GPIO.
379388
*/
@@ -425,7 +434,8 @@ static struct gpio_desc *of_get_named_gpiod_flags(const struct device_node *np,
425434
*
426435
* **DEPRECATED** This function is deprecated and must not be used in new code.
427436
*
428-
* Returns GPIO number to use with Linux generic GPIO API, or one of the errno
437+
* Returns:
438+
* GPIO number to use with Linux generic GPIO API, or one of the errno
429439
* value on the error condition.
430440
*/
431441
int of_get_named_gpio(const struct device_node *np, const char *propname,
@@ -711,7 +721,8 @@ struct gpio_desc *of_find_gpio(struct device_node *np, const char *con_id,
711721
* of_find_gpio() or of_parse_own_gpio()
712722
* @dflags: gpiod_flags - optional GPIO initialization flags
713723
*
714-
* Returns GPIO descriptor to use with Linux GPIO API, or one of the errno
724+
* Returns:
725+
* GPIO descriptor to use with Linux GPIO API, or one of the errno
715726
* value on the error condition.
716727
*/
717728
static struct gpio_desc *of_parse_own_gpio(struct device_node *np,
@@ -779,7 +790,8 @@ static struct gpio_desc *of_parse_own_gpio(struct device_node *np,
779790
* @chip: gpio chip to act on
780791
* @hog: device node describing the hogs
781792
*
782-
* Returns error if it fails otherwise 0 on success.
793+
* Returns:
794+
* 0 on success, or negative errno on failure.
783795
*/
784796
static int of_gpiochip_add_hog(struct gpio_chip *chip, struct device_node *hog)
785797
{
@@ -813,7 +825,9 @@ static int of_gpiochip_add_hog(struct gpio_chip *chip, struct device_node *hog)
813825
*
814826
* This is only used by of_gpiochip_add to request/set GPIO initial
815827
* configuration.
816-
* It returns error if it fails otherwise 0 on success.
828+
*
829+
* Returns:
830+
* 0 on success, or negative errno on failure.
817831
*/
818832
static int of_gpiochip_scan_gpios(struct gpio_chip *chip)
819833
{
@@ -923,6 +937,9 @@ struct notifier_block gpio_of_notifier = {
923937
* This is simple translation function, suitable for the most 1:1 mapped
924938
* GPIO chips. This function performs only one sanity check: whether GPIO
925939
* is less than ngpios (that is specified in the gpio_chip).
940+
*
941+
* Returns:
942+
* GPIO number (>= 0) on success, negative errno on failure.
926943
*/
927944
static int of_gpio_simple_xlate(struct gpio_chip *gc,
928945
const struct of_phandle_args *gpiospec,
@@ -972,6 +989,9 @@ static int of_gpio_simple_xlate(struct gpio_chip *gc,
972989
* If succeeded, this function will map bank's memory and will
973990
* do all necessary work for you. Then you'll able to use .regs
974991
* to manage GPIOs from the callbacks.
992+
*
993+
* Returns:
994+
* 0 on success, or negative errno on failure.
975995
*/
976996
int of_mm_gpiochip_add_data(struct device_node *np,
977997
struct of_mm_gpio_chip *mm_gc,

drivers/gpio/gpiolib-swnode.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ struct gpio_desc *swnode_find_gpio(struct fwnode_handle *fwnode,
106106
* system-global GPIOs
107107
* @con_id: function within the GPIO consumer
108108
*
109-
* Return:
109+
* Returns:
110110
* The number of GPIOs associated with a device / function or %-ENOENT,
111111
* if no GPIO has been assigned to the requested function.
112112
*/

drivers/gpio/gpiolib-sysfs.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -568,7 +568,8 @@ static struct class gpio_class = {
568568
* will see "direction" sysfs attribute which may be used to change
569569
* the gpio's direction. A "value" attribute will always be provided.
570570
*
571-
* Returns zero on success, else an error.
571+
* Returns:
572+
* 0 on success, or negative errno on failure.
572573
*/
573574
int gpiod_export(struct gpio_desc *desc, bool direction_may_change)
574575
{
@@ -667,7 +668,8 @@ static int match_export(struct device *dev, const void *desc)
667668
* Set up a symlink from /sys/.../dev/name to /sys/class/gpio/gpioN
668669
* node. Caller is responsible for unlinking.
669670
*
670-
* Returns zero on success, else an error.
671+
* Returns:
672+
* 0 on success, or negative errno on failure.
671673
*/
672674
int gpiod_export_link(struct device *dev, const char *name,
673675
struct gpio_desc *desc)

0 commit comments

Comments
 (0)