mirror of
git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
synced 2026-03-22 07:27:12 +08:00
spi: intel: Improve resource mapping
Let's use the pci/platform-specialized functions for mapping a resource,
and pass the mapped address to intel_spi_probe. Benefits are:
- No separate call needed for getting the resource, and no access to
struct pci_dev internals (pdev->resource[]).
- More user-friendly output in /proc/iomem. In my case:
before
80704000-80704fff : 0000:00:1f.5
80704000-80704fff : 0000:00:1f.5 0000:00:1f.5
after
80704000-80704fff : 0000:00:1f.5
80704000-80704fff : spi_intel_pci
Signed-off-by: Heiner Kallweit <hkallweit1@gmail.com>
Link: https://patch.msgid.link/2585fa05-60c4-48c4-a838-e87014665ae2@gmail.com
Signed-off-by: Mark Brown <broonie@kernel.org>
This commit is contained in:
committed by
Mark Brown
parent
296e8d289b
commit
b50a1e1f3c
@@ -44,6 +44,7 @@ static int intel_spi_pci_probe(struct pci_dev *pdev,
|
||||
const struct pci_device_id *id)
|
||||
{
|
||||
struct intel_spi_boardinfo *info;
|
||||
void __iomem *base;
|
||||
int ret;
|
||||
|
||||
ret = pcim_enable_device(pdev);
|
||||
@@ -56,7 +57,12 @@ static int intel_spi_pci_probe(struct pci_dev *pdev,
|
||||
return -ENOMEM;
|
||||
|
||||
info->data = pdev;
|
||||
return intel_spi_probe(&pdev->dev, &pdev->resource[0], info);
|
||||
|
||||
base = pcim_iomap_region(pdev, 0, KBUILD_MODNAME);
|
||||
if (IS_ERR(base))
|
||||
return PTR_ERR(base);
|
||||
|
||||
return intel_spi_probe(&pdev->dev, base, info);
|
||||
}
|
||||
|
||||
static const struct pci_device_id intel_spi_pci_ids[] = {
|
||||
|
||||
@@ -14,14 +14,17 @@
|
||||
static int intel_spi_platform_probe(struct platform_device *pdev)
|
||||
{
|
||||
struct intel_spi_boardinfo *info;
|
||||
struct resource *mem;
|
||||
void __iomem *base;
|
||||
|
||||
info = dev_get_platdata(&pdev->dev);
|
||||
if (!info)
|
||||
return -EINVAL;
|
||||
|
||||
mem = platform_get_resource(pdev, IORESOURCE_MEM, 0);
|
||||
return intel_spi_probe(&pdev->dev, mem, info);
|
||||
base = devm_platform_ioremap_resource(pdev, 0);
|
||||
if (IS_ERR(base))
|
||||
return PTR_ERR(base);
|
||||
|
||||
return intel_spi_probe(&pdev->dev, base, info);
|
||||
}
|
||||
|
||||
static struct platform_driver intel_spi_platform_driver = {
|
||||
|
||||
@@ -1467,13 +1467,13 @@ EXPORT_SYMBOL_GPL(intel_spi_groups);
|
||||
/**
|
||||
* intel_spi_probe() - Probe the Intel SPI flash controller
|
||||
* @dev: Pointer to the parent device
|
||||
* @mem: MMIO resource
|
||||
* @base: iomapped MMIO resource
|
||||
* @info: Platform specific information
|
||||
*
|
||||
* Probes Intel SPI flash controller and creates the flash chip device.
|
||||
* Returns %0 on success and negative errno in case of failure.
|
||||
*/
|
||||
int intel_spi_probe(struct device *dev, struct resource *mem,
|
||||
int intel_spi_probe(struct device *dev, void __iomem *base,
|
||||
const struct intel_spi_boardinfo *info)
|
||||
{
|
||||
struct spi_controller *host;
|
||||
@@ -1488,10 +1488,7 @@ int intel_spi_probe(struct device *dev, struct resource *mem,
|
||||
|
||||
ispi = spi_controller_get_devdata(host);
|
||||
|
||||
ispi->base = devm_ioremap_resource(dev, mem);
|
||||
if (IS_ERR(ispi->base))
|
||||
return PTR_ERR(ispi->base);
|
||||
|
||||
ispi->base = base;
|
||||
ispi->dev = dev;
|
||||
ispi->host = host;
|
||||
ispi->info = info;
|
||||
|
||||
@@ -11,11 +11,9 @@
|
||||
|
||||
#include <linux/platform_data/x86/spi-intel.h>
|
||||
|
||||
struct resource;
|
||||
|
||||
extern const struct attribute_group *intel_spi_groups[];
|
||||
|
||||
int intel_spi_probe(struct device *dev, struct resource *mem,
|
||||
int intel_spi_probe(struct device *dev, void __iomem *base,
|
||||
const struct intel_spi_boardinfo *info);
|
||||
|
||||
#endif /* SPI_INTEL_H */
|
||||
|
||||
Reference in New Issue
Block a user