aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/ata/libata-scsi.c
diff options
context:
space:
mode:
authorTejun Heo <htejun@gmail.com>2008-04-28 04:16:52 -0400
committerJeff Garzik <jgarzik@redhat.com>2008-04-29 02:16:37 -0400
commitf0761be344f9b1cc4284b1d945933cd983c233a4 (patch)
treed2b999a039bee7f36b0707b80cd13fd1e1b2cfbb /drivers/ata/libata-scsi.c
parent3dd654bfdf8905d0acb6f6231b5e736d2b0d4bc6 (diff)
libata-scsi: clean up inquiry / mode sense related functions
* make ata_scsiop_*() static * make ata_scsi_set_sense() static and move it above its users * make ata_scsi_rbuf_fill() static * kill unused ata_scsi_badcmd() Signed-off-by: Tejun Heo <htejun@gmail.com> Signed-off-by: Jeff Garzik <jgarzik@redhat.com>
Diffstat (limited to 'drivers/ata/libata-scsi.c')
-rw-r--r--drivers/ata/libata-scsi.c89
1 files changed, 21 insertions, 68 deletions
diff --git a/drivers/ata/libata-scsi.c b/drivers/ata/libata-scsi.c
index a34f32442ed..e516816f66a 100644
--- a/drivers/ata/libata-scsi.c
+++ b/drivers/ata/libata-scsi.c
@@ -179,6 +179,13 @@ DEVICE_ATTR(link_power_management_policy, S_IRUGO | S_IWUSR,
179 ata_scsi_lpm_show, ata_scsi_lpm_put); 179 ata_scsi_lpm_show, ata_scsi_lpm_put);
180EXPORT_SYMBOL_GPL(dev_attr_link_power_management_policy); 180EXPORT_SYMBOL_GPL(dev_attr_link_power_management_policy);
181 181
182static void ata_scsi_set_sense(struct scsi_cmnd *cmd, u8 sk, u8 asc, u8 ascq)
183{
184 cmd->result = (DRIVER_SENSE << 24) | SAM_STAT_CHECK_CONDITION;
185
186 scsi_build_sense_buffer(0, cmd->sense_buffer, sk, asc, ascq);
187}
188
182static void ata_scsi_invalid_field(struct scsi_cmnd *cmd, 189static void ata_scsi_invalid_field(struct scsi_cmnd *cmd,
183 void (*done)(struct scsi_cmnd *)) 190 void (*done)(struct scsi_cmnd *))
184{ 191{
@@ -1696,10 +1703,9 @@ static inline void ata_scsi_rbuf_put(struct scsi_cmnd *cmd, u8 *buf)
1696 * LOCKING: 1703 * LOCKING:
1697 * spin_lock_irqsave(host lock) 1704 * spin_lock_irqsave(host lock)
1698 */ 1705 */
1699 1706static void ata_scsi_rbuf_fill(struct ata_scsi_args *args,
1700void ata_scsi_rbuf_fill(struct ata_scsi_args *args, 1707 unsigned int (*actor)(struct ata_scsi_args *args,
1701 unsigned int (*actor) (struct ata_scsi_args *args, 1708 u8 *rbuf, unsigned int buflen))
1702 u8 *rbuf, unsigned int buflen))
1703{ 1709{
1704 u8 *rbuf; 1710 u8 *rbuf;
1705 unsigned int buflen, rc; 1711 unsigned int buflen, rc;
@@ -1748,9 +1754,8 @@ void ata_scsi_rbuf_fill(struct ata_scsi_args *args,
1748 * LOCKING: 1754 * LOCKING:
1749 * spin_lock_irqsave(host lock) 1755 * spin_lock_irqsave(host lock)
1750 */ 1756 */
1751 1757static unsigned int ata_scsiop_inq_std(struct ata_scsi_args *args, u8 *rbuf,
1752unsigned int ata_scsiop_inq_std(struct ata_scsi_args *args, u8 *rbuf, 1758 unsigned int buflen)
1753 unsigned int buflen)
1754{ 1759{
1755 u8 hdr[] = { 1760 u8 hdr[] = {
1756 TYPE_DISK, 1761 TYPE_DISK,
@@ -1804,9 +1809,8 @@ unsigned int ata_scsiop_inq_std(struct ata_scsi_args *args, u8 *rbuf,
1804 * LOCKING: 1809 * LOCKING:
1805 * spin_lock_irqsave(host lock) 1810 * spin_lock_irqsave(host lock)
1806 */ 1811 */
1807 1812static unsigned int ata_scsiop_inq_00(struct ata_scsi_args *args, u8 *rbuf,
1808unsigned int ata_scsiop_inq_00(struct ata_scsi_args *args, u8 *rbuf, 1813 unsigned int buflen)
1809 unsigned int buflen)
1810{ 1814{
1811 const u8 pages[] = { 1815 const u8 pages[] = {
1812 0x00, /* page 0x00, this page */ 1816 0x00, /* page 0x00, this page */
@@ -1832,9 +1836,8 @@ unsigned int ata_scsiop_inq_00(struct ata_scsi_args *args, u8 *rbuf,
1832 * LOCKING: 1836 * LOCKING:
1833 * spin_lock_irqsave(host lock) 1837 * spin_lock_irqsave(host lock)
1834 */ 1838 */
1835 1839static unsigned int ata_scsiop_inq_80(struct ata_scsi_args *args, u8 *rbuf,
1836unsigned int ata_scsiop_inq_80(struct ata_scsi_args *args, u8 *rbuf, 1840 unsigned int buflen)
1837 unsigned int buflen)
1838{ 1841{
1839 const u8 hdr[] = { 1842 const u8 hdr[] = {
1840 0, 1843 0,
@@ -1865,9 +1868,8 @@ unsigned int ata_scsiop_inq_80(struct ata_scsi_args *args, u8 *rbuf,
1865 * LOCKING: 1868 * LOCKING:
1866 * spin_lock_irqsave(host lock) 1869 * spin_lock_irqsave(host lock)
1867 */ 1870 */
1868 1871static unsigned int ata_scsiop_inq_83(struct ata_scsi_args *args, u8 *rbuf,
1869unsigned int ata_scsiop_inq_83(struct ata_scsi_args *args, u8 *rbuf, 1872 unsigned int buflen)
1870 unsigned int buflen)
1871{ 1873{
1872 int num; 1874 int num;
1873 const int sat_model_serial_desc_len = 68; 1875 const int sat_model_serial_desc_len = 68;
@@ -1915,9 +1917,8 @@ unsigned int ata_scsiop_inq_83(struct ata_scsi_args *args, u8 *rbuf,
1915 * LOCKING: 1917 * LOCKING:
1916 * spin_lock_irqsave(host lock) 1918 * spin_lock_irqsave(host lock)
1917 */ 1919 */
1918
1919static unsigned int ata_scsiop_inq_89(struct ata_scsi_args *args, u8 *rbuf, 1920static unsigned int ata_scsiop_inq_89(struct ata_scsi_args *args, u8 *rbuf,
1920 unsigned int buflen) 1921 unsigned int buflen)
1921{ 1922{
1922 u8 pbuf[60]; 1923 u8 pbuf[60];
1923 struct ata_taskfile tf; 1924 struct ata_taskfile tf;
@@ -1972,9 +1973,8 @@ static unsigned int ata_scsiop_inq_89(struct ata_scsi_args *args, u8 *rbuf,
1972 * LOCKING: 1973 * LOCKING:
1973 * spin_lock_irqsave(host lock) 1974 * spin_lock_irqsave(host lock)
1974 */ 1975 */
1975 1976static unsigned int ata_scsiop_noop(struct ata_scsi_args *args, u8 *rbuf,
1976unsigned int ata_scsiop_noop(struct ata_scsi_args *args, u8 *rbuf, 1977 unsigned int buflen)
1977 unsigned int buflen)
1978{ 1978{
1979 VPRINTK("ENTER\n"); 1979 VPRINTK("ENTER\n");
1980 return 0; 1980 return 0;
@@ -2312,53 +2312,6 @@ unsigned int ata_scsiop_report_luns(struct ata_scsi_args *args, u8 *rbuf,
2312 return 0; 2312 return 0;
2313} 2313}
2314 2314
2315/**
2316 * ata_scsi_set_sense - Set SCSI sense data and status
2317 * @cmd: SCSI request to be handled
2318 * @sk: SCSI-defined sense key
2319 * @asc: SCSI-defined additional sense code
2320 * @ascq: SCSI-defined additional sense code qualifier
2321 *
2322 * Helper function that builds a valid fixed format, current
2323 * response code and the given sense key (sk), additional sense
2324 * code (asc) and additional sense code qualifier (ascq) with
2325 * a SCSI command status of %SAM_STAT_CHECK_CONDITION and
2326 * DRIVER_SENSE set in the upper bits of scsi_cmnd::result .
2327 *
2328 * LOCKING:
2329 * Not required
2330 */
2331
2332void ata_scsi_set_sense(struct scsi_cmnd *cmd, u8 sk, u8 asc, u8 ascq)
2333{
2334 cmd->result = (DRIVER_SENSE << 24) | SAM_STAT_CHECK_CONDITION;
2335
2336 scsi_build_sense_buffer(0, cmd->sense_buffer, sk, asc, ascq);
2337}
2338
2339/**
2340 * ata_scsi_badcmd - End a SCSI request with an error
2341 * @cmd: SCSI request to be handled
2342 * @done: SCSI command completion function
2343 * @asc: SCSI-defined additional sense code
2344 * @ascq: SCSI-defined additional sense code qualifier
2345 *
2346 * Helper function that completes a SCSI command with
2347 * %SAM_STAT_CHECK_CONDITION, with a sense key %ILLEGAL_REQUEST
2348 * and the specified additional sense codes.
2349 *
2350 * LOCKING:
2351 * spin_lock_irqsave(host lock)
2352 */
2353
2354void ata_scsi_badcmd(struct scsi_cmnd *cmd, void (*done)(struct scsi_cmnd *), u8 asc, u8 ascq)
2355{
2356 DPRINTK("ENTER\n");
2357 ata_scsi_set_sense(cmd, ILLEGAL_REQUEST, asc, ascq);
2358
2359 done(cmd);
2360}
2361
2362static void atapi_sense_complete(struct ata_queued_cmd *qc) 2315static void atapi_sense_complete(struct ata_queued_cmd *qc)
2363{ 2316{
2364 if (qc->err_mask && ((qc->err_mask & AC_ERR_DEV) == 0)) { 2317 if (qc->err_mask && ((qc->err_mask & AC_ERR_DEV) == 0)) {