Skip to content

Commit

Permalink
V4L/DVB (4287): Pvrusb2/: possible cleanups
Browse files Browse the repository at this point in the history
This patch contains the following possible cleanups:
- make needlessly global code static
- #if 0 unused global functions

Signed-off-by: Adrian Bunk <bunk@stusta.de>
Signed-off-by: Mauro Carvalho Chehab <mchehab@infradead.org>
  • Loading branch information
Adrian Bunk authored and Mauro Carvalho Chehab committed Jun 30, 2006
1 parent c02a34f commit 07e337e
Show file tree
Hide file tree
Showing 11 changed files with 74 additions and 195 deletions.
4 changes: 2 additions & 2 deletions drivers/media/video/pvrusb2/pvrusb2-debugifc.c
Original file line number Diff line number Diff line change
Expand Up @@ -337,8 +337,8 @@ int pvr2_debugifc_print_status(struct pvr2_hdw *hdw,
}


int pvr2_debugifc_do1cmd(struct pvr2_hdw *hdw,const char *buf,
unsigned int count)
static int pvr2_debugifc_do1cmd(struct pvr2_hdw *hdw,const char *buf,
unsigned int count)
{
const char *wptr;
unsigned int wlen;
Expand Down
17 changes: 0 additions & 17 deletions drivers/media/video/pvrusb2/pvrusb2-hdw-internal.h
Original file line number Diff line number Diff line change
Expand Up @@ -354,23 +354,6 @@ struct pvr2_hdw {
unsigned int control_cnt;
};

int pvr2_hdw_commit_ctl_internal(struct pvr2_hdw *hdw);

unsigned int pvr2_hdw_get_signal_status_internal(struct pvr2_hdw *);

void pvr2_hdw_subsys_bit_chg_no_lock(struct pvr2_hdw *hdw,
unsigned long msk,unsigned long val);
void pvr2_hdw_subsys_stream_bit_chg_no_lock(struct pvr2_hdw *hdw,
unsigned long msk,
unsigned long val);

void pvr2_hdw_internal_find_stdenum(struct pvr2_hdw *hdw);
void pvr2_hdw_internal_set_std_avail(struct pvr2_hdw *hdw);

int pvr2_i2c_basic_op(struct pvr2_hdw *,u8 i2c_addr,
u8 *wdata,u16 wlen,
u8 *rdata,u16 rlen);

#endif /* __PVRUSB2_HDW_INTERNAL_H */

/*
Expand Down
114 changes: 45 additions & 69 deletions drivers/media/video/pvrusb2/pvrusb2-hdw.c
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ static struct pvr2_string_table pvr2_client_lists[] = {
};

static struct pvr2_hdw *unit_pointers[PVR_NUM] = {[ 0 ... PVR_NUM-1 ] = 0};
DECLARE_MUTEX(pvr2_unit_sem);
static DECLARE_MUTEX(pvr2_unit_sem);

static int ctlchg = 0;
static int initusbreset = 1;
Expand Down Expand Up @@ -261,6 +261,25 @@ static const char *control_values_subsystem[] = {
[PVR2_SUBSYS_B_ENC_RUN] = "enc_run",
};

static int pvr2_hdw_cmd_usbstream(struct pvr2_hdw *hdw,int runFl);
static int pvr2_hdw_commit_ctl_internal(struct pvr2_hdw *hdw);
static int pvr2_hdw_get_eeprom_addr(struct pvr2_hdw *hdw);
static unsigned int pvr2_hdw_get_signal_status_internal(struct pvr2_hdw *hdw);
static void pvr2_hdw_internal_find_stdenum(struct pvr2_hdw *hdw);
static void pvr2_hdw_internal_set_std_avail(struct pvr2_hdw *hdw);
static void pvr2_hdw_render_useless_unlocked(struct pvr2_hdw *hdw);
static void pvr2_hdw_subsys_bit_chg_no_lock(struct pvr2_hdw *hdw,
unsigned long msk,
unsigned long val);
static void pvr2_hdw_subsys_stream_bit_chg_no_lock(struct pvr2_hdw *hdw,
unsigned long msk,
unsigned long val);
static int pvr2_send_request_ex(struct pvr2_hdw *hdw,
unsigned int timeout,int probe_fl,
void *write_data,unsigned int write_len,
void *read_data,unsigned int read_len);
static int pvr2_write_u16(struct pvr2_hdw *hdw, u16 data, int res);
static int pvr2_write_u8(struct pvr2_hdw *hdw, u8 data, int res);

static int ctrl_channelfreq_get(struct pvr2_ctrl *cptr,int *vp)
{
Expand Down Expand Up @@ -834,14 +853,6 @@ unsigned long pvr2_hdw_get_sn(struct pvr2_hdw *hdw)
}


struct pvr2_hdw *pvr2_hdw_find(int unit_number)
{
if (unit_number < 0) return 0;
if (unit_number >= PVR_NUM) return 0;
return unit_pointers[unit_number];
}


int pvr2_hdw_get_unit_number(struct pvr2_hdw *hdw)
{
return hdw->unit_number;
Expand Down Expand Up @@ -915,7 +926,7 @@ static int pvr2_locate_firmware(struct pvr2_hdw *hdw,
* is not suitable for an usb transaction.
*
*/
int pvr2_upload_firmware1(struct pvr2_hdw *hdw)
static int pvr2_upload_firmware1(struct pvr2_hdw *hdw)
{
const struct firmware *fw_entry = 0;
void *fw_ptr;
Expand Down Expand Up @@ -1164,8 +1175,9 @@ int pvr2_upload_firmware2(struct pvr2_hdw *hdw)
reconfigure and start over.
*/
void pvr2_hdw_subsys_bit_chg_no_lock(struct pvr2_hdw *hdw,
unsigned long msk,unsigned long val)
static void pvr2_hdw_subsys_bit_chg_no_lock(struct pvr2_hdw *hdw,
unsigned long msk,
unsigned long val)
{
unsigned long nmsk;
unsigned long vmsk;
Expand Down Expand Up @@ -1316,18 +1328,6 @@ void pvr2_hdw_subsys_bit_chg(struct pvr2_hdw *hdw,
}


void pvr2_hdw_subsys_bit_set(struct pvr2_hdw *hdw,unsigned long msk)
{
pvr2_hdw_subsys_bit_chg(hdw,msk,msk);
}


void pvr2_hdw_subsys_bit_clr(struct pvr2_hdw *hdw,unsigned long msk)
{
pvr2_hdw_subsys_bit_chg(hdw,msk,0);
}


unsigned long pvr2_hdw_subsys_get(struct pvr2_hdw *hdw)
{
return hdw->subsys_enabled_mask;
Expand All @@ -1340,9 +1340,9 @@ unsigned long pvr2_hdw_subsys_stream_get(struct pvr2_hdw *hdw)
}


void pvr2_hdw_subsys_stream_bit_chg_no_lock(struct pvr2_hdw *hdw,
unsigned long msk,
unsigned long val)
static void pvr2_hdw_subsys_stream_bit_chg_no_lock(struct pvr2_hdw *hdw,
unsigned long msk,
unsigned long val)
{
unsigned long val2;
msk &= PVR2_SUBSYS_ALL;
Expand All @@ -1364,7 +1364,7 @@ void pvr2_hdw_subsys_stream_bit_chg(struct pvr2_hdw *hdw,
}


int pvr2_hdw_set_streaming_no_lock(struct pvr2_hdw *hdw,int enableFl)
static int pvr2_hdw_set_streaming_no_lock(struct pvr2_hdw *hdw,int enableFl)
{
if ((!enableFl) == !(hdw->flag_streaming_enabled)) return 0;
if (enableFl) {
Expand Down Expand Up @@ -1398,8 +1398,8 @@ int pvr2_hdw_set_streaming(struct pvr2_hdw *hdw,int enable_flag)
}


int pvr2_hdw_set_stream_type_no_lock(struct pvr2_hdw *hdw,
enum pvr2_config config)
static int pvr2_hdw_set_stream_type_no_lock(struct pvr2_hdw *hdw,
enum pvr2_config config)
{
unsigned long sm = hdw->subsys_enabled_mask;
if (!hdw->flag_ok) return -EIO;
Expand Down Expand Up @@ -1926,7 +1926,7 @@ struct pvr2_hdw *pvr2_hdw_create(struct usb_interface *intf,

/* Remove _all_ associations between this driver and the underlying USB
layer. */
void pvr2_hdw_remove_usb_stuff(struct pvr2_hdw *hdw)
static void pvr2_hdw_remove_usb_stuff(struct pvr2_hdw *hdw)
{
if (hdw->flag_disconnected) return;
pvr2_trace(PVR2_TRACE_INIT,"pvr2_hdw_remove_usb_stuff: hdw=%p",hdw);
Expand Down Expand Up @@ -2016,7 +2016,7 @@ void pvr2_hdw_disconnect(struct pvr2_hdw *hdw)

// Attempt to autoselect an appropriate value for std_enum_cur given
// whatever is currently in std_mask_cur
void pvr2_hdw_internal_find_stdenum(struct pvr2_hdw *hdw)
static void pvr2_hdw_internal_find_stdenum(struct pvr2_hdw *hdw)
{
unsigned int idx;
for (idx = 1; idx < hdw->std_enum_cnt; idx++) {
Expand All @@ -2031,7 +2031,7 @@ void pvr2_hdw_internal_find_stdenum(struct pvr2_hdw *hdw)

// Calculate correct set of enumerated standards based on currently known
// set of available standards bits.
void pvr2_hdw_internal_set_std_avail(struct pvr2_hdw *hdw)
static void pvr2_hdw_internal_set_std_avail(struct pvr2_hdw *hdw)
{
struct v4l2_standard *newstd;
unsigned int std_cnt;
Expand Down Expand Up @@ -2180,7 +2180,7 @@ static const char *get_ctrl_typename(enum pvr2_ctl_type tp)
state(s) back to their previous value before this function was called.
Thus we can automatically reconfigure affected pieces of the driver as
controls are changed. */
int pvr2_hdw_commit_ctl_internal(struct pvr2_hdw *hdw)
static int pvr2_hdw_commit_ctl_internal(struct pvr2_hdw *hdw)
{
unsigned long saved_subsys_mask = hdw->subsys_enabled_mask;
unsigned long stale_subsys_mask = 0;
Expand Down Expand Up @@ -2319,14 +2319,6 @@ void pvr2_hdw_poll_trigger_unlocked(struct pvr2_hdw *hdw)
}


void pvr2_hdw_poll_trigger(struct pvr2_hdw *hdw)
{
LOCK_TAKE(hdw->big_lock); do {
pvr2_hdw_poll_trigger_unlocked(hdw);
} while (0); LOCK_GIVE(hdw->big_lock);
}


/* Return name for this driver instance */
const char *pvr2_hdw_get_driver_name(struct pvr2_hdw *hdw)
{
Expand All @@ -2335,7 +2327,7 @@ const char *pvr2_hdw_get_driver_name(struct pvr2_hdw *hdw)


/* Return bit mask indicating signal status */
unsigned int pvr2_hdw_get_signal_status_internal(struct pvr2_hdw *hdw)
static unsigned int pvr2_hdw_get_signal_status_internal(struct pvr2_hdw *hdw)
{
unsigned int msk = 0;
switch (hdw->input_val) {
Expand Down Expand Up @@ -2517,22 +2509,6 @@ void pvr2_hdw_v4l_store_minor_number(struct pvr2_hdw *hdw,int v)
}


void pvr2_reset_ctl_endpoints(struct pvr2_hdw *hdw)
{
if (!hdw->usb_dev) return;
usb_settoggle(hdw->usb_dev, PVR2_CTL_WRITE_ENDPOINT & 0xf,
!(PVR2_CTL_WRITE_ENDPOINT & USB_DIR_IN), 0);
usb_settoggle(hdw->usb_dev, PVR2_CTL_READ_ENDPOINT & 0xf,
!(PVR2_CTL_READ_ENDPOINT & USB_DIR_IN), 0);
usb_clear_halt(hdw->usb_dev,
usb_rcvbulkpipe(hdw->usb_dev,
PVR2_CTL_READ_ENDPOINT & 0x7f));
usb_clear_halt(hdw->usb_dev,
usb_sndbulkpipe(hdw->usb_dev,
PVR2_CTL_WRITE_ENDPOINT & 0x7f));
}


static void pvr2_ctl_write_complete(struct urb *urb, struct pt_regs *regs)
{
struct pvr2_hdw *hdw = urb->context;
Expand Down Expand Up @@ -2566,10 +2542,10 @@ static void pvr2_ctl_timeout(unsigned long data)
}


int pvr2_send_request_ex(struct pvr2_hdw *hdw,
unsigned int timeout,int probe_fl,
void *write_data,unsigned int write_len,
void *read_data,unsigned int read_len)
static int pvr2_send_request_ex(struct pvr2_hdw *hdw,
unsigned int timeout,int probe_fl,
void *write_data,unsigned int write_len,
void *read_data,unsigned int read_len)
{
unsigned int idx;
int status = 0;
Expand Down Expand Up @@ -2824,7 +2800,7 @@ int pvr2_write_register(struct pvr2_hdw *hdw, u16 reg, u32 data)
}


int pvr2_read_register(struct pvr2_hdw *hdw, u16 reg, u32 *data)
static int pvr2_read_register(struct pvr2_hdw *hdw, u16 reg, u32 *data)
{
int ret = 0;

Expand All @@ -2848,7 +2824,7 @@ int pvr2_read_register(struct pvr2_hdw *hdw, u16 reg, u32 *data)
}


int pvr2_write_u16(struct pvr2_hdw *hdw, u16 data, int res)
static int pvr2_write_u16(struct pvr2_hdw *hdw, u16 data, int res)
{
int ret;

Expand All @@ -2865,7 +2841,7 @@ int pvr2_write_u16(struct pvr2_hdw *hdw, u16 data, int res)
}


int pvr2_write_u8(struct pvr2_hdw *hdw, u8 data, int res)
static int pvr2_write_u8(struct pvr2_hdw *hdw, u8 data, int res)
{
int ret;

Expand All @@ -2881,7 +2857,7 @@ int pvr2_write_u8(struct pvr2_hdw *hdw, u8 data, int res)
}


void pvr2_hdw_render_useless_unlocked(struct pvr2_hdw *hdw)
static void pvr2_hdw_render_useless_unlocked(struct pvr2_hdw *hdw)
{
if (!hdw->flag_ok) return;
pvr2_trace(PVR2_TRACE_INIT,"render_useless");
Expand Down Expand Up @@ -2994,7 +2970,7 @@ int pvr2_hdw_cmd_decoder_reset(struct pvr2_hdw *hdw)
}


int pvr2_hdw_cmd_usbstream(struct pvr2_hdw *hdw,int runFl)
static int pvr2_hdw_cmd_usbstream(struct pvr2_hdw *hdw,int runFl)
{
int status;
LOCK_TAKE(hdw->ctl_lock); do {
Expand Down Expand Up @@ -3092,7 +3068,7 @@ int pvr2_hdw_gpio_chg_out(struct pvr2_hdw *hdw,u32 msk,u32 val)
}


int pvr2_hdw_get_eeprom_addr(struct pvr2_hdw *hdw)
static int pvr2_hdw_get_eeprom_addr(struct pvr2_hdw *hdw)
{
int result;
LOCK_TAKE(hdw->ctl_lock); do {
Expand Down
32 changes: 0 additions & 32 deletions drivers/media/video/pvrusb2/pvrusb2-hdw.h
Original file line number Diff line number Diff line change
Expand Up @@ -91,17 +91,13 @@ struct pvr2_hdw *pvr2_hdw_create(struct usb_interface *intf,
void pvr2_hdw_poll(struct pvr2_hdw *);

/* Trigger a poll to take place later at a convenient time */
void pvr2_hdw_poll_trigger(struct pvr2_hdw *);
void pvr2_hdw_poll_trigger_unlocked(struct pvr2_hdw *);

/* Register a callback used to trigger a future poll */
void pvr2_hdw_setup_poll_trigger(struct pvr2_hdw *,
void (*func)(void *),
void *data);

/* Get pointer to structure given unit number */
struct pvr2_hdw *pvr2_hdw_find(int unit_number);

/* Destroy hardware interaction structure */
void pvr2_hdw_destroy(struct pvr2_hdw *);

Expand Down Expand Up @@ -180,12 +176,6 @@ int pvr2_hdw_get_stdenum_value(struct pvr2_hdw *hdw,struct v4l2_standard *std,
void pvr2_hdw_subsys_bit_chg(struct pvr2_hdw *hdw,
unsigned long msk,unsigned long val);

/* Shortcut for pvr2_hdw_subsys_bit_chg(hdw,msk,msk) */
void pvr2_hdw_subsys_bit_set(struct pvr2_hdw *hdw,unsigned long msk);

/* Shortcut for pvr2_hdw_subsys_bit_chg(hdw,msk,0) */
void pvr2_hdw_subsys_bit_clr(struct pvr2_hdw *hdw,unsigned long msk);

/* Retrieve mask indicating which pieces of hardware are currently enabled
/ configured. */
unsigned long pvr2_hdw_subsys_get(struct pvr2_hdw *);
Expand Down Expand Up @@ -225,34 +215,18 @@ void pvr2_hdw_v4l_store_minor_number(struct pvr2_hdw *,int);
/* The following entry points are all lower level things you normally don't
want to worry about. */

/* Attempt to recover from a USB foul-up (in practice I find that if you
have to do this, then it's already too late). */
void pvr2_reset_ctl_endpoints(struct pvr2_hdw *hdw);

/* Issue a command and get a response from the device. LOTS of higher
level stuff is built on this. */
int pvr2_send_request(struct pvr2_hdw *,
void *write_ptr,unsigned int write_len,
void *read_ptr,unsigned int read_len);

/* Issue a command and get a response from the device. This extended
version includes a probe flag (which if set means that device errors
should not be logged or treated as fatal) and a timeout in jiffies.
This can be used to non-lethally probe the health of endpoint 1. */
int pvr2_send_request_ex(struct pvr2_hdw *,unsigned int timeout,int probe_fl,
void *write_ptr,unsigned int write_len,
void *read_ptr,unsigned int read_len);

/* Slightly higher level device communication functions. */
int pvr2_write_register(struct pvr2_hdw *, u16, u32);
int pvr2_read_register(struct pvr2_hdw *, u16, u32 *);
int pvr2_write_u16(struct pvr2_hdw *, u16, int);
int pvr2_write_u8(struct pvr2_hdw *, u8, int);

/* Call if for any reason we can't talk to the hardware anymore - this will
cause the driver to stop flailing on the device. */
void pvr2_hdw_render_useless(struct pvr2_hdw *);
void pvr2_hdw_render_useless_unlocked(struct pvr2_hdw *);

/* Set / clear 8051's reset bit */
void pvr2_hdw_cpureset_assert(struct pvr2_hdw *,int);
Expand All @@ -271,12 +245,6 @@ int pvr2_hdw_cmd_powerup(struct pvr2_hdw *);
/* Order decoder to reset */
int pvr2_hdw_cmd_decoder_reset(struct pvr2_hdw *);

/* Stop / start video stream transport */
int pvr2_hdw_cmd_usbstream(struct pvr2_hdw *hdw,int runFl);

/* Find I2C address of eeprom */
int pvr2_hdw_get_eeprom_addr(struct pvr2_hdw *);

/* Direct manipulation of GPIO bits */
int pvr2_hdw_gpio_get_dir(struct pvr2_hdw *hdw,u32 *);
int pvr2_hdw_gpio_get_out(struct pvr2_hdw *hdw,u32 *);
Expand Down
Loading

0 comments on commit 07e337e

Please sign in to comment.