Skip to content

Commit e16769d

Browse files
Andrzej PietrasiewiczChristoph Hellwig
authored andcommitted
fs: configfs: don't return anything from drop_link
Documentation/filesystems/configfs/configfs.txt says: "When unlink(2) is called on the symbolic link, the source item is notified via the ->drop_link() method. Like the ->drop_item() method, this is a void function and cannot return failure." The ->drop_item() is indeed a void function, the ->drop_link() is actually not. This, together with the fact that the value of ->drop_link() is silently ignored suggests, that it is the ->drop_link() return type that should be corrected and changed to void. This patch changes drop_link() signature and all its users. Signed-off-by: Andrzej Pietrasiewicz <andrzej.p@samsung.com> [hch: reverted reformatting of some code] Signed-off-by: Christoph Hellwig <hch@lst.de>
1 parent e5517c2 commit e16769d

File tree

6 files changed

+17
-37
lines changed

6 files changed

+17
-37
lines changed

Documentation/filesystems/configfs/configfs.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -174,7 +174,7 @@ among other things. For that, it needs a type.
174174
void (*release)(struct config_item *);
175175
int (*allow_link)(struct config_item *src,
176176
struct config_item *target);
177-
int (*drop_link)(struct config_item *src,
177+
void (*drop_link)(struct config_item *src,
178178
struct config_item *target);
179179
};
180180

drivers/nvme/target/configfs.c

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -466,7 +466,7 @@ static int nvmet_port_subsys_allow_link(struct config_item *parent,
466466
return ret;
467467
}
468468

