aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/s390/scsi/zfcp_aux.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/s390/scsi/zfcp_aux.c')
-rw-r--r--drivers/s390/scsi/zfcp_aux.c122
1 files changed, 2 insertions, 120 deletions
diff --git a/drivers/s390/scsi/zfcp_aux.c b/drivers/s390/scsi/zfcp_aux.c
index 5c4b874591ea..044fb22718d2 100644
--- a/drivers/s390/scsi/zfcp_aux.c
+++ b/drivers/s390/scsi/zfcp_aux.c
@@ -56,7 +56,6 @@ static void __init zfcp_init_device_configure(char *busid, u64 wwpn, u64 lun)
56 struct ccw_device *cdev; 56 struct ccw_device *cdev;
57 struct zfcp_adapter *adapter; 57 struct zfcp_adapter *adapter;
58 struct zfcp_port *port; 58 struct zfcp_port *port;
59 struct zfcp_unit *unit;
60 59
61 cdev = get_ccwdev_by_busid(&zfcp_ccw_driver, busid); 60 cdev = get_ccwdev_by_busid(&zfcp_ccw_driver, busid);
62 if (!cdev) 61 if (!cdev)
@@ -72,18 +71,11 @@ static void __init zfcp_init_device_configure(char *busid, u64 wwpn, u64 lun)
72 port = zfcp_get_port_by_wwpn(adapter, wwpn); 71 port = zfcp_get_port_by_wwpn(adapter, wwpn);
73 if (!port) 72 if (!port)
74 goto out_port; 73 goto out_port;
75
76 flush_work(&port->rport_work); 74 flush_work(&port->rport_work);
77 unit = zfcp_unit_enqueue(port, lun);
78 if (IS_ERR(unit))
79 goto out_unit;
80
81 zfcp_erp_unit_reopen(unit, 0, "auidc_1", NULL);
82 zfcp_erp_wait(adapter);
83 zfcp_scsi_scan(unit);
84 75
85out_unit: 76 zfcp_unit_add(port, lun);
86 put_device(&port->dev); 77 put_device(&port->dev);
78
87out_port: 79out_port:
88 zfcp_ccw_adapter_put(adapter); 80 zfcp_ccw_adapter_put(adapter);
89out_ccw_device: 81out_ccw_device:
@@ -215,30 +207,6 @@ static void __exit zfcp_module_exit(void)
215module_exit(zfcp_module_exit); 207module_exit(zfcp_module_exit);
216 208
217/** 209/**
218 * zfcp_get_unit_by_lun - find unit in unit list of port by FCP LUN
219 * @port: pointer to port to search for unit
220 * @fcp_lun: FCP LUN to search for
221 *
222 * Returns: pointer to zfcp_unit or NULL
223 */
224struct zfcp_unit *zfcp_get_unit_by_lun(struct zfcp_port *port, u64 fcp_lun)
225{
226 unsigned long flags;
227 struct zfcp_unit *unit;
228
229 read_lock_irqsave(&port->unit_list_lock, flags);
230 list_for_each_entry(unit, &port->unit_list, list)
231 if (unit->fcp_lun == fcp_lun) {
232 if (!get_device(&unit->dev))
233 unit = NULL;
234 read_unlock_irqrestore(&port->unit_list_lock, flags);
235 return unit;
236 }
237 read_unlock_irqrestore(&port->unit_list_lock, flags);
238 return NULL;
239}
240
241/**
242 * zfcp_get_port_by_wwpn - find port in port list of adapter by wwpn 210 * zfcp_get_port_by_wwpn - find port in port list of adapter by wwpn
243 * @adapter: pointer to adapter to search for port 211 * @adapter: pointer to adapter to search for port
244 * @wwpn: wwpn to search for 212 * @wwpn: wwpn to search for
@@ -263,92 +231,6 @@ struct zfcp_port *zfcp_get_port_by_wwpn(struct zfcp_adapter *adapter,
263 return NULL; 231 return NULL;
264} 232}
265 233
266/**
267 * zfcp_unit_release - dequeue unit
268 * @dev: pointer to device
269 *
270 * waits until all work is done on unit and removes it then from the unit->list
271 * of the associated port.
272 */
273static void zfcp_unit_release(struct device *dev)
274{
275 struct zfcp_unit *unit = container_of(dev, struct zfcp_unit, dev);
276
277 put_device(&unit->port->dev);
278 kfree(unit);
279}
280
281/**
282 * zfcp_unit_enqueue - enqueue unit to unit list of a port.
283 * @port: pointer to port where unit is added
284 * @fcp_lun: FCP LUN of unit to be enqueued
285 * Returns: pointer to enqueued unit on success, ERR_PTR on error
286 *
287 * Sets up some unit internal structures and creates sysfs entry.
288 */
289struct zfcp_unit *zfcp_unit_enqueue(struct zfcp_port *port, u64 fcp_lun)
290{
291 struct zfcp_unit *unit;
292 int retval = -ENOMEM;
293
294 get_device(&port->dev);
295
296 unit = zfcp_get_unit_by_lun(port, fcp_lun);
297 if (unit) {
298 put_device(&unit->dev);
299 retval = -EEXIST;
300 goto err_out;
301 }
302
303 unit = kzalloc(sizeof(struct zfcp_unit), GFP_KERNEL);
304 if (!unit)
305 goto err_out;
306
307 unit->port = port;
308 unit->fcp_lun = fcp_lun;
309 unit->dev.parent = &port->dev;
310 unit->dev.release = zfcp_unit_release;
311
312 if (dev_set_name(&unit->dev, "0x%016llx",
313 (unsigned long long) fcp_lun)) {
314 kfree(unit);
315 goto err_out;
316 }
317 retval = -EINVAL;
318
319 INIT_WORK(&unit->scsi_work, zfcp_scsi_scan_work);
320
321 spin_lock_init(&unit->latencies.lock);
322 unit->latencies.write.channel.min = 0xFFFFFFFF;
323 unit->latencies.write.fabric.min = 0xFFFFFFFF;
324 unit->latencies.read.channel.min = 0xFFFFFFFF;
325 unit->latencies.read.fabric.min = 0xFFFFFFFF;
326 unit->latencies.cmd.channel.min = 0xFFFFFFFF;
327 unit->latencies.cmd.fabric.min = 0xFFFFFFFF;
328
329 if (device_register(&unit->dev)) {
330 put_device(&unit->dev);
331 goto err_out;
332 }
333
334 if (sysfs_create_group(&unit->dev.kobj, &zfcp_sysfs_unit_attrs))
335 goto err_out_put;
336
337 write_lock_irq(&port->unit_list_lock);
338 list_add_tail(&unit->list, &port->unit_list);
339 write_unlock_irq(&port->unit_list_lock);
340
341 atomic_set_mask(ZFCP_STATUS_COMMON_RUNNING, &unit->status);
342
343 return unit;
344
345err_out_put:
346 device_unregister(&unit->dev);
347err_out:
348 put_device(&port->dev);
349 return ERR_PTR(retval);
350}
351
352static int zfcp_allocate_low_mem_buffers(struct zfcp_adapter *adapter) 234static int zfcp_allocate_low_mem_buffers(struct zfcp_adapter *adapter)
353{ 235{
354 adapter->pool.erp_req = 236 adapter->pool.erp_req =