Skip to content

Commit 208ab86

Browse files
Uwe Kleine-Königthierryreding
authored andcommitted
pwm: renesas-tpu: Rename variables to match the usual naming
The driver used "pwm" for struct tpu_pwm_device pointers. This name is usually only used for struct pwm_device pointers which this driver calls "_pwm". So rename to the driver data pointers to "tpd" which then allows to drop the underscore from "_pwm". Signed-off-by: Uwe Kleine-König <[email protected]> Reviewed-by: Geert Uytterhoeven <[email protected]> Signed-off-by: Thierry Reding <[email protected]>
1 parent ec00cd5 commit 208ab86

File tree

1 file changed

+86
-86
lines changed

1 file changed

+86
-86
lines changed

drivers/pwm/pwm-renesas-tpu.c

Lines changed: 86 additions & 86 deletions
Original file line numberDiff line numberDiff line change
@@ -89,80 +89,80 @@ struct tpu_device {
8989

9090
#define to_tpu_device(c) container_of(c, struct tpu_device, chip)
9191

92-
static void tpu_pwm_write(struct tpu_pwm_device *pwm, int reg_nr, u16 value)
92+
static void tpu_pwm_write(struct tpu_pwm_device *tpd, int reg_nr, u16 value)
9393
{
94-
void __iomem *base = pwm->tpu->base + TPU_CHANNEL_OFFSET
95-
+ pwm->channel * TPU_CHANNEL_SIZE;
94+
void __iomem *base = tpd->tpu->base + TPU_CHANNEL_OFFSET
95+
+ tpd->channel * TPU_CHANNEL_SIZE;
9696

9797
iowrite16(value, base + reg_nr);
9898
}
9999

100-
static void tpu_pwm_set_pin(struct tpu_pwm_device *pwm,
100+
static void tpu_pwm_set_pin(struct tpu_pwm_device *tpd,
101101
enum tpu_pin_state state)
102102
{
103103
static const char * const states[] = { "inactive", "PWM", "active" };
104104

105-
dev_dbg(&pwm->tpu->pdev->dev, "%u: configuring pin as %s\n",
106-
pwm->channel, states[state]);
105+
dev_dbg(&tpd->tpu->pdev->dev, "%u: configuring pin as %s\n",
106+
tpd->channel, states[state]);
107107

108108
switch (state) {
109109
case TPU_PIN_INACTIVE:
110-
tpu_pwm_write(pwm, TPU_TIORn,
111-
pwm->polarity == PWM_POLARITY_INVERSED ?
110+
tpu_pwm_write(tpd, TPU_TIORn,
111+
tpd->polarity == PWM_POLARITY_INVERSED ?
112112
TPU_TIOR_IOA_1 : TPU_TIOR_IOA_0);
113113
break;
114114
case TPU_PIN_PWM:
115-
tpu_pwm_write(pwm, TPU_TIORn,
116-
pwm->polarity == PWM_POLARITY_INVERSED ?
115+
tpu_pwm_write(tpd, TPU_TIORn,
116+
tpd->polarity == PWM_POLARITY_INVERSED ?
117117
TPU_TIOR_IOA_0_SET : TPU_TIOR_IOA_1_CLR);
118118
break;
119119
case TPU_PIN_ACTIVE:
120-
tpu_pwm_write(pwm, TPU_TIORn,
121-
pwm->polarity == PWM_POLARITY_INVERSED ?
120+
tpu_pwm_write(tpd, TPU_TIORn,
121+
tpd->polarity == PWM_POLARITY_INVERSED ?
122122
TPU_TIOR_IOA_0 : TPU_TIOR_IOA_1);
123123
break;
124124
}
125125
}
126126

127-
static void tpu_pwm_start_stop(struct tpu_pwm_device *pwm, int start)
127+
static void tpu_pwm_start_stop(struct tpu_pwm_device *tpd, int start)
128128
{
129129
unsigned long flags;
130130
u16 value;
131131

132-
spin_lock_irqsave(&pwm->tpu->lock, flags);
133-
value = ioread16(pwm->tpu->base + TPU_TSTR);
132+
spin_lock_irqsave(&tpd->tpu->lock, flags);
133+
value = ioread16(tpd->tpu->base + TPU_TSTR);
134134

135135
if (start)
136-
value |= 1 << pwm->channel;
136+
value |= 1 << tpd->channel;
137137
else
138-
value &= ~(1 << pwm->channel);
138+
value &= ~(1 << tpd->channel);
139139

140-
iowrite16(value, pwm->tpu->base + TPU_TSTR);
141-
spin_unlock_irqrestore(&pwm->tpu->lock, flags);
140+
iowrite16(value, tpd->tpu->base + TPU_TSTR);
141+
spin_unlock_irqrestore(&tpd->tpu->lock, flags);
142142
}
143143

144-
static int tpu_pwm_timer_start(struct tpu_pwm_device *pwm)
144+
static int tpu_pwm_timer_start(struct tpu_pwm_device *tpd)
145145
{
146146
int ret;
147147

148-
if (!pwm->timer_on) {
148+
if (!tpd->timer_on) {
149149
/* Wake up device and enable clock. */
150-
pm_runtime_get_sync(&pwm->tpu->pdev->dev);
151-
ret = clk_prepare_enable(pwm->tpu->clk);
150+
pm_runtime_get_sync(&tpd->tpu->pdev->dev);
151+
ret = clk_prepare_enable(tpd->tpu->clk);
152152
if (ret) {
153-
dev_err(&pwm->tpu->pdev->dev, "cannot enable clock\n");
153+
dev_err(&tpd->tpu->pdev->dev, "cannot enable clock\n");
154154
return ret;
155155
}
156-
pwm->timer_on = true;
156+
tpd->timer_on = true;
157157
}
158158

159159
/*
160160
* Make sure the channel is stopped, as we need to reconfigure it
161161
* completely. First drive the pin to the inactive state to avoid
162162
* glitches.
163163
*/
164-
tpu_pwm_set_pin(pwm, TPU_PIN_INACTIVE);
165-
tpu_pwm_start_stop(pwm, false);
164+
tpu_pwm_set_pin(tpd, TPU_PIN_INACTIVE);
165+
tpu_pwm_start_stop(tpd, false);
166166

167167
/*
168168
* - Clear TCNT on TGRB match
@@ -172,80 +172,80 @@ static int tpu_pwm_timer_start(struct tpu_pwm_device *pwm)
172172
* - Output 1 until TGRA, output 0 until TGRB (active high polarity
173173
* - PWM mode
174174
*/
175-
tpu_pwm_write(pwm, TPU_TCRn, TPU_TCR_CCLR_TGRB | TPU_TCR_CKEG_RISING |
176-
pwm->prescaler);
177-
tpu_pwm_write(pwm, TPU_TMDRn, TPU_TMDR_MD_PWM);
178-
tpu_pwm_set_pin(pwm, TPU_PIN_PWM);
179-
tpu_pwm_write(pwm, TPU_TGRAn, pwm->duty);
180-
tpu_pwm_write(pwm, TPU_TGRBn, pwm->period);
175+
tpu_pwm_write(tpd, TPU_TCRn, TPU_TCR_CCLR_TGRB | TPU_TCR_CKEG_RISING |
176+
tpd->prescaler);
177+
tpu_pwm_write(tpd, TPU_TMDRn, TPU_TMDR_MD_PWM);
178+
tpu_pwm_set_pin(tpd, TPU_PIN_PWM);
179+
tpu_pwm_write(tpd, TPU_TGRAn, tpd->duty);
180+
tpu_pwm_write(tpd, TPU_TGRBn, tpd->period);
181181

182-
dev_dbg(&pwm->tpu->pdev->dev, "%u: TGRA 0x%04x TGRB 0x%04x\n",
183-
pwm->channel, pwm->duty, pwm->period);
182+
dev_dbg(&tpd->tpu->pdev->dev, "%u: TGRA 0x%04x TGRB 0x%04x\n",
183+
tpd->channel, tpd->duty, tpd->period);
184184

185185
/* Start the channel. */
186-
tpu_pwm_start_stop(pwm, true);
186+
tpu_pwm_start_stop(tpd, true);
187187

188188
return 0;
189189
}
190190

191-
static void tpu_pwm_timer_stop(struct tpu_pwm_device *pwm)
191+
static void tpu_pwm_timer_stop(struct tpu_pwm_device *tpd)
192192
{
193-
if (!pwm->timer_on)
193+
if (!tpd->timer_on)
194194
return;
195195

196196
/* Disable channel. */
197-
tpu_pwm_start_stop(pwm, false);
197+
tpu_pwm_start_stop(tpd, false);
198198

199199
/* Stop clock and mark device as idle. */
200-
clk_disable_unprepare(pwm->tpu->clk);
201-
pm_runtime_put(&pwm->tpu->pdev->dev);
200+
clk_disable_unprepare(tpd->tpu->clk);
201+
pm_runtime_put(&tpd->tpu->pdev->dev);
202202

203-
pwm->timer_on = false;
203+
tpd->timer_on = false;
204204
}
205205

206206
/* -----------------------------------------------------------------------------
207207
* PWM API
208208
*/
209209

210-
static int tpu_pwm_request(struct pwm_chip *chip, struct pwm_device *_pwm)
210+
static int tpu_pwm_request(struct pwm_chip *chip, struct pwm_device *pwm)
211211
{
212212
struct tpu_device *tpu = to_tpu_device(chip);
213-
struct tpu_pwm_device *pwm;
213+
struct tpu_pwm_device *tpd;
214214

215-
if (_pwm->hwpwm >= TPU_CHANNEL_MAX)
215+
if (pwm->hwpwm >= TPU_CHANNEL_MAX)
216216
return -EINVAL;
217217

218-
pwm = kzalloc(sizeof(*pwm), GFP_KERNEL);
219-
if (pwm == NULL)
218+
tpd = kzalloc(sizeof(*tpd), GFP_KERNEL);
219+
if (tpd == NULL)
220220
return -ENOMEM;
221221

222-
pwm->tpu = tpu;
223-
pwm->channel = _pwm->hwpwm;
224-
pwm->polarity = PWM_POLARITY_NORMAL;
225-
pwm->prescaler = 0;
226-
pwm->period = 0;
227-
pwm->duty = 0;
222+
tpd->tpu = tpu;
223+
tpd->channel = pwm->hwpwm;
224+
tpd->polarity = PWM_POLARITY_NORMAL;
225+
tpd->prescaler = 0;
226+
tpd->period = 0;
227+
tpd->duty = 0;
228228

229-
pwm->timer_on = false;
229+
tpd->timer_on = false;
230230

231-
pwm_set_chip_data(_pwm, pwm);
231+
pwm_set_chip_data(pwm, tpd);
232232

233233
return 0;
234234
}
235235

236-
static void tpu_pwm_free(struct pwm_chip *chip, struct pwm_device *_pwm)
236+
static void tpu_pwm_free(struct pwm_chip *chip, struct pwm_device *pwm)
237237
{
238-
struct tpu_pwm_device *pwm = pwm_get_chip_data(_pwm);
238+
struct tpu_pwm_device *tpd = pwm_get_chip_data(pwm);
239239

240-
tpu_pwm_timer_stop(pwm);
241-
kfree(pwm);
240+
tpu_pwm_timer_stop(tpd);
241+
kfree(tpd);
242242
}
243243

244-
static int tpu_pwm_config(struct pwm_chip *chip, struct pwm_device *_pwm,
244+
static int tpu_pwm_config(struct pwm_chip *chip, struct pwm_device *pwm,
245245
int duty_ns, int period_ns, bool enabled)
246246
{
247247
static const unsigned int prescalers[] = { 1, 4, 16, 64 };
248-
struct tpu_pwm_device *pwm = pwm_get_chip_data(_pwm);
248+
struct tpu_pwm_device *tpd = pwm_get_chip_data(pwm);
249249
struct tpu_device *tpu = to_tpu_device(chip);
250250
unsigned int prescaler;
251251
bool duty_only = false;
@@ -285,29 +285,29 @@ static int tpu_pwm_config(struct pwm_chip *chip, struct pwm_device *_pwm,
285285
"rate %u, prescaler %u, period %u, duty %u\n",
286286
clk_rate, prescalers[prescaler], period, duty);
287287

288-
if (pwm->prescaler == prescaler && pwm->period == period)
288+
if (tpd->prescaler == prescaler && tpd->period == period)
289289
duty_only = true;
290290

291-
pwm->prescaler = prescaler;
292-
pwm->period = period;
293-
pwm->duty = duty;
291+
tpd->prescaler = prescaler;
292+
tpd->period = period;
293+
tpd->duty = duty;
294294

295295
/* If the channel is disabled we're done. */
296296
if (!enabled)
297297
return 0;
298298

299-
if (duty_only && pwm->timer_on) {
299+
if (duty_only && tpd->timer_on) {
300300
/*
301301
* If only the duty cycle changed and the timer is already
302302
* running, there's no need to reconfigure it completely, Just
303303
* modify the duty cycle.
304304
*/
305-
tpu_pwm_write(pwm, TPU_TGRAn, pwm->duty);
306-
dev_dbg(&tpu->pdev->dev, "%u: TGRA 0x%04x\n", pwm->channel,
307-
pwm->duty);
305+
tpu_pwm_write(tpd, TPU_TGRAn, tpd->duty);
306+
dev_dbg(&tpu->pdev->dev, "%u: TGRA 0x%04x\n", tpd->channel,
307+
tpd->duty);
308308
} else {
309309
/* Otherwise perform a full reconfiguration. */
310-
ret = tpu_pwm_timer_start(pwm);
310+
ret = tpu_pwm_timer_start(tpd);
311311
if (ret < 0)
312312
return ret;
313313
}
@@ -317,53 +317,53 @@ static int tpu_pwm_config(struct pwm_chip *chip, struct pwm_device *_pwm,
317317
* To avoid running the timer when not strictly required, handle
318318
* 0% and 100% duty cycles as fixed levels and stop the timer.
319319
*/
320-
tpu_pwm_set_pin(pwm, duty ? TPU_PIN_ACTIVE : TPU_PIN_INACTIVE);
321-
tpu_pwm_timer_stop(pwm);
320+
tpu_pwm_set_pin(tpd, duty ? TPU_PIN_ACTIVE : TPU_PIN_INACTIVE);
321+
tpu_pwm_timer_stop(tpd);
322322
}
323323

324324
return 0;
325325
}
326326

327-
static int tpu_pwm_set_polarity(struct pwm_chip *chip, struct pwm_device *_pwm,
327+
static int tpu_pwm_set_polarity(struct pwm_chip *chip, struct pwm_device *pwm,
328328
enum pwm_polarity polarity)
329329
{
330-
struct tpu_pwm_device *pwm = pwm_get_chip_data(_pwm);
330+
struct tpu_pwm_device *tpd = pwm_get_chip_data(pwm);
331331

332-
pwm->polarity = polarity;
332+
tpd->polarity = polarity;
333333

334334
return 0;
335335
}
336336

337-
static int tpu_pwm_enable(struct pwm_chip *chip, struct pwm_device *_pwm)
337+
static int tpu_pwm_enable(struct pwm_chip *chip, struct pwm_device *pwm)
338338
{
339-
struct tpu_pwm_device *pwm = pwm_get_chip_data(_pwm);
339+
struct tpu_pwm_device *tpd = pwm_get_chip_data(pwm);
340340
int ret;
341341

342-
ret = tpu_pwm_timer_start(pwm);
342+
ret = tpu_pwm_timer_start(tpd);
343343
if (ret < 0)
344344
return ret;
345345

346346
/*
347347
* To avoid running the timer when not strictly required, handle 0% and
348348
* 100% duty cycles as fixed levels and stop the timer.
349349
*/
350-
if (pwm->duty == 0 || pwm->duty == pwm->period) {
351-
tpu_pwm_set_pin(pwm, pwm->duty ?
350+
if (tpd->duty == 0 || tpd->duty == tpd->period) {
351+
tpu_pwm_set_pin(tpd, tpd->duty ?
352352
TPU_PIN_ACTIVE : TPU_PIN_INACTIVE);
353-
tpu_pwm_timer_stop(pwm);
353+
tpu_pwm_timer_stop(tpd);
354354
}
355355

356356
return 0;
357357
}
358358

359-
static void tpu_pwm_disable(struct pwm_chip *chip, struct pwm_device *_pwm)
359+
static void tpu_pwm_disable(struct pwm_chip *chip, struct pwm_device *pwm)
360360
{
361-
struct tpu_pwm_device *pwm = pwm_get_chip_data(_pwm);
361+
struct tpu_pwm_device *tpd = pwm_get_chip_data(pwm);
362362

363363
/* The timer must be running to modify the pin output configuration. */
364-
tpu_pwm_timer_start(pwm);
365-
tpu_pwm_set_pin(pwm, TPU_PIN_INACTIVE);
366-
tpu_pwm_timer_stop(pwm);
364+
tpu_pwm_timer_start(tpd);
365+
tpu_pwm_set_pin(tpd, TPU_PIN_INACTIVE);
366+
tpu_pwm_timer_stop(tpd);
367367
}
368368

369369
static int tpu_pwm_apply(struct pwm_chip *chip, struct pwm_device *pwm,

0 commit comments

Comments
 (0)