Lines Matching defs:sdp
197 static Sg_fd *sg_add_sfp(Sg_device * sdp, int dev);
204 static void sg_put_dev(Sg_device *sdp);
227 Sg_device *sdp;
235 sdp = sg_get_dev(dev);
236 if (IS_ERR(sdp)) {
237 retval = PTR_ERR(sdp);
238 sdp = NULL;
244 retval = scsi_device_get(sdp->device);
248 retval = scsi_autopm_get_device(sdp->device);
253 scsi_block_when_processing_errors(sdp->device))) {
264 if (!list_empty(&sdp->sfds) && (flags & O_NONBLOCK)) {
269 __wait_event_interruptible(sdp->o_excl_wait,
270 ((!list_empty(&sdp->sfds) || sdp->exclude) ? 0 : (sdp->exclude = 1)), res);
275 } else if (sdp->exclude) { /* some other fd has an exclusive lock on dev */
281 __wait_event_interruptible(sdp->o_excl_wait, (!sdp->exclude),
288 if (sdp->detached) {
292 if (list_empty(&sdp->sfds)) { /* no existing opens on this device */
293 sdp->sgdebug = 0;
294 q = sdp->device->request_queue;
295 sdp->sg_tablesize = queue_max_segments(q);
297 if ((sfp = sg_add_sfp(sdp, dev)))
301 sdp->exclude = 0; /* undo if error */
302 wake_up_interruptible(&sdp->o_excl_wait);
310 scsi_autopm_put_device(sdp->device);
312 scsi_device_put(sdp->device);
315 if (sdp)
316 sg_put_dev(sdp);
325 Sg_device *sdp;
328 if ((!(sfp = (Sg_fd *) filp->private_data)) || (!(sdp = sfp->parentdp)))
330 SCSI_LOG_TIMEOUT(3, printk("sg_release: %s\n", sdp->disk->disk_name));
334 sdp->exclude = 0;
335 wake_up_interruptible(&sdp->o_excl_wait);
337 scsi_autopm_put_device(sdp->device);
345 Sg_device *sdp;
353 if ((!(sfp = (Sg_fd *) filp->private_data)) || (!(sdp = sfp->parentdp)))
356 sdp->disk->disk_name, (int) count));
390 if (sdp->detached) {
401 (sdp->detached ||
404 if (sdp->detached) {
537 Sg_device *sdp;
544 if ((!(sfp = (Sg_fd *) filp->private_data)) || (!(sdp = sfp->parentdp)))
547 sdp->disk->disk_name, (int) count));
548 if (sdp->detached)
551 scsi_block_when_processing_errors(sdp->device)))
719 Sg_device *sdp = sfp->parentdp;
739 if (sdp->detached) {
765 blk_execute_rq_nowait(sdp->device->request_queue, sdp->disk,
776 Sg_device *sdp;
781 if ((!(sfp = (Sg_fd *) filp->private_data)) || (!(sdp = sfp->parentdp)))
785 sdp->disk->disk_name, (int) cmd_in));
793 if (sdp->detached)
795 if (!scsi_block_when_processing_errors(sdp->device))
807 (srp->done || sdp->detached),
809 if (sdp->detached)
851 if (sdp->detached)
853 sfp->low_dma = sdp->device->host->unchecked_isa_dma;
864 if (sdp->detached)
866 __put_user((int) sdp->device->host->host_no,
868 __put_user((int) sdp->device->channel,
870 __put_user((int) sdp->device->id, &sg_idp->scsi_id);
871 __put_user((int) sdp->device->lun, &sg_idp->lun);
872 __put_user((int) sdp->device->type, &sg_idp->scsi_type);
873 __put_user((short) sdp->device->host->cmd_per_lun,
875 __put_user((short) sdp->device->queue_depth,
911 return put_user(sdp->sg_tablesize, ip);
919 queue_max_sectors(sdp->device->request_queue) * 512);
929 queue_max_sectors(sdp->device->request_queue) * 512);
957 val = (sdp->device ? 1 : 0);
1006 if (sdp->detached)
1008 return put_user(sdp->device->host->hostt->emulated, ip);
1010 if (sdp->detached)
1013 if (scsi_host_in_recovery(sdp->device->host))
1015 } else if (!scsi_block_when_processing_errors(sdp->device))
1040 return (scsi_reset_provider(sdp->device, val) ==
1043 if (sdp->detached)
1054 return sg_scsi_ioctl(sdp->device->request_queue, NULL, filp->f_mode, p);
1059 sdp->sgdebug = (char) val;
1065 if (sdp->detached)
1067 return scsi_ioctl(sdp->device, cmd_in, p);
1069 return put_user(queue_max_sectors(sdp->device->request_queue) * 512,
1072 return blk_trace_setup(sdp->device->request_queue,
1073 sdp->disk->disk_name,
1074 MKDEV(SCSI_GENERIC_MAJOR, sdp->index),
1078 return blk_trace_startstop(sdp->device->request_queue, 1);
1080 return blk_trace_startstop(sdp->device->request_queue, 0);
1082 return blk_trace_remove(sdp->device->request_queue);
1086 return scsi_ioctl(sdp->device, cmd_in, p);
1105 Sg_device *sdp;
1109 if ((!(sfp = (Sg_fd *) filp->private_data)) || (!(sdp = sfp->parentdp)))
1112 sdev = sdp->device;
1129 Sg_device *sdp;
1135 if ((!(sfp = (Sg_fd *) filp->private_data)) || (!(sdp = sfp->parentdp))
1148 if (sdp->detached)
1156 sdp->disk->disk_name, (int) res));
1163 Sg_device *sdp;
1166 if ((!(sfp = (Sg_fd *) filp->private_data)) || (!(sdp = sfp->parentdp)))
1169 sdp->disk->disk_name, mode));
1263 Sg_device *sdp;
1277 sdp = sfp->parentdp;
1278 if (unlikely(sdp->detached))
1286 sdp->disk->disk_name, srp->header.pack_id, result));
1299 if ((sdp->sgdebug > 0) &&
1310 && sdp->device->removable) {
1313 sdp->device->changed = 1;
1363 Sg_device *sdp;
1368 sdp = kzalloc(sizeof(Sg_device), GFP_KERNEL);
1369 if (!sdp) {
1382 error = idr_get_new(&sg_index_idr, sdp, &k);
1396 sdp->disk = disk;
1397 sdp->device = scsidp;
1398 INIT_LIST_HEAD(&sdp->sfds);
1399 init_waitqueue_head(&sdp->o_excl_wait);
1400 sdp->sg_tablesize = queue_max_segments(q);
1401 sdp->index = k;
1402 kref_init(&sdp->d_ref);
1409 kfree(sdp);
1412 return sdp;
1429 Sg_device *sdp = NULL;
1450 sdp = sg_alloc(disk, scsidp);
1451 if (IS_ERR(sdp)) {
1453 error = PTR_ERR(sdp);
1457 error = cdev_add(cdev, MKDEV(SCSI_GENERIC_MAJOR, sdp->index), 1);
1461 sdp->cdev = cdev;
1467 sdp->index),
1468 sdp, "%s", disk->disk_name);
1479 "'generic' back to sg%d\n", sdp->index);
1484 "Attached scsi generic sg%d type %d\n", sdp->index,
1487 dev_set_drvdata(cl_dev, sdp);
1493 idr_remove(&sg_index_idr, sdp->index);
1495 kfree(sdp);
1506 struct sg_device *sdp = container_of(kref, struct sg_device, d_ref);
1515 idr_remove(&sg_index_idr, sdp->index);
1520 sdp->disk->disk_name));
1522 put_disk(sdp->disk);
1523 kfree(sdp);
1529 Sg_device *sdp = dev_get_drvdata(cl_dev);
1533 if (!sdp || sdp->detached)
1536 SCSI_LOG_TIMEOUT(3, printk("sg_remove: %s\n", sdp->disk->disk_name));
1538 /* Need a write lock to set sdp->detached. */
1540 sdp->detached = 1;
1541 list_for_each_entry(sfp, &sdp->sfds, sfd_siblings) {
1548 device_destroy(sg_sysfs_class, MKDEV(SCSI_GENERIC_MAJOR, sdp->index));
1549 cdev_del(sdp->cdev);
1550 sdp->cdev = NULL;
1552 sg_put_dev(sdp);
2047 sg_add_sfp(Sg_device * sdp, int dev)
2065 sdp->device->host->unchecked_isa_dma : 1;
2068 sfp->parentdp = sdp;
2070 list_add_tail(&sfp->sfd_siblings, &sdp->sfds);
2077 queue_max_sectors(sdp->device->request_queue) * 512);
2082 kref_get(&sdp->d_ref);
2090 struct sg_device *sdp = sfp->parentdp;
2106 sdp->disk->disk_name,
2110 scsi_device_put(sdp->device);
2111 sg_put_dev(sdp);
2118 struct sg_device *sdp = sfp->parentdp;
2124 wake_up_interruptible(&sdp->o_excl_wait);
2177 struct sg_device *sdp;
2181 sdp = sg_lookup_dev(dev);
2182 if (!sdp)
2183 sdp = ERR_PTR(-ENXIO);
2184 else if (sdp->detached) {
2185 /* If sdp->detached, then the refcount may already be 0, in
2188 sdp = ERR_PTR(-ENODEV);
2190 kref_get(&sdp->d_ref);
2193 return sdp;
2196 static void sg_put_dev(struct sg_device *sdp)
2198 kref_put(&sdp->d_ref, sg_device_destroy);
2472 Sg_device *sdp;
2477 sdp = it ? sg_lookup_dev(it->index) : NULL;
2478 if (sdp && (scsidp = sdp->device) && (!sdp->detached))
2500 Sg_device *sdp;
2505 sdp = it ? sg_lookup_dev(it->index) : NULL;
2506 if (sdp && (scsidp = sdp->device) && (!sdp->detached))
2516 static void sg_proc_debug_helper(struct seq_file *s, Sg_device * sdp)
2526 list_for_each_entry(fp, &sdp->sfds, sfd_siblings) {
2589 Sg_device *sdp;
2599 sdp = it ? sg_lookup_dev(it->index) : NULL;
2600 if (sdp && !list_empty(&sdp->sfds)) {
2601 struct scsi_device *scsidp = sdp->device;
2603 seq_printf(s, " >>> device=%s ", sdp->disk->disk_name);
2604 if (sdp->detached)
2614 sdp->sg_tablesize, sdp->exclude);
2615 sg_proc_debug_helper(s, sdp);