Skip to contentSkip to conversation

pwm: lpss: split driver to core and probe drivers

PATCH Superseded Andy Shevchenko 1 participant 3 messages Jul 28, 2014

Subsystems (2)

v2 of 4 Superseded Latest is v4 →

lore
Share & tools
lore

Andy Shevchenko

author reviewer
#0 lore raw

v2 cover pwm: lpss: split driver to core and probe drivers

This small series makes the architecture of pwm-lpss driver cleaner.

Since v1:
- hide struct definition in the core part
- rename pwm-lpss-plat to pwm-lpss-platform
- fix Kconfig dependencies and other typos
- add Mika's Reviewed-by tag
- fix spelling in the commit messages

Andy Shevchenko (2):
pwm: lpss: properly split driver to parts
pwm: lpss: pci: move to use pcim_enable_device()

 drivers/pwm/Kconfig             |  21 ++++++-
 drivers/pwm/Makefile            |   2 +
 drivers/pwm/pwm-lpss-pci.c      |  68 ++++++++++++++++++++++
 drivers/pwm/pwm-lpss-platform.c |  61 ++++++++++++++++++++
 drivers/pwm/pwm-lpss.c          | 125 ++--------------------------------------
 drivers/pwm/pwm-lpss.h          |  29 ++++++++++
 6 files changed, 186 insertions(+), 120 deletions(-)
 create mode 100644 drivers/pwm/pwm-lpss-pci.c
 create mode 100644 drivers/pwm/pwm-lpss-platform.c
 create mode 100644 drivers/pwm/pwm-lpss.h
Signature · 1 line
2.0.1
author reviewer
#1 lore raw

PATCH v2 1/2 pwm: lpss: properly split driver to parts

The driver consists core, PCI, and platform parts. It would better to split them into separate files.

The platform driver is now called pwm-lpss-platform. Thus, prevously set CONFIG_PWM_LPSS=m is not enough to build it. But we are on the safe side since it seems no one from outside Intel is using it for now.

While here, move to use macros module_pci_driver() and module_platform_driver().

---
 drivers/pwm/Kconfig             |  21 ++++++-
 drivers/pwm/Makefile            |   2 +
 drivers/pwm/pwm-lpss-pci.c      |  69 ++++++++++++++++++++++
 drivers/pwm/pwm-lpss-platform.c |  61 ++++++++++++++++++++
 drivers/pwm/pwm-lpss.c          | 125 ++--------------------------------------
 drivers/pwm/pwm-lpss.h          |  29 ++++++++++
 6 files changed, 187 insertions(+), 120 deletions(-)
 create mode 100644 drivers/pwm/pwm-lpss-pci.c
 create mode 100644 drivers/pwm/pwm-lpss-platform.c
 create mode 100644 drivers/pwm/pwm-lpss.h
drivers/pwm/Kconfig +20 -1
index 936010a..4feece0 100644
@@ -149,7 +149,6 @@ config PWM_LPC32XX
 
 config PWM_LPSS
 	tristate "Intel LPSS PWM support"
-	depends on ACPI
 	help
 	  Generic PWM framework driver for Intel Low Power Subsystem PWM
 	  controller.
@@ -157,6 +156,26 @@ config PWM_LPSS
 	  To compile this driver as a module, choose M here: the module
 	  will be called pwm-lpss.
 
+config PWM_LPSS_PCI
+	tristate "Intel LPSS PWM PCI driver"
+	depends on PCI
+	select PWN_LPSS
+	help
+	  The PCI driver for Intel Low Power Subsystem PWM controller.
+
+	  To compile this driver as a module, choose M here: the module
+	  will be called pwm-lpss-pci.
+
+config PWM_LPSS_PLATFORM
+	tristate "Intel LPSS PWM platform driver"
+	depends on ACPI
+	select PWN_LPSS
+	help
+	  The platform driver for Intel Low Power Subsystem PWM controller.
+
+	  To compile this driver as a module, choose M here: the module
+	  will be called pwm-lpss-platform.
+
 config PWM_MXS
 	tristate "Freescale MXS PWM support"
 	depends on ARCH_MXS && OF
drivers/pwm/Makefile +2 -0
index e03e2ae..aa12bc5 100644
@@ -13,6 +13,8 @@ obj-$(CONFIG_PWM_JZ4740)	+= pwm-jz4740.o
 obj-$(CONFIG_PWM_LP3943)	+= pwm-lp3943.o
 obj-$(CONFIG_PWM_LPC32XX)	+= pwm-lpc32xx.o
 obj-$(CONFIG_PWM_LPSS)		+= pwm-lpss.o
+obj-$(CONFIG_PWM_LPSS_PCI)	+= pwm-lpss-pci.o
+obj-$(CONFIG_PWM_LPSS_PLATFORM)	+= pwm-lpss-platform.o
 obj-$(CONFIG_PWM_MXS)		+= pwm-mxs.o
 obj-$(CONFIG_PWM_PCA9685)	+= pwm-pca9685.o
 obj-$(CONFIG_PWM_PUV3)		+= pwm-puv3.o
drivers/pwm/pwm-lpss-pci.c new file +69 -0

69 lines not on this page · raw message

drivers/pwm/pwm-lpss-platform.c new file +61 -0

61 lines not on this page · raw message

drivers/pwm/pwm-lpss.c +6 -119

161 lines not on this page · raw message

drivers/pwm/pwm-lpss.h new file +29 -0
new file mode 100644
index 0000000..84c75b0
@@ -0,0 +1,29 @@
+/*
+ * Intel Low Power Subsystem PWM controller driver
+ *
+ * Copyright (C) 2014, Intel Corporation
+ *
+ * Derived from the original pwm-lpss.c
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+ */
+
+#ifndef __PWM_LPSS_H
+#define __PWM_LPSS_H
+
+#include <linux/pwm.h>
+#include <linux/device.h>
+
+struct pwm_lpss_chip;
+
+struct pwm_lpss_boardinfo {
+	unsigned long clk_rate;
+};
+
+extern struct pwm_lpss_chip *pwm_lpss_probe(struct device *dev,
+		struct resource *r, const struct pwm_lpss_boardinfo *info);
+extern int pwm_lpss_remove(struct pwm_lpss_chip *lpwm);
+
+#endif	/* __PWM_LPSS_H */
Signature · 1 line
2.0.1
author reviewer
#2 lore raw

PATCH v2 2/2 pwm: lpss: pci: move to use pcim_enable_device()

In reply to Andy Shevchenko

Let's use managed functions for this driver.

---
 drivers/pwm/pwm-lpss-pci.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
drivers/pwm/pwm-lpss-pci.c +1 -2
index 48b88dd..974f4c8 100644
@@ -28,7 +28,7 @@ static int pwm_lpss_probe_pci(struct pci_dev *pdev,
 	struct pwm_lpss_chip *lpwm;
 	int err;
 
-	err = pci_enable_device(pdev);
+	err = pcim_enable_device(pdev);
 	if (err < 0)
 		return err;
 
@@ -46,7 +46,6 @@ static void pwm_lpss_remove_pci(struct pci_dev *pdev)
 	struct pwm_lpss_chip *lpwm = pci_get_drvdata(pdev);
 
 	pwm_lpss_remove(lpwm);
-	pci_disable_device(pdev);
 }
 
 static struct pci_device_id pwm_lpss_pci_ids[] = {
Signature · 1 line
2.0.1