diff options
author | Bartlomiej Zolnierkiewicz <bzolnier@gmail.com> | 2008-02-01 17:09:22 -0500 |
---|---|---|
committer | Bartlomiej Zolnierkiewicz <bzolnier@gmail.com> | 2008-02-01 17:09:22 -0500 |
commit | 9a6dc668d9b4d639936c683879eb1e0f92c5b944 (patch) | |
tree | 42088236f74069a9bcc58c4f0ffce7c85aabef4b /drivers/ide | |
parent | cdf6000d7e332d0f7f14233e71dee489628f5aae (diff) |
ide-cd: use BCD2BIN()/BIN2BCD() macros from <linux/bcd.h>
Use BCD2BIN()/BIN2BCD() macros from <linux/bcd.h>
and remove the local bcd2bin()/bin2bcd() inlines.
Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
Diffstat (limited to 'drivers/ide')
-rw-r--r-- | drivers/ide/ide-cd.c | 34 |
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 | ||
1778 | static inline | ||
1779 | int bin2bcd (int x) | ||
1780 | { | ||
1781 | return (x%10) | ((x/10) << 4); | ||
1782 | } | ||
1783 | |||
1784 | |||
1785 | static inline | ||
1786 | int bcd2bin (int x) | ||
1787 | { | ||
1788 | return (x >> 4) * 10 + (x & 0x0f); | ||
1789 | } | ||
1790 | |||
1791 | static | 1779 | static |
1792 | void msf_from_bcd (struct atapi_msf *msf) | 1780 | void 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 | ||
1799 | static inline | 1787 | static 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, |