2008-11-22 Robert Millan * disk/ata.c (grub_ata_device_initialize): Avoid passing grub_errno conditions to the upper layer unless they're critical. Index: disk/ata.c =================================================================== --- disk/ata.c (revision 1926) +++ disk/ata.c (working copy) @@ -421,19 +421,13 @@ grub_ata_device_initialize (int port, in grub_ata_regset (dev, GRUB_ATA_REG_SECTORS, 0x5A); grub_ata_wait (); if (grub_ata_regget (dev, GRUB_ATA_REG_SECTORS) != 0x5A) - { - grub_free(dev); - return 0; - } + goto fail; /* Detect if the device is present by issuing a EXECUTE DEVICE DIAGNOSTICS command. */ grub_ata_regset (dev, GRUB_ATA_REG_DISK, dev->device << 4); if (grub_ata_cmd (dev, GRUB_ATA_CMD_EXEC_DEV_DIAGNOSTICS)) - { - grub_free (dev); - return grub_errno; - } + goto fail; grub_ata_wait (); grub_dprintf ("ata", "Registers: %x %x %x %x\n", @@ -460,23 +454,29 @@ grub_ata_device_initialize (int port, in else { grub_dprintf ("ata", "incorrect signature\n"); - grub_free (dev); - return 0; + goto fail; } /* Use the IDENTIFY DEVICE command to query the device. */ if (grub_ata_identify (dev)) - { - grub_free (dev); - return 0; - } + goto fail; /* Register the device. */ for (devp = &grub_ata_devices; *devp; devp = &(*devp)->next); *devp = dev; return 0; + + fail: + grub_free (dev); + + /* If there were errors it means we didn't register this device. Since other + devices may be fine, we don't pass this to the upper layer. */ + if (grub_errno) + grub_print_error (); + + return 0; } static int