aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBartlomiej Zolnierkiewicz <bzolnier@gmail.com>2008-02-01 17:09:24 -0500
committerBartlomiej Zolnierkiewicz <bzolnier@gmail.com>2008-02-01 17:09:24 -0500
commit139c829d9d83cfd6b51682f11a431283121e24b7 (patch)
treed74f5123bf658c940527e2cc66c33323153fd031
parent5c937ae4e7928f825dde2713e9ebba68d50ece6c (diff)
ide-cd: rename cdrom_* functions to ide_cd_*
* cdrom_prepare_request() -> ide_cd_init_rq() * cdrom_queue_packet_command() -> ide_cd_queue_pc() * cdrom_lockdoor() -> ide_cd_lockdoor() * cdrom_read_toc() -> ide_cd_read_toc() * cdrom_get_toc_entry() -> ide_cd_get_toc_entry() This is a preparation to move code handling cdrom.c IOCTLs out of ide-cd.c. Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
-rw-r--r--drivers/ide/ide-cd.c83
1 files changed, 44 insertions, 39 deletions
diff --git a/drivers/ide/ide-cd.c b/drivers/ide/ide-cd.c
index c92f0d4d4524..b82cabfda63e 100644
--- a/drivers/ide/ide-cd.c
+++ b/drivers/ide/ide-cd.c
@@ -206,7 +206,7 @@ void cdrom_analyze_sense_data(ide_drive_t *drive,
206/* 206/*
207 * Initialize a ide-cd packet command request 207 * Initialize a ide-cd packet command request
208 */ 208 */
209static void cdrom_prepare_request(ide_drive_t *drive, struct request *rq) 209static void ide_cd_init_rq(ide_drive_t *drive, struct request *rq)
210{ 210{
211 struct cdrom_info *cd = drive->driver_data; 211 struct cdrom_info *cd = drive->driver_data;
212 212
@@ -225,7 +225,7 @@ static void cdrom_queue_request_sense(ide_drive_t *drive, void *sense,
225 sense = &info->sense_data; 225 sense = &info->sense_data;
226 226
227 /* stuff the sense request in front of our current request */ 227 /* stuff the sense request in front of our current request */
228 cdrom_prepare_request(drive, rq); 228 ide_cd_init_rq(drive, rq);
229 229
230 rq->data = sense; 230 rq->data = sense;
231 rq->cmd[0] = GPCMD_REQUEST_SENSE; 231 rq->cmd[0] = GPCMD_REQUEST_SENSE;
@@ -1168,8 +1168,7 @@ static ide_startstop_t cdrom_do_packet_command (ide_drive_t *drive)
1168 return cdrom_start_packet_command(drive, len, cdrom_do_pc_continuation); 1168 return cdrom_start_packet_command(drive, len, cdrom_do_pc_continuation);
1169} 1169}
1170 1170
1171 1171static int ide_cd_queue_pc(ide_drive_t *drive, struct request *rq)
1172static int cdrom_queue_packet_command(ide_drive_t *drive, struct request *rq)
1173{ 1172{
1174 struct request_sense sense; 1173 struct request_sense sense;
1175 int retries = 10; 1174 int retries = 10;
@@ -1670,7 +1669,7 @@ static int cdrom_check_status(ide_drive_t *drive, struct request_sense *sense)
1670 struct cdrom_info *info = drive->driver_data; 1669 struct cdrom_info *info = drive->driver_data;
1671 struct cdrom_device_info *cdi = &info->devinfo; 1670 struct cdrom_device_info *cdi = &info->devinfo;
1672 1671
1673 cdrom_prepare_request(drive, &req); 1672 ide_cd_init_rq(drive, &req);
1674 1673
1675 req.sense = sense; 1674 req.sense = sense;
1676 req.cmd[0] = GPCMD_TEST_UNIT_READY; 1675 req.cmd[0] = GPCMD_TEST_UNIT_READY;
@@ -1682,13 +1681,12 @@ static int cdrom_check_status(ide_drive_t *drive, struct request_sense *sense)
1682 */ 1681 */
1683 req.cmd[7] = cdi->sanyo_slot % 3; 1682 req.cmd[7] = cdi->sanyo_slot % 3;
1684 1683
1685 return cdrom_queue_packet_command(drive, &req); 1684 return ide_cd_queue_pc(drive, &req);
1686} 1685}
1687 1686
1688
1689/* Lock the door if LOCKFLAG is nonzero; unlock it otherwise. */ 1687/* Lock the door if LOCKFLAG is nonzero; unlock it otherwise. */
1690static int 1688static int ide_cd_lockdoor(ide_drive_t *drive, int lockflag,
1691cdrom_lockdoor(ide_drive_t *drive, int lockflag, struct request_sense *sense) 1689 struct request_sense *sense)
1692{ 1690{
1693 struct cdrom_info *cd = drive->driver_data; 1691 struct cdrom_info *cd = drive->driver_data;
1694 struct request_sense my_sense; 1692 struct request_sense my_sense;
@@ -1702,11 +1700,11 @@ cdrom_lockdoor(ide_drive_t *drive, int lockflag, struct request_sense *sense)
1702 if (cd->cd_flags & IDE_CD_FLAG_NO_DOORLOCK) { 1700 if (cd->cd_flags & IDE_CD_FLAG_NO_DOORLOCK) {
1703 stat = 0; 1701 stat = 0;
1704 } else { 1702 } else {
1705 cdrom_prepare_request(drive, &req); 1703 ide_cd_init_rq(drive, &req);
1706 req.sense = sense; 1704 req.sense = sense;
1707 req.cmd[0] = GPCMD_PREVENT_ALLOW_MEDIUM_REMOVAL; 1705 req.cmd[0] = GPCMD_PREVENT_ALLOW_MEDIUM_REMOVAL;
1708 req.cmd[4] = lockflag ? 1 : 0; 1706 req.cmd[4] = lockflag ? 1 : 0;
1709 stat = cdrom_queue_packet_command(drive, &req); 1707 stat = ide_cd_queue_pc(drive, &req);
1710 } 1708 }
1711 1709
1712 /* If we got an illegal field error, the drive 1710 /* If we got an illegal field error, the drive
@@ -1752,7 +1750,7 @@ static int cdrom_eject(ide_drive_t *drive, int ejectflag,
1752 if ((cd->cd_flags & IDE_CD_FLAG_DOOR_LOCKED) && ejectflag) 1750 if ((cd->cd_flags & IDE_CD_FLAG_DOOR_LOCKED) && ejectflag)
1753 return 0; 1751 return 0;
1754 1752
1755 cdrom_prepare_request(drive, &req); 1753 ide_cd_init_rq(drive, &req);
1756 1754
1757 /* only tell drive to close tray if open, if it can do that */ 1755 /* only tell drive to close tray if open, if it can do that */
1758 if (ejectflag && (cdi->mask & CDC_CLOSE_TRAY)) 1756 if (ejectflag && (cdi->mask & CDC_CLOSE_TRAY))
@@ -1761,7 +1759,8 @@ static int cdrom_eject(ide_drive_t *drive, int ejectflag,
1761 req.sense = sense; 1759 req.sense = sense;
1762 req.cmd[0] = GPCMD_START_STOP_UNIT; 1760 req.cmd[0] = GPCMD_START_STOP_UNIT;
1763 req.cmd[4] = loej | (ejectflag != 0); 1761 req.cmd[4] = loej | (ejectflag != 0);
1764 return cdrom_queue_packet_command(drive, &req); 1762
1763 return ide_cd_queue_pc(drive, &req);
1765} 1764}
1766 1765
1767static int cdrom_read_capacity(ide_drive_t *drive, unsigned long *capacity, 1766static int cdrom_read_capacity(ide_drive_t *drive, unsigned long *capacity,
@@ -1776,7 +1775,7 @@ static int cdrom_read_capacity(ide_drive_t *drive, unsigned long *capacity,
1776 int stat; 1775 int stat;
1777 struct request req; 1776 struct request req;
1778 1777
1779 cdrom_prepare_request(drive, &req); 1778 ide_cd_init_rq(drive, &req);
1780 1779
1781 req.sense = sense; 1780 req.sense = sense;
1782 req.cmd[0] = GPCMD_READ_CDVD_CAPACITY; 1781 req.cmd[0] = GPCMD_READ_CDVD_CAPACITY;
@@ -1784,7 +1783,7 @@ static int cdrom_read_capacity(ide_drive_t *drive, unsigned long *capacity,
1784 req.data_len = sizeof(capbuf); 1783 req.data_len = sizeof(capbuf);
1785 req.cmd_flags |= REQ_QUIET; 1784 req.cmd_flags |= REQ_QUIET;
1786 1785
1787 stat = cdrom_queue_packet_command(drive, &req); 1786 stat = ide_cd_queue_pc(drive, &req);
1788 if (stat == 0) { 1787 if (stat == 0) {
1789 *capacity = 1 + be32_to_cpu(capbuf.lba); 1788 *capacity = 1 + be32_to_cpu(capbuf.lba);
1790 *sectors_per_frame = 1789 *sectors_per_frame =
@@ -1800,7 +1799,7 @@ static int cdrom_read_tocentry(ide_drive_t *drive, int trackno, int msf_flag,
1800{ 1799{
1801 struct request req; 1800 struct request req;
1802 1801
1803 cdrom_prepare_request(drive, &req); 1802 ide_cd_init_rq(drive, &req);
1804 1803
1805 req.sense = sense; 1804 req.sense = sense;
1806 req.data = buf; 1805 req.data = buf;
@@ -1815,12 +1814,12 @@ static int cdrom_read_tocentry(ide_drive_t *drive, int trackno, int msf_flag,
1815 if (msf_flag) 1814 if (msf_flag)
1816 req.cmd[1] = 2; 1815 req.cmd[1] = 2;
1817 1816
1818 return cdrom_queue_packet_command(drive, &req); 1817 return ide_cd_queue_pc(drive, &req);
1819} 1818}
1820 1819
1821 1820
1822/* Try to read the entire TOC for the disk into our internal buffer. */ 1821/* Try to read the entire TOC for the disk into our internal buffer. */
1823static int cdrom_read_toc(ide_drive_t *drive, struct request_sense *sense) 1822static int ide_cd_read_toc(ide_drive_t *drive, struct request_sense *sense)
1824{ 1823{
1825 int stat, ntracks, i; 1824 int stat, ntracks, i;
1826 struct cdrom_info *info = drive->driver_data; 1825 struct cdrom_info *info = drive->driver_data;
@@ -1988,7 +1987,7 @@ static int ide_cd_read_tochdr(ide_drive_t *drive, void *arg)
1988 int stat; 1987 int stat;
1989 1988
1990 /* Make sure our saved TOC is valid. */ 1989 /* Make sure our saved TOC is valid. */
1991 stat = cdrom_read_toc(drive, NULL); 1990 stat = ide_cd_read_toc(drive, NULL);
1992 if (stat) 1991 if (stat)
1993 return stat; 1992 return stat;
1994 1993
@@ -1999,7 +1998,7 @@ static int ide_cd_read_tochdr(ide_drive_t *drive, void *arg)
1999 return 0; 1998 return 0;
2000} 1999}
2001 2000
2002static int cdrom_get_toc_entry(ide_drive_t *drive, int track, 2001static int ide_cd_get_toc_entry(ide_drive_t *drive, int track,
2003 struct atapi_toc_entry **ent) 2002 struct atapi_toc_entry **ent)
2004{ 2003{
2005 struct cdrom_info *info = drive->driver_data; 2004 struct cdrom_info *info = drive->driver_data;
@@ -2034,7 +2033,7 @@ static int ide_cd_read_tocentry(ide_drive_t *drive, void *arg)
2034 struct atapi_toc_entry *toce; 2033 struct atapi_toc_entry *toce;
2035 int stat; 2034 int stat;
2036 2035
2037 stat = cdrom_get_toc_entry(drive, tocentry->cdte_track, &toce); 2036 stat = ide_cd_get_toc_entry(drive, tocentry->cdte_track, &toce);
2038 if (stat) 2037 if (stat)
2039 return stat; 2038 return stat;
2040 2039
@@ -2060,11 +2059,11 @@ static int ide_cd_fake_play_trkind(ide_drive_t *drive, void *arg)
2060 struct request rq; 2059 struct request rq;
2061 struct request_sense sense; 2060 struct request_sense sense;
2062 2061
2063 stat = cdrom_get_toc_entry(drive, ti->cdti_trk0, &first_toc); 2062 stat = ide_cd_get_toc_entry(drive, ti->cdti_trk0, &first_toc);
2064 if (stat) 2063 if (stat)
2065 return stat; 2064 return stat;
2066 2065
2067 stat = cdrom_get_toc_entry(drive, ti->cdti_trk1, &last_toc); 2066 stat = ide_cd_get_toc_entry(drive, ti->cdti_trk1, &last_toc);
2068 if (stat) 2067 if (stat)
2069 return stat; 2068 return stat;
2070 2069
@@ -2076,14 +2075,14 @@ static int ide_cd_fake_play_trkind(ide_drive_t *drive, void *arg)
2076 if (lba_end <= lba_start) 2075 if (lba_end <= lba_start)
2077 return -EINVAL; 2076 return -EINVAL;
2078 2077
2079 cdrom_prepare_request(drive, &rq); 2078 ide_cd_init_rq(drive, &rq);
2080 2079
2081 rq.sense = &sense; 2080 rq.sense = &sense;
2082 rq.cmd[0] = GPCMD_PLAY_AUDIO_MSF; 2081 rq.cmd[0] = GPCMD_PLAY_AUDIO_MSF;
2083 lba_to_msf(lba_start, &rq.cmd[3], &rq.cmd[4], &rq.cmd[5]); 2082 lba_to_msf(lba_start, &rq.cmd[3], &rq.cmd[4], &rq.cmd[5]);
2084 lba_to_msf(lba_end - 1, &rq.cmd[6], &rq.cmd[7], &rq.cmd[8]); 2083 lba_to_msf(lba_end - 1, &rq.cmd[6], &rq.cmd[7], &rq.cmd[8]);
2085 2084
2086 return cdrom_queue_packet_command(drive, &rq); 2085 return ide_cd_queue_pc(drive, &rq);
2087} 2086}
2088 2087
2089/* the generic packet interface to cdrom.c */ 2088/* the generic packet interface to cdrom.c */
@@ -2099,7 +2098,7 @@ static int ide_cdrom_packet(struct cdrom_device_info *cdi,
2099 /* here we queue the commands from the uniform CD-ROM 2098 /* here we queue the commands from the uniform CD-ROM
2100 layer. the packet must be complete, as we do not 2099 layer. the packet must be complete, as we do not
2101 touch it at all. */ 2100 touch it at all. */
2102 cdrom_prepare_request(drive, &req); 2101 ide_cd_init_rq(drive, &req);
2103 memcpy(req.cmd, cgc->cmd, CDROM_PACKET_SIZE); 2102 memcpy(req.cmd, cgc->cmd, CDROM_PACKET_SIZE);
2104 if (cgc->sense) 2103 if (cgc->sense)
2105 memset(cgc->sense, 0, sizeof(struct request_sense)); 2104 memset(cgc->sense, 0, sizeof(struct request_sense));
@@ -2111,7 +2110,7 @@ static int ide_cdrom_packet(struct cdrom_device_info *cdi,
2111 req.cmd_flags |= REQ_QUIET; 2110 req.cmd_flags |= REQ_QUIET;
2112 2111
2113 req.sense = cgc->sense; 2112 req.sense = cgc->sense;
2114 cgc->stat = cdrom_queue_packet_command(drive, &req); 2113 cgc->stat = ide_cd_queue_pc(drive, &req);
2115 if (!cgc->stat) 2114 if (!cgc->stat)
2116 cgc->buflen -= req.data_len; 2115 cgc->buflen -= req.data_len;
2117 return cgc->stat; 2116 return cgc->stat;
@@ -2147,7 +2146,7 @@ int ide_cdrom_reset (struct cdrom_device_info *cdi)
2147 struct request req; 2146 struct request req;
2148 int ret; 2147 int ret;
2149 2148
2150 cdrom_prepare_request(drive, &req); 2149 ide_cd_init_rq(drive, &req);
2151 req.cmd_type = REQ_TYPE_SPECIAL; 2150 req.cmd_type = REQ_TYPE_SPECIAL;
2152 req.cmd_flags = REQ_QUIET; 2151 req.cmd_flags = REQ_QUIET;
2153 ret = ide_do_drive_cmd(drive, &req, ide_wait); 2152 ret = ide_do_drive_cmd(drive, &req, ide_wait);
@@ -2157,7 +2156,7 @@ int ide_cdrom_reset (struct cdrom_device_info *cdi)
2157 * lock it again. 2156 * lock it again.
2158 */ 2157 */
2159 if (cd->cd_flags & IDE_CD_FLAG_DOOR_LOCKED) 2158 if (cd->cd_flags & IDE_CD_FLAG_DOOR_LOCKED)
2160 (void) cdrom_lockdoor(drive, 1, &sense); 2159 (void)ide_cd_lockdoor(drive, 1, &sense);
2161 2160
2162 return ret; 2161 return ret;
2163} 2162}
@@ -2170,7 +2169,8 @@ int ide_cdrom_tray_move (struct cdrom_device_info *cdi, int position)
2170 struct request_sense sense; 2169 struct request_sense sense;
2171 2170
2172 if (position) { 2171 if (position) {
2173 int stat = cdrom_lockdoor(drive, 0, &sense); 2172 int stat = ide_cd_lockdoor(drive, 0, &sense);
2173
2174 if (stat) 2174 if (stat)
2175 return stat; 2175 return stat;
2176 } 2176 }
@@ -2182,7 +2182,8 @@ static
2182int ide_cdrom_lock_door (struct cdrom_device_info *cdi, int lock) 2182int ide_cdrom_lock_door (struct cdrom_device_info *cdi, int lock)
2183{ 2183{
2184 ide_drive_t *drive = cdi->handle; 2184 ide_drive_t *drive = cdi->handle;
2185 return cdrom_lockdoor(drive, lock, NULL); 2185
2186 return ide_cd_lockdoor(drive, lock, NULL);
2186} 2187}
2187 2188
2188static int ide_cdrom_get_capabilities(ide_drive_t *drive, u8 *buf) 2189static int ide_cdrom_get_capabilities(ide_drive_t *drive, u8 *buf)
@@ -2237,7 +2238,7 @@ static int ide_cdrom_select_speed(struct cdrom_device_info *cdi, int speed)
2237 u8 buf[ATAPI_CAPABILITIES_PAGE_SIZE]; 2238 u8 buf[ATAPI_CAPABILITIES_PAGE_SIZE];
2238 int stat; 2239 int stat;
2239 2240
2240 cdrom_prepare_request(drive, &rq); 2241 ide_cd_init_rq(drive, &rq);
2241 2242
2242 rq.sense = &sense; 2243 rq.sense = &sense;
2243 2244
@@ -2257,7 +2258,7 @@ static int ide_cdrom_select_speed(struct cdrom_device_info *cdi, int speed)
2257 rq.cmd[5] = speed & 0xff; 2258 rq.cmd[5] = speed & 0xff;
2258 } 2259 }
2259 2260
2260 stat = cdrom_queue_packet_command(drive, &rq); 2261 stat = ide_cd_queue_pc(drive, &rq);
2261 2262
2262 if (!ide_cdrom_get_capabilities(drive, buf)) { 2263 if (!ide_cdrom_get_capabilities(drive, buf)) {
2263 ide_cdrom_update_speed(drive, buf); 2264 ide_cdrom_update_speed(drive, buf);
@@ -2323,9 +2324,11 @@ int ide_cdrom_get_last_session (struct cdrom_device_info *cdi,
2323 struct request_sense sense; 2324 struct request_sense sense;
2324 int ret; 2325 int ret;
2325 2326
2326 if ((info->cd_flags & IDE_CD_FLAG_TOC_VALID) == 0 || info->toc == NULL) 2327 if ((info->cd_flags & IDE_CD_FLAG_TOC_VALID) == 0 || !info->toc) {
2327 if ((ret = cdrom_read_toc(drive, &sense))) 2328 ret = ide_cd_read_toc(drive, &sense);
2329 if (ret)
2328 return ret; 2330 return ret;
2331 }
2329 2332
2330 toc = info->toc; 2333 toc = info->toc;
2331 ms_info->addr.lba = toc->last_session_lba; 2334 ms_info->addr.lba = toc->last_session_lba;
@@ -2342,7 +2345,7 @@ static int ide_cdrom_get_mcn(struct cdrom_device_info *cdi,
2342 struct request rq; 2345 struct request rq;
2343 char buf[24]; 2346 char buf[24];
2344 2347
2345 cdrom_prepare_request(drive, &rq); 2348 ide_cd_init_rq(drive, &rq);
2346 2349
2347 rq.data = buf; 2350 rq.data = buf;
2348 rq.data_len = sizeof(buf); 2351 rq.data_len = sizeof(buf);
@@ -2353,7 +2356,7 @@ static int ide_cdrom_get_mcn(struct cdrom_device_info *cdi,
2353 rq.cmd[3] = 2; /* format */ 2356 rq.cmd[3] = 2; /* format */
2354 rq.cmd[8] = sizeof(buf); 2357 rq.cmd[8] = sizeof(buf);
2355 2358
2356 stat = cdrom_queue_packet_command(drive, &rq); 2359 stat = ide_cd_queue_pc(drive, &rq);
2357 if (stat) 2360 if (stat)
2358 return stat; 2361 return stat;
2359 2362
@@ -2937,7 +2940,9 @@ static int idecd_revalidate_disk(struct gendisk *disk)
2937{ 2940{
2938 struct cdrom_info *info = ide_cd_g(disk); 2941 struct cdrom_info *info = ide_cd_g(disk);
2939 struct request_sense sense; 2942 struct request_sense sense;
2940 cdrom_read_toc(info->drive, &sense); 2943
2944 ide_cd_read_toc(info->drive, &sense);
2945
2941 return 0; 2946 return 0;
2942} 2947}
2943 2948
@@ -3012,7 +3017,7 @@ static int ide_cd_probe(ide_drive_t *drive)
3012 goto failed; 3017 goto failed;
3013 } 3018 }
3014 3019
3015 cdrom_read_toc(drive, &sense); 3020 ide_cd_read_toc(drive, &sense);
3016 g->fops = &idecd_ops; 3021 g->fops = &idecd_ops;
3017 g->flags |= GENHD_FL_REMOVABLE; 3022 g->flags |= GENHD_FL_REMOVABLE;
3018 add_disk(g); 3023 add_disk(g);