mirror of https://gitee.com/openkylin/linux.git
media: dvb_ca_en50221: Avoid assignments in ifs
Fixed all: ERROR: do not use assignment in if condition Fixed also "-strict" checks in this patch: - Changed "if (ret != 0)" to "if (ret)". - Camel case variables have been converted to kernel_case. - Comparison to NULL written as "!<var>". - No space is necessary after a cast. Signed-off-by: Jasmin Jessich <jasmin@anw.at> Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
This commit is contained in:
parent
a1ca23d10e
commit
bacba9e540
|
@ -349,14 +349,18 @@ static int dvb_ca_en50221_link_init(struct dvb_ca_private *ca, int slot)
|
||||||
ca->slot_info[slot].link_buf_size = 2;
|
ca->slot_info[slot].link_buf_size = 2;
|
||||||
|
|
||||||
/* read the buffer size from the CAM */
|
/* read the buffer size from the CAM */
|
||||||
if ((ret = ca->pub->write_cam_control(ca->pub, slot, CTRLIF_COMMAND, IRQEN | CMDREG_SR)) != 0)
|
ret = ca->pub->write_cam_control(ca->pub, slot, CTRLIF_COMMAND,
|
||||||
|
IRQEN | CMDREG_SR);
|
||||||
|
if (ret)
|
||||||
return ret;
|
return ret;
|
||||||
ret = dvb_ca_en50221_wait_if_status(ca, slot, STATUSREG_DA, HZ);
|
ret = dvb_ca_en50221_wait_if_status(ca, slot, STATUSREG_DA, HZ);
|
||||||
if (ret != 0)
|
if (ret)
|
||||||
return ret;
|
return ret;
|
||||||
if ((ret = dvb_ca_en50221_read_data(ca, slot, buf, 2)) != 2)
|
ret = dvb_ca_en50221_read_data(ca, slot, buf, 2);
|
||||||
|
if (ret != 2)
|
||||||
return -EIO;
|
return -EIO;
|
||||||
if ((ret = ca->pub->write_cam_control(ca->pub, slot, CTRLIF_COMMAND, IRQEN)) != 0)
|
ret = ca->pub->write_cam_control(ca->pub, slot, CTRLIF_COMMAND, IRQEN);
|
||||||
|
if (ret)
|
||||||
return ret;
|
return ret;
|
||||||
|
|
||||||
/* store it, and choose the minimum of our buffer and the CAM's buffer size */
|
/* store it, and choose the minimum of our buffer and the CAM's buffer size */
|
||||||
|
@ -369,13 +373,18 @@ static int dvb_ca_en50221_link_init(struct dvb_ca_private *ca, int slot)
|
||||||
dprintk("Chosen link buffer size of %i\n", buf_size);
|
dprintk("Chosen link buffer size of %i\n", buf_size);
|
||||||
|
|
||||||
/* write the buffer size to the CAM */
|
/* write the buffer size to the CAM */
|
||||||
if ((ret = ca->pub->write_cam_control(ca->pub, slot, CTRLIF_COMMAND, IRQEN | CMDREG_SW)) != 0)
|
ret = ca->pub->write_cam_control(ca->pub, slot, CTRLIF_COMMAND,
|
||||||
|
IRQEN | CMDREG_SW);
|
||||||
|
if (ret)
|
||||||
return ret;
|
return ret;
|
||||||
if ((ret = dvb_ca_en50221_wait_if_status(ca, slot, STATUSREG_FR, HZ / 10)) != 0)
|
ret = dvb_ca_en50221_wait_if_status(ca, slot, STATUSREG_FR, HZ / 10);
|
||||||
|
if (ret)
|
||||||
return ret;
|
return ret;
|
||||||
if ((ret = dvb_ca_en50221_write_data(ca, slot, buf, 2)) != 2)
|
ret = dvb_ca_en50221_write_data(ca, slot, buf, 2);
|
||||||
|
if (ret != 2)
|
||||||
return -EIO;
|
return -EIO;
|
||||||
if ((ret = ca->pub->write_cam_control(ca->pub, slot, CTRLIF_COMMAND, IRQEN)) != 0)
|
ret = ca->pub->write_cam_control(ca->pub, slot, CTRLIF_COMMAND, IRQEN);
|
||||||
|
if (ret)
|
||||||
return ret;
|
return ret;
|
||||||
|
|
||||||
/* success */
|
/* success */
|
||||||
|
@ -395,42 +404,45 @@ static int dvb_ca_en50221_link_init(struct dvb_ca_private *ca, int slot)
|
||||||
* @return 0 on success, nonzero on error.
|
* @return 0 on success, nonzero on error.
|
||||||
*/
|
*/
|
||||||
static int dvb_ca_en50221_read_tuple(struct dvb_ca_private *ca, int slot,
|
static int dvb_ca_en50221_read_tuple(struct dvb_ca_private *ca, int slot,
|
||||||
int *address, int *tupleType,
|
int *address, int *tuple_type,
|
||||||
int *tupleLength, u8 *tuple)
|
int *tuple_length, u8 *tuple)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
int _tupleType;
|
int _tuple_type;
|
||||||
int _tupleLength;
|
int _tuple_length;
|
||||||
int _address = *address;
|
int _address = *address;
|
||||||
|
|
||||||
/* grab the next tuple length and type */
|
/* grab the next tuple length and type */
|
||||||
if ((_tupleType = ca->pub->read_attribute_mem(ca->pub, slot, _address)) < 0)
|
_tuple_type = ca->pub->read_attribute_mem(ca->pub, slot, _address);
|
||||||
return _tupleType;
|
if (_tuple_type < 0)
|
||||||
if (_tupleType == 0xff) {
|
return _tuple_type;
|
||||||
dprintk("END OF CHAIN TUPLE type:0x%x\n", _tupleType);
|
if (_tuple_type == 0xff) {
|
||||||
|
dprintk("END OF CHAIN TUPLE type:0x%x\n", _tuple_type);
|
||||||
*address += 2;
|
*address += 2;
|
||||||
*tupleType = _tupleType;
|
*tuple_type = _tuple_type;
|
||||||
*tupleLength = 0;
|
*tuple_length = 0;
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
if ((_tupleLength = ca->pub->read_attribute_mem(ca->pub, slot, _address + 2)) < 0)
|
_tuple_length = ca->pub->read_attribute_mem(ca->pub, slot,
|
||||||
return _tupleLength;
|
_address + 2);
|
||||||
|
if (_tuple_length < 0)
|
||||||
|
return _tuple_length;
|
||||||
_address += 4;
|
_address += 4;
|
||||||
|
|
||||||
dprintk("TUPLE type:0x%x length:%i\n", _tupleType, _tupleLength);
|
dprintk("TUPLE type:0x%x length:%i\n", _tuple_type, _tuple_length);
|
||||||
|
|
||||||
/* read in the whole tuple */
|
/* read in the whole tuple */
|
||||||
for (i = 0; i < _tupleLength; i++) {
|
for (i = 0; i < _tuple_length; i++) {
|
||||||
tuple[i] = ca->pub->read_attribute_mem(ca->pub, slot, _address + (i * 2));
|
tuple[i] = ca->pub->read_attribute_mem(ca->pub, slot, _address + (i * 2));
|
||||||
dprintk(" 0x%02x: 0x%02x %c\n",
|
dprintk(" 0x%02x: 0x%02x %c\n",
|
||||||
i, tuple[i] & 0xff,
|
i, tuple[i] & 0xff,
|
||||||
((tuple[i] > 31) && (tuple[i] < 127)) ? tuple[i] : '.');
|
((tuple[i] > 31) && (tuple[i] < 127)) ? tuple[i] : '.');
|
||||||
}
|
}
|
||||||
_address += (_tupleLength * 2);
|
_address += (_tuple_length * 2);
|
||||||
|
|
||||||
// success
|
// success
|
||||||
*tupleType = _tupleType;
|
*tuple_type = _tuple_type;
|
||||||
*tupleLength = _tupleLength;
|
*tuple_length = _tuple_length;
|
||||||
*address = _address;
|
*address = _address;
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -448,8 +460,8 @@ static int dvb_ca_en50221_read_tuple(struct dvb_ca_private *ca, int slot,
|
||||||
static int dvb_ca_en50221_parse_attributes(struct dvb_ca_private *ca, int slot)
|
static int dvb_ca_en50221_parse_attributes(struct dvb_ca_private *ca, int slot)
|
||||||
{
|
{
|
||||||
int address = 0;
|
int address = 0;
|
||||||
int tupleLength;
|
int tuple_length;
|
||||||
int tupleType;
|
int tuple_type;
|
||||||
u8 tuple[257];
|
u8 tuple[257];
|
||||||
char *dvb_str;
|
char *dvb_str;
|
||||||
int rasz;
|
int rasz;
|
||||||
|
@ -462,39 +474,43 @@ static int dvb_ca_en50221_parse_attributes(struct dvb_ca_private *ca, int slot)
|
||||||
|
|
||||||
|
|
||||||
// CISTPL_DEVICE_0A
|
// CISTPL_DEVICE_0A
|
||||||
if ((status =
|
status = dvb_ca_en50221_read_tuple(ca, slot, &address, &tuple_type,
|
||||||
dvb_ca_en50221_read_tuple(ca, slot, &address, &tupleType, &tupleLength, tuple)) < 0)
|
&tuple_length, tuple);
|
||||||
|
if (status < 0)
|
||||||
return status;
|
return status;
|
||||||
if (tupleType != 0x1D)
|
if (tuple_type != 0x1D)
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// CISTPL_DEVICE_0C
|
// CISTPL_DEVICE_0C
|
||||||
if ((status =
|
status = dvb_ca_en50221_read_tuple(ca, slot, &address, &tuple_type,
|
||||||
dvb_ca_en50221_read_tuple(ca, slot, &address, &tupleType, &tupleLength, tuple)) < 0)
|
&tuple_length, tuple);
|
||||||
|
if (status < 0)
|
||||||
return status;
|
return status;
|
||||||
if (tupleType != 0x1C)
|
if (tuple_type != 0x1C)
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// CISTPL_VERS_1
|
// CISTPL_VERS_1
|
||||||
if ((status =
|
status = dvb_ca_en50221_read_tuple(ca, slot, &address, &tuple_type,
|
||||||
dvb_ca_en50221_read_tuple(ca, slot, &address, &tupleType, &tupleLength, tuple)) < 0)
|
&tuple_length, tuple);
|
||||||
|
if (status < 0)
|
||||||
return status;
|
return status;
|
||||||
if (tupleType != 0x15)
|
if (tuple_type != 0x15)
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// CISTPL_MANFID
|
// CISTPL_MANFID
|
||||||
if ((status = dvb_ca_en50221_read_tuple(ca, slot, &address, &tupleType,
|
status = dvb_ca_en50221_read_tuple(ca, slot, &address, &tuple_type,
|
||||||
&tupleLength, tuple)) < 0)
|
&tuple_length, tuple);
|
||||||
|
if (status < 0)
|
||||||
return status;
|
return status;
|
||||||
if (tupleType != 0x20)
|
if (tuple_type != 0x20)
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
if (tupleLength != 4)
|
if (tuple_length != 4)
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
manfid = (tuple[1] << 8) | tuple[0];
|
manfid = (tuple[1] << 8) | tuple[0];
|
||||||
devid = (tuple[3] << 8) | tuple[2];
|
devid = (tuple[3] << 8) | tuple[2];
|
||||||
|
@ -502,17 +518,18 @@ static int dvb_ca_en50221_parse_attributes(struct dvb_ca_private *ca, int slot)
|
||||||
|
|
||||||
|
|
||||||
// CISTPL_CONFIG
|
// CISTPL_CONFIG
|
||||||
if ((status = dvb_ca_en50221_read_tuple(ca, slot, &address, &tupleType,
|
status = dvb_ca_en50221_read_tuple(ca, slot, &address, &tuple_type,
|
||||||
&tupleLength, tuple)) < 0)
|
&tuple_length, tuple);
|
||||||
|
if (status < 0)
|
||||||
return status;
|
return status;
|
||||||
if (tupleType != 0x1A)
|
if (tuple_type != 0x1A)
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
if (tupleLength < 3)
|
if (tuple_length < 3)
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
|
|
||||||
/* extract the configbase */
|
/* extract the configbase */
|
||||||
rasz = tuple[0] & 3;
|
rasz = tuple[0] & 3;
|
||||||
if (tupleLength < (3 + rasz + 14))
|
if (tuple_length < (3 + rasz + 14))
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
ca->slot_info[slot].config_base = 0;
|
ca->slot_info[slot].config_base = 0;
|
||||||
for (i = 0; i < rasz + 1; i++) {
|
for (i = 0; i < rasz + 1; i++) {
|
||||||
|
@ -520,10 +537,10 @@ static int dvb_ca_en50221_parse_attributes(struct dvb_ca_private *ca, int slot)
|
||||||
}
|
}
|
||||||
|
|
||||||
/* check it contains the correct DVB string */
|
/* check it contains the correct DVB string */
|
||||||
dvb_str = findstr((char *)tuple, tupleLength, "DVB_CI_V", 8);
|
dvb_str = findstr((char *)tuple, tuple_length, "DVB_CI_V", 8);
|
||||||
if (dvb_str == NULL)
|
if (dvb_str == NULL)
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
if (tupleLength < ((dvb_str - (char *) tuple) + 12))
|
if (tuple_length < ((dvb_str - (char *)tuple) + 12))
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
|
|
||||||
/* is it a version we support? */
|
/* is it a version we support? */
|
||||||
|
@ -536,12 +553,14 @@ static int dvb_ca_en50221_parse_attributes(struct dvb_ca_private *ca, int slot)
|
||||||
|
|
||||||
/* process the CFTABLE_ENTRY tuples, and any after those */
|
/* process the CFTABLE_ENTRY tuples, and any after those */
|
||||||
while ((!end_chain) && (address < 0x1000)) {
|
while ((!end_chain) && (address < 0x1000)) {
|
||||||
if ((status = dvb_ca_en50221_read_tuple(ca, slot, &address, &tupleType,
|
status = dvb_ca_en50221_read_tuple(ca, slot, &address,
|
||||||
&tupleLength, tuple)) < 0)
|
&tuple_type, &tuple_length,
|
||||||
|
tuple);
|
||||||
|
if (status < 0)
|
||||||
return status;
|
return status;
|
||||||
switch (tupleType) {
|
switch (tuple_type) {
|
||||||
case 0x1B: // CISTPL_CFTABLE_ENTRY
|
case 0x1B: // CISTPL_CFTABLE_ENTRY
|
||||||
if (tupleLength < (2 + 11 + 17))
|
if (tuple_length < (2 + 11 + 17))
|
||||||
break;
|
break;
|
||||||
|
|
||||||
/* if we've already parsed one, just use it */
|
/* if we've already parsed one, just use it */
|
||||||
|
@ -552,8 +571,10 @@ static int dvb_ca_en50221_parse_attributes(struct dvb_ca_private *ca, int slot)
|
||||||
ca->slot_info[slot].config_option = tuple[0] & 0x3f;
|
ca->slot_info[slot].config_option = tuple[0] & 0x3f;
|
||||||
|
|
||||||
/* OK, check it contains the correct strings */
|
/* OK, check it contains the correct strings */
|
||||||
if ((findstr((char *)tuple, tupleLength, "DVB_HOST", 8) == NULL) ||
|
if (!findstr((char *)tuple, tuple_length,
|
||||||
(findstr((char *)tuple, tupleLength, "DVB_CI_MODULE", 13) == NULL))
|
"DVB_HOST", 8) ||
|
||||||
|
!findstr((char *)tuple, tuple_length,
|
||||||
|
"DVB_CI_MODULE", 13))
|
||||||
break;
|
break;
|
||||||
|
|
||||||
got_cftableentry = 1;
|
got_cftableentry = 1;
|
||||||
|
@ -568,7 +589,7 @@ static int dvb_ca_en50221_parse_attributes(struct dvb_ca_private *ca, int slot)
|
||||||
|
|
||||||
default: /* Unknown tuple type - just skip this tuple and move to the next one */
|
default: /* Unknown tuple type - just skip this tuple and move to the next one */
|
||||||
dprintk("dvb_ca: Skipping unknown tuple type:0x%x length:0x%x\n",
|
dprintk("dvb_ca: Skipping unknown tuple type:0x%x length:0x%x\n",
|
||||||
tupleType, tupleLength);
|
tuple_type, tuple_length);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -804,7 +825,8 @@ static int dvb_ca_en50221_write_data(struct dvb_ca_private *ca, int slot,
|
||||||
* already in progress, we do nothing but awake the kernel thread to
|
* already in progress, we do nothing but awake the kernel thread to
|
||||||
* process the data if necessary.
|
* process the data if necessary.
|
||||||
*/
|
*/
|
||||||
if ((status = ca->pub->read_cam_control(ca->pub, slot, CTRLIF_STATUS)) < 0)
|
status = ca->pub->read_cam_control(ca->pub, slot, CTRLIF_STATUS);
|
||||||
|
if (status < 0)
|
||||||
goto exitnowrite;
|
goto exitnowrite;
|
||||||
if (status & (STATUSREG_DA | STATUSREG_RE)) {
|
if (status & (STATUSREG_DA | STATUSREG_RE)) {
|
||||||
if (status & STATUSREG_DA)
|
if (status & STATUSREG_DA)
|
||||||
|
@ -815,12 +837,14 @@ static int dvb_ca_en50221_write_data(struct dvb_ca_private *ca, int slot,
|
||||||
}
|
}
|
||||||
|
|
||||||
/* OK, set HC bit */
|
/* OK, set HC bit */
|
||||||
if ((status = ca->pub->write_cam_control(ca->pub, slot, CTRLIF_COMMAND,
|
status = ca->pub->write_cam_control(ca->pub, slot, CTRLIF_COMMAND,
|
||||||
IRQEN | CMDREG_HC)) != 0)
|
IRQEN | CMDREG_HC);
|
||||||
|
if (status)
|
||||||
goto exit;
|
goto exit;
|
||||||
|
|
||||||
/* check if interface is still free */
|
/* check if interface is still free */
|
||||||
if ((status = ca->pub->read_cam_control(ca->pub, slot, CTRLIF_STATUS)) < 0)
|
status = ca->pub->read_cam_control(ca->pub, slot, CTRLIF_STATUS);
|
||||||
|
if (status < 0)
|
||||||
goto exit;
|
goto exit;
|
||||||
if (!(status & STATUSREG_FR)) {
|
if (!(status & STATUSREG_FR)) {
|
||||||
/* it wasn't free => try again later */
|
/* it wasn't free => try again later */
|
||||||
|
@ -852,20 +876,26 @@ static int dvb_ca_en50221_write_data(struct dvb_ca_private *ca, int slot,
|
||||||
}
|
}
|
||||||
|
|
||||||
/* send the amount of data */
|
/* send the amount of data */
|
||||||
if ((status = ca->pub->write_cam_control(ca->pub, slot, CTRLIF_SIZE_HIGH, bytes_write >> 8)) != 0)
|
status = ca->pub->write_cam_control(ca->pub, slot, CTRLIF_SIZE_HIGH,
|
||||||
|
bytes_write >> 8);
|
||||||
|
if (status)
|
||||||
goto exit;
|
goto exit;
|
||||||
if ((status = ca->pub->write_cam_control(ca->pub, slot, CTRLIF_SIZE_LOW,
|
status = ca->pub->write_cam_control(ca->pub, slot, CTRLIF_SIZE_LOW,
|
||||||
bytes_write & 0xff)) != 0)
|
bytes_write & 0xff);
|
||||||
|
if (status)
|
||||||
goto exit;
|
goto exit;
|
||||||
|
|
||||||
/* send the buffer */
|
/* send the buffer */
|
||||||
for (i = 0; i < bytes_write; i++) {
|
for (i = 0; i < bytes_write; i++) {
|
||||||
if ((status = ca->pub->write_cam_control(ca->pub, slot, CTRLIF_DATA, buf[i])) != 0)
|
status = ca->pub->write_cam_control(ca->pub, slot, CTRLIF_DATA,
|
||||||
|
buf[i]);
|
||||||
|
if (status)
|
||||||
goto exit;
|
goto exit;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* check for write error (WE should now be 0) */
|
/* check for write error (WE should now be 0) */
|
||||||
if ((status = ca->pub->read_cam_control(ca->pub, slot, CTRLIF_STATUS)) < 0)
|
status = ca->pub->read_cam_control(ca->pub, slot, CTRLIF_STATUS);
|
||||||
|
if (status < 0)
|
||||||
goto exit;
|
goto exit;
|
||||||
if (status & STATUSREG_WE) {
|
if (status & STATUSREG_WE) {
|
||||||
ca->slot_info[slot].slot_state = DVB_CA_SLOTSTATE_LINKINIT;
|
ca->slot_info[slot].slot_state = DVB_CA_SLOTSTATE_LINKINIT;
|
||||||
|
@ -1591,7 +1621,8 @@ static ssize_t dvb_ca_en50221_io_read(struct file *file, char __user *buf,
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
|
|
||||||
/* wait for some data */
|
/* wait for some data */
|
||||||
if ((status = dvb_ca_en50221_io_read_condition(ca, &result, &slot)) == 0) {
|
status = dvb_ca_en50221_io_read_condition(ca, &result, &slot);
|
||||||
|
if (status == 0) {
|
||||||
|
|
||||||
/* if we're in nonblocking mode, exit immediately */
|
/* if we're in nonblocking mode, exit immediately */
|
||||||
if (file->f_flags & O_NONBLOCK)
|
if (file->f_flags & O_NONBLOCK)
|
||||||
|
@ -1829,7 +1860,8 @@ int dvb_ca_en50221_init(struct dvb_adapter *dvb_adapter,
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
|
|
||||||
/* initialise the system data */
|
/* initialise the system data */
|
||||||
if ((ca = kzalloc(sizeof(struct dvb_ca_private), GFP_KERNEL)) == NULL) {
|
ca = kzalloc(sizeof(*ca), GFP_KERNEL);
|
||||||
|
if (!ca) {
|
||||||
ret = -ENOMEM;
|
ret = -ENOMEM;
|
||||||
goto exit;
|
goto exit;
|
||||||
}
|
}
|
||||||
|
@ -1837,7 +1869,9 @@ int dvb_ca_en50221_init(struct dvb_adapter *dvb_adapter,
|
||||||
ca->pub = pubca;
|
ca->pub = pubca;
|
||||||
ca->flags = flags;
|
ca->flags = flags;
|
||||||
ca->slot_count = slot_count;
|
ca->slot_count = slot_count;
|
||||||
if ((ca->slot_info = kcalloc(slot_count, sizeof(struct dvb_ca_slot), GFP_KERNEL)) == NULL) {
|
ca->slot_info = kcalloc(slot_count, sizeof(struct dvb_ca_slot),
|
||||||
|
GFP_KERNEL);
|
||||||
|
if (!ca->slot_info) {
|
||||||
ret = -ENOMEM;
|
ret = -ENOMEM;
|
||||||
goto free_ca;
|
goto free_ca;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue