[PATCH 4/9] drivers: cdrom: rewrite embedded assignments in multiple lines

From: Simao Gomes Viana
Date: Fri Jun 19 2020 - 15:34:21 EST


These were reported by scripts/checkpatch.pl.
All of them have been fixed in this patch.

Signed-off-by: Simao Gomes Viana <devel@xxxxxxxxxxxxxxx>
---
drivers/cdrom/cdrom.c | 76 +++++++++++++++++++++++++++++--------------
1 file changed, 51 insertions(+), 25 deletions(-)

diff --git a/drivers/cdrom/cdrom.c b/drivers/cdrom/cdrom.c
index e27af76199eb..49073b1c7919 100644
--- a/drivers/cdrom/cdrom.c
+++ b/drivers/cdrom/cdrom.c
@@ -461,7 +461,8 @@ static int cdrom_is_mrw(struct cdrom_device_info *cdi, int *write)
cgc.cmd[8] = sizeof(buffer);
cgc.quiet = 1;

- if ((ret = cdi->ops->generic_packet(cdi, &cgc)))
+ ret = cdi->ops->generic_packet(cdi, &cgc);
+ if (ret)
return ret;

mfd = (struct mrw_feature_desc *)&buffer[sizeof(struct feature_header)];
@@ -469,7 +470,8 @@ static int cdrom_is_mrw(struct cdrom_device_info *cdi, int *write)
return 1;
*write = mfd->write;

