spi: intel: Improve resource mapping
PATCH 1/1 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
--- drivers/spi/spi-intel-pci.c | 8 +++++++- drivers/spi/spi-intel-platform.c | 9 ++++++--- drivers/spi/spi-intel.c | 9 +++------ drivers/spi/spi-intel.h | 4 +--- 4 files changed, 17 insertions(+), 13 deletions(-)
drivers/spi/spi-intel-pci.c +7 -1
@@ -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[] = {
drivers/spi/spi-intel-platform.c +6 -3
@@ -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 = {
drivers/spi/spi-intel.c +3 -6
@@ -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;
drivers/spi/spi-intel.h +1 -3
@@ -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 */
Signature · 1 line
2.49.0
Mark Brown
maintainerQuoted 9 lines · Heiner Kallweit
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_devinternals (pdev->resource[]).- More user-friendly output in
/proc/iomem. In my case:[...]
Applied to
https://git.kernel.org/pub/scm/linux/kernel/git/broonie/spi.git for-next
Thanks!
[1/1] spi: intel: Improve resource mapping
commit: b50a1e1f3c4630f729629a787d891d7b4348007f
All being well this means that it will be integrated into the linux-next tree (usually sometime in the next 24 hours) and sent to Linus during the next merge window (or sooner if it is a bug fix), however if problems are discovered then the patch may be dropped or reverted.
You may get further e-mails resulting from automated or manual testing and review of the tree, please engage with people reporting problems and send followup patches addressing any issues that are reported if needed.
If any updates are required or you are submitting further changes they should be sent as incremental updates against current git, existing patches will not be replaced.
Please add any relevant lists and maintainers to the CCs when replying to this mail.
Thanks,
Mark