@@ -235,7 +235,6 @@ void fbtft_unregister_backlight(struct fbtft_par *par)
235
235
bl_ops = par -> info -> bl_dev -> ops ;
236
236
backlight_device_unregister (par -> info -> bl_dev );
237
237
par -> info -> bl_dev = NULL ;
238
- kfree (bl_ops );
239
238
}
240
239
}
241
240
@@ -253,7 +252,8 @@ void fbtft_register_backlight(struct fbtft_par *par)
253
252
return ;
254
253
}
255
254
256
- bl_ops = kzalloc (sizeof (struct backlight_ops ), GFP_KERNEL );
255
+ bl_ops = devm_kzalloc (par -> info -> device , sizeof (struct backlight_ops ),
256
+ GFP_KERNEL );
257
257
if (!bl_ops ) {
258
258
dev_err (par -> info -> device ,
259
259
"%s: could not allocate memeory for backlight operations.\n" ,
@@ -275,17 +275,12 @@ void fbtft_register_backlight(struct fbtft_par *par)
275
275
dev_err (par -> info -> device ,
276
276
"cannot register backlight device (%ld)\n" ,
277
277
PTR_ERR (bd ));
278
- goto failed ;
278
+ return ;
279
279
}
280
280
par -> info -> bl_dev = bd ;
281
281
282
282
if (!par -> fbtftops .unregister_backlight )
283
283
par -> fbtftops .unregister_backlight = fbtft_unregister_backlight ;
284
-
285
- return ;
286
-
287
- failed :
288
- kfree (bl_ops );
289
284
}
290
285
#else
291
286
void fbtft_register_backlight (struct fbtft_par * par ) { };
@@ -715,20 +710,21 @@ struct fb_info *fbtft_framebuffer_alloc(struct fbtft_display *display,
715
710
if (!vmem )
716
711
goto alloc_fail ;
717
712
718
- fbops = kzalloc ( sizeof (struct fb_ops ), GFP_KERNEL );
713
+ fbops = devm_kzalloc ( dev , sizeof (struct fb_ops ), GFP_KERNEL );
719
714
if (!fbops )
720
715
goto alloc_fail ;
721
716
722
- fbdefio = kzalloc ( sizeof (struct fb_deferred_io ), GFP_KERNEL );
717
+ fbdefio = devm_kzalloc ( dev , sizeof (struct fb_deferred_io ), GFP_KERNEL );
723
718
if (!fbdefio )
724
719
goto alloc_fail ;
725
720
726
- buf = kmalloc ( 128 , GFP_KERNEL );
721
+ buf = devm_kzalloc ( dev , 128 , GFP_KERNEL );
727
722
if (!buf )
728
723
goto alloc_fail ;
729
724
730
725
if (display -> gamma_num && display -> gamma_len ) {
731
- gamma_curves = kzalloc (display -> gamma_num * display -> gamma_len * sizeof (gamma_curves [0 ]), GFP_KERNEL );
726
+ gamma_curves = devm_kzalloc (dev , display -> gamma_num * display -> gamma_len * sizeof (gamma_curves [0 ]),
727
+ GFP_KERNEL );
732
728
if (!gamma_curves )
733
729
goto alloc_fail ;
734
730
}
@@ -815,9 +811,9 @@ struct fb_info *fbtft_framebuffer_alloc(struct fbtft_display *display,
815
811
if (txbuflen > 0 ) {
816
812
if (dma ) {
817
813
dev -> coherent_dma_mask = ~0 ;
818
- txbuf = dma_alloc_coherent (dev , txbuflen , & par -> txbuf .dma , GFP_DMA );
814
+ txbuf = dmam_alloc_coherent (dev , txbuflen , & par -> txbuf .dma , GFP_DMA );
819
815
} else {
820
- txbuf = kmalloc ( txbuflen , GFP_KERNEL );
816
+ txbuf = devm_kzalloc ( par -> info -> device , txbuflen , GFP_KERNEL );
821
817
}
822
818
if (!txbuf )
823
819
goto alloc_fail ;
@@ -846,10 +842,6 @@ struct fb_info *fbtft_framebuffer_alloc(struct fbtft_display *display,
846
842
847
843
alloc_fail :
848
844
vfree (vmem );
849
- kfree (buf );
850
- kfree (fbops );
851
- kfree (fbdefio );
852
- kfree (gamma_curves );
853
845
854
846
return NULL ;
855
847
}
@@ -863,20 +855,8 @@ EXPORT_SYMBOL(fbtft_framebuffer_alloc);
863
855
*/
864
856
void fbtft_framebuffer_release (struct fb_info * info )
865
857
{
866
- struct fbtft_par * par = info -> par ;
867
-
868
858
fb_deferred_io_cleanup (info );
869
859
vfree (info -> screen_base );
870
- if (par -> txbuf .buf ) {
871
- if (par -> txbuf .dma )
872
- dma_free_coherent (info -> device , par -> txbuf .len , par -> txbuf .buf , par -> txbuf .dma );
873
- else
874
- kfree (par -> txbuf .buf );
875
- }
876
- kfree (par -> buf );
877
- kfree (info -> fbops );
878
- kfree (info -> fbdefio );
879
- kfree (par -> gamma .curves );
880
860
framebuffer_release (info );
881
861
}
882
862
EXPORT_SYMBOL (fbtft_framebuffer_release );
@@ -1273,7 +1253,7 @@ int fbtft_probe_common(struct fbtft_display *display,
1273
1253
if (ret )
1274
1254
goto out_release ;
1275
1255
/* allocate buffer with room for dc bits */
1276
- par -> extra = kmalloc (
1256
+ par -> extra = devm_kzalloc ( par -> info -> device ,
1277
1257
par -> txbuf .len + (par -> txbuf .len / 8 ) + 8 ,
1278
1258
GFP_KERNEL );
1279
1259
if (!par -> extra ) {
@@ -1327,12 +1307,9 @@ int fbtft_remove_common(struct device *dev, struct fb_info *info)
1327
1307
if (!info )
1328
1308
return - EINVAL ;
1329
1309
par = info -> par ;
1330
- if (par ) {
1310
+ if (par )
1331
1311
fbtft_par_dbg (DEBUG_DRIVER_INIT_FUNCTIONS , par ,
1332
1312
"%s()\n" , __func__ );
1333
- if (par -> extra )
1334
- kfree (par -> extra );
1335
- }
1336
1313
fbtft_unregister_framebuffer (info );
1337
1314
fbtft_framebuffer_release (info );
1338
1315
0 commit comments