linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Krzysztof Kozlowski <krzk@kernel.org>
To: linux-kernel@vger.kernel.org
Cc: Arnd Bergmann <arnd@arndb.de>,
	Krzysztof Kozlowski <krzk@kernel.org>,
	Russell King <linux@armlinux.org.uk>,
	Sylwester Nawrocki <s.nawrocki@samsung.com>,
	Tomasz Figa <tomasz.figa@gmail.com>,
	Chanwoo Choi <cw00.choi@samsung.com>,
	Michael Turquette <mturquette@baylibre.com>,
	Stephen Boyd <sboyd@kernel.org>, Kukjin Kim <kgene@kernel.org>,
	linux-arm-kernel@lists.infradead.org,
	linux-samsung-soc@vger.kernel.org, linux-clk@vger.kernel.org
Subject: [PATCH v2 06/41] ARM: s3c24xx: pass pointer to clk driver via platform data
Date: Thu,  6 Aug 2020 20:20:23 +0200	[thread overview]
Message-ID: <20200806182059.2431-6-krzk@kernel.org> (raw)
In-Reply-To: <20200806181932.2253-1-krzk@kernel.org>

Passing pointers directly as platform data is fragile and undocumented.
Better to create a platform data structure which explicitly documents
what is passed to the driver.

