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

Commit 887125e3 authored by Tejun Heo's avatar Tejun Heo Committed by Jeff Garzik
Browse files

libata: stop overloading port_info->private_data



port_info->private_data is currently used for two purposes - to record
private data about the port_info or to specify host->private_data to
use when allocating ata_host.

This overloading is confusing and counter-intuitive in that
port_info->private_data becomes host->private_data instead of
port->private_data.  In addition, port_info and host don't correspond
to each other 1-to-1.  Currently, the first non-NULL
port_info->private_data is used.

This patch makes port_info->private_data just be what it is -
private_data for the port_info where LLD can jot down extra info.
libata no longer sets host->private_data to the first non-NULL
port_info->private_data, @host_priv argument is added to
ata_pci_init_one() instead.  LLDs which use ata_pci_init_one() can use
this argument to pass in pointer to host private data.  LLDs which
don't should use init-register model anyway and can initialize
host->private_data directly.

Adding @host_priv instead of using init-register model for LLDs which
use ata_pci_init_one() is suggested by Alan Cox.

Signed-off-by: default avatarTejun Heo <htejun@gmail.com>
Cc: Alan Cox <alan@lxorguk.ukuu.org.uk>
parent 1bd5b715
Loading
Loading
Loading
Loading
+1 −1
Original line number Original line Diff line number Diff line
@@ -152,7 +152,7 @@ static int ata_generic_init_one(struct pci_dev *dev, const struct pci_device_id
	if (dev->vendor == PCI_VENDOR_ID_AL)
	if (dev->vendor == PCI_VENDOR_ID_AL)
	    	ata_pci_clear_simplex(dev);
	    	ata_pci_clear_simplex(dev);


	return ata_pci_init_one(dev, ppi, &generic_sht);
	return ata_pci_init_one(dev, ppi, &generic_sht, NULL);
}
}


static struct pci_device_id ata_generic[] = {
static struct pci_device_id ata_generic[] = {
+0 −2
Original line number Original line Diff line number Diff line
@@ -6995,8 +6995,6 @@ struct ata_host *ata_host_alloc_pinfo(struct device *dev,


		if (!host->ops && (pi->port_ops != &ata_dummy_port_ops))
		if (!host->ops && (pi->port_ops != &ata_dummy_port_ops))
			host->ops = pi->port_ops;
			host->ops = pi->port_ops;
		if (!host->private_data && pi->private_data)
			host->private_data = pi->private_data;
	}
	}


	return host;
	return host;
+3 −1
Original line number Original line Diff line number Diff line
@@ -827,6 +827,7 @@ int ata_pci_activate_sff_host(struct ata_host *host,
 *	@pdev: Controller to be initialized
 *	@pdev: Controller to be initialized
 *	@ppi: array of port_info, must be enough for two ports
 *	@ppi: array of port_info, must be enough for two ports
 *	@sht: scsi_host_template to use when registering the host
 *	@sht: scsi_host_template to use when registering the host
 *	@host_priv: host private_data
 *
 *
 *	This is a helper function which can be called from a driver's
 *	This is a helper function which can be called from a driver's
 *	xxx_init_one() probe function if the hardware uses traditional
 *	xxx_init_one() probe function if the hardware uses traditional
@@ -848,7 +849,7 @@ int ata_pci_activate_sff_host(struct ata_host *host,
 */
 */
int ata_pci_init_one(struct pci_dev *pdev,
int ata_pci_init_one(struct pci_dev *pdev,
		     const struct ata_port_info * const * ppi,
		     const struct ata_port_info * const * ppi,
		     struct scsi_host_template *sht)
		     struct scsi_host_template *sht, void *host_priv)
{
{
	struct device *dev = &pdev->dev;
	struct device *dev = &pdev->dev;
	const struct ata_port_info *pi = NULL;
	const struct ata_port_info *pi = NULL;
@@ -882,6 +883,7 @@ int ata_pci_init_one(struct pci_dev *pdev,
	rc = ata_pci_prepare_sff_host(pdev, ppi, &host);
	rc = ata_pci_prepare_sff_host(pdev, ppi, &host);
	if (rc)
	if (rc)
		goto out;
		goto out;
	host->private_data = host_priv;


	pci_set_master(pdev);
	pci_set_master(pdev);
	rc = ata_pci_activate_sff_host(host, ata_interrupt, sht);
	rc = ata_pci_activate_sff_host(host, ata_interrupt, sht);
+2 −16
Original line number Original line Diff line number Diff line
@@ -67,20 +67,6 @@ static int pacpi_cable_detect(struct ata_port *ap)
		return ATA_CBL_PATA40;
		return ATA_CBL_PATA40;
}
}


/**
 *	pacpi_error_handler - Setup and error handler
 *	@ap: Port to handle
 *
 *	LOCKING:
 *	None (inherited from caller).
 */

static void pacpi_error_handler(struct ata_port *ap)
{
	ata_bmdma_drive_eh(ap, pacpi_pre_reset, ata_std_softreset, NULL,
			   ata_std_postreset);
}

/**
/**
 *	pacpi_discover_modes	-	filter non ACPI modes
 *	pacpi_discover_modes	-	filter non ACPI modes
 *	@adev: ATA device
 *	@adev: ATA device
@@ -242,7 +228,7 @@ static struct ata_port_operations pacpi_ops = {
	.mode_filter		= pacpi_mode_filter,
	.mode_filter		= pacpi_mode_filter,
	.set_piomode		= pacpi_set_piomode,
	.set_piomode		= pacpi_set_piomode,
	.set_dmamode		= pacpi_set_dmamode,
	.set_dmamode		= pacpi_set_dmamode,
	.error_handler		= pacpi_error_handler,
	.prereset		= pacpi_pre_reset,
	.port_start		= pacpi_port_start,
	.port_start		= pacpi_port_start,
};
};


@@ -273,7 +259,7 @@ static int pacpi_init_one (struct pci_dev *pdev, const struct pci_device_id *id)
		.port_ops	= &pacpi_ops,
		.port_ops	= &pacpi_ops,
	};
	};
	const struct ata_port_info *ppi[] = { &info, NULL };
	const struct ata_port_info *ppi[] = { &info, NULL };
	return ata_pci_init_one(pdev, ppi, &pacpi_sht);
	return ata_pci_init_one(pdev, ppi, &pacpi_sht, NULL);
}
}


static const struct pci_device_id pacpi_pci_tbl[] = {
static const struct pci_device_id pacpi_pci_tbl[] = {
+1 −1
Original line number Original line Diff line number Diff line
@@ -552,7 +552,7 @@ static int ali_init_one(struct pci_dev *pdev, const struct pci_device_id *id)
	        	ppi[0] = &info_20_udma;
	        	ppi[0] = &info_20_udma;
		pci_dev_put(isa_bridge);
		pci_dev_put(isa_bridge);
	}
	}
	return ata_pci_init_one(pdev, ppi, &ali_sht);
	return ata_pci_init_one(pdev, ppi, &ali_sht, NULL);
}
}


#ifdef CONFIG_PM
#ifdef CONFIG_PM
Loading