mirror of
https://mirrors.bfsu.edu.cn/git/linux.git
synced 2024-11-29 07:04:10 +08:00
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: Tomasz Figa <tomasz.figa@gmail.com> Signed-off-by: Krzysztof Kozlowski <krzk@kernel.org> Acked-by: Arnd Bergmann <arnd@arndb.de> Reviewed-by: Stephen Boyd <sboyd@kernel.org> Link: https://lore.kernel.org/r/20200806182059.2431-6-krzk@kernel.org
This commit is contained in:
parent
346f183cc1
commit
b84e23f513
@ -15305,6 +15305,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>
|
||||
|
@ -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
|
||||
|
@ -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)
|
||||
|
19
include/linux/platform_data/clk-s3c2410.h
Normal file
19
include/linux/platform_data/clk-s3c2410.h
Normal file
@ -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_ */
|
||||
|
Loading…
Reference in New Issue
Block a user