Suggested-by: Tomasz Figa <tomasz.figa@gmail.com>
[krzk: Update maintainer's entry]
Signed-off-by: Krzysztof Kozlowski <krzk@kernel.org>

---

Changes since v1:
1. Update maintainer's entry.
---
 MAINTAINERS                               |  1 +
 arch/arm/mach-s3c24xx/common.c            |  7 ++++++-
 drivers/clk/samsung/clk-s3c2410-dclk.c    |  7 ++++++-
 include/linux/platform_data/clk-s3c2410.h | 19 +++++++++++++++++++
 4 files changed, 32 insertions(+), 2 deletions(-)
 create mode 100644 include/linux/platform_data/clk-s3c2410.h

diff --git a/MAINTAINERS b/MAINTAINERS
index 5675fc9bfa00..81046738cba9 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -15295,6 +15295,7 @@ F:	Documentation/devicetree/bindings/clock/samsung,s5p*
 F:	drivers/clk/samsung/
 F:	include/dt-bindings/clock/exynos*.h
 F:	include/linux/clk/samsung.h
+F:	include/linux/platform_data/clk-s3c2410.h
 
 SAMSUNG SPI DRIVERS
 M:	Kukjin Kim <kgene@kernel.org>
diff --git a/arch/arm/mach-s3c24xx/common.c b/arch/arm/mach-s3c24xx/common.c
index 222238e8acbb..c476a673d07f 100644
--- a/arch/arm/mach-s3c24xx/common.c
+++ b/arch/arm/mach-s3c24xx/common.c
@@ -17,6 +17,7 @@
 #include <linux/platform_device.h>
 #include <linux/delay.h>
 #include <linux/io.h>
+#include <linux/platform_data/clk-s3c2410.h>
 #include <linux/platform_data/dma-s3c24xx.h>
 #include <linux/dmaengine.h>
 #include <linux/clk/samsung.h>
@@ -663,13 +664,17 @@ static struct resource s3c2410_dclk_resource[] = {
 	[0] = DEFINE_RES_MEM(0x56000084, 0x4),
 };
 
+static struct s3c2410_clk_platform_data s3c_clk_platform_data = {
+	.modify_misccr = s3c2410_modify_misccr,
+};
+
 struct platform_device s3c2410_device_dclk = {
 	.name		= "s3c2410-dclk",
 	.id		= 0,
 	.num_resources	= ARRAY_SIZE(s3c2410_dclk_resource),
 	.resource	= s3c2410_dclk_resource,
 	.dev		= {
-		.platform_data = s3c2410_modify_misccr,
+		.platform_data = &s3c_clk_platform_data,
 	},
 };
 #endif
diff --git a/drivers/clk/samsung/clk-s3c2410-dclk.c b/drivers/clk/samsung/clk-s3c2410-dclk.c
index 3e0f23e8ec21..f5e0a6ba2d12 100644
--- a/drivers/clk/samsung/clk-s3c2410-dclk.c
+++ b/drivers/clk/samsung/clk-s3c2410-dclk.c
@@ -11,6 +11,7 @@
 #include <linux/clk-provider.h>
 #include <linux/io.h>
 #include <linux/platform_device.h>
+#include <linux/platform_data/clk-s3c2410.h>
 #include <linux/module.h>
 #include "clk.h"
 
@@ -89,10 +90,14 @@ static struct clk_hw *s3c24xx_register_clkout(struct device *dev,
 		const char *name, const char **parent_names, u8 num_parents,
 		u8 shift, u32 mask)
 {
+	struct s3c2410_clk_platform_data *pdata = dev_get_platdata(dev);
 	struct s3c24xx_clkout *clkout;
 	struct clk_init_data init;
 	int ret;
 
+	if (!pdata)
+		return ERR_PTR(-EINVAL);
+
 	/* allocate the clkout */
 	clkout = kzalloc(sizeof(*clkout), GFP_KERNEL);
 	if (!clkout)
@@ -107,7 +112,7 @@ static struct clk_hw *s3c24xx_register_clkout(struct device *dev,
 	clkout->shift = shift;
 	clkout->mask = mask;
 	clkout->hw.init = &init;
-	clkout->modify_misccr = dev->platform_data;
+	clkout->modify_misccr = pdata->modify_misccr;
 
 	ret = clk_hw_register(dev, &clkout->hw);
 	if (ret)
diff --git a/include/linux/platform_data/clk-s3c2410.h b/include/linux/platform_data/clk-s3c2410.h
new file mode 100644
index 000000000000..7eb1cfa5409b
--- /dev/null
+++ b/include/linux/platform_data/clk-s3c2410.h
@@ -0,0 +1,19 @@
+/* SPDX-License-Identifier: GPL-2.0 */
+/*
+ * Copyright (c) 2020 Krzysztof Kozlowski <krzk@kernel.org>
+ */
+
+#ifndef __LINUX_PLATFORM_DATA_CLK_S3C2410_H_
+#define __LINUX_PLATFORM_DATA_CLK_S3C2410_H_
+
+/**
+ * struct s3c2410_clk_platform_data - platform data for S3C2410 clock driver
+ *
+ * @modify_misccr: Function to modify the MISCCR and return the new value
+ */
+struct s3c2410_clk_platform_data {
+	unsigned int (*modify_misccr)(unsigned int clr, unsigned int chg);
+};
+
+#endif /* __LINUX_PLATFORM_DATA_CLK_S3C2410_H_ */
+
-- 
2.17.1


  parent reply	other threads:[~2020-08-06 18:42 UTC|newest]

Thread overview: 66+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <20200806181932.2253-1-krzk@kernel.org>
2020-08-06 18:20 ` [PATCH v2 01/41] ARM: s3c: Remove unneeded machine header includes Krzysztof Kozlowski
2020-08-19 12:15   ` Mark Brown
2020-08-19 19:02     ` Krzysztof Kozlowski
2020-08-19 19:17       ` Mark Brown
2020-08-20 15:39         ` Krzysztof Kozlowski
2020-08-06 18:20 ` [PATCH v2 02/41] mmc: s3cmci: Remove unneeded machine header include Krzysztof Kozlowski
2020-08-12 14:05   ` Ulf Hansson
2020-08-06 18:20 ` [PATCH v2 03/41] ARM: s3c24xx: fix mmc gpio lookup tables Krzysztof Kozlowski
2020-08-13  8:10   ` Linus Walleij
2020-08-06 18:20 ` [PATCH v2 04/41] ARM: s3c24xx: iotiming: make functions static Krzysztof Kozlowski
2020-08-06 18:20 ` [PATCH v2 05/41] ARM: s3c24xx: make S3C24XX_MISCCR access indirect Krzysztof Kozlowski
2020-08-12  7:53   ` Stephen Boyd
2020-08-06 18:20 ` Krzysztof Kozlowski [this message]
2020-08-12  7:55   ` [PATCH v2 06/41] ARM: s3c24xx: pass pointer to clk driver via platform data Stephen Boyd
2020-08-06 18:20 ` [PATCH v2 07/41] ARM: s3c24xx: simplify mach/io.h Krzysztof Kozlowski
2020-08-06 18:20 ` [PATCH v2 08/41] usb: gadget: s3c: use platform resources Krzysztof Kozlowski
2020-08-07 13:57   ` Felipe Balbi
2020-08-06 18:20 ` [PATCH v2 09/41] usb: gadget: s3c-hsudc: remove platform header dependency Krzysztof Kozlowski
2020-08-07 13:59   ` Felipe Balbi
2020-08-07 17:42     ` Arnd Bergmann
2020-08-09  8:44       ` Krzysztof Kozlowski
2020-08-10 12:51       ` Felipe Balbi
2020-08-06 18:20 ` [PATCH v2 10/41] ARM: samsung: don't build plat/pm-common for Exynos Krzysztof Kozlowski
2020-08-06 18:20 ` [PATCH v2 11/41] ARM: samsung: remove s3c_pm_debug_init() Krzysztof Kozlowski
2020-08-06 18:20 ` [PATCH v2 12/41] ARM: samsung: make pm-debug platform independent Krzysztof Kozlowski
2020-08-06 18:20 ` [PATCH v2 13/41] ARM: samsung: move CONFIG_DEBUG_S3C_UART to Kconfig.debug Krzysztof Kozlowski
2020-08-06 18:20 ` [PATCH v2 14/41] ARM: exynos: use private samsung_cpu_id copy Krzysztof Kozlowski
2020-08-06 18:20 ` [PATCH v2 15/41] ARM: exynos: stop selecting PLAT_SAMSUNG Krzysztof Kozlowski
2020-08-06 18:20 ` [PATCH v2 16/41] ARM: samsung: move pm check code to drivers/soc Krzysztof Kozlowski
2020-08-06 18:20 ` [PATCH v2 17/41] ARM: s5pv210: use private pm save/restore Krzysztof Kozlowski
2020-08-06 18:20 ` [PATCH v2 18/41] ARM: s5pv210: don't imply CONFIG_PLAT_SAMSUNG Krzysztof Kozlowski
2020-08-07 11:35   ` Mark Brown
2020-08-06 18:20 ` [PATCH v2 19/41] ARM: s3c64xx: remove mach/hardware.h Krzysztof Kozlowski
2020-08-06 18:20 ` [PATCH v2 20/41] ARM: s3c24xx: move regs-spi.h into spi driver Krzysztof Kozlowski
2020-08-07 11:34   ` Mark Brown
2020-08-06 18:20 ` [PATCH v2 21/41] ARM: s3c24xx: move irqchip driver back into platform Krzysztof Kozlowski
2020-08-07  8:01   ` Marc Zyngier
2020-08-06 18:20 ` [PATCH v2 22/41] ARM: s3c: adc: move header to linux/soc/samsung Krzysztof Kozlowski
2020-08-06 18:20 ` [PATCH v2 23/41] ARM: s3c24xx: move spi fiq handler into platform Krzysztof Kozlowski
2020-08-07 11:50   ` Mark Brown
2020-08-19 19:51   ` Krzysztof Kozlowski
2020-08-06 18:20 ` [PATCH v2 24/41] ASoC: samsung: h1940: turn into platform driver Krzysztof Kozlowski
2020-08-06 18:20 ` [PATCH v2 25/41] ASoC: samsung: neo1973: " Krzysztof Kozlowski
2020-08-06 18:20 ` [PATCH v2 26/41] ASoC: samsung: rx1950: " Krzysztof Kozlowski
2020-08-06 18:20 ` [PATCH v2 27/41] ASoC: samsung: s3c2412-i2s: avoid hardcoded S3C2410_PA_IIS Krzysztof Kozlowski
2020-08-06 18:20 ` [PATCH v2 28/41] ARM: s3c24xx: move iis pinctrl config into boards Krzysztof Kozlowski
2020-08-07 11:51   ` Mark Brown
2020-08-06 18:20 ` [PATCH v2 29/41] ARM: s3c24xx: move s3cmci pinctrl handling into board files Krzysztof Kozlowski
2020-08-06 18:20 ` [PATCH v2 30/41] ARM: s3c24xx: include mach/irqs.h where needed Krzysztof Kozlowski
2020-08-06 18:20 ` [PATCH v2 31/41] ARM: s3c24xx: spi: avoid hardcoding fiq number in driver Krzysztof Kozlowski
2020-08-07 11:51   ` Mark Brown
2020-08-06 18:20 ` [PATCH v2 32/41] ARM: s3c24xx: bast: avoid irq_desc array usage Krzysztof Kozlowski
2020-08-06 18:20 ` [PATCH v2 33/41] fbdev: s3c2410fb: remove mach header dependency Krzysztof Kozlowski
2020-08-06 18:20 ` [PATCH v2 34/41] cpufreq: s3c24xx: split out registers Krzysztof Kozlowski
2020-08-07  4:54   ` Viresh Kumar
2020-08-06 18:20 ` [PATCH v2 35/41] ARM: s3c: remove cpufreq header dependencies Krzysztof Kozlowski
2020-08-07  4:56   ` Viresh Kumar
2020-08-06 18:20 ` [PATCH v2 36/41] cpufreq: s3c2412: use global s3c2412_cpufreq_setrefresh Krzysztof Kozlowski
2020-08-07  4:57   ` Viresh Kumar
2020-08-06 18:20 ` [PATCH v2 37/41] cpufreq: s3c24xx: move low-level clk reg access into platform code Krzysztof Kozlowski
2020-08-07  4:58   ` Viresh Kumar
2020-08-06 18:20 ` [PATCH v2 38/41] ARM: s3c24xx: stop including mach/hardware.h from mach/io.h Krzysztof Kozlowski
2020-08-06 18:20 ` [PATCH v2 39/41] ARM: s3c: move into a common directory Krzysztof Kozlowski
2020-08-06 18:20 ` [PATCH v2 40/41] ARM: s3c: make headers local if possible Krzysztof Kozlowski
2020-08-06 18:20 ` [PATCH v2 41/41] MAINTAINERS: Add more name matches for Samsung SoC entries Krzysztof Kozlowski
     [not found] ` <CGME20200820155923eucas1p2f73e16e6321e3592bd702ea657ff0709@eucas1p2.samsung.com>
     [not found]   ` <20200820155913.GA21395@kozik-lap>
2020-08-21 13:52     ` [PATCH v2 00/41] spi / fbdev / cpufreq / usb / mmc / hwmon / ARM: Prepare for multiplatform S3C Bartlomiej Zolnierkiewicz

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20200806182059.2431-6-krzk@kernel.org \
    --to=krzk@kernel.org \
    --cc=arnd@arndb.de \
    --cc=cw00.choi@samsung.com \
    --cc=kgene@kernel.org \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-clk@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-samsung-soc@vger.kernel.org \
    --cc=linux@armlinux.org.uk \
    --cc=mturquette@baylibre.com \
    --cc=s.nawrocki@samsung.com \
    --cc=sboyd@kernel.org \
    --cc=tomasz.figa@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).