hc
2024-05-10 37f49e37ab4cb5d0bc4c60eb5c6d4dd57db767bb
kernel/drivers/scsi/libsas/sas_event.c
....@@ -1,31 +1,14 @@
1
+// SPDX-License-Identifier: GPL-2.0
12 /*
23 * Serial Attached SCSI (SAS) Event processing
34 *
45 * Copyright (C) 2005 Adaptec, Inc. All rights reserved.
56 * Copyright (C) 2005 Luben Tuikov <luben_tuikov@adaptec.com>
6
- *
7
- * This file is licensed under GPLv2.
8
- *
9
- * This program is free software; you can redistribute it and/or
10
- * modify it under the terms of the GNU General Public License as
11
- * published by the Free Software Foundation; either version 2 of the
12
- * License, or (at your option) any later version.
13
- *
14
- * This program is distributed in the hope that it will be useful, but
15
- * WITHOUT ANY WARRANTY; without even the implied warranty of
16
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17
- * General Public License for more details.
18
- *
19
- * You should have received a copy of the GNU General Public License
20
- * along with this program; if not, write to the Free Software
21
- * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
22
- *
237 */
248
259 #include <linux/export.h>
2610 #include <scsi/scsi_host.h>
2711 #include "sas_internal.h"
28
-#include "sas_dump.h"
2912
3013 int sas_queue_work(struct sas_ha_struct *ha, struct sas_work *sw)
3114 {
....@@ -126,7 +109,7 @@
126109
127110 sas_phy = container_of(port->phy_list.next, struct asd_sas_phy,
128111 port_phy_el);
129
- ha->notify_port_event(sas_phy, PORTE_BROADCAST_RCVD);
112
+ sas_notify_port_event(sas_phy, PORTE_BROADCAST_RCVD);
130113 }
131114 mutex_unlock(&ha->disco_mutex);
132115 }
....@@ -148,17 +131,14 @@
148131 sas_free_event(ev);
149132 }
150133
151
-static int sas_notify_port_event(struct asd_sas_phy *phy, enum port_event event)
134
+static int __sas_notify_port_event(struct asd_sas_phy *phy,
135
+ enum port_event event,
136
+ struct asd_sas_event *ev)
152137 {
153
- struct asd_sas_event *ev;
154138 struct sas_ha_struct *ha = phy->ha;
155139 int ret;
156140
157141 BUG_ON(event >= PORT_NUM_EVENTS);
158
-
159
- ev = sas_alloc_event(phy);
160
- if (!ev)
161
- return -ENOMEM;
162142
163143 INIT_SAS_EVENT(ev, sas_port_event_worker, phy, event);
164144
....@@ -169,17 +149,39 @@
169149 return ret;
170150 }
171151
172
-int sas_notify_phy_event(struct asd_sas_phy *phy, enum phy_event event)
152
+int sas_notify_port_event_gfp(struct asd_sas_phy *phy, enum port_event event,
153
+ gfp_t gfp_flags)
173154 {
174155 struct asd_sas_event *ev;
175
- struct sas_ha_struct *ha = phy->ha;
176
- int ret;
177156
178
- BUG_ON(event >= PHY_NUM_EVENTS);
157
+ ev = sas_alloc_event_gfp(phy, gfp_flags);
158
+ if (!ev)
159
+ return -ENOMEM;
160
+
161
+ return __sas_notify_port_event(phy, event, ev);
162
+}
163
+EXPORT_SYMBOL_GPL(sas_notify_port_event_gfp);
164
+
165
+int sas_notify_port_event(struct asd_sas_phy *phy, enum port_event event)
166
+{
167
+ struct asd_sas_event *ev;
179168
180169 ev = sas_alloc_event(phy);
181170 if (!ev)
182171 return -ENOMEM;
172
+
173
+ return __sas_notify_port_event(phy, event, ev);
174
+}
175
+EXPORT_SYMBOL_GPL(sas_notify_port_event);
176
+
177
+static inline int __sas_notify_phy_event(struct asd_sas_phy *phy,
178
+ enum phy_event event,
179
+ struct asd_sas_event *ev)
180
+{
181
+ struct sas_ha_struct *ha = phy->ha;
182
+ int ret;
183
+
184
+ BUG_ON(event >= PHY_NUM_EVENTS);
183185
184186 INIT_SAS_EVENT(ev, sas_phy_event_worker, phy, event);
185187
....@@ -190,10 +192,27 @@
190192 return ret;
191193 }
192194
193
-int sas_init_events(struct sas_ha_struct *sas_ha)
195
+int sas_notify_phy_event_gfp(struct asd_sas_phy *phy, enum phy_event event,
196
+ gfp_t gfp_flags)
194197 {
195
- sas_ha->notify_port_event = sas_notify_port_event;
196
- sas_ha->notify_phy_event = sas_notify_phy_event;
198
+ struct asd_sas_event *ev;
197199
198
- return 0;
200
+ ev = sas_alloc_event_gfp(phy, gfp_flags);
201
+ if (!ev)
202
+ return -ENOMEM;
203
+
204
+ return __sas_notify_phy_event(phy, event, ev);
199205 }
206
+EXPORT_SYMBOL_GPL(sas_notify_phy_event_gfp);
207
+
208
+int sas_notify_phy_event(struct asd_sas_phy *phy, enum phy_event event)
209
+{
210
+ struct asd_sas_event *ev;
211
+
212
+ ev = sas_alloc_event(phy);
213
+ if (!ev)
214
+ return -ENOMEM;
215
+
216
+ return __sas_notify_phy_event(phy, event, ev);
217
+}
218
+EXPORT_SYMBOL_GPL(sas_notify_phy_event);