forked from ~ljy/RK356X_SDK_RELEASE

hc
2024-05-13 9d77db3c730780c8ef5ccd4b66403ff5675cfe4e
kernel/drivers/scsi/fcoe/fcoe_sysfs.c
....@@ -1,18 +1,6 @@
1
+// SPDX-License-Identifier: GPL-2.0-only
12 /*
23 * Copyright(c) 2011 - 2012 Intel Corporation. All rights reserved.
3
- *
4
- * This program is free software; you can redistribute it and/or modify it
5
- * under the terms and conditions of the GNU General Public License,
6
- * version 2, as published by the Free Software Foundation.
7
- *
8
- * This program is distributed in the hope it will be useful, but WITHOUT
9
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
10
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
11
- * more details.
12
- *
13
- * You should have received a copy of the GNU General Public License along with
14
- * this program; if not, write to the Free Software Foundation, Inc.,
15
- * 51 Franklin St - Fifth Floor, Boston, MA 02110-1301 USA.
164 *
175 * Maintained at www.Open-FCoE.org
186 */
....@@ -671,8 +659,19 @@
671659 .release = fcoe_fcf_device_release,
672660 };
673661
674
-static BUS_ATTR(ctlr_create, S_IWUSR, NULL, fcoe_ctlr_create_store);
675
-static BUS_ATTR(ctlr_destroy, S_IWUSR, NULL, fcoe_ctlr_destroy_store);
662
+static ssize_t ctlr_create_store(struct bus_type *bus, const char *buf,
663
+ size_t count)
664
+{
665
+ return fcoe_ctlr_create_store(bus, buf, count);
666
+}
667
+static BUS_ATTR_WO(ctlr_create);
668
+
669
+static ssize_t ctlr_destroy_store(struct bus_type *bus, const char *buf,
670
+ size_t count)
671
+{
672
+ return fcoe_ctlr_destroy_store(bus, buf, count);
673
+}
674
+static BUS_ATTR_WO(ctlr_destroy);
676675
677676 static struct attribute *fcoe_bus_attrs[] = {
678677 &bus_attr_ctlr_create.attr,
....@@ -831,14 +830,15 @@
831830
832831 dev_set_name(&ctlr->dev, "ctlr_%d", ctlr->id);
833832 error = device_register(&ctlr->dev);
834
- if (error)
835
- goto out_del_q2;
833
+ if (error) {
834
+ destroy_workqueue(ctlr->devloss_work_q);
835
+ destroy_workqueue(ctlr->work_q);
836
+ put_device(&ctlr->dev);
837
+ return NULL;
838
+ }
836839
837840 return ctlr;
838841
839
-out_del_q2:
840
- destroy_workqueue(ctlr->devloss_work_q);
841
- ctlr->devloss_work_q = NULL;
842842 out_del_q:
843843 destroy_workqueue(ctlr->work_q);
844844 ctlr->work_q = NULL;
....@@ -1037,16 +1037,16 @@
10371037 fcf->selected = new_fcf->selected;
10381038
10391039 error = device_register(&fcf->dev);
1040
- if (error)
1041
- goto out_del;
1040
+ if (error) {
1041
+ put_device(&fcf->dev);
1042
+ goto out;
1043
+ }
10421044
10431045 fcf->state = FCOE_FCF_STATE_CONNECTED;
10441046 list_add_tail(&fcf->peers, &ctlr->fcfs);
10451047
10461048 return fcf;
10471049
1048
-out_del:
1049
- kfree(fcf);
10501050 out:
10511051 return NULL;
10521052 }
....@@ -1054,16 +1054,10 @@
10541054
10551055 int __init fcoe_sysfs_setup(void)
10561056 {
1057
- int error;
1058
-
10591057 atomic_set(&ctlr_num, 0);
10601058 atomic_set(&fcf_num, 0);
10611059
1062
- error = bus_register(&fcoe_bus_type);
1063
- if (error)
1064
- return error;
1065
-
1066
- return 0;
1060
+ return bus_register(&fcoe_bus_type);
10671061 }
10681062
10691063 void __exit fcoe_sysfs_teardown(void)