mirror of
https://github.com/raspberrypi/linux.git
synced 2025-12-08 10:59:46 +00:00
clk: bcm: rpi: Create helper to retrieve private data
The RaspberryPi firmware clocks driver uses in several instances a container_of to retrieve the struct raspberrypi_clk_data from a pointer to struct clk_hw. Let's create a small function to avoid duplicating it all over the place. Signed-off-by: Maxime Ripard <maxime@cerno.tech>
This commit is contained in:
committed by
Dom Cobley
parent
54d82b2637
commit
b35ae84b66
@@ -56,6 +56,12 @@ struct raspberrypi_clk_data {
|
|||||||
struct raspberrypi_clk *rpi;
|
struct raspberrypi_clk *rpi;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
static inline
|
||||||
|
const struct raspberrypi_clk_data *clk_hw_to_data(const struct clk_hw *hw)
|
||||||
|
{
|
||||||
|
return container_of(hw, struct raspberrypi_clk_data, hw);
|
||||||
|
}
|
||||||
|
|
||||||
struct raspberrypi_clk_variant {
|
struct raspberrypi_clk_variant {
|
||||||
bool export;
|
bool export;
|
||||||
char *clkdev;
|
char *clkdev;
|
||||||
@@ -168,8 +174,7 @@ static int raspberrypi_clock_property(struct rpi_firmware *firmware,
|
|||||||
|
|
||||||
static int raspberrypi_fw_is_prepared(struct clk_hw *hw)
|
static int raspberrypi_fw_is_prepared(struct clk_hw *hw)
|
||||||
{
|
{
|
||||||
struct raspberrypi_clk_data *data =
|
const struct raspberrypi_clk_data *data = clk_hw_to_data(hw);
|
||||||
container_of(hw, struct raspberrypi_clk_data, hw);
|
|
||||||
struct raspberrypi_clk *rpi = data->rpi;
|
struct raspberrypi_clk *rpi = data->rpi;
|
||||||
u32 val = 0;
|
u32 val = 0;
|
||||||
int ret;
|
int ret;
|
||||||
@@ -186,8 +191,7 @@ static int raspberrypi_fw_is_prepared(struct clk_hw *hw)
|
|||||||
static unsigned long raspberrypi_fw_get_rate(struct clk_hw *hw,
|
static unsigned long raspberrypi_fw_get_rate(struct clk_hw *hw,
|
||||||
unsigned long parent_rate)
|
unsigned long parent_rate)
|
||||||
{
|
{
|
||||||
struct raspberrypi_clk_data *data =
|
const struct raspberrypi_clk_data *data = clk_hw_to_data(hw);
|
||||||
container_of(hw, struct raspberrypi_clk_data, hw);
|
|
||||||
struct raspberrypi_clk *rpi = data->rpi;
|
struct raspberrypi_clk *rpi = data->rpi;
|
||||||
u32 val = 0;
|
u32 val = 0;
|
||||||
int ret;
|
int ret;
|
||||||
@@ -203,8 +207,7 @@ static unsigned long raspberrypi_fw_get_rate(struct clk_hw *hw,
|
|||||||
static int raspberrypi_fw_set_rate(struct clk_hw *hw, unsigned long rate,
|
static int raspberrypi_fw_set_rate(struct clk_hw *hw, unsigned long rate,
|
||||||
unsigned long parent_rate)
|
unsigned long parent_rate)
|
||||||
{
|
{
|
||||||
struct raspberrypi_clk_data *data =
|
const struct raspberrypi_clk_data *data = clk_hw_to_data(hw);
|
||||||
container_of(hw, struct raspberrypi_clk_data, hw);
|
|
||||||
struct raspberrypi_clk *rpi = data->rpi;
|
struct raspberrypi_clk *rpi = data->rpi;
|
||||||
u32 _rate = rate;
|
u32 _rate = rate;
|
||||||
int ret;
|
int ret;
|
||||||
@@ -221,8 +224,7 @@ static int raspberrypi_fw_set_rate(struct clk_hw *hw, unsigned long rate,
|
|||||||
static int raspberrypi_fw_dumb_determine_rate(struct clk_hw *hw,
|
static int raspberrypi_fw_dumb_determine_rate(struct clk_hw *hw,
|
||||||
struct clk_rate_request *req)
|
struct clk_rate_request *req)
|
||||||
{
|
{
|
||||||
struct raspberrypi_clk_data *data =
|
const struct raspberrypi_clk_data *data = clk_hw_to_data(hw);
|
||||||
container_of(hw, struct raspberrypi_clk_data, hw);
|
|
||||||
struct raspberrypi_clk_variant *variant = data->variant;
|
struct raspberrypi_clk_variant *variant = data->variant;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|||||||
Reference in New Issue
Block a user