aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/ide/ide-cd.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/ide/ide-cd.c')
-rw-r--r--drivers/ide/ide-cd.c34
1 files changed, 11 insertions, 23 deletions
diff --git a/drivers/ide/ide-cd.c b/drivers/ide/ide-cd.c
index 206d038c1a1f..4bd664dd1e44 100644
--- a/drivers/ide/ide-cd.c
+++ b/drivers/ide/ide-cd.c
@@ -46,6 +46,7 @@
46#include <linux/ide.h> 46#include <linux/ide.h>
47#include <linux/completion.h> 47#include <linux/completion.h>
48#include <linux/mutex.h> 48#include <linux/mutex.h>
49#include <linux/bcd.h>
49 50
50#include <scsi/scsi.h> /* For SCSI -> ATAPI command conversion */ 51#include <scsi/scsi.h> /* For SCSI -> ATAPI command conversion */
51 52
@@ -1775,25 +1776,12 @@ ide_do_rw_cdrom (ide_drive_t *drive, struct request *rq, sector_t block)
1775 * can also be NULL, in which case no sense information is returned. 1776 * can also be NULL, in which case no sense information is returned.
1776 */ 1777 */
1777 1778
1778static inline
1779int bin2bcd (int x)
1780{
1781 return (x%10) | ((x/10) << 4);
1782}
1783
1784
1785static inline
1786int bcd2bin (int x)
1787{
1788 return (x >> 4) * 10 + (x & 0x0f);
1789}
1790
1791static 1779static
1792void msf_from_bcd (struct atapi_msf *msf) 1780void msf_from_bcd (struct atapi_msf *msf)
1793{ 1781{
1794 msf->minute = bcd2bin (msf->minute); 1782 msf->minute = BCD2BIN(msf->minute);
1795 msf->second = bcd2bin (msf->second); 1783 msf->second = BCD2BIN(msf->second);
1796 msf->frame = bcd2bin (msf->frame); 1784 msf->frame = BCD2BIN(msf->frame);
1797} 1785}
1798 1786
1799static inline 1787static inline
@@ -2020,8 +2008,8 @@ static int cdrom_read_toc(ide_drive_t *drive, struct request_sense *sense)
2020 return stat; 2008 return stat;
2021 2009
2022 if (info->cd_flags & IDE_CD_FLAG_TOCTRACKS_AS_BCD) { 2010 if (info->cd_flags & IDE_CD_FLAG_TOCTRACKS_AS_BCD) {
2023 toc->hdr.first_track = bcd2bin(toc->hdr.first_track); 2011 toc->hdr.first_track = BCD2BIN(toc->hdr.first_track);
2024 toc->hdr.last_track = bcd2bin(toc->hdr.last_track); 2012 toc->hdr.last_track = BCD2BIN(toc->hdr.last_track);
2025 } 2013 }
2026 2014
2027 ntracks = toc->hdr.last_track - toc->hdr.first_track + 1; 2015 ntracks = toc->hdr.last_track - toc->hdr.first_track + 1;
@@ -2058,8 +2046,8 @@ static int cdrom_read_toc(ide_drive_t *drive, struct request_sense *sense)
2058 return stat; 2046 return stat;
2059 2047
2060 if (info->cd_flags & IDE_CD_FLAG_TOCTRACKS_AS_BCD) { 2048 if (info->cd_flags & IDE_CD_FLAG_TOCTRACKS_AS_BCD) {
2061 toc->hdr.first_track = bin2bcd(CDROM_LEADOUT); 2049 toc->hdr.first_track = (u8)BIN2BCD(CDROM_LEADOUT);
2062 toc->hdr.last_track = bin2bcd(CDROM_LEADOUT); 2050 toc->hdr.last_track = (u8)BIN2BCD(CDROM_LEADOUT);
2063 } else { 2051 } else {
2064 toc->hdr.first_track = CDROM_LEADOUT; 2052 toc->hdr.first_track = CDROM_LEADOUT;
2065 toc->hdr.last_track = CDROM_LEADOUT; 2053 toc->hdr.last_track = CDROM_LEADOUT;
@@ -2072,14 +2060,14 @@ static int cdrom_read_toc(ide_drive_t *drive, struct request_sense *sense)
2072 toc->hdr.toc_length = ntohs (toc->hdr.toc_length); 2060 toc->hdr.toc_length = ntohs (toc->hdr.toc_length);
2073 2061
2074 if (info->cd_flags & IDE_CD_FLAG_TOCTRACKS_AS_BCD) { 2062 if (info->cd_flags & IDE_CD_FLAG_TOCTRACKS_AS_BCD) {
2075 toc->hdr.first_track = bcd2bin(toc->hdr.first_track); 2063 toc->hdr.first_track = BCD2BIN(toc->hdr.first_track);
2076 toc->hdr.last_track = bcd2bin(toc->hdr.last_track); 2064 toc->hdr.last_track = BCD2BIN(toc->hdr.last_track);
2077 } 2065 }
2078 2066
2079 for (i = 0; i <= ntracks; i++) { 2067 for (i = 0; i <= ntracks; i++) {
2080 if (info->cd_flags & IDE_CD_FLAG_TOCADDR_AS_BCD) { 2068 if (info->cd_flags & IDE_CD_FLAG_TOCADDR_AS_BCD) {
2081 if (info->cd_flags & IDE_CD_FLAG_TOCTRACKS_AS_BCD) 2069 if (info->cd_flags & IDE_CD_FLAG_TOCTRACKS_AS_BCD)
2082 toc->ent[i].track = bcd2bin(toc->ent[i].track); 2070 toc->ent[i].track = BCD2BIN(toc->ent[i].track);
2083 msf_from_bcd(&toc->ent[i].addr.msf); 2071 msf_from_bcd(&toc->ent[i].addr.msf);
2084 } 2072 }
2085 toc->ent[i].addr.lba = msf_to_lba (toc->ent[i].addr.msf.minute, 2073 toc->ent[i].addr.lba = msf_to_lba (toc->ent[i].addr.msf.minute,