Lines Matching +full:max +full:- +full:msg

1 // SPDX-License-Identifier: GPL-2.0
30 return (struct dpll_dump_ctx *)cb->ctx; in dpll_dump_context()
34 dpll_msg_add_dev_handle(struct sk_buff *msg, struct dpll_device *dpll) in dpll_msg_add_dev_handle() argument
36 if (nla_put_u32(msg, DPLL_A_ID, dpll->id)) in dpll_msg_add_dev_handle()
37 return -EMSGSIZE; in dpll_msg_add_dev_handle()
43 dpll_msg_add_dev_parent_handle(struct sk_buff *msg, u32 id) in dpll_msg_add_dev_parent_handle() argument
45 if (nla_put_u32(msg, DPLL_A_PIN_PARENT_ID, id)) in dpll_msg_add_dev_parent_handle()
46 return -EMSGSIZE; in dpll_msg_add_dev_parent_handle()
52 * dpll_msg_add_pin_handle - attach pin handle attribute to a given message
53 * @msg: pointer to sk_buff message to attach a pin handle
57 * * 0 - success
58 * * -EMSGSIZE - no space in message to attach pin handle
60 static int dpll_msg_add_pin_handle(struct sk_buff *msg, struct dpll_pin *pin) in dpll_msg_add_pin_handle() argument
64 if (nla_put_u32(msg, DPLL_A_PIN_ID, pin->id)) in dpll_msg_add_pin_handle()
65 return -EMSGSIZE; in dpll_msg_add_pin_handle()
71 return rcu_dereference_rtnl(dev->dpll_pin); in dpll_netdev_pin()
75 * dpll_netdev_pin_handle_size - get size of pin handle attribute of a netdev
85 int dpll_netdev_add_pin_handle(struct sk_buff *msg, in dpll_netdev_add_pin_handle() argument
88 return dpll_msg_add_pin_handle(msg, dpll_netdev_pin(dev)); in dpll_netdev_add_pin_handle()
92 dpll_msg_add_mode(struct sk_buff *msg, struct dpll_device *dpll, in dpll_msg_add_mode() argument
99 ret = ops->mode_get(dpll, dpll_priv(dpll), &mode, extack); in dpll_msg_add_mode()
102 if (nla_put_u32(msg, DPLL_A_MODE, mode)) in dpll_msg_add_mode()
103 return -EMSGSIZE; in dpll_msg_add_mode()
109 dpll_msg_add_mode_supported(struct sk_buff *msg, struct dpll_device *dpll, in dpll_msg_add_mode_supported() argument
120 ret = ops->mode_get(dpll, dpll_priv(dpll), &mode, extack); in dpll_msg_add_mode_supported()
123 if (nla_put_u32(msg, DPLL_A_MODE_SUPPORTED, mode)) in dpll_msg_add_mode_supported()
124 return -EMSGSIZE; in dpll_msg_add_mode_supported()
130 dpll_msg_add_lock_status(struct sk_buff *msg, struct dpll_device *dpll, in dpll_msg_add_lock_status() argument
138 ret = ops->lock_status_get(dpll, dpll_priv(dpll), &status, in dpll_msg_add_lock_status()
142 if (nla_put_u32(msg, DPLL_A_LOCK_STATUS, status)) in dpll_msg_add_lock_status()
143 return -EMSGSIZE; in dpll_msg_add_lock_status()
147 nla_put_u32(msg, DPLL_A_LOCK_STATUS_ERROR, status_error)) in dpll_msg_add_lock_status()
148 return -EMSGSIZE; in dpll_msg_add_lock_status()
154 dpll_msg_add_temp(struct sk_buff *msg, struct dpll_device *dpll, in dpll_msg_add_temp() argument
161 if (!ops->temp_get) in dpll_msg_add_temp()
163 ret = ops->temp_get(dpll, dpll_priv(dpll), &temp, extack); in dpll_msg_add_temp()
166 if (nla_put_s32(msg, DPLL_A_TEMP, temp)) in dpll_msg_add_temp()
167 return -EMSGSIZE; in dpll_msg_add_temp()
173 dpll_msg_add_clock_quality_level(struct sk_buff *msg, struct dpll_device *dpll, in dpll_msg_add_clock_quality_level() argument
181 if (!ops->clock_quality_level_get) in dpll_msg_add_clock_quality_level()
183 ret = ops->clock_quality_level_get(dpll, dpll_priv(dpll), qls, extack); in dpll_msg_add_clock_quality_level()
187 if (nla_put_u32(msg, DPLL_A_CLOCK_QUALITY_LEVEL, ql)) in dpll_msg_add_clock_quality_level()
188 return -EMSGSIZE; in dpll_msg_add_clock_quality_level()
194 dpll_msg_add_pin_prio(struct sk_buff *msg, struct dpll_pin *pin, in dpll_msg_add_pin_prio() argument
199 struct dpll_device *dpll = ref->dpll; in dpll_msg_add_pin_prio()
203 if (!ops->prio_get) in dpll_msg_add_pin_prio()
205 ret = ops->prio_get(pin, dpll_pin_on_dpll_priv(dpll, pin), dpll, in dpll_msg_add_pin_prio()
209 if (nla_put_u32(msg, DPLL_A_PIN_PRIO, prio)) in dpll_msg_add_pin_prio()
210 return -EMSGSIZE; in dpll_msg_add_pin_prio()
216 dpll_msg_add_pin_on_dpll_state(struct sk_buff *msg, struct dpll_pin *pin, in dpll_msg_add_pin_on_dpll_state() argument
221 struct dpll_device *dpll = ref->dpll; in dpll_msg_add_pin_on_dpll_state()
225 if (!ops->state_on_dpll_get) in dpll_msg_add_pin_on_dpll_state()
227 ret = ops->state_on_dpll_get(pin, dpll_pin_on_dpll_priv(dpll, pin), in dpll_msg_add_pin_on_dpll_state()
231 if (nla_put_u32(msg, DPLL_A_PIN_STATE, state)) in dpll_msg_add_pin_on_dpll_state()
232 return -EMSGSIZE; in dpll_msg_add_pin_on_dpll_state()
238 dpll_msg_add_pin_direction(struct sk_buff *msg, struct dpll_pin *pin, in dpll_msg_add_pin_direction() argument
243 struct dpll_device *dpll = ref->dpll; in dpll_msg_add_pin_direction()
247 ret = ops->direction_get(pin, dpll_pin_on_dpll_priv(dpll, pin), dpll, in dpll_msg_add_pin_direction()
251 if (nla_put_u32(msg, DPLL_A_PIN_DIRECTION, direction)) in dpll_msg_add_pin_direction()
252 return -EMSGSIZE; in dpll_msg_add_pin_direction()
258 dpll_msg_add_pin_phase_adjust(struct sk_buff *msg, struct dpll_pin *pin, in dpll_msg_add_pin_phase_adjust() argument
263 struct dpll_device *dpll = ref->dpll; in dpll_msg_add_pin_phase_adjust()
267 if (!ops->phase_adjust_get) in dpll_msg_add_pin_phase_adjust()
269 ret = ops->phase_adjust_get(pin, dpll_pin_on_dpll_priv(dpll, pin), in dpll_msg_add_pin_phase_adjust()
274 if (nla_put_s32(msg, DPLL_A_PIN_PHASE_ADJUST, phase_adjust)) in dpll_msg_add_pin_phase_adjust()
275 return -EMSGSIZE; in dpll_msg_add_pin_phase_adjust()
281 dpll_msg_add_phase_offset(struct sk_buff *msg, struct dpll_pin *pin, in dpll_msg_add_phase_offset() argument
286 struct dpll_device *dpll = ref->dpll; in dpll_msg_add_phase_offset()
290 if (!ops->phase_offset_get) in dpll_msg_add_phase_offset()
292 ret = ops->phase_offset_get(pin, dpll_pin_on_dpll_priv(dpll, pin), in dpll_msg_add_phase_offset()
297 if (nla_put_64bit(msg, DPLL_A_PIN_PHASE_OFFSET, sizeof(phase_offset), in dpll_msg_add_phase_offset()
299 return -EMSGSIZE; in dpll_msg_add_phase_offset()
304 static int dpll_msg_add_ffo(struct sk_buff *msg, struct dpll_pin *pin, in dpll_msg_add_ffo() argument
309 struct dpll_device *dpll = ref->dpll; in dpll_msg_add_ffo()
313 if (!ops->ffo_get) in dpll_msg_add_ffo()
315 ret = ops->ffo_get(pin, dpll_pin_on_dpll_priv(dpll, pin), in dpll_msg_add_ffo()
318 if (ret == -ENODATA) in dpll_msg_add_ffo()
322 return nla_put_sint(msg, DPLL_A_PIN_FRACTIONAL_FREQUENCY_OFFSET, ffo); in dpll_msg_add_ffo()
326 dpll_msg_add_pin_freq(struct sk_buff *msg, struct dpll_pin *pin, in dpll_msg_add_pin_freq() argument
330 struct dpll_device *dpll = ref->dpll; in dpll_msg_add_pin_freq()
335 if (!ops->frequency_get) in dpll_msg_add_pin_freq()
337 ret = ops->frequency_get(pin, dpll_pin_on_dpll_priv(dpll, pin), dpll, in dpll_msg_add_pin_freq()
341 if (nla_put_64bit(msg, DPLL_A_PIN_FREQUENCY, sizeof(freq), &freq, in dpll_msg_add_pin_freq()
343 return -EMSGSIZE; in dpll_msg_add_pin_freq()
344 for (fs = 0; fs < pin->prop.freq_supported_num; fs++) { in dpll_msg_add_pin_freq()
345 nest = nla_nest_start(msg, DPLL_A_PIN_FREQUENCY_SUPPORTED); in dpll_msg_add_pin_freq()
347 return -EMSGSIZE; in dpll_msg_add_pin_freq()
348 freq = pin->prop.freq_supported[fs].min; in dpll_msg_add_pin_freq()
349 if (nla_put_64bit(msg, DPLL_A_PIN_FREQUENCY_MIN, sizeof(freq), in dpll_msg_add_pin_freq()
351 nla_nest_cancel(msg, nest); in dpll_msg_add_pin_freq()
352 return -EMSGSIZE; in dpll_msg_add_pin_freq()
354 freq = pin->prop.freq_supported[fs].max; in dpll_msg_add_pin_freq()
355 if (nla_put_64bit(msg, DPLL_A_PIN_FREQUENCY_MAX, sizeof(freq), in dpll_msg_add_pin_freq()
357 nla_nest_cancel(msg, nest); in dpll_msg_add_pin_freq()
358 return -EMSGSIZE; in dpll_msg_add_pin_freq()
360 nla_nest_end(msg, nest); in dpll_msg_add_pin_freq()
367 dpll_msg_add_pin_esync(struct sk_buff *msg, struct dpll_pin *pin, in dpll_msg_add_pin_esync() argument
371 struct dpll_device *dpll = ref->dpll; in dpll_msg_add_pin_esync()
376 if (!ops->esync_get) in dpll_msg_add_pin_esync()
378 ret = ops->esync_get(pin, dpll_pin_on_dpll_priv(dpll, pin), dpll, in dpll_msg_add_pin_esync()
380 if (ret == -EOPNOTSUPP) in dpll_msg_add_pin_esync()
384 if (nla_put_64bit(msg, DPLL_A_PIN_ESYNC_FREQUENCY, sizeof(esync.freq), in dpll_msg_add_pin_esync()
386 return -EMSGSIZE; in dpll_msg_add_pin_esync()
387 if (nla_put_u32(msg, DPLL_A_PIN_ESYNC_PULSE, esync.pulse)) in dpll_msg_add_pin_esync()
388 return -EMSGSIZE; in dpll_msg_add_pin_esync()
390 nest = nla_nest_start(msg, in dpll_msg_add_pin_esync()
393 return -EMSGSIZE; in dpll_msg_add_pin_esync()
394 if (nla_put_64bit(msg, DPLL_A_PIN_FREQUENCY_MIN, in dpll_msg_add_pin_esync()
398 if (nla_put_64bit(msg, DPLL_A_PIN_FREQUENCY_MAX, in dpll_msg_add_pin_esync()
399 sizeof(esync.range[i].max), in dpll_msg_add_pin_esync()
400 &esync.range[i].max, DPLL_A_PIN_PAD)) in dpll_msg_add_pin_esync()
402 nla_nest_end(msg, nest); in dpll_msg_add_pin_esync()
407 nla_nest_cancel(msg, nest); in dpll_msg_add_pin_esync()
408 return -EMSGSIZE; in dpll_msg_add_pin_esync()
415 for (fs = 0; fs < pin->prop.freq_supported_num; fs++) in dpll_pin_is_freq_supported()
416 if (freq >= pin->prop.freq_supported[fs].min && in dpll_pin_is_freq_supported()
417 freq <= pin->prop.freq_supported[fs].max) in dpll_pin_is_freq_supported()
423 dpll_msg_add_pin_parents(struct sk_buff *msg, struct dpll_pin *pin, in dpll_msg_add_pin_parents() argument
434 xa_for_each(&pin->parent_refs, index, ref) { in dpll_msg_add_pin_parents()
438 ppin = ref->pin; in dpll_msg_add_pin_parents()
439 parent_priv = dpll_pin_on_dpll_priv(dpll_ref->dpll, ppin); in dpll_msg_add_pin_parents()
440 ret = ops->state_on_pin_get(pin, in dpll_msg_add_pin_parents()
445 nest = nla_nest_start(msg, DPLL_A_PIN_PARENT_PIN); in dpll_msg_add_pin_parents()
447 return -EMSGSIZE; in dpll_msg_add_pin_parents()
448 ret = dpll_msg_add_dev_parent_handle(msg, ppin->id); in dpll_msg_add_pin_parents()
451 if (nla_put_u32(msg, DPLL_A_PIN_STATE, state)) { in dpll_msg_add_pin_parents()
452 ret = -EMSGSIZE; in dpll_msg_add_pin_parents()
455 nla_nest_end(msg, nest); in dpll_msg_add_pin_parents()
461 nla_nest_cancel(msg, nest); in dpll_msg_add_pin_parents()
466 dpll_msg_add_pin_dplls(struct sk_buff *msg, struct dpll_pin *pin, in dpll_msg_add_pin_dplls() argument
474 xa_for_each(&pin->dpll_refs, index, ref) { in dpll_msg_add_pin_dplls()
475 attr = nla_nest_start(msg, DPLL_A_PIN_PARENT_DEVICE); in dpll_msg_add_pin_dplls()
477 return -EMSGSIZE; in dpll_msg_add_pin_dplls()
478 ret = dpll_msg_add_dev_parent_handle(msg, ref->dpll->id); in dpll_msg_add_pin_dplls()
481 ret = dpll_msg_add_pin_on_dpll_state(msg, pin, ref, extack); in dpll_msg_add_pin_dplls()
484 ret = dpll_msg_add_pin_prio(msg, pin, ref, extack); in dpll_msg_add_pin_dplls()
487 ret = dpll_msg_add_pin_direction(msg, pin, ref, extack); in dpll_msg_add_pin_dplls()
490 ret = dpll_msg_add_phase_offset(msg, pin, ref, extack); in dpll_msg_add_pin_dplls()
493 nla_nest_end(msg, attr); in dpll_msg_add_pin_dplls()
499 nla_nest_end(msg, attr); in dpll_msg_add_pin_dplls()
504 dpll_cmd_pin_get_one(struct sk_buff *msg, struct dpll_pin *pin, in dpll_cmd_pin_get_one() argument
507 const struct dpll_pin_properties *prop = &pin->prop; in dpll_cmd_pin_get_one()
511 ref = dpll_xa_ref_dpll_first(&pin->dpll_refs); in dpll_cmd_pin_get_one()
514 ret = dpll_msg_add_pin_handle(msg, pin); in dpll_cmd_pin_get_one()
517 if (nla_put_string(msg, DPLL_A_PIN_MODULE_NAME, in dpll_cmd_pin_get_one()
518 module_name(pin->module))) in dpll_cmd_pin_get_one()
519 return -EMSGSIZE; in dpll_cmd_pin_get_one()
520 if (nla_put_64bit(msg, DPLL_A_PIN_CLOCK_ID, sizeof(pin->clock_id), in dpll_cmd_pin_get_one()
521 &pin->clock_id, DPLL_A_PIN_PAD)) in dpll_cmd_pin_get_one()
522 return -EMSGSIZE; in dpll_cmd_pin_get_one()
523 if (prop->board_label && in dpll_cmd_pin_get_one()
524 nla_put_string(msg, DPLL_A_PIN_BOARD_LABEL, prop->board_label)) in dpll_cmd_pin_get_one()
525 return -EMSGSIZE; in dpll_cmd_pin_get_one()
526 if (prop->panel_label && in dpll_cmd_pin_get_one()
527 nla_put_string(msg, DPLL_A_PIN_PANEL_LABEL, prop->panel_label)) in dpll_cmd_pin_get_one()
528 return -EMSGSIZE; in dpll_cmd_pin_get_one()
529 if (prop->package_label && in dpll_cmd_pin_get_one()
530 nla_put_string(msg, DPLL_A_PIN_PACKAGE_LABEL, in dpll_cmd_pin_get_one()
531 prop->package_label)) in dpll_cmd_pin_get_one()
532 return -EMSGSIZE; in dpll_cmd_pin_get_one()
533 if (nla_put_u32(msg, DPLL_A_PIN_TYPE, prop->type)) in dpll_cmd_pin_get_one()
534 return -EMSGSIZE; in dpll_cmd_pin_get_one()
535 if (nla_put_u32(msg, DPLL_A_PIN_CAPABILITIES, prop->capabilities)) in dpll_cmd_pin_get_one()
536 return -EMSGSIZE; in dpll_cmd_pin_get_one()
537 ret = dpll_msg_add_pin_freq(msg, pin, ref, extack); in dpll_cmd_pin_get_one()
540 if (nla_put_s32(msg, DPLL_A_PIN_PHASE_ADJUST_MIN, in dpll_cmd_pin_get_one()
541 prop->phase_range.min)) in dpll_cmd_pin_get_one()
542 return -EMSGSIZE; in dpll_cmd_pin_get_one()
543 if (nla_put_s32(msg, DPLL_A_PIN_PHASE_ADJUST_MAX, in dpll_cmd_pin_get_one()
544 prop->phase_range.max)) in dpll_cmd_pin_get_one()
545 return -EMSGSIZE; in dpll_cmd_pin_get_one()
546 ret = dpll_msg_add_pin_phase_adjust(msg, pin, ref, extack); in dpll_cmd_pin_get_one()
549 ret = dpll_msg_add_ffo(msg, pin, ref, extack); in dpll_cmd_pin_get_one()
552 ret = dpll_msg_add_pin_esync(msg, pin, ref, extack); in dpll_cmd_pin_get_one()
555 if (xa_empty(&pin->parent_refs)) in dpll_cmd_pin_get_one()
556 ret = dpll_msg_add_pin_dplls(msg, pin, extack); in dpll_cmd_pin_get_one()
558 ret = dpll_msg_add_pin_parents(msg, pin, ref, extack); in dpll_cmd_pin_get_one()
564 dpll_device_get_one(struct dpll_device *dpll, struct sk_buff *msg, in dpll_device_get_one() argument
569 ret = dpll_msg_add_dev_handle(msg, dpll); in dpll_device_get_one()
572 if (nla_put_string(msg, DPLL_A_MODULE_NAME, module_name(dpll->module))) in dpll_device_get_one()
573 return -EMSGSIZE; in dpll_device_get_one()
574 if (nla_put_64bit(msg, DPLL_A_CLOCK_ID, sizeof(dpll->clock_id), in dpll_device_get_one()
575 &dpll->clock_id, DPLL_A_PAD)) in dpll_device_get_one()
576 return -EMSGSIZE; in dpll_device_get_one()
577 ret = dpll_msg_add_temp(msg, dpll, extack); in dpll_device_get_one()
580 ret = dpll_msg_add_lock_status(msg, dpll, extack); in dpll_device_get_one()
583 ret = dpll_msg_add_clock_quality_level(msg, dpll, extack); in dpll_device_get_one()
586 ret = dpll_msg_add_mode(msg, dpll, extack); in dpll_device_get_one()
589 ret = dpll_msg_add_mode_supported(msg, dpll, extack); in dpll_device_get_one()
592 if (nla_put_u32(msg, DPLL_A_TYPE, dpll->type)) in dpll_device_get_one()
593 return -EMSGSIZE; in dpll_device_get_one()
601 struct sk_buff *msg; in dpll_device_event_send() local
602 int ret = -ENOMEM; in dpll_device_event_send()
605 if (WARN_ON(!xa_get_mark(&dpll_device_xa, dpll->id, DPLL_REGISTERED))) in dpll_device_event_send()
606 return -ENODEV; in dpll_device_event_send()
607 msg = genlmsg_new(NLMSG_GOODSIZE, GFP_KERNEL); in dpll_device_event_send()
608 if (!msg) in dpll_device_event_send()
609 return -ENOMEM; in dpll_device_event_send()
610 hdr = genlmsg_put(msg, 0, 0, &dpll_nl_family, 0, event); in dpll_device_event_send()
613 ret = dpll_device_get_one(dpll, msg, NULL); in dpll_device_event_send()
616 genlmsg_end(msg, hdr); in dpll_device_event_send()
617 genlmsg_multicast(&dpll_nl_family, msg, 0, 0, GFP_KERNEL); in dpll_device_event_send()
622 genlmsg_cancel(msg, hdr); in dpll_device_event_send()
624 nlmsg_free(msg); in dpll_device_event_send()
650 if (!xa_get_mark(&dpll_pin_xa, pin->id, DPLL_REGISTERED)) in dpll_pin_available()
652 xa_for_each(&pin->parent_refs, i, par_ref) in dpll_pin_available()
653 if (xa_get_mark(&dpll_pin_xa, par_ref->pin->id, in dpll_pin_available()
656 xa_for_each(&pin->dpll_refs, i, par_ref) in dpll_pin_available()
657 if (xa_get_mark(&dpll_device_xa, par_ref->dpll->id, in dpll_pin_available()
664 * dpll_device_change_ntf - notify that the dpll device has been changed
685 struct sk_buff *msg; in dpll_pin_event_send() local
686 int ret = -ENOMEM; in dpll_pin_event_send()
690 return -ENODEV; in dpll_pin_event_send()
692 msg = genlmsg_new(NLMSG_GOODSIZE, GFP_KERNEL); in dpll_pin_event_send()
693 if (!msg) in dpll_pin_event_send()
694 return -ENOMEM; in dpll_pin_event_send()
696 hdr = genlmsg_put(msg, 0, 0, &dpll_nl_family, 0, event); in dpll_pin_event_send()
699 ret = dpll_cmd_pin_get_one(msg, pin, NULL); in dpll_pin_event_send()
702 genlmsg_end(msg, hdr); in dpll_pin_event_send()
703 genlmsg_multicast(&dpll_nl_family, msg, 0, 0, GFP_KERNEL); in dpll_pin_event_send()
708 genlmsg_cancel(msg, hdr); in dpll_pin_event_send()
710 nlmsg_free(msg); in dpll_pin_event_send()
731 * dpll_pin_change_ntf - notify that the pin has been changed
762 return -EINVAL; in dpll_pin_freq_set()
765 xa_for_each(&pin->dpll_refs, i, ref) { in dpll_pin_freq_set()
767 if (!ops->frequency_set || !ops->frequency_get) { in dpll_pin_freq_set()
769 return -EOPNOTSUPP; in dpll_pin_freq_set()
772 ref = dpll_xa_ref_dpll_first(&pin->dpll_refs); in dpll_pin_freq_set()
774 dpll = ref->dpll; in dpll_pin_freq_set()
775 ret = ops->frequency_get(pin, dpll_pin_on_dpll_priv(dpll, pin), dpll, in dpll_pin_freq_set()
784 xa_for_each(&pin->dpll_refs, i, ref) { in dpll_pin_freq_set()
786 dpll = ref->dpll; in dpll_pin_freq_set()
787 ret = ops->frequency_set(pin, dpll_pin_on_dpll_priv(dpll, pin), in dpll_pin_freq_set()
792 dpll->id); in dpll_pin_freq_set()
801 xa_for_each(&pin->dpll_refs, i, ref) { in dpll_pin_freq_set()
805 dpll = ref->dpll; in dpll_pin_freq_set()
806 if (ops->frequency_set(pin, dpll_pin_on_dpll_priv(dpll, pin), in dpll_pin_freq_set()
826 xa_for_each(&pin->dpll_refs, i, ref) { in dpll_pin_esync_set()
828 if (!ops->esync_set || !ops->esync_get) { in dpll_pin_esync_set()
831 return -EOPNOTSUPP; in dpll_pin_esync_set()
834 ref = dpll_xa_ref_dpll_first(&pin->dpll_refs); in dpll_pin_esync_set()
836 dpll = ref->dpll; in dpll_pin_esync_set()
837 ret = ops->esync_get(pin, dpll_pin_on_dpll_priv(dpll, pin), dpll, in dpll_pin_esync_set()
846 if (freq <= esync.range[i].max && freq >= esync.range[i].min) in dpll_pin_esync_set()
851 return -EINVAL; in dpll_pin_esync_set()
854 xa_for_each(&pin->dpll_refs, i, ref) { in dpll_pin_esync_set()
858 dpll = ref->dpll; in dpll_pin_esync_set()
860 ret = ops->esync_set(pin, pin_dpll_priv, dpll, dpll_priv(dpll), in dpll_pin_esync_set()
866 dpll->id); in dpll_pin_esync_set()
875 xa_for_each(&pin->dpll_refs, i, ref) { in dpll_pin_esync_set()
881 dpll = ref->dpll; in dpll_pin_esync_set()
883 if (ops->esync_set(pin, pin_dpll_priv, dpll, dpll_priv(dpll), in dpll_pin_esync_set()
904 pin->prop.capabilities)) { in dpll_pin_on_pin_state_set()
906 return -EOPNOTSUPP; in dpll_pin_on_pin_state_set()
910 return -EINVAL; in dpll_pin_on_pin_state_set()
911 parent_ref = xa_load(&pin->parent_refs, parent->pin_idx); in dpll_pin_on_pin_state_set()
913 return -EINVAL; in dpll_pin_on_pin_state_set()
914 xa_for_each(&parent->dpll_refs, i, dpll_ref) { in dpll_pin_on_pin_state_set()
916 if (!ops->state_on_pin_set) in dpll_pin_on_pin_state_set()
917 return -EOPNOTSUPP; in dpll_pin_on_pin_state_set()
919 parent_priv = dpll_pin_on_dpll_priv(dpll_ref->dpll, parent); in dpll_pin_on_pin_state_set()
920 ret = ops->state_on_pin_set(pin, pin_priv, parent, parent_priv, in dpll_pin_on_pin_state_set()
940 pin->prop.capabilities)) { in dpll_pin_state_set()
942 return -EOPNOTSUPP; in dpll_pin_state_set()
944 ref = xa_load(&pin->dpll_refs, dpll->id); in dpll_pin_state_set()
947 if (!ops->state_on_dpll_set) in dpll_pin_state_set()
948 return -EOPNOTSUPP; in dpll_pin_state_set()
949 ret = ops->state_on_dpll_set(pin, dpll_pin_on_dpll_priv(dpll, pin), in dpll_pin_state_set()
967 pin->prop.capabilities)) { in dpll_pin_prio_set()
969 return -EOPNOTSUPP; in dpll_pin_prio_set()
971 ref = xa_load(&pin->dpll_refs, dpll->id); in dpll_pin_prio_set()
974 if (!ops->prio_set) in dpll_pin_prio_set()
975 return -EOPNOTSUPP; in dpll_pin_prio_set()
976 ret = ops->prio_set(pin, dpll_pin_on_dpll_priv(dpll, pin), dpll, in dpll_pin_prio_set()
995 pin->prop.capabilities)) { in dpll_pin_direction_set()
997 return -EOPNOTSUPP; in dpll_pin_direction_set()
999 ref = xa_load(&pin->dpll_refs, dpll->id); in dpll_pin_direction_set()
1002 if (!ops->direction_set) in dpll_pin_direction_set()
1003 return -EOPNOTSUPP; in dpll_pin_direction_set()
1004 ret = ops->direction_set(pin, dpll_pin_on_dpll_priv(dpll, pin), in dpll_pin_direction_set()
1025 if (phase_adj > pin->prop.phase_range.max || in dpll_pin_phase_adj_set()
1026 phase_adj < pin->prop.phase_range.min) { in dpll_pin_phase_adj_set()
1029 return -EINVAL; in dpll_pin_phase_adj_set()
1032 xa_for_each(&pin->dpll_refs, i, ref) { in dpll_pin_phase_adj_set()
1034 if (!ops->phase_adjust_set || !ops->phase_adjust_get) { in dpll_pin_phase_adj_set()
1036 return -EOPNOTSUPP; in dpll_pin_phase_adj_set()
1039 ref = dpll_xa_ref_dpll_first(&pin->dpll_refs); in dpll_pin_phase_adj_set()
1041 dpll = ref->dpll; in dpll_pin_phase_adj_set()
1042 ret = ops->phase_adjust_get(pin, dpll_pin_on_dpll_priv(dpll, pin), in dpll_pin_phase_adj_set()
1052 xa_for_each(&pin->dpll_refs, i, ref) { in dpll_pin_phase_adj_set()
1054 dpll = ref->dpll; in dpll_pin_phase_adj_set()
1055 ret = ops->phase_adjust_set(pin, in dpll_pin_phase_adj_set()
1063 dpll->id); in dpll_pin_phase_adj_set()
1072 xa_for_each(&pin->dpll_refs, i, ref) { in dpll_pin_phase_adj_set()
1076 dpll = ref->dpll; in dpll_pin_phase_adj_set()
1077 if (ops->phase_adjust_set(pin, dpll_pin_on_dpll_priv(dpll, pin), in dpll_pin_phase_adj_set()
1101 return -EINVAL; in dpll_pin_parent_device_set()
1107 return -EINVAL; in dpll_pin_parent_device_set()
1109 ref = xa_load(&pin->dpll_refs, dpll->id); in dpll_pin_parent_device_set()
1112 return -EINVAL; in dpll_pin_parent_device_set()
1147 return -EINVAL; in dpll_pin_parent_pin_set()
1168 nla_for_each_attr(a, genlmsg_data(info->genlhdr), in dpll_pin_set_from_nlattr()
1169 genlmsg_len(info->genlhdr), rem) { in dpll_pin_set_from_nlattr()
1172 ret = dpll_pin_freq_set(pin, a, info->extack); in dpll_pin_set_from_nlattr()
1177 ret = dpll_pin_phase_adj_set(pin, a, info->extack); in dpll_pin_set_from_nlattr()
1182 ret = dpll_pin_parent_device_set(pin, a, info->extack); in dpll_pin_set_from_nlattr()
1187 ret = dpll_pin_parent_pin_set(pin, a, info->extack); in dpll_pin_set_from_nlattr()
1192 ret = dpll_pin_esync_set(pin, a, info->extack); in dpll_pin_set_from_nlattr()
1215 prop = &pin->prop; in dpll_pin_find()
1216 cid_match = clock_id ? pin->clock_id == clock_id : true; in dpll_pin_find()
1217 mod_match = mod_name_attr && module_name(pin->module) ? in dpll_pin_find()
1219 module_name(pin->module)) : true; in dpll_pin_find()
1220 type_match = type ? prop->type == type : true; in dpll_pin_find()
1221 board_match = board_label ? (prop->board_label ? in dpll_pin_find()
1222 !nla_strcmp(board_label, prop->board_label) : false) : in dpll_pin_find()
1224 panel_match = panel_label ? (prop->panel_label ? in dpll_pin_find()
1225 !nla_strcmp(panel_label, prop->panel_label) : false) : in dpll_pin_find()
1227 package_match = package_label ? (prop->package_label ? in dpll_pin_find()
1228 !nla_strcmp(package_label, prop->package_label) : in dpll_pin_find()
1234 return ERR_PTR(-EINVAL); in dpll_pin_find()
1241 return ERR_PTR(-ENODEV); in dpll_pin_find()
1254 nla_for_each_attr(attr, genlmsg_data(info->genlhdr), in dpll_pin_find_from_nlattr()
1255 genlmsg_len(info->genlhdr), rem) { in dpll_pin_find_from_nlattr()
1293 NL_SET_ERR_MSG(info->extack, "missing attributes"); in dpll_pin_find_from_nlattr()
1294 return ERR_PTR(-EINVAL); in dpll_pin_find_from_nlattr()
1298 info->extack); in dpll_pin_find_from_nlattr()
1300 NL_SET_ERR_MSG(info->extack, "duplicated attribute"); in dpll_pin_find_from_nlattr()
1301 return ERR_PTR(-EINVAL); in dpll_pin_find_from_nlattr()
1307 struct sk_buff *msg; in dpll_nl_pin_id_get_doit() local
1311 msg = genlmsg_new(NLMSG_GOODSIZE, GFP_KERNEL); in dpll_nl_pin_id_get_doit()
1312 if (!msg) in dpll_nl_pin_id_get_doit()
1313 return -ENOMEM; in dpll_nl_pin_id_get_doit()
1314 hdr = genlmsg_put_reply(msg, info, &dpll_nl_family, 0, in dpll_nl_pin_id_get_doit()
1317 nlmsg_free(msg); in dpll_nl_pin_id_get_doit()
1318 return -EMSGSIZE; in dpll_nl_pin_id_get_doit()
1323 nlmsg_free(msg); in dpll_nl_pin_id_get_doit()
1324 return -ENODEV; in dpll_nl_pin_id_get_doit()
1326 ret = dpll_msg_add_pin_handle(msg, pin); in dpll_nl_pin_id_get_doit()
1328 nlmsg_free(msg); in dpll_nl_pin_id_get_doit()
1332 genlmsg_end(msg, hdr); in dpll_nl_pin_id_get_doit()
1334 return genlmsg_reply(msg, info); in dpll_nl_pin_id_get_doit()
1339 struct dpll_pin *pin = info->user_ptr[0]; in dpll_nl_pin_get_doit()
1340 struct sk_buff *msg; in dpll_nl_pin_get_doit() local
1345 return -ENODEV; in dpll_nl_pin_get_doit()
1346 msg = genlmsg_new(NLMSG_GOODSIZE, GFP_KERNEL); in dpll_nl_pin_get_doit()
1347 if (!msg) in dpll_nl_pin_get_doit()
1348 return -ENOMEM; in dpll_nl_pin_get_doit()
1349 hdr = genlmsg_put_reply(msg, info, &dpll_nl_family, 0, in dpll_nl_pin_get_doit()
1352 nlmsg_free(msg); in dpll_nl_pin_get_doit()
1353 return -EMSGSIZE; in dpll_nl_pin_get_doit()
1355 ret = dpll_cmd_pin_get_one(msg, pin, info->extack); in dpll_nl_pin_get_doit()
1357 nlmsg_free(msg); in dpll_nl_pin_get_doit()
1360 genlmsg_end(msg, hdr); in dpll_nl_pin_get_doit()
1362 return genlmsg_reply(msg, info); in dpll_nl_pin_get_doit()
1375 ctx->idx) { in dpll_nl_pin_get_dumpit()
1378 hdr = genlmsg_put(skb, NETLINK_CB(cb->skb).portid, in dpll_nl_pin_get_dumpit()
1379 cb->nlh->nlmsg_seq, in dpll_nl_pin_get_dumpit()
1383 ret = -EMSGSIZE; in dpll_nl_pin_get_dumpit()
1386 ret = dpll_cmd_pin_get_one(skb, pin, cb->extack); in dpll_nl_pin_get_dumpit()
1395 if (ret == -EMSGSIZE) { in dpll_nl_pin_get_dumpit()
1396 ctx->idx = i; in dpll_nl_pin_get_dumpit()
1397 return skb->len; in dpll_nl_pin_get_dumpit()
1404 struct dpll_pin *pin = info->user_ptr[0]; in dpll_nl_pin_set_doit()
1418 cid_match = clock_id ? dpll->clock_id == clock_id : true; in dpll_device_find()
1419 mod_match = mod_name_attr ? (module_name(dpll->module) ? in dpll_device_find()
1421 module_name(dpll->module)) : false) : true; in dpll_device_find()
1422 type_match = type ? dpll->type == type : true; in dpll_device_find()
1426 return ERR_PTR(-EINVAL); in dpll_device_find()
1433 return ERR_PTR(-ENODEV); in dpll_device_find()
1447 nla_for_each_attr(attr, genlmsg_data(info->genlhdr), in dpll_device_find_from_nlattr()
1448 genlmsg_len(info->genlhdr), rem) { in dpll_device_find_from_nlattr()
1470 NL_SET_ERR_MSG(info->extack, "missing attributes"); in dpll_device_find_from_nlattr()
1471 return ERR_PTR(-EINVAL); in dpll_device_find_from_nlattr()
1473 return dpll_device_find(clock_id, mod_name_attr, type, info->extack); in dpll_device_find_from_nlattr()
1475 NL_SET_ERR_MSG(info->extack, "duplicated attribute"); in dpll_device_find_from_nlattr()
1476 return ERR_PTR(-EINVAL); in dpll_device_find_from_nlattr()
1482 struct sk_buff *msg; in dpll_nl_device_id_get_doit() local
1486 msg = genlmsg_new(NLMSG_GOODSIZE, GFP_KERNEL); in dpll_nl_device_id_get_doit()
1487 if (!msg) in dpll_nl_device_id_get_doit()
1488 return -ENOMEM; in dpll_nl_device_id_get_doit()
1489 hdr = genlmsg_put_reply(msg, info, &dpll_nl_family, 0, in dpll_nl_device_id_get_doit()
1492 nlmsg_free(msg); in dpll_nl_device_id_get_doit()
1493 return -EMSGSIZE; in dpll_nl_device_id_get_doit()
1498 ret = dpll_msg_add_dev_handle(msg, dpll); in dpll_nl_device_id_get_doit()
1500 nlmsg_free(msg); in dpll_nl_device_id_get_doit()
1504 genlmsg_end(msg, hdr); in dpll_nl_device_id_get_doit()
1506 return genlmsg_reply(msg, info); in dpll_nl_device_id_get_doit()
1511 struct dpll_device *dpll = info->user_ptr[0]; in dpll_nl_device_get_doit()
1512 struct sk_buff *msg; in dpll_nl_device_get_doit() local
1516 msg = genlmsg_new(NLMSG_GOODSIZE, GFP_KERNEL); in dpll_nl_device_get_doit()
1517 if (!msg) in dpll_nl_device_get_doit()
1518 return -ENOMEM; in dpll_nl_device_get_doit()
1519 hdr = genlmsg_put_reply(msg, info, &dpll_nl_family, 0, in dpll_nl_device_get_doit()
1522 nlmsg_free(msg); in dpll_nl_device_get_doit()
1523 return -EMSGSIZE; in dpll_nl_device_get_doit()
1526 ret = dpll_device_get_one(dpll, msg, info->extack); in dpll_nl_device_get_doit()
1528 nlmsg_free(msg); in dpll_nl_device_get_doit()
1531 genlmsg_end(msg, hdr); in dpll_nl_device_get_doit()
1533 return genlmsg_reply(msg, info); in dpll_nl_device_get_doit()
1552 ctx->idx) { in dpll_nl_device_get_dumpit()
1553 hdr = genlmsg_put(skb, NETLINK_CB(cb->skb).portid, in dpll_nl_device_get_dumpit()
1554 cb->nlh->nlmsg_seq, &dpll_nl_family, in dpll_nl_device_get_dumpit()
1557 ret = -EMSGSIZE; in dpll_nl_device_get_dumpit()
1560 ret = dpll_device_get_one(dpll, skb, cb->extack); in dpll_nl_device_get_dumpit()
1569 if (ret == -EMSGSIZE) { in dpll_nl_device_get_dumpit()
1570 ctx->idx = i; in dpll_nl_device_get_dumpit()
1571 return skb->len; in dpll_nl_device_get_dumpit()
1582 return -EINVAL; in dpll_pre_doit()
1585 id = nla_get_u32(info->attrs[DPLL_A_ID]); in dpll_pre_doit()
1586 info->user_ptr[0] = dpll_device_get_by_id(id); in dpll_pre_doit()
1587 if (!info->user_ptr[0]) { in dpll_pre_doit()
1588 NL_SET_ERR_MSG(info->extack, "device not found"); in dpll_pre_doit()
1594 return -ENODEV; in dpll_pre_doit()
1626 ret = -EINVAL; in dpll_pin_pre_doit()
1629 info->user_ptr[0] = xa_load(&dpll_pin_xa, in dpll_pin_pre_doit()
1630 nla_get_u32(info->attrs[DPLL_A_PIN_ID])); in dpll_pin_pre_doit()
1631 if (!info->user_ptr[0] || in dpll_pin_pre_doit()
1632 !dpll_pin_available(info->user_ptr[0])) { in dpll_pin_pre_doit()
1633 NL_SET_ERR_MSG(info->extack, "pin not found"); in dpll_pin_pre_doit()
1634 ret = -ENODEV; in dpll_pin_pre_doit()