- if ((ret = cdrom_mrw_probe_pc(cdi))) {
+ ret = cdrom_mrw_probe_pc(cdi);
+ if (ret) {
*write = 0;
return ret;
}
@@ -702,7 +704,8 @@ static int cdrom_get_random_writable(struct cdrom_device_info *cdi,
cgc.cmd[8] = sizeof(buffer); /* often 0x18 */
cgc.quiet = 1;

- if ((ret = cdi->ops->generic_packet(cdi, &cgc)))
+ ret = cdi->ops->generic_packet(cdi, &cgc);
+ if (ret)
return ret;

memcpy(rfd, &buffer[sizeof(struct feature_header)], sizeof(*rfd));
@@ -723,7 +726,8 @@ static int cdrom_has_defect_mgt(struct cdrom_device_info *cdi)
cgc.cmd[8] = sizeof(buffer);
cgc.quiet = 1;

- if ((ret = cdi->ops->generic_packet(cdi, &cgc)))
+ ret = cdi->ops->generic_packet(cdi, &cgc);
+ if (ret)
return ret;

feature_code = (__be16 *) &buffer[sizeof(struct feature_header)];
@@ -741,7 +745,8 @@ static int cdrom_is_random_writable(struct cdrom_device_info *cdi, int *write)

*write = 0;

- if ((ret = cdrom_get_random_writable(cdi, &rfd)))
+ ret = cdrom_get_random_writable(cdi, &rfd);
+ if (ret)
return ret;

if (CDF_RWRT == be16_to_cpu(rfd.feature_code))
@@ -851,10 +856,12 @@ static int cdrom_ram_open_write(struct cdrom_device_info *cdi)
struct rwrt_feature_desc rfd;
int ret;

- if ((ret = cdrom_has_defect_mgt(cdi)))
+ ret = cdrom_has_defect_mgt(cdi);
+ if (ret)
return ret;

- if ((ret = cdrom_get_random_writable(cdi, &rfd)))
+ ret = cdrom_get_random_writable(cdi, &rfd);
+ if (ret)
return ret;
else if (CDF_RWRT == be16_to_cpu(rfd.feature_code))
ret = !rfd.curr;
@@ -877,7 +884,8 @@ static void cdrom_mmc3_profile(struct cdrom_device_info *cdi)
cgc.cmd[8] = sizeof(buffer); /* Allocation Length */
cgc.quiet = 1;

- if ((ret = cdi->ops->generic_packet(cdi, &cgc)))
+ ret = cdi->ops->generic_packet(cdi, &cgc);
+ if (ret)
mmc3_profile = 0xffff;
else
mmc3_profile = (buffer[6] << 8) | buffer[7];
@@ -1354,7 +1362,8 @@ static int cdrom_slot_status(struct cdrom_device_info *cdi, int slot)
if (!info)
return -ENOMEM;

- if ((ret = cdrom_read_mech_status(cdi, info)))
+ ret = cdrom_read_mech_status(cdi, info);
+ if (ret)
goto out_free;

if (info->slots[slot].disc_present)
@@ -1384,7 +1393,8 @@ int cdrom_number_of_slots(struct cdrom_device_info *cdi)
if (!info)
return -ENOMEM;

- if ((status = cdrom_read_mech_status(cdi, info)) == 0)
+ status = cdrom_read_mech_status(cdi, info);
+ if (status == 0)
nslots = info->hdr.nslots;

kfree(info);
@@ -1446,7 +1456,8 @@ static int cdrom_select_disc(struct cdrom_device_info *cdi, int slot)
if (!info)
return -ENOMEM;

- if ((ret = cdrom_read_mech_status(cdi, info))) {
+ ret = cdrom_read_mech_status(cdi, info);
+ if (ret) {
kfree(info);
return ret;
}
@@ -1473,7 +1484,9 @@ static int cdrom_select_disc(struct cdrom_device_info *cdi, int slot)

/* set media changed bits on both queues */
cdi->mc_flags = 0x3;
- if ((ret = cdrom_load_unload(cdi, slot)))
+
+ ret = cdrom_load_unload(cdi, slot);
+ if (ret)
return ret;

return slot;
@@ -1678,7 +1691,8 @@ static int dvd_do_auth(struct cdrom_device_info *cdi, dvd_authinfo *ai)
cgc.quiet = 1;
setup_report_key(&cgc, ai->lsa.agid, 0);

- if ((ret = cdo->generic_packet(cdi, &cgc)))
+ ret = cdo->generic_packet(cdi, &cgc);
+ if (ret)
return ret;

ai->lsa.agid = buf[7] >> 6;
@@ -1689,7 +1703,8 @@ static int dvd_do_auth(struct cdrom_device_info *cdi, dvd_authinfo *ai)
cd_dbg(CD_DVD, "entering DVD_LU_SEND_KEY1\n");
setup_report_key(&cgc, ai->lsk.agid, 2);

- if ((ret = cdo->generic_packet(cdi, &cgc)))
+ ret = cdo->generic_packet(cdi, &cgc);
+ if (ret)
return ret;

copy_key(ai->lsk.key, &buf[4]);
@@ -1700,7 +1715,8 @@ static int dvd_do_auth(struct cdrom_device_info *cdi, dvd_authinfo *ai)
cd_dbg(CD_DVD, "entering DVD_LU_SEND_CHALLENGE\n");
setup_report_key(&cgc, ai->lsc.agid, 1);

- if ((ret = cdo->generic_packet(cdi, &cgc)))
+ ret = cdo->generic_packet(cdi, &cgc);
+ if (ret)
return ret;

copy_chal(ai->lsc.chal, &buf[4]);
@@ -1717,7 +1733,8 @@ static int dvd_do_auth(struct cdrom_device_info *cdi, dvd_authinfo *ai)
cgc.cmd[3] = ai->lstk.lba >> 16;
cgc.cmd[2] = ai->lstk.lba >> 24;

- if ((ret = cdo->generic_packet(cdi, &cgc)))
+ ret = cdo->generic_packet(cdi, &cgc);
+ if (ret)
return ret;

ai->lstk.cpm = (buf[4] >> 7) & 1;
@@ -1730,8 +1747,9 @@ static int dvd_do_auth(struct cdrom_device_info *cdi, dvd_authinfo *ai)
case DVD_LU_SEND_ASF:
cd_dbg(CD_DVD, "entering DVD_LU_SEND_ASF\n");
setup_report_key(&cgc, ai->lsasf.agid, 5);
-
- if ((ret = cdo->generic_packet(cdi, &cgc)))
+
+ ret = cdo->generic_packet(cdi, &cgc);
+ if (ret)
return ret;

ai->lsasf.asf = buf[7] & 1;
@@ -1744,7 +1762,8 @@ static int dvd_do_auth(struct cdrom_device_info *cdi, dvd_authinfo *ai)
buf[1] = 0xe;
copy_chal(&buf[4], ai->hsc.chal);

- if ((ret = cdo->generic_packet(cdi, &cgc)))
+ ret = cdo->generic_packet(cdi, &cgc);
+ if (ret)
return ret;

ai->type = DVD_LU_SEND_KEY1;
@@ -1756,7 +1775,8 @@ static int dvd_do_auth(struct cdrom_device_info *cdi, dvd_authinfo *ai)
buf[1] = 0xa;
copy_key(&buf[4], ai->hsk.key);

- if ((ret = cdo->generic_packet(cdi, &cgc))) {
+ ret = cdo->generic_packet(cdi, &cgc);
+ if (ret) {
ai->type = DVD_AUTH_FAILURE;
return ret;
}
@@ -1768,7 +1788,9 @@ static int dvd_do_auth(struct cdrom_device_info *cdi, dvd_authinfo *ai)
cgc.quiet = 1;
cd_dbg(CD_DVD, "entering DVD_INVALIDATE_AGID\n");
setup_report_key(&cgc, ai->lsa.agid, 0x3f);
- if ((ret = cdo->generic_packet(cdi, &cgc)))
+
+ ret = cdo->generic_packet(cdi, &cgc);
+ if (ret)
return ret;
break;

@@ -1779,7 +1801,8 @@ static int dvd_do_auth(struct cdrom_device_info *cdi, dvd_authinfo *ai)
memset(&rpc_state, 0, sizeof(rpc_state_t));
cgc.buffer = (char *) &rpc_state;

- if ((ret = cdo->generic_packet(cdi, &cgc)))
+ ret = cdo->generic_packet(cdi, &cgc);
+ if (ret)
return ret;

ai->lrpcs.type = rpc_state.type_code;
@@ -1796,7 +1819,8 @@ static int dvd_do_auth(struct cdrom_device_info *cdi, dvd_authinfo *ai)
buf[1] = 6;
buf[4] = ai->hrpcs.pdrc;

- if ((ret = cdo->generic_packet(cdi, &cgc)))
+ ret = cdo->generic_packet(cdi, &cgc);
+ if (ret)
return ret;
break;

@@ -2059,7 +2083,8 @@ static int cdrom_read_subchannel(struct cdrom_device_info *cdi,
cgc.cmd[3] = mcn ? 2 : 1;
cgc.cmd[8] = 16;

- if ((ret = cdo->generic_packet(cdi, &cgc)))
+ ret = cdo->generic_packet(cdi, &cgc);
+ if (ret)
return ret;

subchnl->cdsc_audiostatus = cgc.buffer[1];
@@ -2929,7 +2954,8 @@ int cdrom_get_last_written(struct cdrom_device_info *cdi, long *last_written)

toc.cdte_format = CDROM_MSF;
toc.cdte_track = CDROM_LEADOUT;
- if ((ret = cdi->ops->audio_ioctl(cdi, CDROMREADTOCENTRY, &toc)))
+ ret = cdi->ops->audio_ioctl(cdi, CDROMREADTOCENTRY, &toc);
+ if (ret)
return ret;
sanitize_format(&toc.cdte_addr, &toc.cdte_format, CDROM_LBA);
*last_written = toc.cdte_addr.lba;
--
2.27.0