@@ -1270,6 +1270,37 @@ static int wacom_devm_sysfs_create_group(struct wacom *wacom,
1270
1270
group );
1271
1271
}
1272
1272
1273
+ static void wacom_devm_kfifo_release (struct device * dev , void * res )
1274
+ {
1275
+ struct kfifo_rec_ptr_2 * devres = res ;
1276
+
1277
+ kfifo_free (devres );
1278
+ }
1279
+
1280
+ static int wacom_devm_kfifo_alloc (struct wacom * wacom )
1281
+ {
1282
+ struct wacom_wac * wacom_wac = & wacom -> wacom_wac ;
1283
+ struct kfifo_rec_ptr_2 * pen_fifo = & wacom_wac -> pen_fifo ;
1284
+ int error ;
1285
+
1286
+ pen_fifo = devres_alloc (wacom_devm_kfifo_release ,
1287
+ sizeof (struct kfifo_rec_ptr_2 ),
1288
+ GFP_KERNEL );
1289
+
1290
+ if (!pen_fifo )
1291
+ return - ENOMEM ;
1292
+
1293
+ error = kfifo_alloc (pen_fifo , WACOM_PKGLEN_MAX , GFP_KERNEL );
1294
+ if (error ) {
1295
+ devres_free (pen_fifo );
1296
+ return error ;
1297
+ }
1298
+
1299
+ devres_add (& wacom -> hdev -> dev , pen_fifo );
1300
+
1301
+ return 0 ;
1302
+ }
1303
+
1273
1304
enum led_brightness wacom_leds_brightness_get (struct wacom_led * led )
1274
1305
{
1275
1306
struct wacom * wacom = led -> wacom ;
@@ -2724,7 +2755,7 @@ static int wacom_probe(struct hid_device *hdev,
2724
2755
if (features -> check_for_hid_type && features -> hid_type != hdev -> type )
2725
2756
return - ENODEV ;
2726
2757
2727
- error = kfifo_alloc ( & wacom_wac -> pen_fifo , WACOM_PKGLEN_MAX , GFP_KERNEL );
2758
+ error = wacom_devm_kfifo_alloc ( wacom );
2728
2759
if (error )
2729
2760
return error ;
2730
2761
@@ -2786,8 +2817,6 @@ static void wacom_remove(struct hid_device *hdev)
2786
2817
2787
2818
if (wacom -> wacom_wac .features .type != REMOTE )
2788
2819
wacom_release_resources (wacom );
2789
-
2790
- kfifo_free (& wacom_wac -> pen_fifo );
2791
2820
}
2792
2821
2793
2822
#ifdef CONFIG_PM
0 commit comments