Commit b84e23f5 authored by Krzysztof Kozlowski's avatar Krzysztof Kozlowski

ARM: s3c24xx: pass pointer to clk driver via platform data

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: default avatarTomasz Figa <tomasz.figa@gmail.com>
Signed-off-by: default avatarKrzysztof Kozlowski <krzk@kernel.org>
Acked-by: default avatarArnd Bergmann <arnd@arndb.de>
Reviewed-by: default avatarStephen Boyd <sboyd@kernel.org>
Link: https://lore.kernel.org/r/20200806182059.2431-6-krzk@kernel.org
parent 346f183c
...@@ -15305,6 +15305,7 @@ F: Documentation/devicetree/bindings/clock/samsung,s5p* ...@@ -15305,6 +15305,7 @@ F: Documentation/devicetree/bindings/clock/samsung,s5p*
F: drivers/clk/samsung/ F: drivers/clk/samsung/
F: include/dt-bindings/clock/exynos*.h F: include/dt-bindings/clock/exynos*.h
F: include/linux/clk/samsung.h F: include/linux/clk/samsung.h
F: include/linux/platform_data/clk-s3c2410.h
SAMSUNG SPI DRIVERS SAMSUNG SPI DRIVERS
M: Kukjin Kim <kgene@kernel.org> M: Kukjin Kim <kgene@kernel.org>
......
...@@ -17,6 +17,7 @@ ...@@ -17,6 +17,7 @@
#include <linux/platform_device.h> #include <linux/platform_device.h>
#include <linux/delay.h> #include <linux/delay.h>
#include <linux/io.h> #include <linux/io.h>
#include <linux/platform_data/clk-s3c2410.h>
#include <linux/platform_data/dma-s3c24xx.h> #include <linux/platform_data/dma-s3c24xx.h>
#include <linux/dmaengine.h> #include <linux/dmaengine.h>
#include <linux/clk/samsung.h> #include <linux/clk/samsung.h>
...@@ -663,13 +664,17 @@ static struct resource s3c2410_dclk_resource[] = { ...@@ -663,13 +664,17 @@ static struct resource s3c2410_dclk_resource[] = {
[0] = DEFINE_RES_MEM(0x56000084, 0x4), [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 = { struct platform_device s3c2410_device_dclk = {
.name = "s3c2410-dclk", .name = "s3c2410-dclk",
.id = 0, .id = 0,
.num_resources = ARRAY_SIZE(s3c2410_dclk_resource), .num_resources = ARRAY_SIZE(s3c2410_dclk_resource),
.resource = s3c2410_dclk_resource, .resource = s3c2410_dclk_resource,
.dev = { .dev = {
.platform_data = s3c2410_modify_misccr, .platform_data = &s3c_clk_platform_data,
}, },
}; };
#endif #endif
...@@ -11,6 +11,7 @@ ...@@ -11,6 +11,7 @@
#include <linux/clk-provider.h> #include <linux/clk-provider.h>
#include <linux/io.h> #include <linux/io.h>
#include <linux/platform_device.h> #include <linux/platform_device.h>
#include <linux/platform_data/clk-s3c2410.h>
#include <linux/module.h> #include <linux/module.h>
#include "clk.h" #include "clk.h"
...@@ -89,10 +90,14 @@ static struct clk_hw *s3c24xx_register_clkout(struct device *dev, ...@@ -89,10 +90,14 @@ static struct clk_hw *s3c24xx_register_clkout(struct device *dev,
const char *name, const char **parent_names, u8 num_parents, const char *name, const char **parent_names, u8 num_parents,
u8 shift, u32 mask) u8 shift, u32 mask)
{ {
struct s3c2410_clk_platform_data *pdata = dev_get_platdata(dev);
struct s3c24xx_clkout *clkout; struct s3c24xx_clkout *clkout;
struct clk_init_data init; struct clk_init_data init;
int ret; int ret;
if (!pdata)
return ERR_PTR(-EINVAL);
/* allocate the clkout */ /* allocate the clkout */
clkout = kzalloc(sizeof(*clkout), GFP_KERNEL); clkout = kzalloc(sizeof(*clkout), GFP_KERNEL);
if (!clkout) if (!clkout)
...@@ -107,7 +112,7 @@ static struct clk_hw *s3c24xx_register_clkout(struct device *dev, ...@@ -107,7 +112,7 @@ static struct clk_hw *s3c24xx_register_clkout(struct device *dev,
clkout->shift = shift; clkout->shift = shift;
clkout->mask = mask; clkout->mask = mask;
clkout->hw.init = &init; clkout->hw.init = &init;
clkout->modify_misccr = dev->platform_data; clkout->modify_misccr = pdata->modify_misccr;
ret = clk_hw_register(dev, &clkout->hw); ret = clk_hw_register(dev, &clkout->hw);
if (ret) if (ret)
......
/* 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_ */
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment