Re: [PATCH 1/2] clk: qcom: clk-rpmh: Add QCOM RPMh clock driver

Evan Green
2018-04-10T17:06:08Z

On Thu, Apr 5, 2018 at 4:17 PM Stephen Boyd <sboyd@kernel.org> wrote:

> Quoting Taniya Das (2018-04-02 03:33:26)
> >
> > >
> > >> +
> > >> +#include "common.h"
> > >> +#include "clk-regmap.h"
> > >> +
> > >> +#define CLK_RPMH_ARC_EN_OFFSET 0
> > >> +#define CLK_RPMH_VRM_EN_OFFSET 4
> > >> +#define CLK_RPMH_VRM_OFF_VAL 0
> > >> +#define CLK_RPMH_VRM_ON_VAL 1
> > >> +#define CLK_RPMH_APPS_RSC_AO_STATE_MASK (BIT(RPMH_WAKE_ONLY_STATE)
| \
> > >> + BIT(RPMH_ACTIVE_ONLY_STATE))
> > >> +#define CLK_RPMH_APPS_RSC_STATE_MASK (BIT(RPMH_WAKE_ONLY_STATE) | \
> > >> + BIT(RPMH_ACTIVE_ONLY_STATE) | \
> > >> + BIT(RPMH_SLEEP_STATE))
> > >> +struct clk_rpmh {
> > >> + const char *res_name;
> > >> + u32 res_addr;
> > >> + u32 res_en_offset;
> > >> + u32 res_on_val;
> > >> + u32 res_off_val;
> > >> + u32 state;
> > >> + u32 aggr_state;
> > >> + u32 last_sent_aggr_state;
> > >> + u32 valid_state_mask;
> > >> + struct rpmh_client *rpmh_client;
> > >> + unsigned long rate;
> > >> + struct clk_rpmh *peer;
> > >> + struct clk_hw hw;
> > >
> > > I believe this member should go at the beginning of the structure. At
least
> > > that's what everyone else seems to do, and that's what the clk.txt
> > > documentation seems to ask for.
> > >
> >
> > Yes I missed that, would update it in the next patch series.

> Where is the documentation asking for that? There isn't any place that
> clk_hw should be in a structure. container_of() can figure it out all
> the time, and that macro is preferred instead of plain casts from one
> type to another because it provides slightly more type safety.

Perhaps I'm reading too strictly into the documentation, but this was the
passage that gave me that idea:

To construct a clk hardware structure for your platform you must define
the following::

struct clk_foo {
struct clk_hw hw;
... hardware specific data goes here ...
};

-Evan