@@ -404,33 +404,13 @@ static int ht16k33_keypad_probe(struct i2c_client *client,
404
404
return input_register_device (keypad -> dev );
405
405
}
406
406
407
- static int ht16k33_probe (struct i2c_client * client )
407
+ static int ht16k33_fbdev_probe (struct device * dev , struct ht16k33_priv * priv ,
408
+ uint32_t brightness )
408
409
{
409
- int err ;
410
- uint32_t dft_brightness ;
411
- struct backlight_device * bl ;
410
+ struct ht16k33_fbdev * fbdev = & priv -> fbdev ;
412
411
struct backlight_properties bl_props ;
413
- struct ht16k33_priv * priv ;
414
- struct ht16k33_fbdev * fbdev ;
415
- struct device * dev = & client -> dev ;
416
- struct device_node * node = dev -> of_node ;
417
-
418
- if (!i2c_check_functionality (client -> adapter , I2C_FUNC_I2C )) {
419
- dev_err (dev , "i2c_check_functionality error\n" );
420
- return - EIO ;
421
- }
422
-
423
- priv = devm_kzalloc (dev , sizeof (* priv ), GFP_KERNEL );
424
- if (!priv )
425
- return - ENOMEM ;
426
-
427
- priv -> client = client ;
428
- i2c_set_clientdata (client , priv );
429
- fbdev = & priv -> fbdev ;
430
-
431
- err = ht16k33_initialize (priv );
432
- if (err )
433
- return err ;
412
+ struct backlight_device * bl ;
413
+ int err ;
434
414
435
415
/* Backlight */
436
416
memset (& bl_props , 0 , sizeof (struct backlight_properties ));
@@ -444,18 +424,7 @@ static int ht16k33_probe(struct i2c_client *client)
444
424
return PTR_ERR (bl );
445
425
}
446
426
447
- err = of_property_read_u32 (node , "default-brightness-level" ,
448
- & dft_brightness );
449
- if (err ) {
450
- dft_brightness = MAX_BRIGHTNESS ;
451
- } else if (dft_brightness > MAX_BRIGHTNESS ) {
452
- dev_warn (dev ,
453
- "invalid default brightness level: %u, using %u\n" ,
454
- dft_brightness , MAX_BRIGHTNESS );
455
- dft_brightness = MAX_BRIGHTNESS ;
456
- }
457
-
458
- bl -> props .brightness = dft_brightness ;
427
+ bl -> props .brightness = brightness ;
459
428
ht16k33_bl_update_status (bl );
460
429
461
430
/* Framebuffer (2 bytes per column) */
@@ -476,8 +445,8 @@ static int ht16k33_probe(struct i2c_client *client)
476
445
goto err_fbdev_buffer ;
477
446
}
478
447
479
- err = of_property_read_u32 (node , "refresh-rate-hz" ,
480
- & fbdev -> refresh_rate );
448
+ err = of_property_read_u32 (dev -> of_node , "refresh-rate-hz" ,
449
+ & fbdev -> refresh_rate );
481
450
if (err ) {
482
451
dev_err (dev , "refresh rate not specified\n" );
483
452
goto err_fbdev_info ;
@@ -499,18 +468,9 @@ static int ht16k33_probe(struct i2c_client *client)
499
468
if (err )
500
469
goto err_fbdev_info ;
501
470
502
- /* Keypad */
503
- if (client -> irq > 0 ) {
504
- err = ht16k33_keypad_probe (client , & priv -> keypad );
505
- if (err )
506
- goto err_fbdev_unregister ;
507
- }
508
-
509
471
ht16k33_fb_queue (priv );
510
472
return 0 ;
511
473
512
- err_fbdev_unregister :
513
- unregister_framebuffer (fbdev -> info );
514
474
err_fbdev_info :
515
475
framebuffer_release (fbdev -> info );
516
476
err_fbdev_buffer :
@@ -519,6 +479,51 @@ static int ht16k33_probe(struct i2c_client *client)
519
479
return err ;
520
480
}
521
481
482
+ static int ht16k33_probe (struct i2c_client * client )
483
+ {
484
+ struct device * dev = & client -> dev ;
485
+ struct ht16k33_priv * priv ;
486
+ uint32_t dft_brightness ;
487
+ int err ;
488
+
489
+ if (!i2c_check_functionality (client -> adapter , I2C_FUNC_I2C )) {
490
+ dev_err (dev , "i2c_check_functionality error\n" );
491
+ return - EIO ;
492
+ }
493
+
494
+ priv = devm_kzalloc (dev , sizeof (* priv ), GFP_KERNEL );
495
+ if (!priv )
496
+ return - ENOMEM ;
497
+
498
+ priv -> client = client ;
499
+ i2c_set_clientdata (client , priv );
500
+
501
+ err = ht16k33_initialize (priv );
502
+ if (err )
503
+ return err ;
504
+
505
+ err = of_property_read_u32 (dev -> of_node , "default-brightness-level" ,
506
+ & dft_brightness );
507
+ if (err ) {
508
+ dft_brightness = MAX_BRIGHTNESS ;
509
+ } else if (dft_brightness > MAX_BRIGHTNESS ) {
510
+ dev_warn (dev ,
511
+ "invalid default brightness level: %u, using %u\n" ,
512
+ dft_brightness , MAX_BRIGHTNESS );
513
+ dft_brightness = MAX_BRIGHTNESS ;
514
+ }
515
+
516
+ /* Keypad */
517
+ if (client -> irq > 0 ) {
518
+ err = ht16k33_keypad_probe (client , & priv -> keypad );
519
+ if (err )
520
+ return err ;
521
+ }
522
+
523
+ /* Frame Buffer Display */
524
+ return ht16k33_fbdev_probe (dev , priv , dft_brightness );
525
+ }
526
+
522
527
static int ht16k33_remove (struct i2c_client * client )
523
528
{
524
529
struct ht16k33_priv * priv = i2c_get_clientdata (client );
0 commit comments