.. | .. |
---|
| 1 | +// SPDX-License-Identifier: GPL-2.0-only |
---|
1 | 2 | /* |
---|
2 | 3 | * 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. |
---|
16 | 4 | * |
---|
17 | 5 | * Maintained at www.Open-FCoE.org |
---|
18 | 6 | */ |
---|
.. | .. |
---|
671 | 659 | .release = fcoe_fcf_device_release, |
---|
672 | 660 | }; |
---|
673 | 661 | |
---|
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); |
---|
676 | 675 | |
---|
677 | 676 | static struct attribute *fcoe_bus_attrs[] = { |
---|
678 | 677 | &bus_attr_ctlr_create.attr, |
---|
.. | .. |
---|
831 | 830 | |
---|
832 | 831 | dev_set_name(&ctlr->dev, "ctlr_%d", ctlr->id); |
---|
833 | 832 | 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 | + } |
---|
836 | 839 | |
---|
837 | 840 | return ctlr; |
---|
838 | 841 | |
---|
839 | | -out_del_q2: |
---|
840 | | - destroy_workqueue(ctlr->devloss_work_q); |
---|
841 | | - ctlr->devloss_work_q = NULL; |
---|
842 | 842 | out_del_q: |
---|
843 | 843 | destroy_workqueue(ctlr->work_q); |
---|
844 | 844 | ctlr->work_q = NULL; |
---|
.. | .. |
---|
1037 | 1037 | fcf->selected = new_fcf->selected; |
---|
1038 | 1038 | |
---|
1039 | 1039 | error = device_register(&fcf->dev); |
---|
1040 | | - if (error) |
---|
1041 | | - goto out_del; |
---|
| 1040 | + if (error) { |
---|
| 1041 | + put_device(&fcf->dev); |
---|
| 1042 | + goto out; |
---|
| 1043 | + } |
---|
1042 | 1044 | |
---|
1043 | 1045 | fcf->state = FCOE_FCF_STATE_CONNECTED; |
---|
1044 | 1046 | list_add_tail(&fcf->peers, &ctlr->fcfs); |
---|
1045 | 1047 | |
---|
1046 | 1048 | return fcf; |
---|
1047 | 1049 | |
---|
1048 | | -out_del: |
---|
1049 | | - kfree(fcf); |
---|
1050 | 1050 | out: |
---|
1051 | 1051 | return NULL; |
---|
1052 | 1052 | } |
---|
.. | .. |
---|
1054 | 1054 | |
---|
1055 | 1055 | int __init fcoe_sysfs_setup(void) |
---|
1056 | 1056 | { |
---|
1057 | | - int error; |
---|
1058 | | - |
---|
1059 | 1057 | atomic_set(&ctlr_num, 0); |
---|
1060 | 1058 | atomic_set(&fcf_num, 0); |
---|
1061 | 1059 | |
---|
1062 | | - error = bus_register(&fcoe_bus_type); |
---|
1063 | | - if (error) |
---|
1064 | | - return error; |
---|
1065 | | - |
---|
1066 | | - return 0; |
---|
| 1060 | + return bus_register(&fcoe_bus_type); |
---|
1067 | 1061 | } |
---|
1068 | 1062 | |
---|
1069 | 1063 | void __exit fcoe_sysfs_teardown(void) |
---|