@@ -1462,7 +1462,7 @@ static struct regulator_dev *regulator_lookup_by_name(const char *name)
1462
1462
static struct regulator_dev * regulator_dev_lookup (struct device * dev ,
1463
1463
const char * supply )
1464
1464
{
1465
- struct regulator_dev * r ;
1465
+ struct regulator_dev * r = NULL ;
1466
1466
struct device_node * node ;
1467
1467
struct regulator_map * map ;
1468
1468
const char * devname = NULL ;
@@ -1489,10 +1489,6 @@ static struct regulator_dev *regulator_dev_lookup(struct device *dev,
1489
1489
if (dev )
1490
1490
devname = dev_name (dev );
1491
1491
1492
- r = regulator_lookup_by_name (supply );
1493
- if (r )
1494
- return r ;
1495
-
1496
1492
mutex_lock (& regulator_list_mutex );
1497
1493
list_for_each_entry (map , & regulator_map_list , list ) {
1498
1494
/* If the mapping has a device set up it must match */
@@ -1508,6 +1504,10 @@ static struct regulator_dev *regulator_dev_lookup(struct device *dev,
1508
1504
}
1509
1505
mutex_unlock (& regulator_list_mutex );
1510
1506
1507
+ if (r )
1508
+ return r ;
1509
+
1510
+ r = regulator_lookup_by_name (supply );
1511
1511
if (r )
1512
1512
return r ;
1513
1513
@@ -4312,41 +4312,31 @@ void *regulator_get_init_drvdata(struct regulator_init_data *reg_init_data)
4312
4312
EXPORT_SYMBOL_GPL (regulator_get_init_drvdata );
4313
4313
4314
4314
#ifdef CONFIG_DEBUG_FS
4315
- static ssize_t supply_map_read_file (struct file * file , char __user * user_buf ,
4316
- size_t count , loff_t * ppos )
4315
+ static int supply_map_show (struct seq_file * sf , void * data )
4317
4316
{
4318
- char * buf = kmalloc (PAGE_SIZE , GFP_KERNEL );
4319
- ssize_t len , ret = 0 ;
4320
4317
struct regulator_map * map ;
4321
4318
4322
- if (!buf )
4323
- return - ENOMEM ;
4324
-
4325
4319
list_for_each_entry (map , & regulator_map_list , list ) {
4326
- len = snprintf (buf + ret , PAGE_SIZE - ret ,
4327
- "%s -> %s.%s\n" ,
4328
- rdev_get_name (map -> regulator ), map -> dev_name ,
4329
- map -> supply );
4330
- if (len >= 0 )
4331
- ret += len ;
4332
- if (ret > PAGE_SIZE ) {
4333
- ret = PAGE_SIZE ;
4334
- break ;
4335
- }
4320
+ seq_printf (sf , "%s -> %s.%s\n" ,
4321
+ rdev_get_name (map -> regulator ), map -> dev_name ,
4322
+ map -> supply );
4336
4323
}
4337
4324
4338
- ret = simple_read_from_buffer (user_buf , count , ppos , buf , ret );
4339
-
4340
- kfree (buf );
4325
+ return 0 ;
4326
+ }
4341
4327
4342
- return ret ;
4328
+ static int supply_map_open (struct inode * inode , struct file * file )
4329
+ {
4330
+ return single_open (file , supply_map_show , inode -> i_private );
4343
4331
}
4344
4332
#endif
4345
4333
4346
4334
static const struct file_operations supply_map_fops = {
4347
4335
#ifdef CONFIG_DEBUG_FS
4348
- .read = supply_map_read_file ,
4349
- .llseek = default_llseek ,
4336
+ .open = supply_map_open ,
4337
+ .read = seq_read ,
4338
+ .llseek = seq_lseek ,
4339
+ .release = single_release ,
4350
4340
#endif
4351
4341
};
4352
4342
0 commit comments