[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20230307224627.28011-33-linux@zary.sk>
Date: Tue, 7 Mar 2023 23:46:27 +0100
From: Ondrej Zary <linux@...y.sk>
To: Damien Le Moal <damien.lemoal@...nsource.wdc.com>,
Sudip Mukherjee <sudipm.mukherjee@...il.com>
Cc: Christoph Hellwig <hch@....de>,
Sergey Shtylyov <s.shtylyov@....ru>,
Jens Axboe <axboe@...nel.dk>, Tim Waugh <tim@...erelk.net>,
linux-block@...r.kernel.org, linux-parport@...ts.infradead.org,
linux-ide@...r.kernel.org, linux-kernel@...r.kernel.org
Subject: [PATCH 32/32] pata_parport-bpck6: reduce indents in bpck6_open
Reverse error handling conditions to reduce code indents in bpck6_open.
Signed-off-by: Ondrej Zary <linux@...y.sk>
---
drivers/ata/pata_parport/bpck6.c | 48 +++++++++++++++++---------------
1 file changed, 25 insertions(+), 23 deletions(-)
diff --git a/drivers/ata/pata_parport/bpck6.c b/drivers/ata/pata_parport/bpck6.c
index 53d0ad1d6e89..295dbe5cdaa4 100644
--- a/drivers/ata/pata_parport/bpck6.c
+++ b/drivers/ata/pata_parport/bpck6.c
@@ -318,30 +318,32 @@ static int bpck6_open(struct pi_adapter *pi)
j = ((i & 0x08) << 4) | ((i & 0x07) << 3);
k = parport_read_status(pi->pardev->port) & 0xB8;
- if (j == k) {
- parport_frob_control(pi->pardev->port, PARPORT_CONTROL_AUTOFD, 0);
- k = (parport_read_status(pi->pardev->port) & 0xB8) ^ 0xB8;
- if (j == k) {
- if (i & 4) // EPP
- parport_frob_control(pi->pardev->port,
- PARPORT_CONTROL_SELECT | PARPORT_CONTROL_INIT, 0);
- else // PPC/ECP
- parport_frob_control(pi->pardev->port,
- PARPORT_CONTROL_SELECT, 0);
-
- pi->private = 0;
-
- bpck6_send_cmd(pi, ACCESS_REG | ACCESS_WRITE | REG_RAMSIZE);
- bpck6_wr_data_byte(pi, RAMSIZE_128K);
-
- bpck6_send_cmd(pi, ACCESS_REG | ACCESS_READ | REG_VERSION);
- if ((bpck6_rd_data_byte(pi) & 0x3F) == 0x0C)
- pi->private |= fifo_wait;
-
- return 1;
- }
- }
+ if (j != k)
+ goto fail;
+
+ parport_frob_control(pi->pardev->port, PARPORT_CONTROL_AUTOFD, 0);
+ k = (parport_read_status(pi->pardev->port) & 0xB8) ^ 0xB8;
+ if (j != k)
+ goto fail;
+
+ if (i & 4) // EPP
+ parport_frob_control(pi->pardev->port,
+ PARPORT_CONTROL_SELECT | PARPORT_CONTROL_INIT, 0);
+ else // PPC/ECP
+ parport_frob_control(pi->pardev->port, PARPORT_CONTROL_SELECT, 0);
+
+ pi->private = 0;
+
+ bpck6_send_cmd(pi, ACCESS_REG | ACCESS_WRITE | REG_RAMSIZE);
+ bpck6_wr_data_byte(pi, RAMSIZE_128K);
+
+ bpck6_send_cmd(pi, ACCESS_REG | ACCESS_READ | REG_VERSION);
+ if ((bpck6_rd_data_byte(pi) & 0x3F) == 0x0C)
+ pi->private |= fifo_wait;
+
+ return 1;
+fail:
parport_write_control(pi->pardev->port, pi->saved_r2);
parport_write_data(pi->pardev->port, pi->saved_r0);
--
Ondrej Zary
Powered by blists - more mailing lists