Commit 7e59ea21 authored by Bartlomiej Zolnierkiewicz's avatar Bartlomiej Zolnierkiewicz
Browse files

ide: check drive->present in ide_get_paired_drive()



* Change ide_get_paired_drive() to return NULL if peer device
  is not present and update all users accordingly.

While at it:

* ide_get_paired_drive() -> ide_get_pair_dev()

* Use ide_get_pair_dev() in cs5530.c, sc1200.c and via82cxxx.c.

There should be no functional changes caused by this patch.

Acked-by: default avatarSergei Shtylyov <sshtylyov@ru.mvista.com>
Signed-off-by: default avatarBartlomiej Zolnierkiewicz <bzolnier@gmail.com>
parent 2a924662
Loading
Loading
Loading
Loading
+2 −2
Original line number Diff line number Diff line
@@ -180,7 +180,7 @@ static void palm_bk3710_setpiomode(void __iomem *base, ide_drive_t *mate,
	val32 |= (t2i << (dev ? 8 : 0));
	writel(val32, base + BK3710_DATRCVR);

	if (mate && mate->present) {
	if (mate) {
		u8 mode2 = ide_get_best_pio_mode(mate, 255, 4);

		if (mode2 < mode)
@@ -230,7 +230,7 @@ static void palm_bk3710_set_pio_mode(ide_drive_t *drive, u8 pio)
	 * Obtain the drive PIO data for tuning the Palm Chip registers
	 */
	cycle_time = ide_pio_cycle_time(drive, pio);
	mate = ide_get_paired_drive(drive);
	mate = ide_get_pair_dev(drive);
	palm_bk3710_setpiomode(base, mate, is_slave, cycle_time, pio);
}

+2 −2
Original line number Diff line number Diff line
@@ -81,11 +81,11 @@ static void cs5530_set_pio_mode(ide_drive_t *drive, const u8 pio)
static u8 cs5530_udma_filter(ide_drive_t *drive)
{
	ide_hwif_t *hwif = drive->hwif;
	ide_drive_t *mate = &hwif->drives[(drive->dn & 1) ^ 1];
	ide_drive_t *mate = ide_get_pair_dev(drive);
	u16 *mateid = mate->id;
	u8 mask = hwif->ultra_mask;

	if (mate->present == 0)
	if (mate == NULL)
		goto out;

	if (ata_id_has_dma(mateid) && __ide_dma_bad_drive(mate) == 0) {
+2 −2
Original line number Diff line number Diff line
@@ -80,12 +80,12 @@ static void cs5535_set_speed(ide_drive_t *drive, const u8 speed)

	/* Set the PIO timings */
	if (speed < XFER_SW_DMA_0) {
		ide_drive_t *pair = ide_get_paired_drive(drive);
		ide_drive_t *pair = ide_get_pair_dev(drive);
		u8 cmd, pioa;

		cmd = pioa = speed - XFER_PIO_0;

		if (pair->present) {
		if (pair) {
			u8 piob = ide_get_best_pio_mode(pair, 255, 4);

			if (piob < cmd)
+2 −2
Original line number Diff line number Diff line
@@ -137,7 +137,7 @@ static u8 read_reg(int reg)
static void opti621_set_pio_mode(ide_drive_t *drive, const u8 pio)
{
	ide_hwif_t *hwif = drive->hwif;
	ide_drive_t *pair = ide_get_paired_drive(drive);
	ide_drive_t *pair = ide_get_pair_dev(drive);
	unsigned long flags;
	u8 tim, misc, addr_pio = pio, clk;

@@ -153,7 +153,7 @@ static void opti621_set_pio_mode(ide_drive_t *drive, const u8 pio)

	drive->drive_data = XFER_PIO_0 + pio;

	if (pair->present) {
	if (pair) {
		if (pair->drive_data && pair->drive_data < drive->drive_data)
			addr_pio = pair->drive_data - XFER_PIO_0;
	}
+2 −2
Original line number Diff line number Diff line
@@ -104,11 +104,11 @@ static void sc1200_tunepio(ide_drive_t *drive, u8 pio)
static u8 sc1200_udma_filter(ide_drive_t *drive)
{
	ide_hwif_t *hwif = drive->hwif;
	ide_drive_t *mate = &hwif->drives[(drive->dn & 1) ^ 1];
	ide_drive_t *mate = ide_get_pair_dev(drive);
	u16 *mateid = mate->id;
	u8 mask = hwif->ultra_mask;

	if (mate->present == 0)
	if (mate == NULL)
		goto out;

	if (ata_id_has_dma(mateid) && __ide_dma_bad_drive(mate) == 0) {
Loading