Skip to content

Commit deae17f

Browse files
Sergei Shtylyovbzolnier
authored andcommitted
ide-io-std: shorten ide_{in|out}put_data()
ide_{in|out|put_data() can be somewhat shortened by merging the paths doing 16-bit I/O... Signed-off-by: Sergei Shtylyov <sshtylyov@ru.mvista.com> Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
1 parent 6762511 commit deae17f

1 file changed

Lines changed: 28 additions & 32 deletions

File tree

‎drivers/ide/ide-io-std.c‎

Lines changed: 28 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -216,11 +216,10 @@ void ide_input_data(ide_drive_t *drive, struct ide_cmd *cmd, void *buf,
216216
ide_hwif_t *hwif = drive->hwif;
217217
struct ide_io_ports *io_ports = &hwif->io_ports;
218218
unsigned long data_addr = io_ports->data_addr;
219+
unsigned int words = (len + 1) >> 1;
219220
u8 io_32bit = drive->io_32bit;
220221
u8 mmio = (hwif->host_flags & IDE_HFLAG_MMIO) ? 1 : 0;
221222

222-
len++;
223-
224223
if (io_32bit) {
225224
unsigned long uninitialized_var(flags);
226225

@@ -229,27 +228,26 @@ void ide_input_data(ide_drive_t *drive, struct ide_cmd *cmd, void *buf,
229228
ata_vlb_sync(io_ports->nsect_addr);
230229
}
231230

231+
words >>= 1;
232232
if (mmio)
233-
__ide_mm_insl((void __iomem *)data_addr, buf, len / 4);
233+
__ide_mm_insl((void __iomem *)data_addr, buf, words);
234234
else
235-
insl(data_addr, buf, len / 4);
235+
insl(data_addr, buf, words);
236236

237237
if ((io_32bit & 2) && !mmio)
238238
local_irq_restore(flags);
239239

240-
if ((len & 3) >= 2) {
241-
if (mmio)
242-
__ide_mm_insw((void __iomem *)data_addr,
243-
(u8 *)buf + (len & ~3), 1);
244-
else
245-
insw(data_addr, (u8 *)buf + (len & ~3), 1);
246-
}
247-
} else {
248-
if (mmio)
249-
__ide_mm_insw((void __iomem *)data_addr, buf, len / 2);
250-
else
251-
insw(data_addr, buf, len / 2);
240+
if (((len + 1) & 3) < 2)
241+
return;
242+
243+
buf += len & ~3;
244+
words = 1;
252245
}
246+
247+
if (mmio)
248+
__ide_mm_insw((void __iomem *)data_addr, buf, words);
249+
else
250+
insw(data_addr, buf, words);
253251
}
254252
EXPORT_SYMBOL_GPL(ide_input_data);
255253

@@ -262,11 +260,10 @@ void ide_output_data(ide_drive_t *drive, struct ide_cmd *cmd, void *buf,
262260
ide_hwif_t *hwif = drive->hwif;
263261
struct ide_io_ports *io_ports = &hwif->io_ports;
264262
unsigned long data_addr = io_ports->data_addr;
263+
unsigned int words = (len + 1) >> 1;
265264
u8 io_32bit = drive->io_32bit;
266265
u8 mmio = (hwif->host_flags & IDE_HFLAG_MMIO) ? 1 : 0;
267266

268-
len++;
269-
270267
if (io_32bit) {
271268
unsigned long uninitialized_var(flags);
272269

@@ -275,27 +272,26 @@ void ide_output_data(ide_drive_t *drive, struct ide_cmd *cmd, void *buf,
275272
ata_vlb_sync(io_ports->nsect_addr);
276273
}
277274

275+
words >>= 1;
278276
if (mmio)
279-
__ide_mm_outsl((void __iomem *)data_addr, buf, len / 4);
277+
__ide_mm_outsl((void __iomem *)data_addr, buf, words);
280278
else
281-
outsl(data_addr, buf, len / 4);
279+
outsl(data_addr, buf, words);
282280

283281
if ((io_32bit & 2) && !mmio)
284282
local_irq_restore(flags);
285283

286-
if ((len & 3) >= 2) {
287-
if (mmio)
288-
__ide_mm_outsw((void __iomem *)data_addr,
289-
(u8 *)buf + (len & ~3), 1);
290-
else
291-
outsw(data_addr, (u8 *)buf + (len & ~3), 1);
292-
}
293-
} else {
294-
if (mmio)
295-
__ide_mm_outsw((void __iomem *)data_addr, buf, len / 2);
296-
else
297-
outsw(data_addr, buf, len / 2);
284+
if (((len + 1) & 3) < 2)
285+
return;
286+
287+
buf += len & ~3;
288+
words = 1;
298289
}
290+
291+
if (mmio)
292+
__ide_mm_outsw((void __iomem *)data_addr, buf, words);
293+
else
294+
outsw(data_addr, buf, words);
299295
}
300296
EXPORT_SYMBOL_GPL(ide_output_data);
301297

0 commit comments

Comments
 (0)