aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/scsi/scsi.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/scsi/scsi.c')
-rw-r--r--drivers/scsi/scsi.c37
1 files changed, 12 insertions, 25 deletions
diff --git a/drivers/scsi/scsi.c b/drivers/scsi/scsi.c
index fb86479ffd4a..2b12983d2b2d 100644
--- a/drivers/scsi/scsi.c
+++ b/drivers/scsi/scsi.c
@@ -284,27 +284,19 @@ EXPORT_SYMBOL_GPL(__scsi_get_command);
284 */ 284 */
285struct scsi_cmnd *scsi_get_command(struct scsi_device *dev, gfp_t gfp_mask) 285struct scsi_cmnd *scsi_get_command(struct scsi_device *dev, gfp_t gfp_mask)
286{ 286{
287 struct scsi_cmnd *cmd; 287 struct scsi_cmnd *cmd = __scsi_get_command(dev->host, gfp_mask);
288 unsigned long flags;
288 289
289 /* Bail if we can't get a reference to the device */ 290 if (unlikely(cmd == NULL))
290 if (!get_device(&dev->sdev_gendev))
291 return NULL; 291 return NULL;
292 292
293 cmd = __scsi_get_command(dev->host, gfp_mask); 293 cmd->device = dev;
294 294 INIT_LIST_HEAD(&cmd->list);
295 if (likely(cmd != NULL)) { 295 INIT_DELAYED_WORK(&cmd->abort_work, scmd_eh_abort_handler);
296 unsigned long flags; 296 spin_lock_irqsave(&dev->list_lock, flags);
297 297 list_add_tail(&cmd->list, &dev->cmd_list);
298 cmd->device = dev; 298 spin_unlock_irqrestore(&dev->list_lock, flags);
299 INIT_LIST_HEAD(&cmd->list); 299 cmd->jiffies_at_alloc = jiffies;
300 INIT_DELAYED_WORK(&cmd->abort_work, scmd_eh_abort_handler);
301 spin_lock_irqsave(&dev->list_lock, flags);
302 list_add_tail(&cmd->list, &dev->cmd_list);
303 spin_unlock_irqrestore(&dev->list_lock, flags);
304 cmd->jiffies_at_alloc = jiffies;
305 } else
306 put_device(&dev->sdev_gendev);
307
308 return cmd; 300 return cmd;
309} 301}
310EXPORT_SYMBOL(scsi_get_command); 302EXPORT_SYMBOL(scsi_get_command);
@@ -313,10 +305,8 @@ EXPORT_SYMBOL(scsi_get_command);
313 * __scsi_put_command - Free a struct scsi_cmnd 305 * __scsi_put_command - Free a struct scsi_cmnd
314 * @shost: dev->host 306 * @shost: dev->host
315 * @cmd: Command to free 307 * @cmd: Command to free
316 * @dev: parent scsi device
317 */ 308 */
318void __scsi_put_command(struct Scsi_Host *shost, struct scsi_cmnd *cmd, 309void __scsi_put_command(struct Scsi_Host *shost, struct scsi_cmnd *cmd)
319 struct device *dev)
320{ 310{
321 unsigned long flags; 311 unsigned long flags;
322 312
@@ -331,8 +321,6 @@ void __scsi_put_command(struct Scsi_Host *shost, struct scsi_cmnd *cmd,
331 321
332 if (likely(cmd != NULL)) 322 if (likely(cmd != NULL))
333 scsi_pool_free_command(shost->cmd_pool, cmd); 323 scsi_pool_free_command(shost->cmd_pool, cmd);
334
335 put_device(dev);
336} 324}
337EXPORT_SYMBOL(__scsi_put_command); 325EXPORT_SYMBOL(__scsi_put_command);
338 326
@@ -346,7 +334,6 @@ EXPORT_SYMBOL(__scsi_put_command);
346 */ 334 */
347void scsi_put_command(struct scsi_cmnd *cmd) 335void scsi_put_command(struct scsi_cmnd *cmd)
348{ 336{
349 struct scsi_device *sdev = cmd->device;
350 unsigned long flags; 337 unsigned long flags;
351 338
352 /* serious error if the command hasn't come from a device list */ 339 /* serious error if the command hasn't come from a device list */
@@ -357,7 +344,7 @@ void scsi_put_command(struct scsi_cmnd *cmd)
357 344
358 cancel_delayed_work(&cmd->abort_work); 345 cancel_delayed_work(&cmd->abort_work);
359 346
360 __scsi_put_command(cmd->device->host, cmd, &sdev->sdev_gendev); 347 __scsi_put_command(cmd->device->host, cmd);
361} 348}
362EXPORT_SYMBOL(scsi_put_command); 349EXPORT_SYMBOL(scsi_put_command);
363 350