All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 1/4] mtd: denali: hide core part from user in Kconfig
@ 2015-08-06 13:04 Andy Shevchenko
  2015-08-06 13:04 ` [PATCH 2/4] mtd: denali_pci: use module_pci_driver() macro Andy Shevchenko
                   ` (3 more replies)
  0 siblings, 4 replies; 5+ messages in thread
From: Andy Shevchenko @ 2015-08-06 13:04 UTC (permalink / raw)
  To: linux-mtd, David Woodhouse; +Cc: Andy Shevchenko

There is no need to user to see the core part of the driver.

Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
---
 drivers/mtd/nand/Kconfig | 13 +++++--------
 1 file changed, 5 insertions(+), 8 deletions(-)

diff --git a/drivers/mtd/nand/Kconfig b/drivers/mtd/nand/Kconfig
index 5b2806a..3324281 100644
--- a/drivers/mtd/nand/Kconfig
+++ b/drivers/mtd/nand/Kconfig
@@ -42,23 +42,20 @@ config MTD_SM_COMMON
 	default n
 
 config MTD_NAND_DENALI
-        tristate "Support Denali NAND controller"
-        depends on HAS_DMA
-        help
-	  Enable support for the Denali NAND controller.  This should be
-	  combined with either the PCI or platform drivers to provide device
-	  registration.
+	tristate
 
 config MTD_NAND_DENALI_PCI
         tristate "Support Denali NAND controller on Intel Moorestown"
-	depends on PCI && MTD_NAND_DENALI
+	select MTD_NAND_DENALI
+	depends on HAS_DMA && PCI
         help
           Enable the driver for NAND flash on Intel Moorestown, using the
           Denali NAND controller core.
 
 config MTD_NAND_DENALI_DT
 	tristate "Support Denali NAND controller as a DT device"
-	depends on HAVE_CLK && MTD_NAND_DENALI
+	select MTD_NAND_DENALI
+	depends on HAS_DMA && HAVE_CLK
 	help
 	  Enable the driver for NAND flash on platforms using a Denali NAND
 	  controller as a DT device.
-- 
2.4.6

^ permalink raw reply related	[flat|nested] 5+ messages in thread

* [PATCH 2/4] mtd: denali_pci: use module_pci_driver() macro
  2015-08-06 13:04 [PATCH 1/4] mtd: denali: hide core part from user in Kconfig Andy Shevchenko
@ 2015-08-06 13:04 ` Andy Shevchenko
  2015-08-06 13:04 ` [PATCH 3/4] mtd: denali_pci: refactor driver using devres API Andy Shevchenko
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 5+ messages in thread
From: Andy Shevchenko @ 2015-08-06 13:04 UTC (permalink / raw)
  To: linux-mtd, David Woodhouse; +Cc: Andy Shevchenko

Let's use module_pci_driver() macro to reduce code base of the driver.

There is no functional change.

Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
---
 drivers/mtd/nand/denali_pci.c | 12 +-----------
 1 file changed, 1 insertion(+), 11 deletions(-)

diff --git a/drivers/mtd/nand/denali_pci.c b/drivers/mtd/nand/denali_pci.c
index 6e2f387..29e5d0c 100644
--- a/drivers/mtd/nand/denali_pci.c
+++ b/drivers/mtd/nand/denali_pci.c
@@ -129,14 +129,4 @@ static struct pci_driver denali_pci_driver = {
 	.remove = denali_pci_remove,
 };
 
-static int denali_init_pci(void)
-{
-	return pci_register_driver(&denali_pci_driver);
-}
-module_init(denali_init_pci);
-
-static void denali_exit_pci(void)
-{
-	pci_unregister_driver(&denali_pci_driver);
-}
-module_exit(denali_exit_pci);
+module_pci_driver(denali_pci_driver);
-- 
2.4.6

^ permalink raw reply related	[flat|nested] 5+ messages in thread

