/* Use the standard setup to tune the chipset and then finalise the configuration by writing the nibble of extra bits of data into the chip.  */
static int optidma_set_mode(struct ata_link *link, struct ata_device **r_failed)
/* Use the standard setup to tune the chipset and then finalise the configuration by writing the nibble of extra bits of data into the chip.  */
static int optidma_set_mode(struct ata_link *link, struct ata_device **r_failed)
{
	struct ata_port *ap = link->ap;
	u8 r;
	int nybble = 4 * ap->port_no;
	struct pci_dev *pdev = to_pci_dev(ap->host->dev);
	int rc  = ata_do_set_mode(link, r_failed);
	if (rc == 0) {
		pci_read_config_byte(pdev, 0x43, &r);
		r &= (0x0F << nybble);
		r |= (optidma_make_bits43(&link->device[0]) +
		     (optidma_make_bits43(&link->device[0]) << 2)) << nybble;
		pci_write_config_byte(pdev, 0x43, r);
	}
	return rc;
}