@@ -39,9 +39,9 @@ static int gb_pwm_count_operation(struct gb_pwm_chip *pwmc)
39
39
return 0 ;
40
40
}
41
41
42
- static int gb_pwm_activate_operation (struct gb_pwm_chip * pwmc ,
43
- u8 which )
42
+ static int gb_pwm_activate_operation (struct pwm_chip * chip , u8 which )
44
43
{
44
+ struct gb_pwm_chip * pwmc = pwm_chip_to_gb_pwm_chip (chip );
45
45
struct gb_pwm_activate_request request ;
46
46
struct gbphy_device * gbphy_dev ;
47
47
int ret ;
@@ -51,7 +51,7 @@ static int gb_pwm_activate_operation(struct gb_pwm_chip *pwmc,
51
51
52
52
request .which = which ;
53
53
54
- gbphy_dev = to_gbphy_dev (pwmc -> chip . dev );
54
+ gbphy_dev = to_gbphy_dev (chip -> dev );
55
55
ret = gbphy_runtime_get_sync (gbphy_dev );
56
56
if (ret )
57
57
return ret ;
@@ -64,9 +64,9 @@ static int gb_pwm_activate_operation(struct gb_pwm_chip *pwmc,
64
64
return ret ;
65
65
}
66
66
67
- static int gb_pwm_deactivate_operation (struct gb_pwm_chip * pwmc ,
68
- u8 which )
67
+ static int gb_pwm_deactivate_operation (struct pwm_chip * chip , u8 which )
69
68
{
69
+ struct gb_pwm_chip * pwmc = pwm_chip_to_gb_pwm_chip (chip );
70
70
struct gb_pwm_deactivate_request request ;
71
71
struct gbphy_device * gbphy_dev ;
72
72
int ret ;
@@ -76,7 +76,7 @@ static int gb_pwm_deactivate_operation(struct gb_pwm_chip *pwmc,
76
76
77
77
request .which = which ;
78
78
79
- gbphy_dev = to_gbphy_dev (pwmc -> chip . dev );
79
+ gbphy_dev = to_gbphy_dev (chip -> dev );
80
80
ret = gbphy_runtime_get_sync (gbphy_dev );
81
81
if (ret )
82
82
return ret ;
@@ -89,9 +89,10 @@ static int gb_pwm_deactivate_operation(struct gb_pwm_chip *pwmc,
89
89
return ret ;
90
90
}
91
91
92
- static int gb_pwm_config_operation (struct gb_pwm_chip * pwmc ,
92
+ static int gb_pwm_config_operation (struct pwm_chip * chip ,
93
93
u8 which , u32 duty , u32 period )
94
94
{
95
+ struct gb_pwm_chip * pwmc = pwm_chip_to_gb_pwm_chip (chip );
95
96
struct gb_pwm_config_request request ;
96
97
struct gbphy_device * gbphy_dev ;
97
98
int ret ;
@@ -103,7 +104,7 @@ static int gb_pwm_config_operation(struct gb_pwm_chip *pwmc,
103
104
request .duty = cpu_to_le32 (duty );
104
105
request .period = cpu_to_le32 (period );
105
106
106
- gbphy_dev = to_gbphy_dev (pwmc -> chip . dev );
107
+ gbphy_dev = to_gbphy_dev (chip -> dev );
107
108
ret = gbphy_runtime_get_sync (gbphy_dev );
108
109
if (ret )
109
110
return ret ;
@@ -116,9 +117,10 @@ static int gb_pwm_config_operation(struct gb_pwm_chip *pwmc,
116
117
return ret ;
117
118
}
118
119
119
- static int gb_pwm_set_polarity_operation (struct gb_pwm_chip * pwmc ,
120
+ static int gb_pwm_set_polarity_operation (struct pwm_chip * chip ,
120
121
u8 which , u8 polarity )
121
122
{
123
+ struct gb_pwm_chip * pwmc = pwm_chip_to_gb_pwm_chip (chip );
122
124
struct gb_pwm_polarity_request request ;
123
125
struct gbphy_device * gbphy_dev ;
124
126
int ret ;
@@ -129,7 +131,7 @@ static int gb_pwm_set_polarity_operation(struct gb_pwm_chip *pwmc,
129
131
request .which = which ;
130
132
request .polarity = polarity ;
131
133
132
- gbphy_dev = to_gbphy_dev (pwmc -> chip . dev );
134
+ gbphy_dev = to_gbphy_dev (chip -> dev );
133
135
ret = gbphy_runtime_get_sync (gbphy_dev );
134
136
if (ret )
135
137
return ret ;
@@ -142,9 +144,9 @@ static int gb_pwm_set_polarity_operation(struct gb_pwm_chip *pwmc,
142
144
return ret ;
143
145
}
144
146
145
- static int gb_pwm_enable_operation (struct gb_pwm_chip * pwmc ,
146
- u8 which )
147
+ static int gb_pwm_enable_operation (struct pwm_chip * chip , u8 which )
147
148
{
149
+ struct gb_pwm_chip * pwmc = pwm_chip_to_gb_pwm_chip (chip );
148
150
struct gb_pwm_enable_request request ;
149
151
struct gbphy_device * gbphy_dev ;
150
152
int ret ;
@@ -154,7 +156,7 @@ static int gb_pwm_enable_operation(struct gb_pwm_chip *pwmc,
154
156
155
157
request .which = which ;
156
158
157
- gbphy_dev = to_gbphy_dev (pwmc -> chip . dev );
159
+ gbphy_dev = to_gbphy_dev (chip -> dev );
158
160
ret = gbphy_runtime_get_sync (gbphy_dev );
159
161
if (ret )
160
162
return ret ;
@@ -167,9 +169,9 @@ static int gb_pwm_enable_operation(struct gb_pwm_chip *pwmc,
167
169
return ret ;
168
170
}
169
171
170
- static int gb_pwm_disable_operation (struct gb_pwm_chip * pwmc ,
171
- u8 which )
172
+ static int gb_pwm_disable_operation (struct pwm_chip * chip , u8 which )
172
173
{
174
+ struct gb_pwm_chip * pwmc = pwm_chip_to_gb_pwm_chip (chip );
173
175
struct gb_pwm_disable_request request ;
174
176
struct gbphy_device * gbphy_dev ;
175
177
int ret ;
@@ -182,27 +184,23 @@ static int gb_pwm_disable_operation(struct gb_pwm_chip *pwmc,
182
184
ret = gb_operation_sync (pwmc -> connection , GB_PWM_TYPE_DISABLE ,
183
185
& request , sizeof (request ), NULL , 0 );
184
186
185
- gbphy_dev = to_gbphy_dev (pwmc -> chip . dev );
187
+ gbphy_dev = to_gbphy_dev (chip -> dev );
186
188
gbphy_runtime_put_autosuspend (gbphy_dev );
187
189
188
190
return ret ;
189
191
}
190
192
191
193
static int gb_pwm_request (struct pwm_chip * chip , struct pwm_device * pwm )
192
194
{
193
- struct gb_pwm_chip * pwmc = pwm_chip_to_gb_pwm_chip (chip );
194
-
195
- return gb_pwm_activate_operation (pwmc , pwm -> hwpwm );
195
+ return gb_pwm_activate_operation (chip , pwm -> hwpwm );
196
196
};
197
197
198
198
static void gb_pwm_free (struct pwm_chip * chip , struct pwm_device * pwm )
199
199
{
200
- struct gb_pwm_chip * pwmc = pwm_chip_to_gb_pwm_chip (chip );
201
-
202
200
if (pwm_is_enabled (pwm ))
203
201
dev_warn (chip -> dev , "freeing PWM device without disabling\n" );
204
202
205
- gb_pwm_deactivate_operation (pwmc , pwm -> hwpwm );
203
+ gb_pwm_deactivate_operation (chip , pwm -> hwpwm );
206
204
}
207
205
208
206
static int gb_pwm_apply (struct pwm_chip * chip , struct pwm_device * pwm ,
@@ -212,22 +210,21 @@ static int gb_pwm_apply(struct pwm_chip *chip, struct pwm_device *pwm,
212
210
bool enabled = pwm -> state .enabled ;
213
211
u64 period = state -> period ;
214
212
u64 duty_cycle = state -> duty_cycle ;
215
- struct gb_pwm_chip * pwmc = pwm_chip_to_gb_pwm_chip (chip );
216
213
217
214
/* Set polarity */
218
215
if (state -> polarity != pwm -> state .polarity ) {
219
216
if (enabled ) {
220
- gb_pwm_disable_operation (pwmc , pwm -> hwpwm );
217
+ gb_pwm_disable_operation (chip , pwm -> hwpwm );
221
218
enabled = false;
222
219
}
223
- err = gb_pwm_set_polarity_operation (pwmc , pwm -> hwpwm , state -> polarity );
220
+ err = gb_pwm_set_polarity_operation (chip , pwm -> hwpwm , state -> polarity );
224
221
if (err )
225
222
return err ;
226
223
}
227
224
228
225
if (!state -> enabled ) {
229
226
if (enabled )
230
- gb_pwm_disable_operation (pwmc , pwm -> hwpwm );
227
+ gb_pwm_disable_operation (chip , pwm -> hwpwm );
231
228
return 0 ;
232
229
}
233
230
@@ -243,13 +240,13 @@ static int gb_pwm_apply(struct pwm_chip *chip, struct pwm_device *pwm,
243
240
if (duty_cycle > period )
244
241
duty_cycle = period ;
245
242
246
- err = gb_pwm_config_operation (pwmc , pwm -> hwpwm , duty_cycle , period );
243
+ err = gb_pwm_config_operation (chip , pwm -> hwpwm , duty_cycle , period );
247
244
if (err )
248
245
return err ;
249
246
250
247
/* enable/disable */
251
248
if (!enabled )
252
- return gb_pwm_enable_operation (pwmc , pwm -> hwpwm );
249
+ return gb_pwm_enable_operation (chip , pwm -> hwpwm );
253
250
254
251
return 0 ;
255
252
}
@@ -282,7 +279,7 @@ static int gb_pwm_probe(struct gbphy_device *gbphy_dev,
282
279
283
280
pwmc -> connection = connection ;
284
281
gb_connection_set_data (connection , pwmc );
285
- gb_gbphy_set_data (gbphy_dev , pwmc );
282
+ gb_gbphy_set_data (gbphy_dev , chip );
286
283
287
284
ret = gb_connection_enable (connection );
288
285
if (ret )
@@ -320,15 +317,16 @@ static int gb_pwm_probe(struct gbphy_device *gbphy_dev,
320
317
321
318
static void gb_pwm_remove (struct gbphy_device * gbphy_dev )
322
319
{
323
- struct gb_pwm_chip * pwmc = gb_gbphy_get_data (gbphy_dev );
320
+ struct pwm_chip * chip = gb_gbphy_get_data (gbphy_dev );
321
+ struct gb_pwm_chip * pwmc = pwm_chip_to_gb_pwm_chip (chip );
324
322
struct gb_connection * connection = pwmc -> connection ;
325
323
int ret ;
326
324
327
325
ret = gbphy_runtime_get_sync (gbphy_dev );
328
326
if (ret )
329
327
gbphy_runtime_get_noresume (gbphy_dev );
330
328
331
- pwmchip_remove (& pwmc -> chip );
329
+ pwmchip_remove (chip );
332
330
gb_connection_disable (connection );
333
331
gb_connection_destroy (connection );
334
332
kfree (pwmc );
0 commit comments