@@ -66,6 +66,22 @@ static bool dpll_pin_available(struct dpll_pin *pin)
6666 return false;
6767}
6868
69+ static bool dpll_device_registered (struct dpll_device * dpll )
70+ {
71+ return dpll_device_ops (dpll );
72+ }
73+
74+ static struct dpll_pin_ref * dpll_pin_first_registered_ref (struct dpll_pin * pin )
75+ {
76+ struct dpll_pin_ref * ref ;
77+ unsigned long i ;
78+
79+ xa_for_each (& pin -> dpll_refs , i , ref )
80+ if (dpll_device_registered (ref -> dpll ))
81+ return ref ;
82+ return NULL ;
83+ }
84+
6985/**
7086 * dpll_msg_add_pin_handle - attach pin handle attribute to a given message
7187 * @msg: pointer to sk_buff message to attach a pin handle
@@ -656,6 +672,8 @@ dpll_msg_add_pin_dplls(struct sk_buff *msg, struct dpll_pin *pin,
656672 int ret ;
657673
658674 xa_for_each (& pin -> dpll_refs , index , ref ) {
675+ if (!dpll_device_registered (ref -> dpll ))
676+ continue ;
659677 attr = nla_nest_start (msg , DPLL_A_PIN_PARENT_DEVICE );
660678 if (!attr )
661679 return - EMSGSIZE ;
@@ -700,9 +718,10 @@ dpll_cmd_pin_get_one(struct sk_buff *msg, struct dpll_pin *pin,
700718 int ret ;
701719
702720 ref = dpll_pin_own_dpll_ref_first (pin );
721+ if (!ref || !dpll_device_registered (ref -> dpll ))
722+ ref = dpll_pin_first_registered_ref (pin );
703723 if (!ref )
704- ref = dpll_xa_ref_dpll_first (& pin -> dpll_refs );
705- ASSERT_NOT_NULL (ref );
724+ return - ENODEV ;
706725
707726 ret = dpll_msg_add_pin_handle (msg , pin );
708727 if (ret )
@@ -1090,7 +1109,7 @@ dpll_pin_freq_set(struct dpll_pin *pin, struct nlattr *a,
10901109 }
10911110
10921111 ref = dpll_pin_own_dpll_ref_first (pin );
1093- if (!ref ) {
1112+ if (!ref || ! dpll_device_registered ( ref -> dpll ) ) {
10941113 NL_SET_ERR_MSG (extack , "pin owner dpll not found" );
10951114 return - ENODEV ;
10961115 }
@@ -1136,7 +1155,7 @@ dpll_pin_esync_set(struct dpll_pin *pin, struct nlattr *a,
11361155 int ret , i ;
11371156
11381157 ref = dpll_pin_own_dpll_ref_first (pin );
1139- if (!ref ) {
1158+ if (!ref || ! dpll_device_registered ( ref -> dpll ) ) {
11401159 NL_SET_ERR_MSG (extack , "pin owner dpll not found" );
11411160 return - ENODEV ;
11421161 }
@@ -1201,7 +1220,7 @@ dpll_pin_ref_sync_state_set(struct dpll_pin *pin,
12011220 return - EINVAL ;
12021221 }
12031222 ref = dpll_pin_own_dpll_ref_first (pin );
1204- if (!ref ) {
1223+ if (!ref || ! dpll_device_registered ( ref -> dpll ) ) {
12051224 NL_SET_ERR_MSG (extack , "pin owner dpll not found" );
12061225 return - ENODEV ;
12071226 }
@@ -1416,7 +1435,7 @@ dpll_pin_phase_adj_set(struct dpll_pin *pin, struct nlattr *phase_adj_attr,
14161435 }
14171436
14181437 ref = dpll_pin_own_dpll_ref_first (pin );
1419- if (!ref ) {
1438+ if (!ref || ! dpll_device_registered ( ref -> dpll ) ) {
14201439 NL_SET_ERR_MSG (extack , "pin owner dpll not found" );
14211440 return - ENODEV ;
14221441 }
@@ -1468,7 +1487,7 @@ dpll_pin_parent_device_set(struct dpll_pin *pin, struct nlattr *parent_nest,
14681487 return - EINVAL ;
14691488 }
14701489 pdpll_idx = nla_get_u32 (tb [DPLL_A_PIN_PARENT_ID ]);
1471- dpll = xa_load ( & dpll_device_xa , pdpll_idx );
1490+ dpll = dpll_device_get_by_id ( pdpll_idx );
14721491 if (!dpll ) {
14731492 NL_SET_ERR_MSG (extack , "parent device not found" );
14741493 return - EINVAL ;
@@ -1760,6 +1779,10 @@ int dpll_nl_pin_get_dumpit(struct sk_buff *skb, struct netlink_callback *cb)
17601779 ret = dpll_cmd_pin_get_one (skb , pin , cb -> extack );
17611780 if (ret ) {
17621781 genlmsg_cancel (skb , hdr );
1782+ if (ret == - ENODEV ) {
1783+ ret = 0 ;
1784+ continue ;
1785+ }
17631786 break ;
17641787 }
17651788 genlmsg_end (skb , hdr );
0 commit comments