Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit ef0b0427 authored by Bartlomiej Zolnierkiewicz's avatar Bartlomiej Zolnierkiewicz
Browse files

ide: add ide_pci_remove() helper



* Add 'unsigned long host_flags' field to struct ide_host.

* Set ->host_flags in ide_host_alloc_all().

* Always set PCI dev's ->driver_data in ide_pci_init_{one,two}().

* Add ide_pci_remove() helper (the default implementation for
  struct pci_driver's ->remove method).

Signed-off-by: default avatarBartlomiej Zolnierkiewicz <bzolnier@gmail.com>
parent 37525beb
Loading
Loading
Loading
Loading
+3 −0
Original line number Original line Diff line number Diff line
@@ -1609,6 +1609,9 @@ struct ide_host *ide_host_alloc_all(const struct ide_port_info *d,
	if (hws[0])
	if (hws[0])
		host->dev[0] = hws[0]->dev;
		host->dev[0] = hws[0]->dev;


	if (d)
		host->host_flags = d->host_flags;

	return host;
	return host;
}
}
EXPORT_SYMBOL_GPL(ide_host_alloc_all);
EXPORT_SYMBOL_GPL(ide_host_alloc_all);
+33 −6
Original line number Original line Diff line number Diff line
@@ -548,7 +548,6 @@ int ide_pci_init_one(struct pci_dev *dev, const struct ide_port_info *d,


	host->host_priv = priv;
	host->host_priv = priv;


	if (priv)
	pci_set_drvdata(dev, host);
	pci_set_drvdata(dev, host);


	ret = do_ide_setup_pci_device(dev, d, 1);
	ret = do_ide_setup_pci_device(dev, d, 1);
@@ -593,10 +592,8 @@ int ide_pci_init_two(struct pci_dev *dev1, struct pci_dev *dev2,


	host->host_priv = priv;
	host->host_priv = priv;


	if (priv) {
	pci_set_drvdata(pdev[0], host);
	pci_set_drvdata(pdev[0], host);
	pci_set_drvdata(pdev[1], host);
	pci_set_drvdata(pdev[1], host);
	}


	for (i = 0; i < 2; i++) {
	for (i = 0; i < 2; i++) {
		ret = do_ide_setup_pci_device(pdev[i], d, !i);
		ret = do_ide_setup_pci_device(pdev[i], d, !i);
@@ -619,3 +616,33 @@ int ide_pci_init_two(struct pci_dev *dev1, struct pci_dev *dev2,
	return ret;
	return ret;
}
}
EXPORT_SYMBOL_GPL(ide_pci_init_two);
EXPORT_SYMBOL_GPL(ide_pci_init_two);

void ide_pci_remove(struct pci_dev *dev)
{
	struct ide_host *host = pci_get_drvdata(dev);
	struct pci_dev *dev2 = host->dev[1] ? to_pci_dev(host->dev[1]) : NULL;
	int bars;

	if (host->host_flags & IDE_HFLAG_SINGLE)
		bars = (1 << 2) - 1;
	else
		bars = (1 << 4) - 1;

	if ((host->host_flags & IDE_HFLAG_NO_DMA) == 0) {
		if (host->host_flags & IDE_HFLAG_CS5520)
			bars |= (1 << 2);
		else
			bars |= (1 << 4);
	}

	ide_host_remove(host);

	if (dev2)
		pci_release_selected_regions(dev2, bars);
	pci_release_selected_regions(dev, bars);

	if (dev2)
		pci_disable_device(dev2);
	pci_disable_device(dev);
}
EXPORT_SYMBOL_GPL(ide_pci_remove);
+2 −0
Original line number Original line Diff line number Diff line
@@ -631,6 +631,7 @@ struct ide_host {
	ide_hwif_t	*ports[MAX_HWIFS];
	ide_hwif_t	*ports[MAX_HWIFS];
	unsigned int	n_ports;
	unsigned int	n_ports;
	struct device	*dev[2];
	struct device	*dev[2];
	unsigned long	host_flags;
	void		*host_priv;
	void		*host_priv;
};
};


@@ -1213,6 +1214,7 @@ struct ide_port_info {
int ide_pci_init_one(struct pci_dev *, const struct ide_port_info *, void *);
int ide_pci_init_one(struct pci_dev *, const struct ide_port_info *, void *);
int ide_pci_init_two(struct pci_dev *, struct pci_dev *,
int ide_pci_init_two(struct pci_dev *, struct pci_dev *,
		     const struct ide_port_info *, void *);
		     const struct ide_port_info *, void *);
void ide_pci_remove(struct pci_dev *);


void ide_map_sg(ide_drive_t *, struct request *);
void ide_map_sg(ide_drive_t *, struct request *);
void ide_init_sg_cmd(ide_drive_t *, struct request *);
void ide_init_sg_cmd(ide_drive_t *, struct request *);