@@ -42,6 +42,7 @@ struct dpll_pin_registration {
4242 struct list_head list ;
4343 const struct dpll_pin_ops * ops ;
4444 void * priv ;
45+ void * cookie ;
4546};
4647
4748struct dpll_device * dpll_device_get_by_id (int id )
@@ -54,20 +55,23 @@ struct dpll_device *dpll_device_get_by_id(int id)
5455
5556static struct dpll_pin_registration *
5657dpll_pin_registration_find (struct dpll_pin_ref * ref ,
57- const struct dpll_pin_ops * ops , void * priv )
58+ const struct dpll_pin_ops * ops , void * priv ,
59+ void * cookie )
5860{
5961 struct dpll_pin_registration * reg ;
6062
6163 list_for_each_entry (reg , & ref -> registration_list , list ) {
62- if (reg -> ops == ops && reg -> priv == priv )
64+ if (reg -> ops == ops && reg -> priv == priv &&
65+ reg -> cookie == cookie )
6366 return reg ;
6467 }
6568 return NULL ;
6669}
6770
6871static int
6972dpll_xa_ref_pin_add (struct xarray * xa_pins , struct dpll_pin * pin ,
70- const struct dpll_pin_ops * ops , void * priv )
73+ const struct dpll_pin_ops * ops , void * priv ,
74+ void * cookie )
7175{
7276 struct dpll_pin_registration * reg ;
7377 struct dpll_pin_ref * ref ;
@@ -78,7 +82,7 @@ dpll_xa_ref_pin_add(struct xarray *xa_pins, struct dpll_pin *pin,
7882 xa_for_each (xa_pins , i , ref ) {
7983 if (ref -> pin != pin )
8084 continue ;
81- reg = dpll_pin_registration_find (ref , ops , priv );
85+ reg = dpll_pin_registration_find (ref , ops , priv , cookie );
8286 if (reg ) {
8387 refcount_inc (& ref -> refcount );
8488 return 0 ;
@@ -111,6 +115,7 @@ dpll_xa_ref_pin_add(struct xarray *xa_pins, struct dpll_pin *pin,
111115 }
112116 reg -> ops = ops ;
113117 reg -> priv = priv ;
118+ reg -> cookie = cookie ;
114119 if (ref_exists )
115120 refcount_inc (& ref -> refcount );
116121 list_add_tail (& reg -> list , & ref -> registration_list );
@@ -119,7 +124,8 @@ dpll_xa_ref_pin_add(struct xarray *xa_pins, struct dpll_pin *pin,
119124}
120125
121126static int dpll_xa_ref_pin_del (struct xarray * xa_pins , struct dpll_pin * pin ,
122- const struct dpll_pin_ops * ops , void * priv )
127+ const struct dpll_pin_ops * ops , void * priv ,
128+ void * cookie )
123129{
124130 struct dpll_pin_registration * reg ;
125131 struct dpll_pin_ref * ref ;
@@ -128,7 +134,7 @@ static int dpll_xa_ref_pin_del(struct xarray *xa_pins, struct dpll_pin *pin,
128134 xa_for_each (xa_pins , i , ref ) {
129135 if (ref -> pin != pin )
130136 continue ;
131- reg = dpll_pin_registration_find (ref , ops , priv );
137+ reg = dpll_pin_registration_find (ref , ops , priv , cookie );
132138 if (WARN_ON (!reg ))
133139 return - EINVAL ;
134140 list_del (& reg -> list );
@@ -146,7 +152,7 @@ static int dpll_xa_ref_pin_del(struct xarray *xa_pins, struct dpll_pin *pin,
146152
147153static int
148154dpll_xa_ref_dpll_add (struct xarray * xa_dplls , struct dpll_device * dpll ,
149- const struct dpll_pin_ops * ops , void * priv )
155+ const struct dpll_pin_ops * ops , void * priv , void * cookie )
150156{
151157 struct dpll_pin_registration * reg ;
152158 struct dpll_pin_ref * ref ;
@@ -157,7 +163,7 @@ dpll_xa_ref_dpll_add(struct xarray *xa_dplls, struct dpll_device *dpll,
157163 xa_for_each (xa_dplls , i , ref ) {
158164 if (ref -> dpll != dpll )
159165 continue ;
160- reg = dpll_pin_registration_find (ref , ops , priv );
166+ reg = dpll_pin_registration_find (ref , ops , priv , cookie );
161167 if (reg ) {
162168 refcount_inc (& ref -> refcount );
163169 return 0 ;
@@ -190,6 +196,7 @@ dpll_xa_ref_dpll_add(struct xarray *xa_dplls, struct dpll_device *dpll,
190196 }
191197 reg -> ops = ops ;
192198 reg -> priv = priv ;
199+ reg -> cookie = cookie ;
193200 if (ref_exists )
194201 refcount_inc (& ref -> refcount );
195202 list_add_tail (& reg -> list , & ref -> registration_list );
@@ -199,7 +206,7 @@ dpll_xa_ref_dpll_add(struct xarray *xa_dplls, struct dpll_device *dpll,
199206
200207static void
201208dpll_xa_ref_dpll_del (struct xarray * xa_dplls , struct dpll_device * dpll ,
202- const struct dpll_pin_ops * ops , void * priv )
209+ const struct dpll_pin_ops * ops , void * priv , void * cookie )
203210{
204211 struct dpll_pin_registration * reg ;
205212 struct dpll_pin_ref * ref ;
@@ -208,7 +215,7 @@ dpll_xa_ref_dpll_del(struct xarray *xa_dplls, struct dpll_device *dpll,
208215 xa_for_each (xa_dplls , i , ref ) {
209216 if (ref -> dpll != dpll )
210217 continue ;
211- reg = dpll_pin_registration_find (ref , ops , priv );
218+ reg = dpll_pin_registration_find (ref , ops , priv , cookie );
212219 if (WARN_ON (!reg ))
213220 return ;
214221 list_del (& reg -> list );
@@ -594,14 +601,14 @@ EXPORT_SYMBOL_GPL(dpll_pin_put);
594601
595602static int
596603__dpll_pin_register (struct dpll_device * dpll , struct dpll_pin * pin ,
597- const struct dpll_pin_ops * ops , void * priv )
604+ const struct dpll_pin_ops * ops , void * priv , void * cookie )
598605{
599606 int ret ;
600607
601- ret = dpll_xa_ref_pin_add (& dpll -> pin_refs , pin , ops , priv );
608+ ret = dpll_xa_ref_pin_add (& dpll -> pin_refs , pin , ops , priv , cookie );
602609 if (ret )
603610 return ret ;
604- ret = dpll_xa_ref_dpll_add (& pin -> dpll_refs , dpll , ops , priv );
611+ ret = dpll_xa_ref_dpll_add (& pin -> dpll_refs , dpll , ops , priv , cookie );
605612 if (ret )
606613 goto ref_pin_del ;
607614 xa_set_mark (& dpll_pin_xa , pin -> id , DPLL_REGISTERED );
@@ -610,7 +617,7 @@ __dpll_pin_register(struct dpll_device *dpll, struct dpll_pin *pin,
610617 return ret ;
611618
612619ref_pin_del :
613- dpll_xa_ref_pin_del (& dpll -> pin_refs , pin , ops , priv );
620+ dpll_xa_ref_pin_del (& dpll -> pin_refs , pin , ops , priv , cookie );
614621 return ret ;
615622}
616623
@@ -642,7 +649,7 @@ dpll_pin_register(struct dpll_device *dpll, struct dpll_pin *pin,
642649 dpll -> clock_id == pin -> clock_id )))
643650 ret = - EINVAL ;
644651 else
645- ret = __dpll_pin_register (dpll , pin , ops , priv );
652+ ret = __dpll_pin_register (dpll , pin , ops , priv , NULL );
646653 mutex_unlock (& dpll_lock );
647654
648655 return ret ;
@@ -651,11 +658,11 @@ EXPORT_SYMBOL_GPL(dpll_pin_register);
651658
652659static void
653660__dpll_pin_unregister (struct dpll_device * dpll , struct dpll_pin * pin ,
654- const struct dpll_pin_ops * ops , void * priv )
661+ const struct dpll_pin_ops * ops , void * priv , void * cookie )
655662{
656663 ASSERT_DPLL_PIN_REGISTERED (pin );
657- dpll_xa_ref_pin_del (& dpll -> pin_refs , pin , ops , priv );
658- dpll_xa_ref_dpll_del (& pin -> dpll_refs , dpll , ops , priv );
664+ dpll_xa_ref_pin_del (& dpll -> pin_refs , pin , ops , priv , cookie );
665+ dpll_xa_ref_dpll_del (& pin -> dpll_refs , dpll , ops , priv , cookie );
659666 if (xa_empty (& pin -> dpll_refs ))
660667 xa_clear_mark (& dpll_pin_xa , pin -> id , DPLL_REGISTERED );
661668}
@@ -680,7 +687,7 @@ void dpll_pin_unregister(struct dpll_device *dpll, struct dpll_pin *pin,
680687
681688 mutex_lock (& dpll_lock );
682689 dpll_pin_delete_ntf (pin );
683- __dpll_pin_unregister (dpll , pin , ops , priv );
690+ __dpll_pin_unregister (dpll , pin , ops , priv , NULL );
684691 mutex_unlock (& dpll_lock );
685692}
686693EXPORT_SYMBOL_GPL (dpll_pin_unregister );
@@ -716,12 +723,12 @@ int dpll_pin_on_pin_register(struct dpll_pin *parent, struct dpll_pin *pin,
716723 return - EINVAL ;
717724
718725 mutex_lock (& dpll_lock );
719- ret = dpll_xa_ref_pin_add (& pin -> parent_refs , parent , ops , priv );
726+ ret = dpll_xa_ref_pin_add (& pin -> parent_refs , parent , ops , priv , pin );
720727 if (ret )
721728 goto unlock ;
722729 refcount_inc (& pin -> refcount );
723730 xa_for_each (& parent -> dpll_refs , i , ref ) {
724- ret = __dpll_pin_register (ref -> dpll , pin , ops , priv );
731+ ret = __dpll_pin_register (ref -> dpll , pin , ops , priv , parent );
725732 if (ret ) {
726733 stop = i ;
727734 goto dpll_unregister ;
@@ -735,11 +742,12 @@ int dpll_pin_on_pin_register(struct dpll_pin *parent, struct dpll_pin *pin,
735742dpll_unregister :
736743 xa_for_each (& parent -> dpll_refs , i , ref )
737744 if (i < stop ) {
738- __dpll_pin_unregister (ref -> dpll , pin , ops , priv );
745+ __dpll_pin_unregister (ref -> dpll , pin , ops , priv ,
746+ parent );
739747 dpll_pin_delete_ntf (pin );
740748 }
741749 refcount_dec (& pin -> refcount );
742- dpll_xa_ref_pin_del (& pin -> parent_refs , parent , ops , priv );
750+ dpll_xa_ref_pin_del (& pin -> parent_refs , parent , ops , priv , pin );
743751unlock :
744752 mutex_unlock (& dpll_lock );
745753 return ret ;
@@ -764,10 +772,10 @@ void dpll_pin_on_pin_unregister(struct dpll_pin *parent, struct dpll_pin *pin,
764772
765773 mutex_lock (& dpll_lock );
766774 dpll_pin_delete_ntf (pin );
767- dpll_xa_ref_pin_del (& pin -> parent_refs , parent , ops , priv );
775+ dpll_xa_ref_pin_del (& pin -> parent_refs , parent , ops , priv , pin );
768776 refcount_dec (& pin -> refcount );
769777 xa_for_each (& pin -> dpll_refs , i , ref )
770- __dpll_pin_unregister (ref -> dpll , pin , ops , priv );
778+ __dpll_pin_unregister (ref -> dpll , pin , ops , priv , parent );
771779 mutex_unlock (& dpll_lock );
772780}
773781EXPORT_SYMBOL_GPL (dpll_pin_on_pin_unregister );
0 commit comments