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

configfs: Introduce config_item_get_unless_zero()

Signed-off-by: Bart Van Assche <bart.vanassche@sandisk.com>
[hch: minor style tweak]
Signed-off-by: Christoph Hellwig <hch@lst.de>

authored by

Bart Van Assche and committed by
Christoph Hellwig
19e72d3a ba80aa90

+10 -1
+8
fs/configfs/item.c
··· 138 138 } 139 139 EXPORT_SYMBOL(config_item_get); 140 140 141 + struct config_item *config_item_get_unless_zero(struct config_item *item) 142 + { 143 + if (item && kref_get_unless_zero(&item->ci_kref)) 144 + return item; 145 + return NULL; 146 + } 147 + EXPORT_SYMBOL(config_item_get_unless_zero); 148 + 141 149 static void config_item_cleanup(struct config_item *item) 142 150 { 143 151 struct config_item_type *t = item->ci_type;
+2 -1
include/linux/configfs.h
··· 74 74 const char *name, 75 75 struct config_item_type *type); 76 76 77 - extern struct config_item * config_item_get(struct config_item *); 77 + extern struct config_item *config_item_get(struct config_item *); 78 + extern struct config_item *config_item_get_unless_zero(struct config_item *); 78 79 extern void config_item_put(struct config_item *); 79 80 80 81 struct config_item_type {