@@ -38,11 +38,11 @@ static inline struct atmel_hlcdc_pwm *to_atmel_hlcdc_pwm(struct pwm_chip *chip)
38
38
return container_of (chip , struct atmel_hlcdc_pwm , chip );
39
39
}
40
40
41
- static int atmel_hlcdc_pwm_apply (struct pwm_chip * c , struct pwm_device * pwm ,
41
+ static int atmel_hlcdc_pwm_apply (struct pwm_chip * chip , struct pwm_device * pwm ,
42
42
const struct pwm_state * state )
43
43
{
44
- struct atmel_hlcdc_pwm * chip = to_atmel_hlcdc_pwm (c );
45
- struct atmel_hlcdc * hlcdc = chip -> hlcdc ;
44
+ struct atmel_hlcdc_pwm * atmel = to_atmel_hlcdc_pwm (chip );
45
+ struct atmel_hlcdc * hlcdc = atmel -> hlcdc ;
46
46
unsigned int status ;
47
47
int ret ;
48
48
@@ -54,7 +54,7 @@ static int atmel_hlcdc_pwm_apply(struct pwm_chip *c, struct pwm_device *pwm,
54
54
u32 pwmcfg ;
55
55
int pres ;
56
56
57
- if (!chip -> errata || !chip -> errata -> slow_clk_erratum ) {
57
+ if (!atmel -> errata || !atmel -> errata -> slow_clk_erratum ) {
58
58
clk_freq = clk_get_rate (new_clk );
59
59
if (!clk_freq )
60
60
return - EINVAL ;
@@ -64,7 +64,7 @@ static int atmel_hlcdc_pwm_apply(struct pwm_chip *c, struct pwm_device *pwm,
64
64
}
65
65
66
66
/* Errata: cannot use slow clk on some IP revisions */
67
- if ((chip -> errata && chip -> errata -> slow_clk_erratum ) ||
67
+ if ((atmel -> errata && atmel -> errata -> slow_clk_erratum ) ||
68
68
clk_period_ns > state -> period ) {
69
69
new_clk = hlcdc -> sys_clk ;
70
70
clk_freq = clk_get_rate (new_clk );
@@ -77,8 +77,8 @@ static int atmel_hlcdc_pwm_apply(struct pwm_chip *c, struct pwm_device *pwm,
77
77
78
78
for (pres = 0 ; pres <= ATMEL_HLCDC_PWMPS_MAX ; pres ++ ) {
79
79
/* Errata: cannot divide by 1 on some IP revisions */
80
- if (!pres && chip -> errata &&
81
- chip -> errata -> div1_clk_erratum )
80
+ if (!pres && atmel -> errata &&
81
+ atmel -> errata -> div1_clk_erratum )
82
82
continue ;
83
83
84
84
if ((clk_period_ns << pres ) >= state -> period )
@@ -90,16 +90,16 @@ static int atmel_hlcdc_pwm_apply(struct pwm_chip *c, struct pwm_device *pwm,
90
90
91
91
pwmcfg = ATMEL_HLCDC_PWMPS (pres );
92
92
93
- if (new_clk != chip -> cur_clk ) {
93
+ if (new_clk != atmel -> cur_clk ) {
94
94
u32 gencfg = 0 ;
95
95
int ret ;
96
96
97
97
ret = clk_prepare_enable (new_clk );
98
98
if (ret )
99
99
return ret ;
100
100
101
- clk_disable_unprepare (chip -> cur_clk );
102
- chip -> cur_clk = new_clk ;
101
+ clk_disable_unprepare (atmel -> cur_clk );
102
+ atmel -> cur_clk = new_clk ;
103
103
104
104
if (new_clk == hlcdc -> sys_clk )
105
105
gencfg = ATMEL_HLCDC_CLKPWMSEL ;
@@ -160,8 +160,8 @@ static int atmel_hlcdc_pwm_apply(struct pwm_chip *c, struct pwm_device *pwm,
160
160
if (ret )
161
161
return ret ;
162
162
163
- clk_disable_unprepare (chip -> cur_clk );
164
- chip -> cur_clk = NULL ;
163
+ clk_disable_unprepare (atmel -> cur_clk );
164
+ atmel -> cur_clk = NULL ;
165
165
}
166
166
167
167
return 0 ;
@@ -183,31 +183,32 @@ static const struct atmel_hlcdc_pwm_errata atmel_hlcdc_pwm_sama5d3_errata = {
183
183
#ifdef CONFIG_PM_SLEEP
184
184
static int atmel_hlcdc_pwm_suspend (struct device * dev )
185
185
{
186
- struct atmel_hlcdc_pwm * chip = dev_get_drvdata (dev );
186
+ struct atmel_hlcdc_pwm * atmel = dev_get_drvdata (dev );
187
187
188
188
/* Keep the periph clock enabled if the PWM is still running. */
189
- if (pwm_is_enabled (& chip -> chip .pwms [0 ]))
190
- clk_disable_unprepare (chip -> hlcdc -> periph_clk );
189
+ if (pwm_is_enabled (& atmel -> chip .pwms [0 ]))
190
+ clk_disable_unprepare (atmel -> hlcdc -> periph_clk );
191
191
192
192
return 0 ;
193
193
}
194
194
195
195
static int atmel_hlcdc_pwm_resume (struct device * dev )
196
196
{
197
- struct atmel_hlcdc_pwm * chip = dev_get_drvdata (dev );
197
+ struct atmel_hlcdc_pwm * atmel = dev_get_drvdata (dev );
198
198
struct pwm_state state ;
199
199
int ret ;
200
200
201
- pwm_get_state (& chip -> chip .pwms [0 ], & state );
201
+ pwm_get_state (& atmel -> chip .pwms [0 ], & state );
202
202
203
203
/* Re-enable the periph clock it was stopped during suspend. */
204
204
if (!state .enabled ) {
205
- ret = clk_prepare_enable (chip -> hlcdc -> periph_clk );
205
+ ret = clk_prepare_enable (atmel -> hlcdc -> periph_clk );
206
206
if (ret )
207
207
return ret ;
208
208
}
209
209
210
- return atmel_hlcdc_pwm_apply (& chip -> chip , & chip -> chip .pwms [0 ], & state );
210
+ return atmel_hlcdc_pwm_apply (& atmel -> chip , & atmel -> chip .pwms [0 ],
211
+ & state );
211
212
}
212
213
#endif
213
214
@@ -244,14 +245,14 @@ static int atmel_hlcdc_pwm_probe(struct platform_device *pdev)
244
245
{
245
246
const struct of_device_id * match ;
246
247
struct device * dev = & pdev -> dev ;
247
- struct atmel_hlcdc_pwm * chip ;
248
+ struct atmel_hlcdc_pwm * atmel ;
248
249
struct atmel_hlcdc * hlcdc ;
249
250
int ret ;
250
251
251
252
hlcdc = dev_get_drvdata (dev -> parent );
252
253
253
- chip = devm_kzalloc (dev , sizeof (* chip ), GFP_KERNEL );
254
- if (!chip )
254
+ atmel = devm_kzalloc (dev , sizeof (* atmel ), GFP_KERNEL );
255
+ if (!atmel )
255
256
return - ENOMEM ;
256
257
257
258
ret = clk_prepare_enable (hlcdc -> periph_clk );
@@ -260,31 +261,31 @@ static int atmel_hlcdc_pwm_probe(struct platform_device *pdev)
260
261
261
262
match = of_match_node (atmel_hlcdc_dt_ids , dev -> parent -> of_node );
262
263
if (match )
263
- chip -> errata = match -> data ;
264
+ atmel -> errata = match -> data ;
264
265
265
- chip -> hlcdc = hlcdc ;
266
- chip -> chip .ops = & atmel_hlcdc_pwm_ops ;
267
- chip -> chip .dev = dev ;
268
- chip -> chip .npwm = 1 ;
266
+ atmel -> hlcdc = hlcdc ;
267
+ atmel -> chip .ops = & atmel_hlcdc_pwm_ops ;
268
+ atmel -> chip .dev = dev ;
269
+ atmel -> chip .npwm = 1 ;
269
270
270
- ret = pwmchip_add (& chip -> chip );
271
+ ret = pwmchip_add (& atmel -> chip );
271
272
if (ret ) {
272
273
clk_disable_unprepare (hlcdc -> periph_clk );
273
274
return ret ;
274
275
}
275
276
276
- platform_set_drvdata (pdev , chip );
277
+ platform_set_drvdata (pdev , atmel );
277
278
278
279
return 0 ;
279
280
}
280
281
281
282
static void atmel_hlcdc_pwm_remove (struct platform_device * pdev )
282
283
{
283
- struct atmel_hlcdc_pwm * chip = platform_get_drvdata (pdev );
284
+ struct atmel_hlcdc_pwm * atmel = platform_get_drvdata (pdev );
284
285
285
- pwmchip_remove (& chip -> chip );
286
+ pwmchip_remove (& atmel -> chip );
286
287
287
- clk_disable_unprepare (chip -> hlcdc -> periph_clk );
288
+ clk_disable_unprepare (atmel -> hlcdc -> periph_clk );
288
289
}
289
290
290
291
static const struct of_device_id atmel_hlcdc_pwm_dt_ids [] = {
0 commit comments