469-
static int nvmet_port_subsys_drop_link(struct config_item *parent,
469+
static void nvmet_port_subsys_drop_link(struct config_item *parent,
470470
struct config_item *target)
471471
{
472472
struct nvmet_port *port = to_nvmet_port(parent->ci_parent);
@@ -479,7 +479,7 @@ static int nvmet_port_subsys_drop_link(struct config_item *parent,
479479
goto found;
480480
}
481481
up_write(&nvmet_config_sem);
482-
return -EINVAL;
482+
return;
483483

484484
found:
485485
list_del(&p->entry);
@@ -488,7 +488,6 @@ static int nvmet_port_subsys_drop_link(struct config_item *parent,
488488
nvmet_disable_port(port);
489489
up_write(&nvmet_config_sem);
490490
kfree(p);
491-
return 0;
492491
}
493492

494493
static struct configfs_item_operations nvmet_port_subsys_item_ops = {
@@ -542,7 +541,7 @@ static int nvmet_allowed_hosts_allow_link(struct config_item *parent,
542541
return ret;
543542
}
544543

545-
static int nvmet_allowed_hosts_drop_link(struct config_item *parent,
544+
static void nvmet_allowed_hosts_drop_link(struct config_item *parent,
546545
struct config_item *target)
547546
{
548547
struct nvmet_subsys *subsys = to_subsys(parent->ci_parent);
@@ -555,14 +554,13 @@ static int nvmet_allowed_hosts_drop_link(struct config_item *parent,
555554
goto found;
556555
}
557556
up_write(&nvmet_config_sem);
558-
return -EINVAL;
557+
return;
559558

560559
found:
561560
list_del(&p->entry);
562561
nvmet_genctr++;
563562
up_write(&nvmet_config_sem);
564563
kfree(p);
565-
return 0;
566564
}
567565

568566
static struct configfs_item_operations nvmet_allowed_hosts_item_ops = {

drivers/target/target_core_fabric_configfs.c

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,7 @@ static int target_fabric_mappedlun_link(
137137
return core_dev_add_initiator_node_lun_acl(se_tpg, lacl, lun, lun_access_ro);
138138
}
139139

140-
static int target_fabric_mappedlun_unlink(
140+
static void target_fabric_mappedlun_unlink(
141141
struct config_item *lun_acl_ci,
142142
struct config_item *lun_ci)
143143
{
@@ -146,7 +146,7 @@ static int target_fabric_mappedlun_unlink(
146146
struct se_lun *lun = container_of(to_config_group(lun_ci),
147147
struct se_lun, lun_group);
148148

149-
return core_dev_del_initiator_node_lun_acl(lun, lacl);
149+
core_dev_del_initiator_node_lun_acl(lun, lacl);
150150
}
151151

152152
static struct se_lun_acl *item_to_lun_acl(struct config_item *item)
@@ -669,7 +669,7 @@ static int target_fabric_port_link(
669669
return ret;
670670
}
671671

672-
static int target_fabric_port_unlink(
672+
static void target_fabric_port_unlink(
673673
struct config_item *lun_ci,
674674
struct config_item *se_dev_ci)
675675
{
@@ -688,7 +688,6 @@ static int target_fabric_port_unlink(
688688
}
689689

690690
core_dev_del_lun(se_tpg, lun);
691-
return 0;
692691
}
693692

694693
static void target_fabric_port_release(struct config_item *item)

drivers/usb/gadget/configfs.c

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -408,7 +408,7 @@ static int config_usb_cfg_link(
408408
return ret;
409409
}
410410

411-
static int config_usb_cfg_unlink(
411+
static void config_usb_cfg_unlink(
412412
struct config_item *usb_cfg_ci,
413413
struct config_item *usb_func_ci)
414414
{
@@ -437,12 +437,11 @@ static int config_usb_cfg_unlink(
437437
list_del(&f->list);
438438
usb_put_function(f);
439439
mutex_unlock(&gi->lock);
440-
return 0;
440+
return;
441441
}
442442
}
443443
mutex_unlock(&gi->lock);
444444
WARN(1, "Unable to locate function to unbind\n");
445-
return 0;
446445
}
447446

448447
static struct configfs_item_operations gadget_config_item_ops = {
@@ -865,7 +864,7 @@ static int os_desc_link(struct config_item *os_desc_ci,
865864
return ret;
866865
}
867866

868-
static int os_desc_unlink(struct config_item *os_desc_ci,
867+
static void os_desc_unlink(struct config_item *os_desc_ci,
869868
struct config_item *usb_cfg_ci)
870869
{
871870
struct gadget_info *gi = container_of(to_config_group(os_desc_ci),
@@ -878,7 +877,6 @@ static int os_desc_unlink(struct config_item *os_desc_ci,
878877
cdev->os_desc_config = NULL;
879878
WARN_ON(gi->composite.gadget_driver.udc_name);
880879
mutex_unlock(&gi->lock);
881-
return 0;
882880
}
883881

884882
static struct configfs_item_operations os_desc_ops = {

drivers/usb/gadget/function/uvc_configfs.c

Lines changed: 5 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -547,15 +547,14 @@ static int uvcg_control_class_allow_link(struct config_item *src,
547547
return ret;
548548
}
549549

550-
static int uvcg_control_class_drop_link(struct config_item *src,
550+
static void uvcg_control_class_drop_link(struct config_item *src,
551551
struct config_item *target)
552552
{
553553
struct config_item *control, *header;
554554
struct f_uvc_opts *opts;
555555
struct mutex *su_mutex = &src->ci_group->cg_subsys->su_mutex;
556556
struct uvc_descriptor_header **class_array;
557557
struct uvcg_control_header *target_hdr;
558-
int ret = -EINVAL;
559558

560559
mutex_lock(su_mutex); /* for navigating configfs hierarchy */
561560

@@ -569,23 +568,17 @@ static int uvcg_control_class_drop_link(struct config_item *src,
569568
mutex_lock(&opts->lock);
570569

571570
class_array = uvcg_get_ctl_class_arr(src, opts);
572-
if (!class_array)
573-
goto unlock;
574-
if (opts->refcnt) {
575-
ret = -EBUSY;
571+
if (!class_array || opts->refcnt)
576572
goto unlock;
577-
}
578573

579574
target_hdr = to_uvcg_control_header(target);
580575
--target_hdr->linked;
581576
class_array[0] = NULL;
582-
ret = 0;
583577

584578
unlock:
585579
mutex_unlock(&opts->lock);
586580
out:
587581
mutex_unlock(su_mutex);
588-
return ret;
589582
}
590583

591584
static struct configfs_item_operations uvcg_control_class_item_ops = {
@@ -777,7 +770,7 @@ static int uvcg_streaming_header_allow_link(struct config_item *src,
777770
return ret;
778771
}
779772

780-
static int uvcg_streaming_header_drop_link(struct config_item *src,
773+
static void uvcg_streaming_header_drop_link(struct config_item *src,
781774
struct config_item *target)
782775
{
783776
struct mutex *su_mutex = &src->ci_group->cg_subsys->su_mutex;
@@ -786,7 +779,6 @@ static int uvcg_streaming_header_drop_link(struct config_item *src,
786779
struct uvcg_streaming_header *src_hdr;
787780
struct uvcg_format *target_fmt = NULL;
788781
struct uvcg_format_ptr *format_ptr, *tmp;
789-
int ret = -EINVAL;
790782

791783
src_hdr = to_uvcg_streaming_header(src);
792784
mutex_lock(su_mutex); /* for navigating configfs hierarchy */
@@ -811,8 +803,6 @@ static int uvcg_streaming_header_drop_link(struct config_item *src,
811803
out:
812804
mutex_unlock(&opts->lock);
813805
mutex_unlock(su_mutex);
814-
return ret;
815-
816806
}
817807

818808
static struct configfs_item_operations uvcg_streaming_header_item_ops = {
@@ -2051,15 +2041,14 @@ static int uvcg_streaming_class_allow_link(struct config_item *src,
20512041
return ret;
20522042
}
20532043

2054-
static int uvcg_streaming_class_drop_link(struct config_item *src,
2044+
static void uvcg_streaming_class_drop_link(struct config_item *src,
20552045
struct config_item *target)
20562046
{
20572047
struct config_item *streaming, *header;
20582048
struct f_uvc_opts *opts;
20592049
struct mutex *su_mutex = &src->ci_group->cg_subsys->su_mutex;
20602050
struct uvc_descriptor_header ***class_array;
20612051
struct uvcg_streaming_header *target_hdr;
2062-
int ret = -EINVAL;
20632052

20642053
mutex_lock(su_mutex); /* for navigating configfs hierarchy */
20652054

@@ -2076,23 +2065,19 @@ static int uvcg_streaming_class_drop_link(struct config_item *src,
20762065
if (!class_array || !*class_array)
20772066
goto unlock;
20782067

2079-
if (opts->refcnt) {
2080-
ret = -EBUSY;
2068+
if (opts->refcnt)
20812069
goto unlock;
2082-
}
20832070

20842071
target_hdr = to_uvcg_streaming_header(target);
20852072
--target_hdr->linked;
20862073
kfree(**class_array);
20872074
kfree(*class_array);
20882075
*class_array = NULL;
2089-
ret = 0;
20902076

20912077
unlock:
20922078
mutex_unlock(&opts->lock);
20932079
out:
20942080
mutex_unlock(su_mutex);
2095-
return ret;
20962081
}
20972082

20982083
static struct configfs_item_operations uvcg_streaming_class_item_ops = {

include/linux/configfs.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -228,7 +228,7 @@ static struct configfs_bin_attribute _pfx##attr_##_name = { \
228228
struct configfs_item_operations {
229229
void (*release)(struct config_item *);
230230
int (*allow_link)(struct config_item *src, struct config_item *target);
231-
int (*drop_link)(struct config_item *src, struct config_item *target);
231+
void (*drop_link)(struct config_item *src, struct config_item *target);
232232
};
233233

234234
struct configfs_group_operations {

0 commit comments

Comments
 (0)