* [PATCH 3/4] mtd: denali_pci: refactor driver using devres API
  2015-08-06 13:04 [PATCH 1/4] mtd: denali: hide core part from user in Kconfig Andy Shevchenko
  2015-08-06 13:04 ` [PATCH 2/4] mtd: denali_pci: use module_pci_driver() macro Andy Shevchenko
@ 2015-08-06 13:04 ` Andy Shevchenko
  2015-08-06 13:04 ` [PATCH 4/4] mtd: denali_pci: switch to dev_err() Andy Shevchenko
  2015-08-19  0:27 ` [PATCH 1/4] mtd: denali: hide core part from user in Kconfig Brian Norris
  3 siblings, 0 replies; 5+ messages in thread
From: Andy Shevchenko @ 2015-08-06 13:04 UTC (permalink / raw)
  To: linux-mtd, David Woodhouse; +Cc: Andy Shevchenko

In recent kernels we have a lot of helper functions, including
devres API, to make life of device driver developer easy.

Convert the driver using devm_kzalloc() and pcim_enable_device().

Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
---
 drivers/mtd/nand/denali_pci.c | 23 ++++++-----------------
 1 file changed, 6 insertions(+), 17 deletions(-)

diff --git a/drivers/mtd/nand/denali_pci.c b/drivers/mtd/nand/denali_pci.c
index 29e5d0c..ad16e2e 100644
--- a/drivers/mtd/nand/denali_pci.c
+++ b/drivers/mtd/nand/denali_pci.c
@@ -30,19 +30,19 @@ MODULE_DEVICE_TABLE(pci, denali_pci_ids);
 
 static int denali_pci_probe(struct pci_dev *dev, const struct pci_device_id *id)
 {
-	int ret = -ENODEV;
+	int ret;
 	resource_size_t csr_base, mem_base;
 	unsigned long csr_len, mem_len;
 	struct denali_nand_info *denali;
 
-	denali = kzalloc(sizeof(*denali), GFP_KERNEL);
+	denali = devm_kzalloc(&dev->dev, sizeof(*denali), GFP_KERNEL);
 	if (!denali)
 		return -ENOMEM;
 
-	ret = pci_enable_device(dev);
+	ret = pcim_enable_device(dev);
 	if (ret) {
 		pr_err("Spectra: pci_enable_device failed.\n");
-		goto failed_alloc_memery;
+		return ret;
 	}
 
 	if (id->driver_data == INTEL_CE4100) {
@@ -70,14 +70,13 @@ static int denali_pci_probe(struct pci_dev *dev, const struct pci_device_id *id)
 	ret = pci_request_regions(dev, DENALI_NAND_NAME);
 	if (ret) {
 		pr_err("Spectra: Unable to request memory regions\n");
-		goto failed_enable_dev;
+		return ret;
 	}
 
 	denali->flash_reg = ioremap_nocache(csr_base, csr_len);
 	if (!denali->flash_reg) {
 		pr_err("Spectra: Unable to remap memory region\n");
-		ret = -ENOMEM;
-		goto failed_req_regions;
+		return -ENOMEM;
 	}
 
 	denali->flash_mem = ioremap_nocache(mem_base, mem_len);
@@ -99,13 +98,6 @@ failed_remap_mem:
 	iounmap(denali->flash_mem);
 failed_remap_reg:
 	iounmap(denali->flash_reg);
-failed_req_regions:
-	pci_release_regions(dev);
-failed_enable_dev:
-	pci_disable_device(dev);
-failed_alloc_memery:
-	kfree(denali);
-
 	return ret;
 }
 
@@ -117,9 +109,6 @@ static void denali_pci_remove(struct pci_dev *dev)
 	denali_remove(denali);
 	iounmap(denali->flash_reg);
 	iounmap(denali->flash_mem);
-	pci_release_regions(dev);
-	pci_disable_device(dev);
-	kfree(denali);
 }
 
 static struct pci_driver denali_pci_driver = {
-- 
2.4.6

^ permalink raw reply related	[flat|nested] 5+ messages in thread

* [PATCH 4/4] mtd: denali_pci: switch to dev_err()
  2015-08-06 13:04 [PATCH 1/4] mtd: denali: hide core part from user in Kconfig Andy Shevchenko
  2015-08-06 13:04 ` [PATCH 2/4] mtd: denali_pci: use module_pci_driver() macro Andy Shevchenko
  2015-08-06 13:04 ` [PATCH 3/4] mtd: denali_pci: refactor driver using devres API Andy Shevchenko
@ 2015-08-06 13:04 ` Andy Shevchenko
  2015-08-19  0:27 ` [PATCH 1/4] mtd: denali: hide core part from user in Kconfig Brian Norris
  3 siblings, 0 replies; 5+ messages in thread
From: Andy Shevchenko @ 2015-08-06 13:04 UTC (permalink / raw)
  To: linux-mtd, David Woodhouse; +Cc: Andy Shevchenko

It is better to have device name prefixed the actual error message.

Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
---
 drivers/mtd/nand/denali_pci.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/drivers/mtd/nand/denali_pci.c b/drivers/mtd/nand/denali_pci.c
index ad16e2e..de31514 100644
--- a/drivers/mtd/nand/denali_pci.c
+++ b/drivers/mtd/nand/denali_pci.c
@@ -41,7 +41,7 @@ static int denali_pci_probe(struct pci_dev *dev, const struct pci_device_id *id)
 
 	ret = pcim_enable_device(dev);
 	if (ret) {
-		pr_err("Spectra: pci_enable_device failed.\n");
+		dev_err(&dev->dev, "Spectra: pci_enable_device failed.\n");
 		return ret;
 	}
 
@@ -69,19 +69,19 @@ static int denali_pci_probe(struct pci_dev *dev, const struct pci_device_id *id)
 
 	ret = pci_request_regions(dev, DENALI_NAND_NAME);
 	if (ret) {
-		pr_err("Spectra: Unable to request memory regions\n");
+		dev_err(&dev->dev, "Spectra: Unable to request memory regions\n");
 		return ret;
 	}
 
 	denali->flash_reg = ioremap_nocache(csr_base, csr_len);
 	if (!denali->flash_reg) {
-		pr_err("Spectra: Unable to remap memory region\n");
+		dev_err(&dev->dev, "Spectra: Unable to remap memory region\n");
 		return -ENOMEM;
 	}
 
 	denali->flash_mem = ioremap_nocache(mem_base, mem_len);
 	if (!denali->flash_mem) {
-		pr_err("Spectra: ioremap_nocache failed!");
+		dev_err(&dev->dev, "Spectra: ioremap_nocache failed!");
 		ret = -ENOMEM;
 		goto failed_remap_reg;
 	}
-- 
2.4.6

^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [PATCH 1/4] mtd: denali: hide core part from user in Kconfig
  2015-08-06 13:04 [PATCH 1/4] mtd: denali: hide core part from user in Kconfig Andy Shevchenko
                   ` (2 preceding siblings ...)
  2015-08-06 13:04 ` [PATCH 4/4] mtd: denali_pci: switch to dev_err() Andy Shevchenko
@ 2015-08-19  0:27 ` Brian Norris
  3 siblings, 0 replies; 5+ messages in thread
From: Brian Norris @ 2015-08-19  0:27 UTC (permalink / raw)
  To: Andy Shevchenko; +Cc: linux-mtd, David Woodhouse

On Thu, Aug 06, 2015 at 04:04:21PM +0300, Andy Shevchenko wrote:
> There is no need to user to see the core part of the driver.
> 
> Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>

Pushed all 4 to l2-mtd.git. Thanks.

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2015-08-19  0:27 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-08-06 13:04 [PATCH 1/4] mtd: denali: hide core part from user in Kconfig Andy Shevchenko
2015-08-06 13:04 ` [PATCH 2/4] mtd: denali_pci: use module_pci_driver() macro Andy Shevchenko
2015-08-06 13:04 ` [PATCH 3/4] mtd: denali_pci: refactor driver using devres API Andy Shevchenko
2015-08-06 13:04 ` [PATCH 4/4] mtd: denali_pci: switch to dev_err() Andy Shevchenko
2015-08-19  0:27 ` [PATCH 1/4] mtd: denali: hide core part from user in Kconfig Brian Norris

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.