• Home
  • Raw
  • Download

Lines Matching +full:parent +full:- +full:child

27 	struct device child;  member
32 static struct pwm_export *child_to_pwm_export(struct device *child) in child_to_pwm_export() argument
34 return container_of(child, struct pwm_export, child); in child_to_pwm_export()
37 static struct pwm_device *child_to_pwm_device(struct device *child) in child_to_pwm_device() argument
39 struct pwm_export *export = child_to_pwm_export(child); in child_to_pwm_device()
41 return export->pwm; in child_to_pwm_device()
44 static ssize_t period_show(struct device *child, in period_show() argument
48 const struct pwm_device *pwm = child_to_pwm_device(child); in period_show()
56 static ssize_t period_store(struct device *child, in period_store() argument
60 struct pwm_export *export = child_to_pwm_export(child); in period_store()
61 struct pwm_device *pwm = export->pwm; in period_store()
70 mutex_lock(&export->lock); in period_store()
74 mutex_unlock(&export->lock); in period_store()
79 static ssize_t duty_cycle_show(struct device *child, in duty_cycle_show() argument
83 const struct pwm_device *pwm = child_to_pwm_device(child); in duty_cycle_show()
91 static ssize_t duty_cycle_store(struct device *child, in duty_cycle_store() argument
95 struct pwm_export *export = child_to_pwm_export(child); in duty_cycle_store()
96 struct pwm_device *pwm = export->pwm; in duty_cycle_store()
105 mutex_lock(&export->lock); in duty_cycle_store()
109 mutex_unlock(&export->lock); in duty_cycle_store()
114 static ssize_t enable_show(struct device *child, in enable_show() argument
118 const struct pwm_device *pwm = child_to_pwm_device(child); in enable_show()
126 static ssize_t enable_store(struct device *child, in enable_store() argument
130 struct pwm_export *export = child_to_pwm_export(child); in enable_store()
131 struct pwm_device *pwm = export->pwm; in enable_store()
139 mutex_lock(&export->lock); in enable_store()
151 ret = -EINVAL; in enable_store()
158 mutex_unlock(&export->lock); in enable_store()
162 static ssize_t polarity_show(struct device *child, in polarity_show() argument
166 const struct pwm_device *pwm = child_to_pwm_device(child); in polarity_show()
185 static ssize_t polarity_store(struct device *child, in polarity_store() argument
189 struct pwm_export *export = child_to_pwm_export(child); in polarity_store()
190 struct pwm_device *pwm = export->pwm; in polarity_store()
200 return -EINVAL; in polarity_store()
202 mutex_lock(&export->lock); in polarity_store()
206 mutex_unlock(&export->lock); in polarity_store()
211 static ssize_t capture_show(struct device *child, in capture_show() argument
215 struct pwm_device *pwm = child_to_pwm_device(child); in capture_show()
242 static void pwm_export_release(struct device *child) in pwm_export_release() argument
244 struct pwm_export *export = child_to_pwm_export(child); in pwm_export_release()
249 static int pwm_export_child(struct device *parent, struct pwm_device *pwm) in pwm_export_child() argument
254 if (test_and_set_bit(PWMF_EXPORTED, &pwm->flags)) in pwm_export_child()
255 return -EBUSY; in pwm_export_child()
259 clear_bit(PWMF_EXPORTED, &pwm->flags); in pwm_export_child()
260 return -ENOMEM; in pwm_export_child()
263 export->pwm = pwm; in pwm_export_child()
264 mutex_init(&export->lock); in pwm_export_child()
266 export->child.release = pwm_export_release; in pwm_export_child()
267 export->child.parent = parent; in pwm_export_child()
268 export->child.devt = MKDEV(0, 0); in pwm_export_child()
269 export->child.groups = pwm_groups; in pwm_export_child()
270 dev_set_name(&export->child, "pwm%u", pwm->hwpwm); in pwm_export_child()
272 ret = device_register(&export->child); in pwm_export_child()
274 clear_bit(PWMF_EXPORTED, &pwm->flags); in pwm_export_child()
275 put_device(&export->child); in pwm_export_child()
283 static int pwm_unexport_match(struct device *child, void *data) in pwm_unexport_match() argument
285 return child_to_pwm_device(child) == data; in pwm_unexport_match()
288 static int pwm_unexport_child(struct device *parent, struct pwm_device *pwm) in pwm_unexport_child() argument
290 struct device *child; in pwm_unexport_child() local
292 if (!test_and_clear_bit(PWMF_EXPORTED, &pwm->flags)) in pwm_unexport_child()
293 return -ENODEV; in pwm_unexport_child()
295 child = device_find_child(parent, pwm, pwm_unexport_match); in pwm_unexport_child()
296 if (!child) in pwm_unexport_child()
297 return -ENODEV; in pwm_unexport_child()
300 put_device(child); in pwm_unexport_child()
301 device_unregister(child); in pwm_unexport_child()
307 static ssize_t export_store(struct device *parent, in export_store() argument
311 struct pwm_chip *chip = dev_get_drvdata(parent); in export_store()
320 if (hwpwm >= chip->npwm) in export_store()
321 return -ENODEV; in export_store()
327 ret = pwm_export_child(parent, pwm); in export_store()
335 static ssize_t unexport_store(struct device *parent, in unexport_store() argument
339 struct pwm_chip *chip = dev_get_drvdata(parent); in unexport_store()
347 if (hwpwm >= chip->npwm) in unexport_store()
348 return -ENODEV; in unexport_store()
350 ret = pwm_unexport_child(parent, &chip->pwms[hwpwm]); in unexport_store()
356 static ssize_t npwm_show(struct device *parent, struct device_attribute *attr, in npwm_show() argument
359 const struct pwm_chip *chip = dev_get_drvdata(parent); in npwm_show()
361 return sprintf(buf, "%u\n", chip->npwm); in npwm_show()
379 static int pwmchip_sysfs_match(struct device *parent, const void *data) in pwmchip_sysfs_match() argument
381 return dev_get_drvdata(parent) == data; in pwmchip_sysfs_match()
386 struct device *parent; in pwmchip_sysfs_export() local
392 parent = device_create(&pwm_class, chip->dev, MKDEV(0, 0), chip, in pwmchip_sysfs_export()
393 "pwmchip%d", chip->base); in pwmchip_sysfs_export()
394 if (IS_ERR(parent)) { in pwmchip_sysfs_export()
395 dev_warn(chip->dev, in pwmchip_sysfs_export()
402 struct device *parent; in pwmchip_sysfs_unexport() local
405 parent = class_find_device(&pwm_class, NULL, chip, in pwmchip_sysfs_unexport()
407 if (!parent) in pwmchip_sysfs_unexport()
410 for (i = 0; i < chip->npwm; i++) { in pwmchip_sysfs_unexport()
411 struct pwm_device *pwm = &chip->pwms[i]; in pwmchip_sysfs_unexport()
413 if (test_bit(PWMF_EXPORTED, &pwm->flags)) in pwmchip_sysfs_unexport()
414 pwm_unexport_child(parent, pwm); in pwmchip_sysfs_unexport()
417 put_device(parent); in pwmchip_sysfs_unexport()
418 device_unregister(parent); in pwmchip_sysfs_unexport()