aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/ata/libata-scsi.c
diff options
context:
space:
mode:
authorJeff Garzik <jeff@garzik.org>2007-10-19 06:42:56 -0400
committerJeff Garzik <jeff@garzik.org>2007-10-23 20:59:42 -0400
commit2dcb407e61458ded17503d6bd12b8c064965368b (patch)
tree6044e032197b84f9943a385b0c9dbb6656c3f97f /drivers/ata/libata-scsi.c
parent01e7ae8c13bb06a2ce622ebace33bb7e28ef596c (diff)
[libata] checkpatch-inspired cleanups
Tackle the relatively sane complaints of checkpatch --file. The vast majority is indentation and whitespace changes, the rest are * #include fixes * printk KERN_xxx prefix addition * BSS/initializer cleanups Signed-off-by: Jeff Garzik <jgarzik@redhat.com>
Diffstat (limited to 'drivers/ata/libata-scsi.c')
-rw-r--r--drivers/ata/libata-scsi.c240
1 files changed, 120 insertions, 120 deletions
diff --git a/drivers/ata/libata-scsi.c b/drivers/ata/libata-scsi.c
index 5b758b9ad0b..f5d5420a1ba 100644
--- a/drivers/ata/libata-scsi.c
+++ b/drivers/ata/libata-scsi.c
@@ -45,7 +45,7 @@
45#include <scsi/scsi_transport.h> 45#include <scsi/scsi_transport.h>
46#include <linux/libata.h> 46#include <linux/libata.h>
47#include <linux/hdreg.h> 47#include <linux/hdreg.h>
48#include <asm/uaccess.h> 48#include <linux/uaccess.h>
49 49
50#include "libata.h" 50#include "libata.h"
51 51
@@ -53,9 +53,9 @@
53 53
54typedef unsigned int (*ata_xlat_func_t)(struct ata_queued_cmd *qc); 54typedef unsigned int (*ata_xlat_func_t)(struct ata_queued_cmd *qc);
55 55
56static struct ata_device * __ata_scsi_find_dev(struct ata_port *ap, 56static struct ata_device *__ata_scsi_find_dev(struct ata_port *ap,
57 const struct scsi_device *scsidev); 57 const struct scsi_device *scsidev);
58static struct ata_device * ata_scsi_find_dev(struct ata_port *ap, 58static struct ata_device *ata_scsi_find_dev(struct ata_port *ap,
59 const struct scsi_device *scsidev); 59 const struct scsi_device *scsidev);
60static int ata_scsi_user_scan(struct Scsi_Host *shost, unsigned int channel, 60static int ata_scsi_user_scan(struct Scsi_Host *shost, unsigned int channel,
61 unsigned int id, unsigned int lun); 61 unsigned int id, unsigned int lun);
@@ -228,7 +228,7 @@ int ata_cmd_ioctl(struct scsi_device *scsidev, void __user *arg)
228 228
229 scsi_cmd[1] = (4 << 1); /* PIO Data-in */ 229 scsi_cmd[1] = (4 << 1); /* PIO Data-in */
230 scsi_cmd[2] = 0x0e; /* no off.line or cc, read from dev, 230 scsi_cmd[2] = 0x0e; /* no off.line or cc, read from dev,
231 block count in sector count field */ 231 block count in sector count field */
232 data_dir = DMA_FROM_DEVICE; 232 data_dir = DMA_FROM_DEVICE;
233 } else { 233 } else {
234 scsi_cmd[1] = (3 << 1); /* Non-data */ 234 scsi_cmd[1] = (3 << 1); /* Non-data */
@@ -252,7 +252,7 @@ int ata_cmd_ioctl(struct scsi_device *scsidev, void __user *arg)
252 /* Good values for timeout and retries? Values below 252 /* Good values for timeout and retries? Values below
253 from scsi_ioctl_send_command() for default case... */ 253 from scsi_ioctl_send_command() for default case... */
254 cmd_result = scsi_execute(scsidev, scsi_cmd, data_dir, argbuf, argsize, 254 cmd_result = scsi_execute(scsidev, scsi_cmd, data_dir, argbuf, argsize,
255 sensebuf, (10*HZ), 5, 0); 255 sensebuf, (10*HZ), 5, 0);
256 256
257 if (driver_byte(cmd_result) == DRIVER_SENSE) {/* sense data available */ 257 if (driver_byte(cmd_result) == DRIVER_SENSE) {/* sense data available */
258 u8 *desc = sensebuf + 8; 258 u8 *desc = sensebuf + 8;
@@ -263,18 +263,18 @@ int ata_cmd_ioctl(struct scsi_device *scsidev, void __user *arg)
263 if (cmd_result & SAM_STAT_CHECK_CONDITION) { 263 if (cmd_result & SAM_STAT_CHECK_CONDITION) {
264 struct scsi_sense_hdr sshdr; 264 struct scsi_sense_hdr sshdr;
265 scsi_normalize_sense(sensebuf, SCSI_SENSE_BUFFERSIZE, 265 scsi_normalize_sense(sensebuf, SCSI_SENSE_BUFFERSIZE,
266 &sshdr); 266 &sshdr);
267 if (sshdr.sense_key==0 && 267 if (sshdr.sense_key == 0 &&
268 sshdr.asc==0 && sshdr.ascq==0) 268 sshdr.asc == 0 && sshdr.ascq == 0)
269 cmd_result &= ~SAM_STAT_CHECK_CONDITION; 269 cmd_result &= ~SAM_STAT_CHECK_CONDITION;
270 } 270 }
271 271
272 /* Send userspace a few ATA registers (same as drivers/ide) */ 272 /* Send userspace a few ATA registers (same as drivers/ide) */
273 if (sensebuf[0] == 0x72 && /* format is "descriptor" */ 273 if (sensebuf[0] == 0x72 && /* format is "descriptor" */
274 desc[0] == 0x09 ) { /* code is "ATA Descriptor" */ 274 desc[0] == 0x09) { /* code is "ATA Descriptor" */
275 args[0] = desc[13]; /* status */ 275 args[0] = desc[13]; /* status */
276 args[1] = desc[3]; /* error */ 276 args[1] = desc[3]; /* error */
277 args[2] = desc[5]; /* sector count (0:7) */ 277 args[2] = desc[5]; /* sector count (0:7) */
278 if (copy_to_user(arg, args, sizeof(args))) 278 if (copy_to_user(arg, args, sizeof(args)))
279 rc = -EFAULT; 279 rc = -EFAULT;
280 } 280 }
@@ -350,8 +350,8 @@ int ata_task_ioctl(struct scsi_device *scsidev, void __user *arg)
350 struct scsi_sense_hdr sshdr; 350 struct scsi_sense_hdr sshdr;
351 scsi_normalize_sense(sensebuf, SCSI_SENSE_BUFFERSIZE, 351 scsi_normalize_sense(sensebuf, SCSI_SENSE_BUFFERSIZE,
352 &sshdr); 352 &sshdr);
353 if (sshdr.sense_key==0 && 353 if (sshdr.sense_key == 0 &&
354 sshdr.asc==0 && sshdr.ascq==0) 354 sshdr.asc == 0 && sshdr.ascq == 0)
355 cmd_result &= ~SAM_STAT_CHECK_CONDITION; 355 cmd_result &= ~SAM_STAT_CHECK_CONDITION;
356 } 356 }
357 357
@@ -975,7 +975,7 @@ static unsigned int ata_scsi_start_stop_xlat(struct ata_queued_cmd *qc)
975 if ((qc->dev->flags & ATA_DFLAG_SPUNDOWN) && 975 if ((qc->dev->flags & ATA_DFLAG_SPUNDOWN) &&
976 (system_state == SYSTEM_HALT || 976 (system_state == SYSTEM_HALT ||
977 system_state == SYSTEM_POWER_OFF)) { 977 system_state == SYSTEM_POWER_OFF)) {
978 static unsigned long warned = 0; 978 static unsigned long warned;
979 979
980 if (!test_and_set_bit(0, &warned)) { 980 if (!test_and_set_bit(0, &warned)) {
981 ata_dev_printk(qc->dev, KERN_WARNING, 981 ata_dev_printk(qc->dev, KERN_WARNING,
@@ -1364,7 +1364,7 @@ static void ata_scsi_qc_complete(struct ata_queued_cmd *qc)
1364 struct ata_eh_info *ehi = &qc->dev->link->eh_info; 1364 struct ata_eh_info *ehi = &qc->dev->link->eh_info;
1365 struct scsi_cmnd *cmd = qc->scsicmd; 1365 struct scsi_cmnd *cmd = qc->scsicmd;
1366 u8 *cdb = cmd->cmnd; 1366 u8 *cdb = cmd->cmnd;
1367 int need_sense = (qc->err_mask != 0); 1367 int need_sense = (qc->err_mask != 0);
1368 1368
1369 /* We snoop the SET_FEATURES - Write Cache ON/OFF command, and 1369 /* We snoop the SET_FEATURES - Write Cache ON/OFF command, and
1370 * schedule EH_REVALIDATE operation to update the IDENTIFY DEVICE 1370 * schedule EH_REVALIDATE operation to update the IDENTIFY DEVICE
@@ -1396,7 +1396,7 @@ static void ata_scsi_qc_complete(struct ata_queued_cmd *qc)
1396 * was no error, SK, ASC and ASCQ will all be zero. 1396 * was no error, SK, ASC and ASCQ will all be zero.
1397 */ 1397 */
1398 if (((cdb[0] == ATA_16) || (cdb[0] == ATA_12)) && 1398 if (((cdb[0] == ATA_16) || (cdb[0] == ATA_12)) &&
1399 ((cdb[2] & 0x20) || need_sense)) { 1399 ((cdb[2] & 0x20) || need_sense)) {
1400 ata_gen_passthru_sense(qc); 1400 ata_gen_passthru_sense(qc);
1401 } else { 1401 } else {
1402 if (!need_sense) { 1402 if (!need_sense) {
@@ -1500,7 +1500,7 @@ static int ata_scsi_translate(struct ata_device *dev, struct scsi_cmnd *cmd,
1500 return 0; 1500 return 0;
1501 1501
1502early_finish: 1502early_finish:
1503 ata_qc_free(qc); 1503 ata_qc_free(qc);
1504 qc->scsidone(cmd); 1504 qc->scsidone(cmd);
1505 DPRINTK("EXIT - early finish (good or error)\n"); 1505 DPRINTK("EXIT - early finish (good or error)\n");
1506 return 0; 1506 return 0;
@@ -1590,8 +1590,8 @@ static inline void ata_scsi_rbuf_put(struct scsi_cmnd *cmd, u8 *buf)
1590 */ 1590 */
1591 1591
1592void ata_scsi_rbuf_fill(struct ata_scsi_args *args, 1592void ata_scsi_rbuf_fill(struct ata_scsi_args *args,
1593 unsigned int (*actor) (struct ata_scsi_args *args, 1593 unsigned int (*actor) (struct ata_scsi_args *args,
1594 u8 *rbuf, unsigned int buflen)) 1594 u8 *rbuf, unsigned int buflen))
1595{ 1595{
1596 u8 *rbuf; 1596 u8 *rbuf;
1597 unsigned int buflen, rc; 1597 unsigned int buflen, rc;
@@ -2140,7 +2140,7 @@ saving_not_supp:
2140 * None. 2140 * None.
2141 */ 2141 */
2142unsigned int ata_scsiop_read_cap(struct ata_scsi_args *args, u8 *rbuf, 2142unsigned int ata_scsiop_read_cap(struct ata_scsi_args *args, u8 *rbuf,
2143 unsigned int buflen) 2143 unsigned int buflen)
2144{ 2144{
2145 u64 last_lba = args->dev->n_sectors - 1; /* LBA of the last block */ 2145 u64 last_lba = args->dev->n_sectors - 1; /* LBA of the last block */
2146 2146
@@ -2464,7 +2464,7 @@ static unsigned int atapi_xlat(struct ata_queued_cmd *qc)
2464 return 0; 2464 return 0;
2465} 2465}
2466 2466
2467static struct ata_device * ata_find_dev(struct ata_port *ap, int devno) 2467static struct ata_device *ata_find_dev(struct ata_port *ap, int devno)
2468{ 2468{
2469 if (ap->nr_pmp_links == 0) { 2469 if (ap->nr_pmp_links == 0) {
2470 if (likely(devno < ata_link_max_devices(&ap->link))) 2470 if (likely(devno < ata_link_max_devices(&ap->link)))
@@ -2477,8 +2477,8 @@ static struct ata_device * ata_find_dev(struct ata_port *ap, int devno)
2477 return NULL; 2477 return NULL;
2478} 2478}
2479 2479
2480static struct ata_device * __ata_scsi_find_dev(struct ata_port *ap, 2480static struct ata_device *__ata_scsi_find_dev(struct ata_port *ap,
2481 const struct scsi_device *scsidev) 2481 const struct scsi_device *scsidev)
2482{ 2482{
2483 int devno; 2483 int devno;
2484 2484
@@ -2564,27 +2564,27 @@ static u8
2564ata_scsi_map_proto(u8 byte1) 2564ata_scsi_map_proto(u8 byte1)
2565{ 2565{
2566 switch((byte1 & 0x1e) >> 1) { 2566 switch((byte1 & 0x1e) >> 1) {
2567 case 3: /* Non-data */ 2567 case 3: /* Non-data */
2568 return ATA_PROT_NODATA; 2568 return ATA_PROT_NODATA;
2569 2569
2570 case 6: /* DMA */ 2570 case 6: /* DMA */
2571 case 10: /* UDMA Data-in */ 2571 case 10: /* UDMA Data-in */
2572 case 11: /* UDMA Data-Out */ 2572 case 11: /* UDMA Data-Out */
2573 return ATA_PROT_DMA; 2573 return ATA_PROT_DMA;
2574 2574
2575 case 4: /* PIO Data-in */ 2575 case 4: /* PIO Data-in */
2576 case 5: /* PIO Data-out */ 2576 case 5: /* PIO Data-out */
2577 return ATA_PROT_PIO; 2577 return ATA_PROT_PIO;
2578 2578
2579 case 0: /* Hard Reset */ 2579 case 0: /* Hard Reset */
2580 case 1: /* SRST */ 2580 case 1: /* SRST */
2581 case 8: /* Device Diagnostic */ 2581 case 8: /* Device Diagnostic */
2582 case 9: /* Device Reset */ 2582 case 9: /* Device Reset */
2583 case 7: /* DMA Queued */ 2583 case 7: /* DMA Queued */
2584 case 12: /* FPDMA */ 2584 case 12: /* FPDMA */
2585 case 15: /* Return Response Info */ 2585 case 15: /* Return Response Info */
2586 default: /* Reserved */ 2586 default: /* Reserved */
2587 break; 2587 break;
2588 } 2588 }
2589 2589
2590 return ATA_PROT_UNKNOWN; 2590 return ATA_PROT_UNKNOWN;
@@ -2919,94 +2919,94 @@ void ata_scsi_simulate(struct ata_device *dev, struct scsi_cmnd *cmd,
2919 args.done = done; 2919 args.done = done;
2920 2920
2921 switch(scsicmd[0]) { 2921 switch(scsicmd[0]) {
2922 /* TODO: worth improving? */ 2922 /* TODO: worth improving? */
2923 case FORMAT_UNIT: 2923 case FORMAT_UNIT:
2924 ata_scsi_invalid_field(cmd, done);
2925 break;
2926
2927 case INQUIRY:
2928 if (scsicmd[1] & 2) /* is CmdDt set? */
2924 ata_scsi_invalid_field(cmd, done); 2929 ata_scsi_invalid_field(cmd, done);
2930 else if ((scsicmd[1] & 1) == 0) /* is EVPD clear? */
2931 ata_scsi_rbuf_fill(&args, ata_scsiop_inq_std);
2932 else switch (scsicmd[2]) {
2933 case 0x00:
2934 ata_scsi_rbuf_fill(&args, ata_scsiop_inq_00);
2925 break; 2935 break;
2926 2936 case 0x80:
2927 case INQUIRY: 2937 ata_scsi_rbuf_fill(&args, ata_scsiop_inq_80);
2928 if (scsicmd[1] & 2) /* is CmdDt set? */
2929 ata_scsi_invalid_field(cmd, done);
2930 else if ((scsicmd[1] & 1) == 0) /* is EVPD clear? */
2931 ata_scsi_rbuf_fill(&args, ata_scsiop_inq_std);
2932 else switch (scsicmd[2]) {
2933 case 0x00:
2934 ata_scsi_rbuf_fill(&args, ata_scsiop_inq_00);
2935 break;
2936 case 0x80:
2937 ata_scsi_rbuf_fill(&args, ata_scsiop_inq_80);
2938 break;
2939 case 0x83:
2940 ata_scsi_rbuf_fill(&args, ata_scsiop_inq_83);
2941 break;
2942 case 0x89:
2943 ata_scsi_rbuf_fill(&args, ata_scsiop_inq_89);
2944 break;
2945 default:
2946 ata_scsi_invalid_field(cmd, done);
2947 break;
2948 }
2949 break; 2938 break;
2950 2939 case 0x83:
2951 case MODE_SENSE: 2940 ata_scsi_rbuf_fill(&args, ata_scsiop_inq_83);
2952 case MODE_SENSE_10:
2953 ata_scsi_rbuf_fill(&args, ata_scsiop_mode_sense);
2954 break; 2941 break;
2955 2942 case 0x89:
2956 case MODE_SELECT: /* unconditionally return */ 2943 ata_scsi_rbuf_fill(&args, ata_scsiop_inq_89);
2957 case MODE_SELECT_10: /* bad-field-in-cdb */ 2944 break;
2945 default:
2958 ata_scsi_invalid_field(cmd, done); 2946 ata_scsi_invalid_field(cmd, done);
2959 break; 2947 break;
2948 }
2949 break;
2950
2951 case MODE_SENSE:
2952 case MODE_SENSE_10:
2953 ata_scsi_rbuf_fill(&args, ata_scsiop_mode_sense);
2954 break;
2960 2955
2961 case READ_CAPACITY: 2956 case MODE_SELECT: /* unconditionally return */
2957 case MODE_SELECT_10: /* bad-field-in-cdb */
2958 ata_scsi_invalid_field(cmd, done);
2959 break;
2960
2961 case READ_CAPACITY:
2962 ata_scsi_rbuf_fill(&args, ata_scsiop_read_cap);
2963 break;
2964
2965 case SERVICE_ACTION_IN:
2966 if ((scsicmd[1] & 0x1f) == SAI_READ_CAPACITY_16)
2962 ata_scsi_rbuf_fill(&args, ata_scsiop_read_cap); 2967 ata_scsi_rbuf_fill(&args, ata_scsiop_read_cap);
2963 break; 2968 else
2969 ata_scsi_invalid_field(cmd, done);
2970 break;
2964 2971
2965 case SERVICE_ACTION_IN: 2972 case REPORT_LUNS:
2966 if ((scsicmd[1] & 0x1f) == SAI_READ_CAPACITY_16) 2973 ata_scsi_rbuf_fill(&args, ata_scsiop_report_luns);
2967 ata_scsi_rbuf_fill(&args, ata_scsiop_read_cap); 2974 break;
2968 else
2969 ata_scsi_invalid_field(cmd, done);
2970 break;
2971 2975
2972 case REPORT_LUNS: 2976 case REQUEST_SENSE:
2973 ata_scsi_rbuf_fill(&args, ata_scsiop_report_luns); 2977 ata_scsi_set_sense(cmd, 0, 0, 0);
2974 break; 2978 cmd->result = (DRIVER_SENSE << 24);
2979 done(cmd);
2980 break;
2975 2981
2976 case REQUEST_SENSE: 2982 /* if we reach this, then writeback caching is disabled,
2977 ata_scsi_set_sense(cmd, 0, 0, 0); 2983 * turning this into a no-op.
2978 cmd->result = (DRIVER_SENSE << 24); 2984 */
2979 done(cmd); 2985 case SYNCHRONIZE_CACHE:
2980 break; 2986 /* fall through */
2987
2988 /* no-op's, complete with success */
2989 case REZERO_UNIT:
2990 case SEEK_6:
2991 case SEEK_10:
2992 case TEST_UNIT_READY:
2993 ata_scsi_rbuf_fill(&args, ata_scsiop_noop);
2994 break;
2981 2995
2982 /* if we reach this, then writeback caching is disabled, 2996 case SEND_DIAGNOSTIC:
2983 * turning this into a no-op. 2997 tmp8 = scsicmd[1] & ~(1 << 3);
2984 */ 2998 if ((tmp8 == 0x4) && (!scsicmd[3]) && (!scsicmd[4]))
2985 case SYNCHRONIZE_CACHE:
2986 /* fall through */
2987
2988 /* no-op's, complete with success */
2989 case REZERO_UNIT:
2990 case SEEK_6:
2991 case SEEK_10:
2992 case TEST_UNIT_READY:
2993 ata_scsi_rbuf_fill(&args, ata_scsiop_noop); 2999 ata_scsi_rbuf_fill(&args, ata_scsiop_noop);
2994 break; 3000 else
2995 3001 ata_scsi_invalid_field(cmd, done);
2996 case SEND_DIAGNOSTIC: 3002 break;
2997 tmp8 = scsicmd[1] & ~(1 << 3);
2998 if ((tmp8 == 0x4) && (!scsicmd[3]) && (!scsicmd[4]))
2999 ata_scsi_rbuf_fill(&args, ata_scsiop_noop);
3000 else
3001 ata_scsi_invalid_field(cmd, done);
3002 break;
3003 3003
3004 /* all other commands */ 3004 /* all other commands */
3005 default: 3005 default:
3006 ata_scsi_set_sense(cmd, ILLEGAL_REQUEST, 0x20, 0x0); 3006 ata_scsi_set_sense(cmd, ILLEGAL_REQUEST, 0x20, 0x0);
3007 /* "Invalid command operation code" */ 3007 /* "Invalid command operation code" */
3008 done(cmd); 3008 done(cmd);
3009 break; 3009 break;
3010 } 3010 }
3011} 3011}
3012 3012