Skip to content

Commit 0b38dd1

Browse files
mansrdlezcano
authored andcommitted
clocksource/drivers/sun5i: Remove pointless struct
Remove the pointless struct added in the previous patch to make the diff smaller. Signed-off-by: Mans Rullgard <mans@mansr.com> Acked-by: Jernej Skrabec <jernej.skrabec@gmail.com> Acked-by: Maxime Ripard <mripard@kernel.org> Signed-off-by: Daniel Lezcano <daniel.lezcano@linaro.org> Link: https://lore.kernel.org/r/20230630201800.16501-3-mans@mansr.com
1 parent 7ded803 commit 0b38dd1

File tree

1 file changed

+22
-27
lines changed

1 file changed

+22
-27
lines changed

drivers/clocksource/timer-sun5i.c

Lines changed: 22 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -35,22 +35,17 @@
3535

3636
#define TIMER_SYNC_TICKS 3
3737

38-
/* Pointless struct to minimise diff */
39-
struct _sun5i_timer {
38+
struct sun5i_timer {
4039
void __iomem *base;
4140
struct clk *clk;
4241
struct notifier_block clk_rate_cb;
4342
u32 ticks_per_jiffy;
44-
};
45-
46-
struct sun5i_timer {
47-
struct _sun5i_timer timer;
4843
struct clocksource clksrc;
4944
struct clock_event_device clkevt;
5045
};
5146

5247
#define nb_to_sun5i_timer(x) \
53-
container_of(x, struct sun5i_timer, timer.clk_rate_cb)
48+
container_of(x, struct sun5i_timer, clk_rate_cb)
5449
#define clksrc_to_sun5i_timer(x) \
5550
container_of(x, struct sun5i_timer, clksrc)
5651
#define clkevt_to_sun5i_timer(x) \
@@ -64,36 +59,36 @@ struct sun5i_timer {
6459
*/
6560
static void sun5i_clkevt_sync(struct sun5i_timer *ce)
6661
{
67-
u32 old = readl(ce->timer.base + TIMER_CNTVAL_LO_REG(1));
62+
u32 old = readl(ce->base + TIMER_CNTVAL_LO_REG(1));
6863

69-
while ((old - readl(ce->timer.base + TIMER_CNTVAL_LO_REG(1))) < TIMER_SYNC_TICKS)
64+
while ((old - readl(ce->base + TIMER_CNTVAL_LO_REG(1))) < TIMER_SYNC_TICKS)
7065
cpu_relax();
7166
}
7267

7368
static void sun5i_clkevt_time_stop(struct sun5i_timer *ce, u8 timer)
7469
{
75-
u32 val = readl(ce->timer.base + TIMER_CTL_REG(timer));
76-
writel(val & ~TIMER_CTL_ENABLE, ce->timer.base + TIMER_CTL_REG(timer));
70+
u32 val = readl(ce->base + TIMER_CTL_REG(timer));
71+
writel(val & ~TIMER_CTL_ENABLE, ce->base + TIMER_CTL_REG(timer));
7772

7873
sun5i_clkevt_sync(ce);
7974
}
8075

8176
static void sun5i_clkevt_time_setup(struct sun5i_timer *ce, u8 timer, u32 delay)
8277
{
83-
writel(delay, ce->timer.base + TIMER_INTVAL_LO_REG(timer));
78+
writel(delay, ce->base + TIMER_INTVAL_LO_REG(timer));
8479
}
8580

8681
static void sun5i_clkevt_time_start(struct sun5i_timer *ce, u8 timer, bool periodic)
8782
{
88-
u32 val = readl(ce->timer.base + TIMER_CTL_REG(timer));
83+
u32 val = readl(ce->base + TIMER_CTL_REG(timer));
8984

9085
if (periodic)
9186
val &= ~TIMER_CTL_ONESHOT;
9287
else
9388
val |= TIMER_CTL_ONESHOT;
9489

9590
writel(val | TIMER_CTL_ENABLE | TIMER_CTL_RELOAD,
96-
ce->timer.base + TIMER_CTL_REG(timer));
91+
ce->base + TIMER_CTL_REG(timer));
9792
}
9893

9994
static int sun5i_clkevt_shutdown(struct clock_event_device *clkevt)
@@ -118,7 +113,7 @@ static int sun5i_clkevt_set_periodic(struct clock_event_device *clkevt)
118113
struct sun5i_timer *ce = clkevt_to_sun5i_timer(clkevt);
119114

120115
sun5i_clkevt_time_stop(ce, 0);
121-
sun5i_clkevt_time_setup(ce, 0, ce->timer.ticks_per_jiffy);
116+
sun5i_clkevt_time_setup(ce, 0, ce->ticks_per_jiffy);
122117
sun5i_clkevt_time_start(ce, 0, true);
123118
return 0;
124119
}
@@ -139,7 +134,7 @@ static irqreturn_t sun5i_timer_interrupt(int irq, void *dev_id)
139134
{
140135
struct sun5i_timer *ce = dev_id;
141136

142-
writel(0x1, ce->timer.base + TIMER_IRQ_ST_REG);
137+
writel(0x1, ce->base + TIMER_IRQ_ST_REG);
143138
ce->clkevt.event_handler(&ce->clkevt);
144139

145140
return IRQ_HANDLED;
@@ -149,7 +144,7 @@ static u64 sun5i_clksrc_read(struct clocksource *clksrc)
149144
{
150145
struct sun5i_timer *cs = clksrc_to_sun5i_timer(clksrc);
151146

152-
return ~readl(cs->timer.base + TIMER_CNTVAL_LO_REG(1));
147+
return ~readl(cs->base + TIMER_CNTVAL_LO_REG(1));
153148
}
154149

155150
static int sun5i_rate_cb(struct notifier_block *nb,
@@ -166,7 +161,7 @@ static int sun5i_rate_cb(struct notifier_block *nb,
166161
case POST_RATE_CHANGE:
167162
clocksource_register_hz(&cs->clksrc, ndata->new_rate);
168163
clockevents_update_freq(&cs->clkevt, ndata->new_rate);
169-
cs->timer.ticks_per_jiffy = DIV_ROUND_UP(ndata->new_rate, HZ);
164+
cs->ticks_per_jiffy = DIV_ROUND_UP(ndata->new_rate, HZ);
170165
break;
171166

172167
default:
@@ -180,7 +175,7 @@ static int __init sun5i_setup_clocksource(struct device_node *node,
180175
struct sun5i_timer *cs,
181176
unsigned long rate)
182177
{
183-
void __iomem *base = cs->timer.base;
178+
void __iomem *base = cs->base;
184179
int ret;
185180

186181
writel(~0, base + TIMER_INTVAL_LO_REG(1));
@@ -206,7 +201,7 @@ static int __init sun5i_setup_clockevent(struct device_node *node,
206201
struct sun5i_timer *ce,
207202
unsigned long rate, int irq)
208203
{
209-
void __iomem *base = ce->timer.base;
204+
void __iomem *base = ce->base;
210205
int ret;
211206
u32 val;
212207

@@ -282,13 +277,13 @@ static int __init sun5i_timer_init(struct device_node *node)
282277
goto err_disable_clk;
283278
}
284279

285-
st->timer.base = timer_base;
286-
st->timer.ticks_per_jiffy = DIV_ROUND_UP(rate, HZ);
287-
st->timer.clk = clk;
288-
st->timer.clk_rate_cb.notifier_call = sun5i_rate_cb;
289-
st->timer.clk_rate_cb.next = NULL;
280+
st->base = timer_base;
281+
st->ticks_per_jiffy = DIV_ROUND_UP(rate, HZ);
282+
st->clk = clk;
283+
st->clk_rate_cb.notifier_call = sun5i_rate_cb;
284+
st->clk_rate_cb.next = NULL;
290285

291-
ret = clk_notifier_register(clk, &st->timer.clk_rate_cb);
286+
ret = clk_notifier_register(clk, &st->clk_rate_cb);
292287
if (ret) {
293288
pr_err("Unable to register clock notifier.\n");
294289
goto err_disable_clk;
@@ -305,7 +300,7 @@ static int __init sun5i_timer_init(struct device_node *node)
305300
return sun5i_setup_clockevent(node, st, rate, irq);
306301

307302
err_remove_notifier:
308-
clk_notifier_unregister(clk, &st->timer.clk_rate_cb);
303+
clk_notifier_unregister(clk, &st->clk_rate_cb);
309304
err_disable_clk:
310305
clk_disable_unprepare(clk);
311306
err_free:

0 commit comments

Comments
 (0)