@@ -42,6 +42,7 @@ struct dpll_pin_registration {
42
42
struct list_head list ;
43
43
const struct dpll_pin_ops * ops ;
44
44
void * priv ;
45
+ void * cookie ;
45
46
};
46
47
47
48
struct dpll_device * dpll_device_get_by_id (int id )
@@ -54,20 +55,23 @@ struct dpll_device *dpll_device_get_by_id(int id)
54
55
55
56
static struct dpll_pin_registration *
56
57
dpll_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 )
58
60
{
59
61
struct dpll_pin_registration * reg ;
60
62
61
63
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 )
63
66
return reg ;
64
67
}
65
68
return NULL ;
66
69
}
67
70
68
71
static int
69
72
dpll_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 )
71
75
{
72
76
struct dpll_pin_registration * reg ;
73
77
struct dpll_pin_ref * ref ;
@@ -78,7 +82,7 @@ dpll_xa_ref_pin_add(struct xarray *xa_pins, struct dpll_pin *pin,
78
82
xa_for_each (xa_pins , i , ref ) {
79
83
if (ref -> pin != pin )
80
84
continue ;
81
- reg = dpll_pin_registration_find (ref , ops , priv );
85
+ reg = dpll_pin_registration_find (ref , ops , priv , cookie );
82
86
if (reg ) {
83
87
refcount_inc (& ref -> refcount );
84
88
return 0 ;
@@ -111,6 +115,7 @@ dpll_xa_ref_pin_add(struct xarray *xa_pins, struct dpll_pin *pin,
111
115
}
112
116
reg -> ops = ops ;
113
117
reg -> priv = priv ;
118
+ reg -> cookie = cookie ;
114
119
if (ref_exists )
115
120
refcount_inc (& ref -> refcount );
116
121
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,
119
124
}
120
125
121
126
static 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 )
123
129
{
124
130
struct dpll_pin_registration * reg ;
125
131
struct dpll_pin_ref * ref ;
@@ -128,7 +134,7 @@ static int dpll_xa_ref_pin_del(struct xarray *xa_pins, struct dpll_pin *pin,
128
134
xa_for_each (xa_pins , i , ref ) {
129
135
if (ref -> pin != pin )
130
136
continue ;
131
- reg = dpll_pin_registration_find (ref , ops , priv );
137
+ reg = dpll_pin_registration_find (ref , ops , priv , cookie );
132
138
if (WARN_ON (!reg ))
133
139
return - EINVAL ;
134
140
list_del (& reg -> list );
@@ -146,7 +152,7 @@ static int dpll_xa_ref_pin_del(struct xarray *xa_pins, struct dpll_pin *pin,
146
152
147
153
static int
148
154
dpll_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 )
150
156
{
151
157
struct dpll_pin_registration * reg ;
152
158
struct dpll_pin_ref * ref ;
@@ -157,7 +163,7 @@ dpll_xa_ref_dpll_add(struct xarray *xa_dplls, struct dpll_device *dpll,
157
163
xa_for_each (xa_dplls , i , ref ) {
158
164
if (ref -> dpll != dpll )
159
165
continue ;
160
- reg = dpll_pin_registration_find (ref , ops , priv );
166
+ reg = dpll_pin_registration_find (ref , ops , priv , cookie );
161
167
if (reg ) {
162
168
refcount_inc (& ref -> refcount );
163
169
return 0 ;
@@ -190,6 +196,7 @@ dpll_xa_ref_dpll_add(struct xarray *xa_dplls, struct dpll_device *dpll,
190
196
}
191
197
reg -> ops = ops ;
192
198
reg -> priv = priv ;
199
+ reg -> cookie = cookie ;
193
200
if (ref_exists )
194
201
refcount_inc (& ref -> refcount );
195
202
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,
199
206
200
207
static void
201
208
dpll_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 )
203
210
{
204
211
struct dpll_pin_registration * reg ;
205
212
struct dpll_pin_ref * ref ;
@@ -208,7 +215,7 @@ dpll_xa_ref_dpll_del(struct xarray *xa_dplls, struct dpll_device *dpll,
208
215
xa_for_each (xa_dplls , i , ref ) {
209
216
if (ref -> dpll != dpll )
210
217
continue ;
211
- reg = dpll_pin_registration_find (ref , ops , priv );
218
+ reg = dpll_pin_registration_find (ref , ops , priv , cookie );
212
219
if (WARN_ON (!reg ))
213
220
return ;
214
221
list_del (& reg -> list );
@@ -594,14 +601,14 @@ EXPORT_SYMBOL_GPL(dpll_pin_put);
594
601
595
602
static int
596
603
__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 )
598
605
{
599
606
int ret ;
600
607
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 );
602
609
if (ret )
603
610
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 );
605
612
if (ret )
606
613
goto ref_pin_del ;
607
614
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,
610
617
return ret ;
611
618
612
619
ref_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 );
614
621
return ret ;
615
622
}
616
623
@@ -642,7 +649,7 @@ dpll_pin_register(struct dpll_device *dpll, struct dpll_pin *pin,
642
649
dpll -> clock_id == pin -> clock_id )))
643
650
ret = - EINVAL ;
644
651
else
645
- ret = __dpll_pin_register (dpll , pin , ops , priv );
652
+ ret = __dpll_pin_register (dpll , pin , ops , priv , NULL );
646
653
mutex_unlock (& dpll_lock );
647
654
648
655
return ret ;
@@ -651,11 +658,11 @@ EXPORT_SYMBOL_GPL(dpll_pin_register);
651
658
652
659
static void
653
660
__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 )
655
662
{
656
663
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 );
659
666
if (xa_empty (& pin -> dpll_refs ))
660
667
xa_clear_mark (& dpll_pin_xa , pin -> id , DPLL_REGISTERED );
661
668
}
@@ -680,7 +687,7 @@ void dpll_pin_unregister(struct dpll_device *dpll, struct dpll_pin *pin,
680
687
681
688
mutex_lock (& dpll_lock );
682
689
dpll_pin_delete_ntf (pin );
683
- __dpll_pin_unregister (dpll , pin , ops , priv );
690
+ __dpll_pin_unregister (dpll , pin , ops , priv , NULL );
684
691
mutex_unlock (& dpll_lock );
685
692
}
686
693
EXPORT_SYMBOL_GPL (dpll_pin_unregister );
@@ -716,12 +723,12 @@ int dpll_pin_on_pin_register(struct dpll_pin *parent, struct dpll_pin *pin,
716
723
return - EINVAL ;
717
724
718
725
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 );
720
727
if (ret )
721
728
goto unlock ;
722
729
refcount_inc (& pin -> refcount );
723
730
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 );
725
732
if (ret ) {
726
733
stop = i ;
727
734
goto dpll_unregister ;
@@ -735,11 +742,12 @@ int dpll_pin_on_pin_register(struct dpll_pin *parent, struct dpll_pin *pin,
735
742
dpll_unregister :
736
743
xa_for_each (& parent -> dpll_refs , i , ref )
737
744
if (i < stop ) {
738
- __dpll_pin_unregister (ref -> dpll , pin , ops , priv );
745
+ __dpll_pin_unregister (ref -> dpll , pin , ops , priv ,
746
+ parent );
739
747
dpll_pin_delete_ntf (pin );
740
748
}
741
749
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 );
743
751
unlock :
744
752
mutex_unlock (& dpll_lock );
745
753
return ret ;
@@ -764,10 +772,10 @@ void dpll_pin_on_pin_unregister(struct dpll_pin *parent, struct dpll_pin *pin,
764
772
765
773
mutex_lock (& dpll_lock );
766
774
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 );
768
776
refcount_dec (& pin -> refcount );
769
777
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 );
771
779
mutex_unlock (& dpll_lock );
772
780
}
773
781
EXPORT_SYMBOL_GPL (dpll_pin_on_pin_unregister );
0 commit comments