提交 8b3d4a2a 编写于 作者: A Adrian Bunk 提交者: Linus Torvalds

[PATCH] drivers/cdrom/cm206.c: cleanups

This patch contains the following cleanups:
- make needlessly global functions static
- remove the following unused global function:
  - cm206_delay
Signed-off-by: NAdrian Bunk <bunk@stusta.de>
Cc: Jens Axboe <axboe@suse.de>
Signed-off-by: NAndrew Morton <akpm@osdl.org>
Signed-off-by: NLinus Torvalds <torvalds@osdl.org>
上级 995c6ed2
...@@ -307,7 +307,7 @@ static DEFINE_SPINLOCK(cm206_lock); ...@@ -307,7 +307,7 @@ static DEFINE_SPINLOCK(cm206_lock);
/* First, we define some polling functions. These are actually /* First, we define some polling functions. These are actually
only being used in the initialization. */ only being used in the initialization. */
void send_command_polled(int command) static void send_command_polled(int command)
{ {
int loop = POLLOOP; int loop = POLLOOP;
while (!(inw(r_line_status) & ls_transmitter_buffer_empty) while (!(inw(r_line_status) & ls_transmitter_buffer_empty)
...@@ -318,7 +318,7 @@ void send_command_polled(int command) ...@@ -318,7 +318,7 @@ void send_command_polled(int command)
outw(command, r_uart_transmit); outw(command, r_uart_transmit);
} }
uch receive_echo_polled(void) static uch receive_echo_polled(void)
{ {
int loop = POLLOOP; int loop = POLLOOP;
while (!(inw(r_line_status) & ls_receive_buffer_full) && loop > 0) { while (!(inw(r_line_status) & ls_receive_buffer_full) && loop > 0) {
...@@ -328,13 +328,13 @@ uch receive_echo_polled(void) ...@@ -328,13 +328,13 @@ uch receive_echo_polled(void)
return ((uch) inw(r_uart_receive)); return ((uch) inw(r_uart_receive));
} }
uch send_receive_polled(int command) static uch send_receive_polled(int command)
{ {
send_command_polled(command); send_command_polled(command);
return receive_echo_polled(); return receive_echo_polled();
} }
inline void clear_ur(void) static inline void clear_ur(void)
{ {
if (cd->ur_r != cd->ur_w) { if (cd->ur_r != cd->ur_w) {
debug(("Deleting bytes from fifo:")); debug(("Deleting bytes from fifo:"));
...@@ -439,7 +439,7 @@ static irqreturn_t cm206_interrupt(int sig, void *dev_id, struct pt_regs *regs) ...@@ -439,7 +439,7 @@ static irqreturn_t cm206_interrupt(int sig, void *dev_id, struct pt_regs *regs)
} }
/* we have put the address of the wait queue in who */ /* we have put the address of the wait queue in who */
void cm206_timeout(unsigned long who) static void cm206_timeout(unsigned long who)
{ {
cd->timed_out = 1; cd->timed_out = 1;
debug(("Timing out\n")); debug(("Timing out\n"));
...@@ -448,7 +448,7 @@ void cm206_timeout(unsigned long who) ...@@ -448,7 +448,7 @@ void cm206_timeout(unsigned long who)
/* This function returns 1 if a timeout occurred, 0 if an interrupt /* This function returns 1 if a timeout occurred, 0 if an interrupt
happened */ happened */
int sleep_or_timeout(wait_queue_head_t * wait, int timeout) static int sleep_or_timeout(wait_queue_head_t * wait, int timeout)
{ {
cd->timed_out = 0; cd->timed_out = 0;
init_timer(&cd->timer); init_timer(&cd->timer);
...@@ -465,13 +465,7 @@ int sleep_or_timeout(wait_queue_head_t * wait, int timeout) ...@@ -465,13 +465,7 @@ int sleep_or_timeout(wait_queue_head_t * wait, int timeout)
return 0; return 0;
} }
void cm206_delay(int nr_jiffies) static void send_command(int command)
{
DECLARE_WAIT_QUEUE_HEAD(wait);
sleep_or_timeout(&wait, nr_jiffies);
}
void send_command(int command)
{ {
debug(("Sending 0x%x\n", command)); debug(("Sending 0x%x\n", command));
if (!(inw(r_line_status) & ls_transmitter_buffer_empty)) { if (!(inw(r_line_status) & ls_transmitter_buffer_empty)) {
...@@ -490,7 +484,7 @@ void send_command(int command) ...@@ -490,7 +484,7 @@ void send_command(int command)
outw(command, r_uart_transmit); outw(command, r_uart_transmit);
} }
uch receive_byte(int timeout) static uch receive_byte(int timeout)
{ {
uch ret; uch ret;
cli(); cli();
...@@ -521,23 +515,23 @@ uch receive_byte(int timeout) ...@@ -521,23 +515,23 @@ uch receive_byte(int timeout)
return ret; return ret;
} }
inline uch receive_echo(void) static inline uch receive_echo(void)
{ {
return receive_byte(UART_TIMEOUT); return receive_byte(UART_TIMEOUT);
} }
inline uch send_receive(int command) static inline uch send_receive(int command)
{ {
send_command(command); send_command(command);
return receive_echo(); return receive_echo();
} }
inline uch wait_dsb(void) static inline uch wait_dsb(void)
{ {
return receive_byte(DSB_TIMEOUT); return receive_byte(DSB_TIMEOUT);
} }
int type_0_command(int command, int expect_dsb) static int type_0_command(int command, int expect_dsb)
{ {
int e; int e;
clear_ur(); clear_ur();
...@@ -552,7 +546,7 @@ int type_0_command(int command, int expect_dsb) ...@@ -552,7 +546,7 @@ int type_0_command(int command, int expect_dsb)
return 0; return 0;
} }
int type_1_command(int command, int bytes, uch * status) static int type_1_command(int command, int bytes, uch * status)
{ /* returns info */ { /* returns info */
int i; int i;
if (type_0_command(command, 0)) if (type_0_command(command, 0))
...@@ -564,7 +558,7 @@ int type_1_command(int command, int bytes, uch * status) ...@@ -564,7 +558,7 @@ int type_1_command(int command, int bytes, uch * status)
/* This function resets the adapter card. We'd better not do this too /* This function resets the adapter card. We'd better not do this too
* often, because it tends to generate `lost interrupts.' */ * often, because it tends to generate `lost interrupts.' */
void reset_cm260(void) static void reset_cm260(void)
{ {
outw(dc_normal | dc_initialize | READ_AHEAD, r_data_control); outw(dc_normal | dc_initialize | READ_AHEAD, r_data_control);
udelay(10); /* 3.3 mu sec minimum */ udelay(10); /* 3.3 mu sec minimum */
...@@ -572,7 +566,7 @@ void reset_cm260(void) ...@@ -572,7 +566,7 @@ void reset_cm260(void)
} }
/* fsm: frame-sec-min from linear address; one of many */ /* fsm: frame-sec-min from linear address; one of many */
void fsm(int lba, uch * fsm) static void fsm(int lba, uch * fsm)
{ {
fsm[0] = lba % 75; fsm[0] = lba % 75;
lba /= 75; lba /= 75;
...@@ -581,17 +575,17 @@ void fsm(int lba, uch * fsm) ...@@ -581,17 +575,17 @@ void fsm(int lba, uch * fsm)
fsm[2] = lba / 60; fsm[2] = lba / 60;
} }
inline int fsm2lba(uch * fsm) static inline int fsm2lba(uch * fsm)
{ {
return fsm[0] + 75 * (fsm[1] - 2 + 60 * fsm[2]); return fsm[0] + 75 * (fsm[1] - 2 + 60 * fsm[2]);
} }
inline int f_s_m2lba(uch f, uch s, uch m) static inline int f_s_m2lba(uch f, uch s, uch m)
{ {
return f + 75 * (s - 2 + 60 * m); return f + 75 * (s - 2 + 60 * m);
} }
int start_read(int start) static int start_read(int start)
{ {
uch read_sector[4] = { c_read_data, }; uch read_sector[4] = { c_read_data, };
int i, e; int i, e;
...@@ -613,7 +607,7 @@ int start_read(int start) ...@@ -613,7 +607,7 @@ int start_read(int start)
return 0; return 0;
} }
int stop_read(void) static int stop_read(void)
{ {
int e; int e;
type_0_command(c_stop, 0); type_0_command(c_stop, 0);
...@@ -630,7 +624,7 @@ int stop_read(void) ...@@ -630,7 +624,7 @@ int stop_read(void)
routine takes care of this. Set a flag `background' in the cd routine takes care of this. Set a flag `background' in the cd
struct to indicate the process. */ struct to indicate the process. */
int read_background(int start, int reading) static int read_background(int start, int reading)
{ {
if (cd->background) if (cd->background)
return -1; /* can't do twice */ return -1; /* can't do twice */
...@@ -658,7 +652,7 @@ void transport_data(int port, ush * dest, int count) ...@@ -658,7 +652,7 @@ void transport_data(int port, ush * dest, int count)
#define MAX_TRIES 100 #define MAX_TRIES 100
int read_sector(int start) static int read_sector(int start)
{ {
int tries = 0; int tries = 0;
if (cd->background) { if (cd->background) {
...@@ -753,7 +747,7 @@ static DECLARE_TASKLET(cm206_tasklet, cm206_tasklet_func, 0); ...@@ -753,7 +747,7 @@ static DECLARE_TASKLET(cm206_tasklet, cm206_tasklet_func, 0);
/* This command clears the dsb_possible_media_change flag, so we must /* This command clears the dsb_possible_media_change flag, so we must
* retain it. * retain it.
*/ */
void get_drive_status(void) static void get_drive_status(void)
{ {
uch status[2]; uch status[2];
type_1_command(c_drive_status, 2, status); /* this might be done faster */ type_1_command(c_drive_status, 2, status); /* this might be done faster */
...@@ -764,7 +758,7 @@ void get_drive_status(void) ...@@ -764,7 +758,7 @@ void get_drive_status(void)
dsb_drive_not_ready | dsb_tray_not_closed)); dsb_drive_not_ready | dsb_tray_not_closed));
} }
void get_disc_status(void) static void get_disc_status(void)
{ {
if (type_1_command(c_disc_status, 7, cd->disc_status)) { if (type_1_command(c_disc_status, 7, cd->disc_status)) {
debug(("get_disc_status: error\n")); debug(("get_disc_status: error\n"));
...@@ -801,7 +795,7 @@ static void cm206_release(struct cdrom_device_info *cdi) ...@@ -801,7 +795,7 @@ static void cm206_release(struct cdrom_device_info *cdi)
/* Empty buffer empties $sectors$ sectors of the adapter card buffer, /* Empty buffer empties $sectors$ sectors of the adapter card buffer,
* and then reads a sector in kernel memory. */ * and then reads a sector in kernel memory. */
void empty_buffer(int sectors) static void empty_buffer(int sectors)
{ {
while (sectors >= 0) { while (sectors >= 0) {
transport_data(r_fifo_output_buffer, transport_data(r_fifo_output_buffer,
...@@ -819,7 +813,7 @@ void empty_buffer(int sectors) ...@@ -819,7 +813,7 @@ void empty_buffer(int sectors)
/* try_adapter. This function determines if the requested sector is /* try_adapter. This function determines if the requested sector is
in adapter memory, or will appear there soon. Returns 0 upon in adapter memory, or will appear there soon. Returns 0 upon
success */ success */
int try_adapter(int sector) static int try_adapter(int sector)
{ {
if (cd->adapter_first <= sector && sector < cd->adapter_last) { if (cd->adapter_first <= sector && sector < cd->adapter_last) {
/* sector is in adapter memory */ /* sector is in adapter memory */
...@@ -910,7 +904,7 @@ static void do_cm206_request(request_queue_t * q) ...@@ -910,7 +904,7 @@ static void do_cm206_request(request_queue_t * q)
*/ */
/* seek seeks to address lba. It does wait to arrive there. */ /* seek seeks to address lba. It does wait to arrive there. */
void seek(int lba) static void seek(int lba)
{ {
int i; int i;
uch seek_command[4] = { c_seek, }; uch seek_command[4] = { c_seek, };
...@@ -926,7 +920,7 @@ uch bcdbin(unsigned char bcd) ...@@ -926,7 +920,7 @@ uch bcdbin(unsigned char bcd)
return (bcd >> 4) * 10 + (bcd & 0xf); return (bcd >> 4) * 10 + (bcd & 0xf);
} }
inline uch normalize_track(uch track) static inline uch normalize_track(uch track)
{ {
if (track < 1) if (track < 1)
return 1; return 1;
...@@ -939,7 +933,7 @@ inline uch normalize_track(uch track) ...@@ -939,7 +933,7 @@ inline uch normalize_track(uch track)
* tracks seen in the process. Input $track$ must be between 1 and * tracks seen in the process. Input $track$ must be between 1 and
* #-of-tracks+1. Note that the start of the disc must be in toc[1].fsm. * #-of-tracks+1. Note that the start of the disc must be in toc[1].fsm.
*/ */
int get_toc_lba(uch track) static int get_toc_lba(uch track)
{ {
int max = 74 * 60 * 75 - 150, min = fsm2lba(cd->toc[1].fsm); int max = 74 * 60 * 75 - 150, min = fsm2lba(cd->toc[1].fsm);
int i, lba, l, old_lba = 0; int i, lba, l, old_lba = 0;
...@@ -991,7 +985,7 @@ int get_toc_lba(uch track) ...@@ -991,7 +985,7 @@ int get_toc_lba(uch track)
return lba; return lba;
} }
void update_toc_entry(uch track) static void update_toc_entry(uch track)
{ {
track = normalize_track(track); track = normalize_track(track);
if (!cd->toc[track].track) if (!cd->toc[track].track)
...@@ -999,7 +993,7 @@ void update_toc_entry(uch track) ...@@ -999,7 +993,7 @@ void update_toc_entry(uch track)
} }
/* return 0 upon success */ /* return 0 upon success */
int read_toc_header(struct cdrom_tochdr *hp) static int read_toc_header(struct cdrom_tochdr *hp)
{ {
if (!FIRST_TRACK) if (!FIRST_TRACK)
get_disc_status(); get_disc_status();
...@@ -1016,7 +1010,7 @@ int read_toc_header(struct cdrom_tochdr *hp) ...@@ -1016,7 +1010,7 @@ int read_toc_header(struct cdrom_tochdr *hp)
return -1; return -1;
} }
void play_from_to_msf(struct cdrom_msf *msfp) static void play_from_to_msf(struct cdrom_msf *msfp)
{ {
uch play_command[] = { c_play, uch play_command[] = { c_play,
msfp->cdmsf_frame0, msfp->cdmsf_sec0, msfp->cdmsf_min0, msfp->cdmsf_frame0, msfp->cdmsf_sec0, msfp->cdmsf_min0,
...@@ -1032,7 +1026,7 @@ void play_from_to_msf(struct cdrom_msf *msfp) ...@@ -1032,7 +1026,7 @@ void play_from_to_msf(struct cdrom_msf *msfp)
cd->dsb = wait_dsb(); cd->dsb = wait_dsb();
} }
void play_from_to_track(int from, int to) static void play_from_to_track(int from, int to)
{ {
uch play_command[8] = { c_play, }; uch play_command[8] = { c_play, };
int i; int i;
...@@ -1059,7 +1053,7 @@ void play_from_to_track(int from, int to) ...@@ -1059,7 +1053,7 @@ void play_from_to_track(int from, int to)
cd->dsb = wait_dsb(); cd->dsb = wait_dsb();
} }
int get_current_q(struct cdrom_subchnl *qp) static int get_current_q(struct cdrom_subchnl *qp)
{ {
int i; int i;
uch *q = cd->q; uch *q = cd->q;
...@@ -1093,14 +1087,14 @@ int get_current_q(struct cdrom_subchnl *qp) ...@@ -1093,14 +1087,14 @@ int get_current_q(struct cdrom_subchnl *qp)
return 0; return 0;
} }
void invalidate_toc(void) static void invalidate_toc(void)
{ {
memset(cd->toc, 0, sizeof(cd->toc)); memset(cd->toc, 0, sizeof(cd->toc));
memset(cd->disc_status, 0, sizeof(cd->disc_status)); memset(cd->disc_status, 0, sizeof(cd->disc_status));
} }
/* cdrom.c guarantees that cdte_format == CDROM_MSF */ /* cdrom.c guarantees that cdte_format == CDROM_MSF */
void get_toc_entry(struct cdrom_tocentry *ep) static void get_toc_entry(struct cdrom_tocentry *ep)
{ {
uch track = normalize_track(ep->cdte_track); uch track = normalize_track(ep->cdte_track);
update_toc_entry(track); update_toc_entry(track);
...@@ -1117,7 +1111,7 @@ void get_toc_entry(struct cdrom_tocentry *ep) ...@@ -1117,7 +1111,7 @@ void get_toc_entry(struct cdrom_tocentry *ep)
* upon success. Memory checking has been done by cdrom_ioctl(), the * upon success. Memory checking has been done by cdrom_ioctl(), the
* calling function, as well as LBA/MSF sanitization. * calling function, as well as LBA/MSF sanitization.
*/ */
int cm206_audio_ioctl(struct cdrom_device_info *cdi, unsigned int cmd, static int cm206_audio_ioctl(struct cdrom_device_info *cdi, unsigned int cmd,
void *arg) void *arg)
{ {
switch (cmd) { switch (cmd) {
...@@ -1189,7 +1183,7 @@ static int cm206_ioctl(struct cdrom_device_info *cdi, unsigned int cmd, ...@@ -1189,7 +1183,7 @@ static int cm206_ioctl(struct cdrom_device_info *cdi, unsigned int cmd,
} }
} }
int cm206_media_changed(struct cdrom_device_info *cdi, int disc_nr) static int cm206_media_changed(struct cdrom_device_info *cdi, int disc_nr)
{ {
if (cd != NULL) { if (cd != NULL) {
int r; int r;
...@@ -1204,16 +1198,9 @@ int cm206_media_changed(struct cdrom_device_info *cdi, int disc_nr) ...@@ -1204,16 +1198,9 @@ int cm206_media_changed(struct cdrom_device_info *cdi, int disc_nr)
/* The new generic cdrom support. Routines should be concise, most of /* The new generic cdrom support. Routines should be concise, most of
the logic should be in cdrom.c */ the logic should be in cdrom.c */
/* returns number of times device is in use */
int cm206_open_files(struct cdrom_device_info *cdi)
{
if (cd)
return cd->openfiles;
return -1;
}
/* controls tray movement */ /* controls tray movement */
int cm206_tray_move(struct cdrom_device_info *cdi, int position) static int cm206_tray_move(struct cdrom_device_info *cdi, int position)
{ {
if (position) { /* 1: eject */ if (position) { /* 1: eject */
type_0_command(c_open_tray, 1); type_0_command(c_open_tray, 1);
...@@ -1224,7 +1211,7 @@ int cm206_tray_move(struct cdrom_device_info *cdi, int position) ...@@ -1224,7 +1211,7 @@ int cm206_tray_move(struct cdrom_device_info *cdi, int position)
} }
/* gives current state of the drive */ /* gives current state of the drive */
int cm206_drive_status(struct cdrom_device_info *cdi, int slot_nr) static int cm206_drive_status(struct cdrom_device_info *cdi, int slot_nr)
{ {
get_drive_status(); get_drive_status();
if (cd->dsb & dsb_tray_not_closed) if (cd->dsb & dsb_tray_not_closed)
...@@ -1237,7 +1224,7 @@ int cm206_drive_status(struct cdrom_device_info *cdi, int slot_nr) ...@@ -1237,7 +1224,7 @@ int cm206_drive_status(struct cdrom_device_info *cdi, int slot_nr)
} }
/* locks or unlocks door lock==1: lock; return 0 upon success */ /* locks or unlocks door lock==1: lock; return 0 upon success */
int cm206_lock_door(struct cdrom_device_info *cdi, int lock) static int cm206_lock_door(struct cdrom_device_info *cdi, int lock)
{ {
uch command = (lock) ? c_lock_tray : c_unlock_tray; uch command = (lock) ? c_lock_tray : c_unlock_tray;
type_0_command(command, 1); /* wait and get dsb */ type_0_command(command, 1); /* wait and get dsb */
...@@ -1248,7 +1235,7 @@ int cm206_lock_door(struct cdrom_device_info *cdi, int lock) ...@@ -1248,7 +1235,7 @@ int cm206_lock_door(struct cdrom_device_info *cdi, int lock)
/* Although a session start should be in LBA format, we return it in /* Although a session start should be in LBA format, we return it in
MSF format because it is slightly easier, and the new generic ioctl MSF format because it is slightly easier, and the new generic ioctl
will take care of the necessary conversion. */ will take care of the necessary conversion. */
int cm206_get_last_session(struct cdrom_device_info *cdi, static int cm206_get_last_session(struct cdrom_device_info *cdi,
struct cdrom_multisession *mssp) struct cdrom_multisession *mssp)
{ {
if (!FIRST_TRACK) if (!FIRST_TRACK)
...@@ -1268,7 +1255,7 @@ int cm206_get_last_session(struct cdrom_device_info *cdi, ...@@ -1268,7 +1255,7 @@ int cm206_get_last_session(struct cdrom_device_info *cdi,
return 0; return 0;
} }
int cm206_get_upc(struct cdrom_device_info *cdi, struct cdrom_mcn *mcn) static int cm206_get_upc(struct cdrom_device_info *cdi, struct cdrom_mcn *mcn)
{ {
uch upc[10]; uch upc[10];
char *ret = mcn->medium_catalog_number; char *ret = mcn->medium_catalog_number;
...@@ -1287,7 +1274,7 @@ int cm206_get_upc(struct cdrom_device_info *cdi, struct cdrom_mcn *mcn) ...@@ -1287,7 +1274,7 @@ int cm206_get_upc(struct cdrom_device_info *cdi, struct cdrom_mcn *mcn)
return 0; return 0;
} }
int cm206_reset(struct cdrom_device_info *cdi) static int cm206_reset(struct cdrom_device_info *cdi)
{ {
stop_read(); stop_read();
reset_cm260(); reset_cm260();
...@@ -1300,7 +1287,7 @@ int cm206_reset(struct cdrom_device_info *cdi) ...@@ -1300,7 +1287,7 @@ int cm206_reset(struct cdrom_device_info *cdi)
return 0; return 0;
} }
int cm206_select_speed(struct cdrom_device_info *cdi, int speed) static int cm206_select_speed(struct cdrom_device_info *cdi, int speed)
{ {
int r; int r;
switch (speed) { switch (speed) {
...@@ -1392,7 +1379,7 @@ static struct gendisk *cm206_gendisk; ...@@ -1392,7 +1379,7 @@ static struct gendisk *cm206_gendisk;
request_region, 15 bits of one port and 6 of another make things request_region, 15 bits of one port and 6 of another make things
likely enough to accept the region on the first hit... likely enough to accept the region on the first hit...
*/ */
int __init probe_base_port(int base) static int __init probe_base_port(int base)
{ {
int b = 0x300, e = 0x370; /* this is the range of start addresses */ int b = 0x300, e = 0x370; /* this is the range of start addresses */
volatile int fool, i; volatile int fool, i;
...@@ -1416,7 +1403,7 @@ int __init probe_base_port(int base) ...@@ -1416,7 +1403,7 @@ int __init probe_base_port(int base)
#if !defined(MODULE) || defined(AUTO_PROBE_MODULE) #if !defined(MODULE) || defined(AUTO_PROBE_MODULE)
/* Probe for irq# nr. If nr==0, probe for all possible irq's. */ /* Probe for irq# nr. If nr==0, probe for all possible irq's. */
int __init probe_irq(int nr) static int __init probe_irq(int nr)
{ {
int irqs, irq; int irqs, irq;
outw(dc_normal | READ_AHEAD, r_data_control); /* disable irq-generation */ outw(dc_normal | READ_AHEAD, r_data_control); /* disable irq-generation */
...@@ -1558,7 +1545,7 @@ static void __init parse_options(void) ...@@ -1558,7 +1545,7 @@ static void __init parse_options(void)
} }
} }
int __cm206_init(void) static int __cm206_init(void)
{ {
parse_options(); parse_options();
#if !defined(AUTO_PROBE_MODULE) #if !defined(AUTO_PROBE_MODULE)
...@@ -1567,7 +1554,7 @@ int __cm206_init(void) ...@@ -1567,7 +1554,7 @@ int __cm206_init(void)
return cm206_init(); return cm206_init();
} }
void __exit cm206_exit(void) static void __exit cm206_exit(void)
{ {
del_gendisk(cm206_gendisk); del_gendisk(cm206_gendisk);
put_disk(cm206_gendisk); put_disk(cm206_gendisk);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册