blob: 8158a434f7b878cc445b15a95cbc9ec02423cd4d [file] [log] [blame]
H Hartley Sweeten76abbdde2013-06-11 10:38:59 -07001/*
2 * A simple sysfs interface for the generic PWM framework
3 *
4 * Copyright (C) 2013 H Hartley Sweeten <hsweeten@visionengravers.com>
5 *
6 * Based on previous work by Lars Poeschel <poeschel@lemonage.de>
7 *
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation; either version 2, or (at your option)
11 * any later version.
12 *
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
17 */
18
19#include <linux/device.h>
20#include <linux/mutex.h>
21#include <linux/err.h>
22#include <linux/slab.h>
23#include <linux/kdev_t.h>
24#include <linux/pwm.h>
25
26struct pwm_export {
27 struct device child;
28 struct pwm_device *pwm;
Boris BREZILLON459a25a2016-03-30 22:03:27 +020029 struct mutex lock;
Yoshihiro Shimoda7fd4edc2019-05-31 18:55:00 +090030 struct pwm_state suspend;
H Hartley Sweeten76abbdde2013-06-11 10:38:59 -070031};
32
33static struct pwm_export *child_to_pwm_export(struct device *child)
34{
35 return container_of(child, struct pwm_export, child);
36}
37
38static struct pwm_device *child_to_pwm_device(struct device *child)
39{
40 struct pwm_export *export = child_to_pwm_export(child);
41
42 return export->pwm;
43}
44
Olliver Schinagl65cdc692015-10-26 22:32:37 +010045static ssize_t period_show(struct device *child,
46 struct device_attribute *attr,
47 char *buf)
H Hartley Sweeten76abbdde2013-06-11 10:38:59 -070048{
49 const struct pwm_device *pwm = child_to_pwm_device(child);
Boris Brezillon39100ce2016-04-14 21:17:43 +020050 struct pwm_state state;
H Hartley Sweeten76abbdde2013-06-11 10:38:59 -070051
Boris Brezillon39100ce2016-04-14 21:17:43 +020052 pwm_get_state(pwm, &state);
53
54 return sprintf(buf, "%u\n", state.period);
H Hartley Sweeten76abbdde2013-06-11 10:38:59 -070055}
56
Olliver Schinagl65cdc692015-10-26 22:32:37 +010057static ssize_t period_store(struct device *child,
58 struct device_attribute *attr,
59 const char *buf, size_t size)
H Hartley Sweeten76abbdde2013-06-11 10:38:59 -070060{
Boris BREZILLON459a25a2016-03-30 22:03:27 +020061 struct pwm_export *export = child_to_pwm_export(child);
62 struct pwm_device *pwm = export->pwm;
Boris Brezillon39100ce2016-04-14 21:17:43 +020063 struct pwm_state state;
H Hartley Sweeten76abbdde2013-06-11 10:38:59 -070064 unsigned int val;
65 int ret;
66
67 ret = kstrtouint(buf, 0, &val);
68 if (ret)
69 return ret;
70
Boris BREZILLON459a25a2016-03-30 22:03:27 +020071 mutex_lock(&export->lock);
Boris Brezillon39100ce2016-04-14 21:17:43 +020072 pwm_get_state(pwm, &state);
73 state.period = val;
74 ret = pwm_apply_state(pwm, &state);
Boris BREZILLON459a25a2016-03-30 22:03:27 +020075 mutex_unlock(&export->lock);
H Hartley Sweeten76abbdde2013-06-11 10:38:59 -070076
77 return ret ? : size;
78}
79
Olliver Schinagl65cdc692015-10-26 22:32:37 +010080static ssize_t duty_cycle_show(struct device *child,
81 struct device_attribute *attr,
82 char *buf)
H Hartley Sweeten76abbdde2013-06-11 10:38:59 -070083{
84 const struct pwm_device *pwm = child_to_pwm_device(child);
Boris Brezillon39100ce2016-04-14 21:17:43 +020085 struct pwm_state state;
H Hartley Sweeten76abbdde2013-06-11 10:38:59 -070086
Boris Brezillon39100ce2016-04-14 21:17:43 +020087 pwm_get_state(pwm, &state);
88
89 return sprintf(buf, "%u\n", state.duty_cycle);
H Hartley Sweeten76abbdde2013-06-11 10:38:59 -070090}
91
Olliver Schinagl65cdc692015-10-26 22:32:37 +010092static ssize_t duty_cycle_store(struct device *child,
93 struct device_attribute *attr,
94 const char *buf, size_t size)
H Hartley Sweeten76abbdde2013-06-11 10:38:59 -070095{
Boris BREZILLON459a25a2016-03-30 22:03:27 +020096 struct pwm_export *export = child_to_pwm_export(child);
97 struct pwm_device *pwm = export->pwm;
Boris Brezillon39100ce2016-04-14 21:17:43 +020098 struct pwm_state state;
H Hartley Sweeten76abbdde2013-06-11 10:38:59 -070099 unsigned int val;
100 int ret;
101
102 ret = kstrtouint(buf, 0, &val);
103 if (ret)
104 return ret;
105
Boris BREZILLON459a25a2016-03-30 22:03:27 +0200106 mutex_lock(&export->lock);
Boris Brezillon39100ce2016-04-14 21:17:43 +0200107 pwm_get_state(pwm, &state);
108 state.duty_cycle = val;
109 ret = pwm_apply_state(pwm, &state);
Boris BREZILLON459a25a2016-03-30 22:03:27 +0200110 mutex_unlock(&export->lock);
H Hartley Sweeten76abbdde2013-06-11 10:38:59 -0700111
112 return ret ? : size;
113}
114
Olliver Schinagl65cdc692015-10-26 22:32:37 +0100115static ssize_t enable_show(struct device *child,
116 struct device_attribute *attr,
117 char *buf)
H Hartley Sweeten76abbdde2013-06-11 10:38:59 -0700118{
119 const struct pwm_device *pwm = child_to_pwm_device(child);
Boris Brezillon39100ce2016-04-14 21:17:43 +0200120 struct pwm_state state;
H Hartley Sweeten76abbdde2013-06-11 10:38:59 -0700121
Boris Brezillon39100ce2016-04-14 21:17:43 +0200122 pwm_get_state(pwm, &state);
123
124 return sprintf(buf, "%d\n", state.enabled);
H Hartley Sweeten76abbdde2013-06-11 10:38:59 -0700125}
126
Olliver Schinagl65cdc692015-10-26 22:32:37 +0100127static ssize_t enable_store(struct device *child,
128 struct device_attribute *attr,
129 const char *buf, size_t size)
H Hartley Sweeten76abbdde2013-06-11 10:38:59 -0700130{
Boris BREZILLON459a25a2016-03-30 22:03:27 +0200131 struct pwm_export *export = child_to_pwm_export(child);
132 struct pwm_device *pwm = export->pwm;
Boris Brezillon39100ce2016-04-14 21:17:43 +0200133 struct pwm_state state;
H Hartley Sweeten76abbdde2013-06-11 10:38:59 -0700134 int val, ret;
135
136 ret = kstrtoint(buf, 0, &val);
137 if (ret)
138 return ret;
139
Boris BREZILLON459a25a2016-03-30 22:03:27 +0200140 mutex_lock(&export->lock);
141
Boris Brezillon39100ce2016-04-14 21:17:43 +0200142 pwm_get_state(pwm, &state);
143
H Hartley Sweeten76abbdde2013-06-11 10:38:59 -0700144 switch (val) {
145 case 0:
Boris Brezillon39100ce2016-04-14 21:17:43 +0200146 state.enabled = false;
H Hartley Sweeten76abbdde2013-06-11 10:38:59 -0700147 break;
148 case 1:
Boris Brezillon39100ce2016-04-14 21:17:43 +0200149 state.enabled = true;
H Hartley Sweeten76abbdde2013-06-11 10:38:59 -0700150 break;
151 default:
152 ret = -EINVAL;
Boris Brezillon39100ce2016-04-14 21:17:43 +0200153 goto unlock;
H Hartley Sweeten76abbdde2013-06-11 10:38:59 -0700154 }
155
Ryo Kodamafe5aa342016-06-08 10:58:23 +0900156 ret = pwm_apply_state(pwm, &state);
Boris BREZILLON459a25a2016-03-30 22:03:27 +0200157
Boris Brezillon39100ce2016-04-14 21:17:43 +0200158unlock:
159 mutex_unlock(&export->lock);
H Hartley Sweeten76abbdde2013-06-11 10:38:59 -0700160 return ret ? : size;
161}
162
Olliver Schinagl65cdc692015-10-26 22:32:37 +0100163static ssize_t polarity_show(struct device *child,
164 struct device_attribute *attr,
165 char *buf)
H Hartley Sweeten76abbdde2013-06-11 10:38:59 -0700166{
167 const struct pwm_device *pwm = child_to_pwm_device(child);
Thierry Reding5a063d82015-07-20 09:56:05 +0200168 const char *polarity = "unknown";
Boris Brezillon39100ce2016-04-14 21:17:43 +0200169 struct pwm_state state;
H Hartley Sweeten76abbdde2013-06-11 10:38:59 -0700170
Boris Brezillon39100ce2016-04-14 21:17:43 +0200171 pwm_get_state(pwm, &state);
172
173 switch (state.polarity) {
Thierry Reding5a063d82015-07-20 09:56:05 +0200174 case PWM_POLARITY_NORMAL:
175 polarity = "normal";
176 break;
177
178 case PWM_POLARITY_INVERSED:
179 polarity = "inversed";
180 break;
181 }
182
183 return sprintf(buf, "%s\n", polarity);
H Hartley Sweeten76abbdde2013-06-11 10:38:59 -0700184}
185
Olliver Schinagl65cdc692015-10-26 22:32:37 +0100186static ssize_t polarity_store(struct device *child,
187 struct device_attribute *attr,
188 const char *buf, size_t size)
H Hartley Sweeten76abbdde2013-06-11 10:38:59 -0700189{
Boris BREZILLON459a25a2016-03-30 22:03:27 +0200190 struct pwm_export *export = child_to_pwm_export(child);
191 struct pwm_device *pwm = export->pwm;
H Hartley Sweeten76abbdde2013-06-11 10:38:59 -0700192 enum pwm_polarity polarity;
Boris Brezillon39100ce2016-04-14 21:17:43 +0200193 struct pwm_state state;
H Hartley Sweeten76abbdde2013-06-11 10:38:59 -0700194 int ret;
195
196 if (sysfs_streq(buf, "normal"))
197 polarity = PWM_POLARITY_NORMAL;
198 else if (sysfs_streq(buf, "inversed"))
199 polarity = PWM_POLARITY_INVERSED;
200 else
201 return -EINVAL;
202
Boris BREZILLON459a25a2016-03-30 22:03:27 +0200203 mutex_lock(&export->lock);
Boris Brezillon39100ce2016-04-14 21:17:43 +0200204 pwm_get_state(pwm, &state);
205 state.polarity = polarity;
206 ret = pwm_apply_state(pwm, &state);
Boris BREZILLON459a25a2016-03-30 22:03:27 +0200207 mutex_unlock(&export->lock);
H Hartley Sweeten76abbdde2013-06-11 10:38:59 -0700208
209 return ret ? : size;
210}
211
Lee Jones1a366fe2016-06-08 10:21:25 +0100212static ssize_t capture_show(struct device *child,
213 struct device_attribute *attr,
214 char *buf)
215{
216 struct pwm_device *pwm = child_to_pwm_device(child);
217 struct pwm_capture result;
218 int ret;
219
220 ret = pwm_capture(pwm, &result, jiffies_to_msecs(HZ));
221 if (ret)
222 return ret;
223
224 return sprintf(buf, "%u %u\n", result.period, result.duty_cycle);
225}
226
Olliver Schinagl65cdc692015-10-26 22:32:37 +0100227static DEVICE_ATTR_RW(period);
228static DEVICE_ATTR_RW(duty_cycle);
229static DEVICE_ATTR_RW(enable);
230static DEVICE_ATTR_RW(polarity);
Lee Jones1a366fe2016-06-08 10:21:25 +0100231static DEVICE_ATTR_RO(capture);
H Hartley Sweeten76abbdde2013-06-11 10:38:59 -0700232
233static struct attribute *pwm_attrs[] = {
234 &dev_attr_period.attr,
235 &dev_attr_duty_cycle.attr,
236 &dev_attr_enable.attr,
237 &dev_attr_polarity.attr,
Lee Jones1a366fe2016-06-08 10:21:25 +0100238 &dev_attr_capture.attr,
H Hartley Sweeten76abbdde2013-06-11 10:38:59 -0700239 NULL
240};
Axel Lin6ca142a2013-12-04 18:29:53 +0800241ATTRIBUTE_GROUPS(pwm);
H Hartley Sweeten76abbdde2013-06-11 10:38:59 -0700242
243static void pwm_export_release(struct device *child)
244{
245 struct pwm_export *export = child_to_pwm_export(child);
246
247 kfree(export);
248}
249
250static int pwm_export_child(struct device *parent, struct pwm_device *pwm)
251{
252 struct pwm_export *export;
Fabrice Gasnier552c02e2018-10-01 15:23:57 +0200253 char *pwm_prop[2];
H Hartley Sweeten76abbdde2013-06-11 10:38:59 -0700254 int ret;
255
256 if (test_and_set_bit(PWMF_EXPORTED, &pwm->flags))
257 return -EBUSY;
258
259 export = kzalloc(sizeof(*export), GFP_KERNEL);
260 if (!export) {
261 clear_bit(PWMF_EXPORTED, &pwm->flags);
262 return -ENOMEM;
263 }
264
265 export->pwm = pwm;
Boris BREZILLON459a25a2016-03-30 22:03:27 +0200266 mutex_init(&export->lock);
H Hartley Sweeten76abbdde2013-06-11 10:38:59 -0700267
268 export->child.release = pwm_export_release;
269 export->child.parent = parent;
270 export->child.devt = MKDEV(0, 0);
Axel Lin6ca142a2013-12-04 18:29:53 +0800271 export->child.groups = pwm_groups;
H Hartley Sweeten76abbdde2013-06-11 10:38:59 -0700272 dev_set_name(&export->child, "pwm%u", pwm->hwpwm);
273
274 ret = device_register(&export->child);
275 if (ret) {
276 clear_bit(PWMF_EXPORTED, &pwm->flags);
Arvind Yadav8bbf5b42018-03-08 15:27:37 +0530277 put_device(&export->child);
278 export = NULL;
H Hartley Sweeten76abbdde2013-06-11 10:38:59 -0700279 return ret;
280 }
Fabrice Gasnier552c02e2018-10-01 15:23:57 +0200281 pwm_prop[0] = kasprintf(GFP_KERNEL, "EXPORT=pwm%u", pwm->hwpwm);
282 pwm_prop[1] = NULL;
283 kobject_uevent_env(&parent->kobj, KOBJ_CHANGE, pwm_prop);
284 kfree(pwm_prop[0]);
H Hartley Sweeten76abbdde2013-06-11 10:38:59 -0700285
286 return 0;
287}
288
289static int pwm_unexport_match(struct device *child, void *data)
290{
291 return child_to_pwm_device(child) == data;
292}
293
294static int pwm_unexport_child(struct device *parent, struct pwm_device *pwm)
295{
296 struct device *child;
Fabrice Gasnier552c02e2018-10-01 15:23:57 +0200297 char *pwm_prop[2];
H Hartley Sweeten76abbdde2013-06-11 10:38:59 -0700298
299 if (!test_and_clear_bit(PWMF_EXPORTED, &pwm->flags))
300 return -ENODEV;
301
302 child = device_find_child(parent, pwm, pwm_unexport_match);
303 if (!child)
304 return -ENODEV;
305
Fabrice Gasnier552c02e2018-10-01 15:23:57 +0200306 pwm_prop[0] = kasprintf(GFP_KERNEL, "UNEXPORT=pwm%u", pwm->hwpwm);
307 pwm_prop[1] = NULL;
308 kobject_uevent_env(&parent->kobj, KOBJ_CHANGE, pwm_prop);
309 kfree(pwm_prop[0]);
310
H Hartley Sweeten76abbdde2013-06-11 10:38:59 -0700311 /* for device_find_child() */
312 put_device(child);
313 device_unregister(child);
314 pwm_put(pwm);
315
316 return 0;
317}
318
Olliver Schinagl65cdc692015-10-26 22:32:37 +0100319static ssize_t export_store(struct device *parent,
320 struct device_attribute *attr,
321 const char *buf, size_t len)
H Hartley Sweeten76abbdde2013-06-11 10:38:59 -0700322{
323 struct pwm_chip *chip = dev_get_drvdata(parent);
324 struct pwm_device *pwm;
325 unsigned int hwpwm;
326 int ret;
327
328 ret = kstrtouint(buf, 0, &hwpwm);
329 if (ret < 0)
330 return ret;
331
332 if (hwpwm >= chip->npwm)
333 return -ENODEV;
334
335 pwm = pwm_request_from_chip(chip, hwpwm, "sysfs");
336 if (IS_ERR(pwm))
337 return PTR_ERR(pwm);
338
339 ret = pwm_export_child(parent, pwm);
340 if (ret < 0)
341 pwm_put(pwm);
342
343 return ret ? : len;
344}
Olliver Schinagl65cdc692015-10-26 22:32:37 +0100345static DEVICE_ATTR_WO(export);
H Hartley Sweeten76abbdde2013-06-11 10:38:59 -0700346
Olliver Schinagl65cdc692015-10-26 22:32:37 +0100347static ssize_t unexport_store(struct device *parent,
348 struct device_attribute *attr,
349 const char *buf, size_t len)
H Hartley Sweeten76abbdde2013-06-11 10:38:59 -0700350{
351 struct pwm_chip *chip = dev_get_drvdata(parent);
352 unsigned int hwpwm;
353 int ret;
354
355 ret = kstrtouint(buf, 0, &hwpwm);
356 if (ret < 0)
357 return ret;
358
359 if (hwpwm >= chip->npwm)
360 return -ENODEV;
361
362 ret = pwm_unexport_child(parent, &chip->pwms[hwpwm]);
363
364 return ret ? : len;
365}
Olliver Schinagl65cdc692015-10-26 22:32:37 +0100366static DEVICE_ATTR_WO(unexport);
H Hartley Sweeten76abbdde2013-06-11 10:38:59 -0700367
Greg Kroah-Hartman9da01752013-07-24 15:05:39 -0700368static ssize_t npwm_show(struct device *parent, struct device_attribute *attr,
369 char *buf)
H Hartley Sweeten76abbdde2013-06-11 10:38:59 -0700370{
371 const struct pwm_chip *chip = dev_get_drvdata(parent);
372
373 return sprintf(buf, "%u\n", chip->npwm);
374}
Greg Kroah-Hartman9da01752013-07-24 15:05:39 -0700375static DEVICE_ATTR_RO(npwm);
H Hartley Sweeten76abbdde2013-06-11 10:38:59 -0700376
Greg Kroah-Hartman9da01752013-07-24 15:05:39 -0700377static struct attribute *pwm_chip_attrs[] = {
378 &dev_attr_export.attr,
379 &dev_attr_unexport.attr,
380 &dev_attr_npwm.attr,
381 NULL,
H Hartley Sweeten76abbdde2013-06-11 10:38:59 -0700382};
Greg Kroah-Hartman9da01752013-07-24 15:05:39 -0700383ATTRIBUTE_GROUPS(pwm_chip);
H Hartley Sweeten76abbdde2013-06-11 10:38:59 -0700384
Yoshihiro Shimoda7fd4edc2019-05-31 18:55:00 +0900385/* takes export->lock on success */
386static struct pwm_export *pwm_class_get_state(struct device *parent,
387 struct pwm_device *pwm,
388 struct pwm_state *state)
389{
390 struct device *child;
391 struct pwm_export *export;
392
393 if (!test_bit(PWMF_EXPORTED, &pwm->flags))
394 return NULL;
395
396 child = device_find_child(parent, pwm, pwm_unexport_match);
397 if (!child)
398 return NULL;
399
400 export = child_to_pwm_export(child);
401 put_device(child); /* for device_find_child() */
402
403 mutex_lock(&export->lock);
404 pwm_get_state(pwm, state);
405
406 return export;
407}
408
409static int pwm_class_apply_state(struct pwm_export *export,
410 struct pwm_device *pwm,
411 struct pwm_state *state)
412{
413 int ret = pwm_apply_state(pwm, state);
414
415 /* release lock taken in pwm_class_get_state */
416 mutex_unlock(&export->lock);
417
418 return ret;
419}
420
421static int pwm_class_resume_npwm(struct device *parent, unsigned int npwm)
422{
423 struct pwm_chip *chip = dev_get_drvdata(parent);
424 unsigned int i;
425 int ret = 0;
426
427 for (i = 0; i < npwm; i++) {
428 struct pwm_device *pwm = &chip->pwms[i];
429 struct pwm_state state;
430 struct pwm_export *export;
431
432 export = pwm_class_get_state(parent, pwm, &state);
433 if (!export)
434 continue;
435
436 state.enabled = export->suspend.enabled;
437 ret = pwm_class_apply_state(export, pwm, &state);
438 if (ret < 0)
439 break;
440 }
441
442 return ret;
443}
444
445static int __maybe_unused pwm_class_suspend(struct device *parent)
446{
447 struct pwm_chip *chip = dev_get_drvdata(parent);
448 unsigned int i;
449 int ret = 0;
450
451 for (i = 0; i < chip->npwm; i++) {
452 struct pwm_device *pwm = &chip->pwms[i];
453 struct pwm_state state;
454 struct pwm_export *export;
455
456 export = pwm_class_get_state(parent, pwm, &state);
457 if (!export)
458 continue;
459
460 export->suspend = state;
461 state.enabled = false;
462 ret = pwm_class_apply_state(export, pwm, &state);
463 if (ret < 0) {
464 /*
465 * roll back the PWM devices that were disabled by
466 * this suspend function.
467 */
468 pwm_class_resume_npwm(parent, i);
469 break;
470 }
471 }
472
473 return ret;
474}
475
476static int __maybe_unused pwm_class_resume(struct device *parent)
477{
478 struct pwm_chip *chip = dev_get_drvdata(parent);
479
480 return pwm_class_resume_npwm(parent, chip->npwm);
481}
482
483static SIMPLE_DEV_PM_OPS(pwm_class_pm_ops, pwm_class_suspend, pwm_class_resume);
484
H Hartley Sweeten76abbdde2013-06-11 10:38:59 -0700485static struct class pwm_class = {
Thierry Reding412820d2015-07-20 09:58:09 +0200486 .name = "pwm",
487 .owner = THIS_MODULE,
488 .dev_groups = pwm_chip_groups,
Yoshihiro Shimoda7fd4edc2019-05-31 18:55:00 +0900489 .pm = &pwm_class_pm_ops,
H Hartley Sweeten76abbdde2013-06-11 10:38:59 -0700490};
491
492static int pwmchip_sysfs_match(struct device *parent, const void *data)
493{
494 return dev_get_drvdata(parent) == data;
495}
496
497void pwmchip_sysfs_export(struct pwm_chip *chip)
498{
499 struct device *parent;
500
501 /*
502 * If device_create() fails the pwm_chip is still usable by
Uwe Kleine-König9ff06672019-03-12 10:25:47 +0100503 * the kernel it's just not exported.
H Hartley Sweeten76abbdde2013-06-11 10:38:59 -0700504 */
505 parent = device_create(&pwm_class, chip->dev, MKDEV(0, 0), chip,
506 "pwmchip%d", chip->base);
507 if (IS_ERR(parent)) {
508 dev_warn(chip->dev,
509 "device_create failed for pwm_chip sysfs export\n");
510 }
511}
512
513void pwmchip_sysfs_unexport(struct pwm_chip *chip)
514{
515 struct device *parent;
David Hsu07334242016-08-09 14:57:46 -0700516 unsigned int i;
517
518 parent = class_find_device(&pwm_class, NULL, chip,
519 pwmchip_sysfs_match);
520 if (!parent)
521 return;
522
523 for (i = 0; i < chip->npwm; i++) {
524 struct pwm_device *pwm = &chip->pwms[i];
525
526 if (test_bit(PWMF_EXPORTED, &pwm->flags))
527 pwm_unexport_child(parent, pwm);
528 }
Johan Hovold0e1614a2016-11-01 11:46:39 +0100529
530 put_device(parent);
Phong Hoang347ab942019-03-19 19:40:08 +0900531 device_unregister(parent);
David Hsu07334242016-08-09 14:57:46 -0700532}
533
H Hartley Sweeten76abbdde2013-06-11 10:38:59 -0700534static int __init pwm_sysfs_init(void)
535{
536 return class_register(&pwm_class);
537}
538subsys_initcall(pwm_sysfs_init);