aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/ata
diff options
context:
space:
mode:
authorJeff Garzik <jeff@garzik.org>2010-11-17 22:56:48 -0500
committerJeff Garzik <jgarzik@redhat.com>2011-01-05 19:43:22 -0500
commitb27dcfb0670ea7352a67137f4ff7947c2a9f6892 (patch)
treecd48976174179304780651fa4e75bd5d1ffd1522 /drivers/ata
parent02cdfcf043c5c6ebcbbaba1c35130b5fbcb10867 (diff)
[libata] avoid needlessly passing around ptr to SCSI completion func
It's stored in struct scsi_cmnd->scsi_done, making several 'done' parameters to functions redundant. Signed-off-by: Jeff Garzik <jgarzik@redhat.com>
Diffstat (limited to 'drivers/ata')
-rw-r--r--drivers/ata/libata-scsi.c60
1 files changed, 25 insertions, 35 deletions
diff --git a/drivers/ata/libata-scsi.c b/drivers/ata/libata-scsi.c
index 66aa4bee80a6..5defc74973d7 100644
--- a/drivers/ata/libata-scsi.c
+++ b/drivers/ata/libata-scsi.c
@@ -346,12 +346,11 @@ struct device_attribute *ata_common_sdev_attrs[] = {
346}; 346};
347EXPORT_SYMBOL_GPL(ata_common_sdev_attrs); 347EXPORT_SYMBOL_GPL(ata_common_sdev_attrs);
348 348
349static void ata_scsi_invalid_field(struct scsi_cmnd *cmd, 349static void ata_scsi_invalid_field(struct scsi_cmnd *cmd)
350 void (*done)(struct scsi_cmnd *))
351{ 350{
352 ata_scsi_set_sense(cmd, ILLEGAL_REQUEST, 0x24, 0x0); 351 ata_scsi_set_sense(cmd, ILLEGAL_REQUEST, 0x24, 0x0);
353 /* "Invalid field in cbd" */ 352 /* "Invalid field in cbd" */
354 done(cmd); 353 cmd->scsi_done(cmd);
355} 354}
356 355
357/** 356/**
@@ -719,7 +718,6 @@ EXPORT_SYMBOL_GPL(ata_scsi_ioctl);
719 * ata_scsi_qc_new - acquire new ata_queued_cmd reference 718 * ata_scsi_qc_new - acquire new ata_queued_cmd reference
720 * @dev: ATA device to which the new command is attached 719 * @dev: ATA device to which the new command is attached
721 * @cmd: SCSI command that originated this ATA command 720 * @cmd: SCSI command that originated this ATA command
722 * @done: SCSI command completion function
723 * 721 *
724 * Obtain a reference to an unused ata_queued_cmd structure, 722 * Obtain a reference to an unused ata_queued_cmd structure,
725 * which is the basic libata structure representing a single 723 * which is the basic libata structure representing a single
@@ -736,21 +734,20 @@ EXPORT_SYMBOL_GPL(ata_scsi_ioctl);
736 * Command allocated, or %NULL if none available. 734 * Command allocated, or %NULL if none available.
737 */ 735 */
738static struct ata_queued_cmd *ata_scsi_qc_new(struct ata_device *dev, 736static struct ata_queued_cmd *ata_scsi_qc_new(struct ata_device *dev,
739 struct scsi_cmnd *cmd, 737 struct scsi_cmnd *cmd)
740 void (*done)(struct scsi_cmnd *))
741{ 738{
742 struct ata_queued_cmd *qc; 739 struct ata_queued_cmd *qc;
743 740
744 qc = ata_qc_new_init(dev); 741 qc = ata_qc_new_init(dev);
745 if (qc) { 742 if (qc) {
746 qc->scsicmd = cmd; 743 qc->scsicmd = cmd;
747 qc->scsidone = done; 744 qc->scsidone = cmd->scsi_done;
748 745
749 qc->sg = scsi_sglist(cmd); 746 qc->sg = scsi_sglist(cmd);
750 qc->n_elem = scsi_sg_count(cmd); 747 qc->n_elem = scsi_sg_count(cmd);
751 } else { 748 } else {
752 cmd->result = (DID_OK << 16) | (QUEUE_FULL << 1); 749 cmd->result = (DID_OK << 16) | (QUEUE_FULL << 1);
753 done(cmd); 750 cmd->scsi_done(cmd);
754 } 751 }
755 752
756 return qc; 753 return qc;
@@ -1735,7 +1732,6 @@ static void ata_scsi_qc_complete(struct ata_queued_cmd *qc)
1735 * ata_scsi_translate - Translate then issue SCSI command to ATA device 1732 * ata_scsi_translate - Translate then issue SCSI command to ATA device
1736 * @dev: ATA device to which the command is addressed 1733 * @dev: ATA device to which the command is addressed
1737 * @cmd: SCSI command to execute 1734 * @cmd: SCSI command to execute
1738 * @done: SCSI command completion function
1739 * @xlat_func: Actor which translates @cmd to an ATA taskfile 1735 * @xlat_func: Actor which translates @cmd to an ATA taskfile
1740 * 1736 *
1741 * Our ->queuecommand() function has decided that the SCSI 1737 * Our ->queuecommand() function has decided that the SCSI
@@ -1759,7 +1755,6 @@ static void ata_scsi_qc_complete(struct ata_queued_cmd *qc)
1759 * needs to be deferred. 1755 * needs to be deferred.
1760 */ 1756 */
1761static int ata_scsi_translate(struct ata_device *dev, struct scsi_cmnd *cmd, 1757static int ata_scsi_translate(struct ata_device *dev, struct scsi_cmnd *cmd,
1762 void (*done)(struct scsi_cmnd *),
1763 ata_xlat_func_t xlat_func) 1758 ata_xlat_func_t xlat_func)
1764{ 1759{
1765 struct ata_port *ap = dev->link->ap; 1760 struct ata_port *ap = dev->link->ap;
@@ -1768,7 +1763,7 @@ static int ata_scsi_translate(struct ata_device *dev, struct scsi_cmnd *cmd,
1768 1763
1769 VPRINTK("ENTER\n"); 1764 VPRINTK("ENTER\n");
1770 1765
1771 qc = ata_scsi_qc_new(dev, cmd, done); 1766 qc = ata_scsi_qc_new(dev, cmd);
1772 if (!qc) 1767 if (!qc)
1773 goto err_mem; 1768 goto err_mem;
1774 1769
@@ -1804,14 +1799,14 @@ static int ata_scsi_translate(struct ata_device *dev, struct scsi_cmnd *cmd,
1804 1799
1805early_finish: 1800early_finish:
1806 ata_qc_free(qc); 1801 ata_qc_free(qc);
1807 qc->scsidone(cmd); 1802 cmd->scsi_done(cmd);
1808 DPRINTK("EXIT - early finish (good or error)\n"); 1803 DPRINTK("EXIT - early finish (good or error)\n");
1809 return 0; 1804 return 0;
1810 1805
1811err_did: 1806err_did:
1812 ata_qc_free(qc); 1807 ata_qc_free(qc);
1813 cmd->result = (DID_ERROR << 16); 1808 cmd->result = (DID_ERROR << 16);
1814 qc->scsidone(cmd); 1809 cmd->scsi_done(cmd);
1815err_mem: 1810err_mem:
1816 DPRINTK("EXIT - internal\n"); 1811 DPRINTK("EXIT - internal\n");
1817 return 0; 1812 return 0;
@@ -3116,7 +3111,6 @@ static inline void ata_scsi_dump_cdb(struct ata_port *ap,
3116} 3111}
3117 3112
3118static inline int __ata_scsi_queuecmd(struct scsi_cmnd *scmd, 3113static inline int __ata_scsi_queuecmd(struct scsi_cmnd *scmd,
3119 void (*done)(struct scsi_cmnd *),
3120 struct ata_device *dev) 3114 struct ata_device *dev)
3121{ 3115{
3122 u8 scsi_op = scmd->cmnd[0]; 3116 u8 scsi_op = scmd->cmnd[0];
@@ -3150,9 +3144,9 @@ static inline int __ata_scsi_queuecmd(struct scsi_cmnd *scmd,
3150 } 3144 }
3151 3145
3152 if (xlat_func) 3146 if (xlat_func)
3153 rc = ata_scsi_translate(dev, scmd, done, xlat_func); 3147 rc = ata_scsi_translate(dev, scmd, xlat_func);
3154 else 3148 else
3155 ata_scsi_simulate(dev, scmd, done); 3149 ata_scsi_simulate(dev, scmd);
3156 3150
3157 return rc; 3151 return rc;
3158 3152
@@ -3160,7 +3154,7 @@ static inline int __ata_scsi_queuecmd(struct scsi_cmnd *scmd,
3160 DPRINTK("bad CDB len=%u, scsi_op=0x%02x, max=%u\n", 3154 DPRINTK("bad CDB len=%u, scsi_op=0x%02x, max=%u\n",
3161 scmd->cmd_len, scsi_op, dev->cdb_len); 3155 scmd->cmd_len, scsi_op, dev->cdb_len);
3162 scmd->result = DID_ERROR << 16; 3156 scmd->result = DID_ERROR << 16;
3163 done(scmd); 3157 scmd->scsi_done(scmd);
3164 return 0; 3158 return 0;
3165} 3159}
3166 3160
@@ -3199,7 +3193,7 @@ int ata_scsi_queuecmd(struct Scsi_Host *shost, struct scsi_cmnd *cmd)
3199 3193
3200 dev = ata_scsi_find_dev(ap, scsidev); 3194 dev = ata_scsi_find_dev(ap, scsidev);
3201 if (likely(dev)) 3195 if (likely(dev))
3202 rc = __ata_scsi_queuecmd(cmd, cmd->scsi_done, dev); 3196 rc = __ata_scsi_queuecmd(cmd, dev);
3203 else { 3197 else {
3204 cmd->result = (DID_BAD_TARGET << 16); 3198 cmd->result = (DID_BAD_TARGET << 16);
3205 cmd->scsi_done(cmd); 3199 cmd->scsi_done(cmd);
@@ -3214,7 +3208,6 @@ int ata_scsi_queuecmd(struct Scsi_Host *shost, struct scsi_cmnd *cmd)
3214 * ata_scsi_simulate - simulate SCSI command on ATA device 3208 * ata_scsi_simulate - simulate SCSI command on ATA device
3215 * @dev: the target device 3209 * @dev: the target device
3216 * @cmd: SCSI command being sent to device. 3210 * @cmd: SCSI command being sent to device.
3217 * @done: SCSI command completion function.
3218 * 3211 *
3219 * Interprets and directly executes a select list of SCSI commands 3212 * Interprets and directly executes a select list of SCSI commands
3220 * that can be handled internally. 3213 * that can be handled internally.
@@ -3223,8 +3216,7 @@ int ata_scsi_queuecmd(struct Scsi_Host *shost, struct scsi_cmnd *cmd)
3223 * spin_lock_irqsave(host lock) 3216 * spin_lock_irqsave(host lock)
3224 */ 3217 */
3225 3218
3226void ata_scsi_simulate(struct ata_device *dev, struct scsi_cmnd *cmd, 3219void ata_scsi_simulate(struct ata_device *dev, struct scsi_cmnd *cmd)
3227 void (*done)(struct scsi_cmnd *))
3228{ 3220{
3229 struct ata_scsi_args args; 3221 struct ata_scsi_args args;
3230 const u8 *scsicmd = cmd->cmnd; 3222 const u8 *scsicmd = cmd->cmnd;
@@ -3233,17 +3225,17 @@ void ata_scsi_simulate(struct ata_device *dev, struct scsi_cmnd *cmd,
3233 args.dev = dev; 3225 args.dev = dev;
3234 args.id = dev->id; 3226 args.id = dev->id;
3235 args.cmd = cmd; 3227 args.cmd = cmd;
3236 args.done = done; 3228 args.done = cmd->scsi_done;
3237 3229
3238 switch(scsicmd[0]) { 3230 switch(scsicmd[0]) {
3239 /* TODO: worth improving? */ 3231 /* TODO: worth improving? */
3240 case FORMAT_UNIT: 3232 case FORMAT_UNIT:
3241 ata_scsi_invalid_field(cmd, done); 3233 ata_scsi_invalid_field(cmd);
3242 break; 3234 break;
3243 3235
3244 case INQUIRY: 3236 case INQUIRY:
3245 if (scsicmd[1] & 2) /* is CmdDt set? */ 3237 if (scsicmd[1] & 2) /* is CmdDt set? */
3246 ata_scsi_invalid_field(cmd, done); 3238 ata_scsi_invalid_field(cmd);
3247 else if ((scsicmd[1] & 1) == 0) /* is EVPD clear? */ 3239 else if ((scsicmd[1] & 1) == 0) /* is EVPD clear? */
3248 ata_scsi_rbuf_fill(&args, ata_scsiop_inq_std); 3240 ata_scsi_rbuf_fill(&args, ata_scsiop_inq_std);
3249 else switch (scsicmd[2]) { 3241 else switch (scsicmd[2]) {
@@ -3269,7 +3261,7 @@ void ata_scsi_simulate(struct ata_device *dev, struct scsi_cmnd *cmd,
3269 ata_scsi_rbuf_fill(&args, ata_scsiop_inq_b2); 3261 ata_scsi_rbuf_fill(&args, ata_scsiop_inq_b2);
3270 break; 3262 break;
3271 default: 3263 default:
3272 ata_scsi_invalid_field(cmd, done); 3264 ata_scsi_invalid_field(cmd);
3273 break; 3265 break;
3274 } 3266 }
3275 break; 3267 break;
@@ -3281,7 +3273,7 @@ void ata_scsi_simulate(struct ata_device *dev, struct scsi_cmnd *cmd,
3281 3273
3282 case MODE_SELECT: /* unconditionally return */ 3274 case MODE_SELECT: /* unconditionally return */
3283 case MODE_SELECT_10: /* bad-field-in-cdb */ 3275 case MODE_SELECT_10: /* bad-field-in-cdb */
3284 ata_scsi_invalid_field(cmd, done); 3276 ata_scsi_invalid_field(cmd);
3285 break; 3277 break;
3286 3278
3287 case READ_CAPACITY: 3279 case READ_CAPACITY:
@@ -3292,7 +3284,7 @@ void ata_scsi_simulate(struct ata_device *dev, struct scsi_cmnd *cmd,
3292 if ((scsicmd[1] & 0x1f) == SAI_READ_CAPACITY_16) 3284 if ((scsicmd[1] & 0x1f) == SAI_READ_CAPACITY_16)
3293 ata_scsi_rbuf_fill(&args, ata_scsiop_read_cap); 3285 ata_scsi_rbuf_fill(&args, ata_scsiop_read_cap);
3294 else 3286 else
3295 ata_scsi_invalid_field(cmd, done); 3287 ata_scsi_invalid_field(cmd);
3296 break; 3288 break;
3297 3289
3298 case REPORT_LUNS: 3290 case REPORT_LUNS:
@@ -3302,7 +3294,7 @@ void ata_scsi_simulate(struct ata_device *dev, struct scsi_cmnd *cmd,
3302 case REQUEST_SENSE: 3294 case REQUEST_SENSE:
3303 ata_scsi_set_sense(cmd, 0, 0, 0); 3295 ata_scsi_set_sense(cmd, 0, 0, 0);
3304 cmd->result = (DRIVER_SENSE << 24); 3296 cmd->result = (DRIVER_SENSE << 24);
3305 done(cmd); 3297 cmd->scsi_done(cmd);
3306 break; 3298 break;
3307 3299
3308 /* if we reach this, then writeback caching is disabled, 3300 /* if we reach this, then writeback caching is disabled,
@@ -3324,14 +3316,14 @@ void ata_scsi_simulate(struct ata_device *dev, struct scsi_cmnd *cmd,
3324 if ((tmp8 == 0x4) && (!scsicmd[3]) && (!scsicmd[4])) 3316 if ((tmp8 == 0x4) && (!scsicmd[3]) && (!scsicmd[4]))
3325 ata_scsi_rbuf_fill(&args, ata_scsiop_noop); 3317 ata_scsi_rbuf_fill(&args, ata_scsiop_noop);
3326 else 3318 else
3327 ata_scsi_invalid_field(cmd, done); 3319 ata_scsi_invalid_field(cmd);
3328 break; 3320 break;
3329 3321
3330 /* all other commands */ 3322 /* all other commands */
3331 default: 3323 default:
3332 ata_scsi_set_sense(cmd, ILLEGAL_REQUEST, 0x20, 0x0); 3324 ata_scsi_set_sense(cmd, ILLEGAL_REQUEST, 0x20, 0x0);
3333 /* "Invalid command operation code" */ 3325 /* "Invalid command operation code" */
3334 done(cmd); 3326 cmd->scsi_done(cmd);
3335 break; 3327 break;
3336 } 3328 }
3337} 3329}
@@ -3858,7 +3850,6 @@ EXPORT_SYMBOL_GPL(ata_sas_slave_configure);
3858/** 3850/**
3859 * ata_sas_queuecmd - Issue SCSI cdb to libata-managed device 3851 * ata_sas_queuecmd - Issue SCSI cdb to libata-managed device
3860 * @cmd: SCSI command to be sent 3852 * @cmd: SCSI command to be sent
3861 * @done: Completion function, called when command is complete
3862 * @ap: ATA port to which the command is being sent 3853 * @ap: ATA port to which the command is being sent
3863 * 3854 *
3864 * RETURNS: 3855 * RETURNS:
@@ -3866,18 +3857,17 @@ EXPORT_SYMBOL_GPL(ata_sas_slave_configure);
3866 * 0 otherwise. 3857 * 0 otherwise.
3867 */ 3858 */
3868 3859
3869int ata_sas_queuecmd(struct scsi_cmnd *cmd, void (*done)(struct scsi_cmnd *), 3860int ata_sas_queuecmd(struct scsi_cmnd *cmd, struct ata_port *ap)
3870 struct ata_port *ap)
3871{ 3861{
3872 int rc = 0; 3862 int rc = 0;
3873 3863
3874 ata_scsi_dump_cdb(ap, cmd); 3864 ata_scsi_dump_cdb(ap, cmd);
3875 3865
3876 if (likely(ata_dev_enabled(ap->link.device))) 3866 if (likely(ata_dev_enabled(ap->link.device)))
3877 rc = __ata_scsi_queuecmd(cmd, done, ap->link.device); 3867 rc = __ata_scsi_queuecmd(cmd, ap->link.device);
3878 else { 3868 else {
3879 cmd->result = (DID_BAD_TARGET << 16); 3869 cmd->result = (DID_BAD_TARGET << 16);
3880 done(cmd); 3870 cmd->scsi_done(cmd);
3881 } 3871 }
3882 return rc; 3872 return rc;
3883} 3873}