summaryrefslogtreecommitdiff
path: root/linux/drivers
diff options
context:
space:
mode:
Diffstat (limited to 'linux/drivers')
-rw-r--r--linux/drivers/media/dvb/bt8xx/dst_ca.c61
1 files changed, 29 insertions, 32 deletions
diff --git a/linux/drivers/media/dvb/bt8xx/dst_ca.c b/linux/drivers/media/dvb/bt8xx/dst_ca.c
index e2f8203b6..199320a40 100644
--- a/linux/drivers/media/dvb/bt8xx/dst_ca.c
+++ b/linux/drivers/media/dvb/bt8xx/dst_ca.c
@@ -139,7 +139,7 @@ static int dst_put_ci(struct dst_state *state, u8 *data, int len, u8 *ca_string,
break;
}
}
-
+
if(dst_ca_comm_err == RETRIES)
return -1;
@@ -164,7 +164,7 @@ static int ca_get_app_info(struct dst_state *state)
state->messages[7], (state->messages[8] << 8) | state->messages[9],
(state->messages[10] << 8) | state->messages[11], __FUNCTION__, (char *)(&state->messages[12]));
dprintk(verbose, DST_CA_INFO, 1, " ==================================================================================================");
-
+
// Transform dst message to correct application_info message
length = state->messages[5];
str_length = length - 6;
@@ -172,17 +172,17 @@ static int ca_get_app_info(struct dst_state *state)
str_length = 0;
dprintk(verbose, DST_CA_ERROR, 1, "Invalid string length returned in ca_get_app_info(). Recovering.");
}
-
+
// First, the command and length fields
put_command_and_length(&state->messages[0], CA_APP_INFO, length);
-
+
// Copy application_type, application_manufacturer and manufacturer_code
memcpy(&state->messages[4], &state->messages[7], 5);
-
+
// Set string length and copy string
state->messages[9] = str_length;
memcpy(&state->messages[10], &state->messages[12], str_length);
-
+
return 0;
}
@@ -205,7 +205,7 @@ static int ca_get_ca_info(struct dst_state *state)
dprintk(verbose, DST_CA_INFO, 0, " 0x%02x", state->messages[i]);
}
dprintk(verbose, DST_CA_INFO, 0, "]\n");
-
+
// Set the command and length of the output
num_ids = state->messages[in_num_ids_pos];
if (num_ids >= 100) {
@@ -213,7 +213,7 @@ static int ca_get_ca_info(struct dst_state *state)
dprintk(verbose, DST_CA_ERROR, 1, "Invalid number of ids (>100). Recovering.");
}
put_command_and_length(&state->messages[0], CA_INFO, num_ids * 2);
-
+
dprintk(verbose, DST_CA_INFO, 0, " CA_INFO = [");
srcPtr = in_system_id_pos;
dstPtr = out_system_id_pos;
@@ -423,7 +423,7 @@ static int debug_string(u8 *msg, u32 length, u32 offset)
static int ca_get_mmi(struct dst_state *state, struct ca_msg *hw_msg, struct ca_msg *mmi_msg)
{
static u8 get_mmi[] = { 0x07, 0x40, 0x00, 0x00, 0x0d, 0x00, 0x00, 0x0f };
-
+
put_checksum(&get_mmi[0], 7);
if ((dst_put_ci(state, get_mmi, sizeof (get_mmi), hw_msg->msg, GET_REPLY)) < 0) {
dprintk(verbose, DST_CA_ERROR, 1, " -->dst_put_ci FAILED !");
@@ -431,7 +431,7 @@ static int ca_get_mmi(struct dst_state *state, struct ca_msg *hw_msg, struct ca_
}
dprintk(verbose, DST_CA_NOTICE, 1, " -->dst_put_ci SUCCESS !");
memcpy(mmi_msg->msg, hw_msg->msg, hw_msg->msg[4]);
-
+
return 0;
}
@@ -441,14 +441,14 @@ static int ca_get_mmi(struct dst_state *state, struct ca_msg *hw_msg, struct ca_
static int ca_get_menu(struct dst_state *state)
{
static u8 get_menu[] = { 0x07, 0x40, 0x00, 0x00, 0x09, 0x00, 0x00, 0xff };
-
+
put_checksum(&get_menu[0], 7);
if ((dst_put_ci(state, get_menu, sizeof (get_menu), get_menu, NO_REPLY)) < 0) {
dprintk(verbose, DST_CA_ERROR, 1, " -->dst_put_ci FAILED !");
return -1;
}
dprintk(verbose, DST_CA_NOTICE, 1, " -->dst_put_ci SUCCESS !");
-
+
return 0;
}
@@ -458,9 +458,9 @@ static int ca_get_menu(struct dst_state *state)
static int ca_answer_menu(struct dst_state *state, struct ca_msg *hw_msg, struct ca_msg *menu_answ)
{
u8 choice = 0;
-
+
static u8 answer_menu[] = { 0x08, 0x40, 0x00, 0x00, 0x0b, 0x01, 0x00, 0x01, 0xff };
-
+
/* derive answer from menu (This comes from the user) */
answer_menu[7] = choice;
put_checksum(&answer_menu[0], 7);
@@ -469,16 +469,16 @@ static int ca_answer_menu(struct dst_state *state, struct ca_msg *hw_msg, struct
return -1;
}
dprintk(verbose, DST_CA_NOTICE, 1, " -->dst_put_ci SUCCESS !");
-
+
return 0;
}
static int ca_answer_mmi(struct dst_state *state, struct ca_msg *hw_msg, struct ca_msg *answ_msg)
{
u8 answer =0, length = 0;
-
+
static u8 answer_mmi[] = { 0x08, 0x40, 0x00, 0x00, 0x08, 0x01, 0x00, 0x01, 0xff };
-
+
/* derive answer from answ_msg (This comes from the user) */
if (answer == 0) /* 0x00 == Cancel */
answer_mmi[7] = 0x00;
@@ -495,22 +495,22 @@ static int ca_answer_mmi(struct dst_state *state, struct ca_msg *hw_msg, struct
return -1;
}
dprintk(verbose, DST_CA_NOTICE, 1, " -->dst_put_ci SUCCESS !");
-
+
return 0;
}
static int ca_close_mmi(struct dst_state *state, struct ca_msg *hw_msg)
{
static u8 close_mmi[] = { 0x07, 0x40, 0x00, 0x00, 0x0e, 0x00, 0x00, 0xff };
-
+
put_checksum(&close_mmi[0], 7);
if ((dst_put_ci(state, close_mmi, sizeof (close_mmi), hw_msg->msg, NO_REPLY)) < 0) {
dprintk(verbose, DST_CA_ERROR, 1, " -->dst_put_ci FAILED !");
-
+
return -1;
}
dprintk(verbose, DST_CA_NOTICE, 1, " -->dst_put_ci SUCCESS !");
-
+
return 0;
}
#endif
@@ -632,7 +632,7 @@ static int ca_send_message(struct dst_state *state, struct ca_msg *p_ca_message,
break;
case CA_INFO_ENQUIRY:
dprintk(verbose, DST_CA_INFO, 1, " Getting CA Information");
-
+
if ((ca_get_ca_info(state)) < 0) {
dprintk(verbose, DST_CA_ERROR, 1, " -->CA_INFO_ENQUIRY Failed !");
result = -1;
@@ -658,18 +658,15 @@ static int dst_ca_ioctl(struct inode *inode, struct file *file, unsigned int cmd
void __user *arg = (void __user *)ioctl_arg;
int result = 0;
- if ((p_ca_message = (struct ca_msg *) kmalloc(sizeof (struct ca_msg), GFP_KERNEL)) == NULL) {
+ p_ca_message = kmalloc(sizeof (struct ca_msg), GFP_KERNEL);
+ p_ca_slot_info = kmalloc(sizeof (struct ca_slot_info), GFP_KERNEL);
+ p_ca_caps = kmalloc(sizeof (struct ca_caps), GFP_KERNEL);
+ if (!p_ca_message || !p_ca_slot_info || !p_ca_caps) {
dprintk(verbose, DST_CA_ERROR, 1, " Memory allocation failure");
- return -ENOMEM;
- }
- if ((p_ca_slot_info = (struct ca_slot_info *) kmalloc(sizeof (struct ca_slot_info), GFP_KERNEL)) == NULL) {
- dprintk(verbose, DST_CA_ERROR, 1, " Memory allocation failure");
- return -ENOMEM;
- }
- if ((p_ca_caps = (struct ca_caps *) kmalloc(sizeof (struct ca_caps), GFP_KERNEL)) == NULL) {
- dprintk(verbose, DST_CA_ERROR, 1, " Memory allocation failure");
- return -ENOMEM;
+ result = -ENOMEM;
+ goto free_mem_and_exit;
}
+
/* We have now only the standard ioctl's, the driver is upposed to handle internals. */
switch (cmd) {
case CA_SEND_MSG: