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

debugfs: update documented return values of debugfs helpers

Since commit ff9fb72bc077 ("debugfs: return error values, not NULL")
these helper functions do not return NULL anymore (with the exception
of debugfs_create_u32_array()).

Fixes: ff9fb72bc077 ("debugfs: return error values, not NULL")
Signed-off-by: Ronald Tschalär <ronald@innovation.ch>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

authored by

Ronald Tschalär and committed by
Greg Kroah-Hartman
9abb2499 5de363b6

+44 -49
+9 -7
Documentation/filesystems/debugfs.txt
··· 31 31 indicated parent directory. If parent is NULL, the directory will be 32 32 created in the debugfs root. On success, the return value is a struct 33 33 dentry pointer which can be used to create files in the directory (and to 34 - clean it up at the end). A NULL return value indicates that something went 35 - wrong. If ERR_PTR(-ENODEV) is returned, that is an indication that the 36 - kernel has been built without debugfs support and none of the functions 37 - described below will work. 34 + clean it up at the end). An ERR_PTR(-ERROR) return value indicates that 35 + something went wrong. If ERR_PTR(-ENODEV) is returned, that is an 36 + indication that the kernel has been built without debugfs support and none 37 + of the functions described below will work. 38 38 39 39 The most general way to create a file within a debugfs directory is with: 40 40 ··· 48 48 resulting inode structure, and fops is a set of file operations which 49 49 implement the file's behavior. At a minimum, the read() and/or write() 50 50 operations should be provided; others can be included as needed. Again, 51 - the return value will be a dentry pointer to the created file, NULL for 52 - error, or ERR_PTR(-ENODEV) if debugfs support is missing. 51 + the return value will be a dentry pointer to the created file, 52 + ERR_PTR(-ERROR) on error, or ERR_PTR(-ENODEV) if debugfs support is 53 + missing. 53 54 54 55 Create a file with an initial size, the following function can be used 55 56 instead: ··· 215 214 216 215 void debugfs_remove(struct dentry *dentry); 217 216 218 - The dentry value can be NULL, in which case nothing will be removed. 217 + The dentry value can be NULL or an error value, in which case nothing will 218 + be removed. 219 219 220 220 Once upon a time, debugfs users were required to remember the dentry 221 221 pointer for every debugfs file they created so that all files could be
+35 -42
fs/debugfs/file.c
··· 394 394 * This function will return a pointer to a dentry if it succeeds. This 395 395 * pointer must be passed to the debugfs_remove() function when the file is 396 396 * to be removed (no automatic cleanup happens if your module is unloaded, 397 - * you are responsible here.) If an error occurs, %NULL will be returned. 397 + * you are responsible here.) If an error occurs, %ERR_PTR(-ERROR) will be 398 + * returned. 398 399 * 399 - * If debugfs is not enabled in the kernel, the value -%ENODEV will be 400 - * returned. It is not wise to check for this value, but rather, check for 401 - * %NULL or !%NULL instead as to eliminate the need for #ifdef in the calling 402 - * code. 400 + * If debugfs is not enabled in the kernel, the value %ERR_PTR(-ENODEV) will 401 + * be returned. 403 402 */ 404 403 struct dentry *debugfs_create_u8(const char *name, umode_t mode, 405 404 struct dentry *parent, u8 *value) ··· 439 440 * This function will return a pointer to a dentry if it succeeds. This 440 441 * pointer must be passed to the debugfs_remove() function when the file is 441 442 * to be removed (no automatic cleanup happens if your module is unloaded, 442 - * you are responsible here.) If an error occurs, %NULL will be returned. 443 + * you are responsible here.) If an error occurs, %ERR_PTR(-ERROR) will be 444 + * returned. 443 445 * 444 - * If debugfs is not enabled in the kernel, the value -%ENODEV will be 445 - * returned. It is not wise to check for this value, but rather, check for 446 - * %NULL or !%NULL instead as to eliminate the need for #ifdef in the calling 447 - * code. 446 + * If debugfs is not enabled in the kernel, the value %ERR_PTR(-ENODEV) will 447 + * be returned. 448 448 */ 449 449 struct dentry *debugfs_create_u16(const char *name, umode_t mode, 450 450 struct dentry *parent, u16 *value) ··· 484 486 * This function will return a pointer to a dentry if it succeeds. This 485 487 * pointer must be passed to the debugfs_remove() function when the file is 486 488 * to be removed (no automatic cleanup happens if your module is unloaded, 487 - * you are responsible here.) If an error occurs, %NULL will be returned. 489 + * you are responsible here.) If an error occurs, %ERR_PTR(-ERROR) will be 490 + * returned. 488 491 * 489 - * If debugfs is not enabled in the kernel, the value -%ENODEV will be 490 - * returned. It is not wise to check for this value, but rather, check for 491 - * %NULL or !%NULL instead as to eliminate the need for #ifdef in the calling 492 - * code. 492 + * If debugfs is not enabled in the kernel, the value %ERR_PTR(-ENODEV) will 493 + * be returned. 493 494 */ 494 495 struct dentry *debugfs_create_u32(const char *name, umode_t mode, 495 496 struct dentry *parent, u32 *value) ··· 530 533 * This function will return a pointer to a dentry if it succeeds. This 531 534 * pointer must be passed to the debugfs_remove() function when the file is 532 535 * to be removed (no automatic cleanup happens if your module is unloaded, 533 - * you are responsible here.) If an error occurs, %NULL will be returned. 536 + * you are responsible here.) If an error occurs, %ERR_PTR(-ERROR) will be 537 + * returned. 534 538 * 535 - * If debugfs is not enabled in the kernel, the value -%ENODEV will be 536 - * returned. It is not wise to check for this value, but rather, check for 537 - * %NULL or !%NULL instead as to eliminate the need for #ifdef in the calling 538 - * code. 539 + * If debugfs is not enabled in the kernel, the value %ERR_PTR(-ENODEV) will 540 + * be returned. 539 541 */ 540 542 struct dentry *debugfs_create_u64(const char *name, umode_t mode, 541 543 struct dentry *parent, u64 *value) ··· 578 582 * This function will return a pointer to a dentry if it succeeds. This 579 583 * pointer must be passed to the debugfs_remove() function when the file is 580 584 * to be removed (no automatic cleanup happens if your module is unloaded, 581 - * you are responsible here.) If an error occurs, %NULL will be returned. 585 + * you are responsible here.) If an error occurs, %ERR_PTR(-ERROR) will be 586 + * returned. 582 587 * 583 - * If debugfs is not enabled in the kernel, the value -%ENODEV will be 584 - * returned. It is not wise to check for this value, but rather, check for 585 - * %NULL or !%NULL instead as to eliminate the need for #ifdef in the calling 586 - * code. 588 + * If debugfs is not enabled in the kernel, the value %ERR_PTR(-ENODEV) will 589 + * be returned. 587 590 */ 588 591 struct dentry *debugfs_create_ulong(const char *name, umode_t mode, 589 592 struct dentry *parent, unsigned long *value) ··· 845 850 * This function will return a pointer to a dentry if it succeeds. This 846 851 * pointer must be passed to the debugfs_remove() function when the file is 847 852 * to be removed (no automatic cleanup happens if your module is unloaded, 848 - * you are responsible here.) If an error occurs, %NULL will be returned. 853 + * you are responsible here.) If an error occurs, %ERR_PTR(-ERROR) will be 854 + * returned. 849 855 * 850 - * If debugfs is not enabled in the kernel, the value -%ENODEV will be 851 - * returned. It is not wise to check for this value, but rather, check for 852 - * %NULL or !%NULL instead as to eliminate the need for #ifdef in the calling 853 - * code. 856 + * If debugfs is not enabled in the kernel, the value %ERR_PTR(-ENODEV) will 857 + * be returned. 854 858 */ 855 859 struct dentry *debugfs_create_bool(const char *name, umode_t mode, 856 860 struct dentry *parent, bool *value) ··· 898 904 * This function will return a pointer to a dentry if it succeeds. This 899 905 * pointer must be passed to the debugfs_remove() function when the file is 900 906 * to be removed (no automatic cleanup happens if your module is unloaded, 901 - * you are responsible here.) If an error occurs, %NULL will be returned. 907 + * you are responsible here.) If an error occurs, %ERR_PTR(-ERROR) will be 908 + * returned. 902 909 * 903 - * If debugfs is not enabled in the kernel, the value -%ENODEV will be 904 - * returned. It is not wise to check for this value, but rather, check for 905 - * %NULL or !%NULL instead as to eliminate the need for #ifdef in the calling 906 - * code. 910 + * If debugfs is not enabled in the kernel, the value %ERR_PTR(-ENODEV) will 911 + * be returned. 907 912 */ 908 913 struct dentry *debugfs_create_blob(const char *name, umode_t mode, 909 914 struct dentry *parent, ··· 998 1005 * Writing is not supported. Seek within the file is also not supported. 999 1006 * Once array is created its size can not be changed. 1000 1007 * 1001 - * The function returns a pointer to dentry on success. If debugfs is not 1002 - * enabled in the kernel, the value -%ENODEV will be returned. 1008 + * The function returns a pointer to dentry on success. If an error occurs, 1009 + * %ERR_PTR(-ERROR) or NULL will be returned. If debugfs is not enabled in 1010 + * the kernel, the value %ERR_PTR(-ENODEV) will be returned. 1003 1011 */ 1004 1012 struct dentry *debugfs_create_u32_array(const char *name, umode_t mode, 1005 1013 struct dentry *parent, ··· 1096 1102 * This function will return a pointer to a dentry if it succeeds. This 1097 1103 * pointer must be passed to the debugfs_remove() function when the file is 1098 1104 * to be removed (no automatic cleanup happens if your module is unloaded, 1099 - * you are responsible here.) If an error occurs, %NULL will be returned. 1105 + * you are responsible here.) If an error occurs, %ERR_PTR(-ERROR) will be 1106 + * returned. 1100 1107 * 1101 - * If debugfs is not enabled in the kernel, the value -%ENODEV will be 1102 - * returned. It is not wise to check for this value, but rather, check for 1103 - * %NULL or !%NULL instead as to eliminate the need for #ifdef in the calling 1104 - * code. 1108 + * If debugfs is not enabled in the kernel, the value %ERR_PTR(-ENODEV) will 1109 + * be returned. 1105 1110 */ 1106 1111 struct dentry *debugfs_create_regset32(const char *name, umode_t mode, 1107 1112 struct dentry *parent,