@@ -507,14 +507,6 @@ static const struct at24_chip_data *at24_get_chip_data(struct device *dev)
507
507
return cdata ;
508
508
}
509
509
510
- static void at24_remove_dummy_clients (struct at24_data * at24 )
511
- {
512
- int i ;
513
-
514
- for (i = 1 ; i < at24 -> num_addresses ; i ++ )
515
- i2c_unregister_device (at24 -> client [i ].client );
516
- }
517
-
518
510
static int at24_make_dummy_client (struct at24_data * at24 , unsigned int index ,
519
511
struct regmap_config * regmap_config )
520
512
{
@@ -527,18 +519,14 @@ static int at24_make_dummy_client(struct at24_data *at24, unsigned int index,
527
519
dev = & base_client -> dev ;
528
520
addr = base_client -> addr + index ;
529
521
530
- dummy_client = i2c_new_dummy (base_client -> adapter ,
531
- base_client -> addr + index );
532
- if (!dummy_client ) {
533
- dev_err (dev , "address 0x%02x unavailable\n" , addr );
534
- return - EADDRINUSE ;
535
- }
522
+ dummy_client = devm_i2c_new_dummy_device (dev , base_client -> adapter ,
523
+ base_client -> addr + index );
524
+ if (IS_ERR (dummy_client ))
525
+ return PTR_ERR (dummy_client );
536
526
537
527
regmap = devm_regmap_init_i2c (dummy_client , regmap_config );
538
- if (IS_ERR (regmap )) {
539
- i2c_unregister_device (dummy_client );
528
+ if (IS_ERR (regmap ))
540
529
return PTR_ERR (regmap );
541
- }
542
530
543
531
at24 -> client [index ].client = dummy_client ;
544
532
at24 -> client [index ].regmap = regmap ;
@@ -693,10 +681,8 @@ static int at24_probe(struct i2c_client *client)
693
681
/* use dummy devices for multiple-address chips */
694
682
for (i = 1 ; i < num_addresses ; i ++ ) {
695
683
err = at24_make_dummy_client (at24 , i , & regmap_config );
696
- if (err ) {
697
- at24_remove_dummy_clients (at24 );
684
+ if (err )
698
685
return err ;
699
- }
700
686
}
701
687
702
688
i2c_set_clientdata (client , at24 );
@@ -713,7 +699,7 @@ static int at24_probe(struct i2c_client *client)
713
699
pm_runtime_idle (dev );
714
700
if (err ) {
715
701
err = - ENODEV ;
716
- goto err_clients ;
702
+ goto err_runtime_pm ;
717
703
}
718
704
719
705
nvmem_config .name = dev_name (dev );
@@ -733,7 +719,7 @@ static int at24_probe(struct i2c_client *client)
733
719
at24 -> nvmem = devm_nvmem_register (dev , & nvmem_config );
734
720
if (IS_ERR (at24 -> nvmem )) {
735
721
err = PTR_ERR (at24 -> nvmem );
736
- goto err_clients ;
722
+ goto err_runtime_pm ;
737
723
}
738
724
739
725
dev_info (dev , "%u byte %s EEPROM, %s, %u bytes/write\n" ,
@@ -742,20 +728,14 @@ static int at24_probe(struct i2c_client *client)
742
728
743
729
return 0 ;
744
730
745
- err_clients :
746
- at24_remove_dummy_clients (at24 );
731
+ err_runtime_pm :
747
732
pm_runtime_disable (dev );
748
733
749
734
return err ;
750
735
}
751
736
752
737
static int at24_remove (struct i2c_client * client )
753
738
{
754
- struct at24_data * at24 ;
755
-
756
- at24 = i2c_get_clientdata (client );
757
-
758
- at24_remove_dummy_clients (at24 );
759
739
pm_runtime_disable (& client -> dev );
760
740
pm_runtime_set_suspended (& client -> dev );
761
741
0 commit comments