@@ -68,11 +68,13 @@ struct i2c_atr_alias_pool {
68
68
* @atr: The parent I2C ATR
69
69
* @chan_id: The ID of this channel
70
70
* @alias_pairs_lock: Mutex protecting @alias_pairs
71
+ * @alias_pairs_lock_key: Lock key for @alias_pairs_lock
71
72
* @alias_pairs: List of @struct i2c_atr_alias_pair containing the
72
73
* assigned aliases
73
74
* @alias_pool: Pool of available client aliases
74
75
*
75
76
* @orig_addrs_lock: Mutex protecting @orig_addrs
77
+ * @orig_addrs_lock_key: Lock key for @orig_addrs_lock
76
78
* @orig_addrs: Buffer used to store the original addresses during transmit
77
79
* @orig_addrs_size: Size of @orig_addrs
78
80
*/
@@ -83,11 +85,13 @@ struct i2c_atr_chan {
83
85
84
86
/* Lock alias_pairs during attach/detach */
85
87
struct mutex alias_pairs_lock ;
88
+ struct lock_class_key alias_pairs_lock_key ;
86
89
struct list_head alias_pairs ;
87
90
struct i2c_atr_alias_pool * alias_pool ;
88
91
89
92
/* Lock orig_addrs during xfer */
90
93
struct mutex orig_addrs_lock ;
94
+ struct lock_class_key orig_addrs_lock_key ;
91
95
u16 * orig_addrs ;
92
96
unsigned int orig_addrs_size ;
93
97
};
@@ -100,6 +104,7 @@ struct i2c_atr_chan {
100
104
* @priv: Private driver data, set with i2c_atr_set_driver_data()
101
105
* @algo: The &struct i2c_algorithm for adapters
102
106
* @lock: Lock for the I2C bus segment (see &struct i2c_lock_operations)
107
+ * @lock_key: Lock key for @lock
103
108
* @max_adapters: Maximum number of adapters this I2C ATR can have
104
109
* @alias_pool: Optional common pool of available client aliases
105
110
* @i2c_nb: Notifier for remote client add & del events
@@ -115,6 +120,7 @@ struct i2c_atr {
115
120
struct i2c_algorithm algo ;
116
121
/* lock for the I2C bus segment (see struct i2c_lock_operations) */
117
122
struct mutex lock ;
123
+ struct lock_class_key lock_key ;
118
124
int max_adapters ;
119
125
120
126
struct i2c_atr_alias_pool * alias_pool ;
@@ -683,7 +689,8 @@ struct i2c_atr *i2c_atr_new(struct i2c_adapter *parent, struct device *dev,
683
689
if (!atr )
684
690
return ERR_PTR (- ENOMEM );
685
691
686
- mutex_init (& atr -> lock );
692
+ lockdep_register_key (& atr -> lock_key );
693
+ mutex_init_with_key (& atr -> lock , & atr -> lock_key );
687
694
688
695
atr -> parent = parent ;
689
696
atr -> dev = dev ;
@@ -711,6 +718,7 @@ struct i2c_atr *i2c_atr_new(struct i2c_adapter *parent, struct device *dev,
711
718
i2c_atr_free_alias_pool (atr -> alias_pool );
712
719
err_destroy_mutex :
713
720
mutex_destroy (& atr -> lock );
721
+ lockdep_unregister_key (& atr -> lock_key );
714
722
kfree (atr );
715
723
716
724
return ERR_PTR (ret );
@@ -727,6 +735,7 @@ void i2c_atr_delete(struct i2c_atr *atr)
727
735
bus_unregister_notifier (& i2c_bus_type , & atr -> i2c_nb );
728
736
i2c_atr_free_alias_pool (atr -> alias_pool );
729
737
mutex_destroy (& atr -> lock );
738
+ lockdep_unregister_key (& atr -> lock_key );
730
739
kfree (atr );
731
740
}
732
741
EXPORT_SYMBOL_NS_GPL (i2c_atr_delete , "I2C_ATR" );
@@ -761,8 +770,10 @@ int i2c_atr_add_adapter(struct i2c_atr *atr, struct i2c_atr_adap_desc *desc)
761
770
chan -> atr = atr ;
762
771
chan -> chan_id = chan_id ;
763
772
INIT_LIST_HEAD (& chan -> alias_pairs );
764
- mutex_init (& chan -> alias_pairs_lock );
765
- mutex_init (& chan -> orig_addrs_lock );
773
+ lockdep_register_key (& chan -> alias_pairs_lock_key );
774
+ lockdep_register_key (& chan -> orig_addrs_lock_key );
775
+ mutex_init_with_key (& chan -> alias_pairs_lock , & chan -> alias_pairs_lock_key );
776
+ mutex_init_with_key (& chan -> orig_addrs_lock , & chan -> orig_addrs_lock_key );
766
777
767
778
snprintf (chan -> adap .name , sizeof (chan -> adap .name ), "i2c-%d-atr-%d" ,
768
779
i2c_adapter_id (parent ), chan_id );
@@ -839,6 +850,8 @@ int i2c_atr_add_adapter(struct i2c_atr *atr, struct i2c_atr_adap_desc *desc)
839
850
fwnode_handle_put (dev_fwnode (& chan -> adap .dev ));
840
851
mutex_destroy (& chan -> orig_addrs_lock );
841
852
mutex_destroy (& chan -> alias_pairs_lock );
853
+ lockdep_unregister_key (& chan -> orig_addrs_lock_key );
854
+ lockdep_unregister_key (& chan -> alias_pairs_lock_key );
842
855
kfree (chan );
843
856
return ret ;
844
857
}
@@ -876,6 +889,8 @@ void i2c_atr_del_adapter(struct i2c_atr *atr, u32 chan_id)
876
889
fwnode_handle_put (fwnode );
877
890
mutex_destroy (& chan -> orig_addrs_lock );
878
891
mutex_destroy (& chan -> alias_pairs_lock );
892
+ lockdep_unregister_key (& chan -> orig_addrs_lock_key );
893
+ lockdep_unregister_key (& chan -> alias_pairs_lock_key );
879
894
kfree (chan -> orig_addrs );
880
895
kfree (chan );
881
896
}
0 commit comments