@@ -60,6 +60,7 @@ struct aspeed_lpc_snoop_model_data {
60
60
};
61
61
62
62
struct aspeed_lpc_snoop_channel {
63
+ bool enabled ;
63
64
struct kfifo fifo ;
64
65
wait_queue_head_t wq ;
65
66
struct miscdevice miscdev ;
@@ -192,6 +193,9 @@ static int aspeed_lpc_enable_snoop(struct aspeed_lpc_snoop *lpc_snoop,
192
193
const struct aspeed_lpc_snoop_model_data * model_data =
193
194
of_device_get_match_data (dev );
194
195
196
+ if (WARN_ON (lpc_snoop -> chan [channel ].enabled ))
197
+ return - EBUSY ;
198
+
195
199
init_waitqueue_head (& lpc_snoop -> chan [channel ].wq );
196
200
/* Create FIFO datastructure */
197
201
rc = kfifo_alloc (& lpc_snoop -> chan [channel ].fifo ,
@@ -238,6 +242,8 @@ static int aspeed_lpc_enable_snoop(struct aspeed_lpc_snoop *lpc_snoop,
238
242
regmap_update_bits (lpc_snoop -> regmap , HICRB ,
239
243
hicrb_en , hicrb_en );
240
244
245
+ lpc_snoop -> chan [channel ].enabled = true;
246
+
241
247
return 0 ;
242
248
243
249
err_misc_deregister :
@@ -250,6 +256,9 @@ static int aspeed_lpc_enable_snoop(struct aspeed_lpc_snoop *lpc_snoop,
250
256
static void aspeed_lpc_disable_snoop (struct aspeed_lpc_snoop * lpc_snoop ,
251
257
int channel )
252
258
{
259
+ if (!lpc_snoop -> chan [channel ].enabled )
260
+ return ;
261
+
253
262
switch (channel ) {
254
263
case 0 :
255
264
regmap_update_bits (lpc_snoop -> regmap , HICR5 ,
@@ -265,6 +274,8 @@ static void aspeed_lpc_disable_snoop(struct aspeed_lpc_snoop *lpc_snoop,
265
274
return ;
266
275
}
267
276
277
+ lpc_snoop -> chan [channel ].enabled = false;
278
+ /* Consider improving safety wrt concurrent reader(s) */
268
279
misc_deregister (& lpc_snoop -> chan [channel ].miscdev );
269
280
kfifo_free (& lpc_snoop -> chan [channel ].fifo );
270
281
}
0 commit comments