@@ -1157,7 +1157,6 @@ struct opp_table *dev_pm_opp_set_supported_hw(struct device *dev,
1157
1157
const u32 * versions , unsigned int count )
1158
1158
{
1159
1159
struct opp_table * opp_table ;
1160
- int ret ;
1161
1160
1162
1161
opp_table = dev_pm_opp_get_opp_table (dev );
1163
1162
if (!opp_table )
@@ -1166,29 +1165,20 @@ struct opp_table *dev_pm_opp_set_supported_hw(struct device *dev,
1166
1165
/* Make sure there are no concurrent readers while updating opp_table */
1167
1166
WARN_ON (!list_empty (& opp_table -> opp_list ));
1168
1167
1169
- /* Do we already have a version hierarchy associated with opp_table? */
1170
- if (opp_table -> supported_hw ) {
1171
- dev_err (dev , "%s: Already have supported hardware list\n" ,
1172
- __func__ );
1173
- ret = - EBUSY ;
1174
- goto err ;
1175
- }
1168
+ /* Another CPU that shares the OPP table has set the property ? */
1169
+ if (opp_table -> supported_hw )
1170
+ return opp_table ;
1176
1171
1177
1172
opp_table -> supported_hw = kmemdup (versions , count * sizeof (* versions ),
1178
1173
GFP_KERNEL );
1179
1174
if (!opp_table -> supported_hw ) {
1180
- ret = - ENOMEM ;
1181
- goto err ;
1175
+ dev_pm_opp_put_opp_table ( opp_table ) ;
1176
+ return ERR_PTR ( - ENOMEM ) ;
1182
1177
}
1183
1178
1184
1179
opp_table -> supported_hw_count = count ;
1185
1180
1186
1181
return opp_table ;
1187
-
1188
- err :
1189
- dev_pm_opp_put_opp_table (opp_table );
1190
-
1191
- return ERR_PTR (ret );
1192
1182
}
1193
1183
EXPORT_SYMBOL_GPL (dev_pm_opp_set_supported_hw );
1194
1184
@@ -1205,12 +1195,6 @@ void dev_pm_opp_put_supported_hw(struct opp_table *opp_table)
1205
1195
/* Make sure there are no concurrent readers while updating opp_table */
1206
1196
WARN_ON (!list_empty (& opp_table -> opp_list ));
1207
1197
1208
- if (!opp_table -> supported_hw ) {
1209
- pr_err ("%s: Doesn't have supported hardware list\n" ,
1210
- __func__ );
1211
- return ;
1212
- }
1213
-
1214
1198
kfree (opp_table -> supported_hw );
1215
1199
opp_table -> supported_hw = NULL ;
1216
1200
opp_table -> supported_hw_count = 0 ;
@@ -1232,7 +1216,6 @@ EXPORT_SYMBOL_GPL(dev_pm_opp_put_supported_hw);
1232
1216
struct opp_table * dev_pm_opp_set_prop_name (struct device * dev , const char * name )
1233
1217
{
1234
1218
struct opp_table * opp_table ;
1235
- int ret ;
1236
1219
1237
1220
opp_table = dev_pm_opp_get_opp_table (dev );
1238
1221
if (!opp_table )
@@ -1241,26 +1224,17 @@ struct opp_table *dev_pm_opp_set_prop_name(struct device *dev, const char *name)
1241
1224
/* Make sure there are no concurrent readers while updating opp_table */
1242
1225
WARN_ON (!list_empty (& opp_table -> opp_list ));
1243
1226
1244
- /* Do we already have a prop-name associated with opp_table? */
1245
- if (opp_table -> prop_name ) {
1246
- dev_err (dev , "%s: Already have prop-name %s\n" , __func__ ,
1247
- opp_table -> prop_name );
1248
- ret = - EBUSY ;
1249
- goto err ;
1250
- }
1227
+ /* Another CPU that shares the OPP table has set the property ? */
1228
+ if (opp_table -> prop_name )
1229
+ return opp_table ;
1251
1230
1252
1231
opp_table -> prop_name = kstrdup (name , GFP_KERNEL );
1253
1232
if (!opp_table -> prop_name ) {
1254
- ret = - ENOMEM ;
1255
- goto err ;
1233
+ dev_pm_opp_put_opp_table ( opp_table ) ;
1234
+ return ERR_PTR ( - ENOMEM ) ;
1256
1235
}
1257
1236
1258
1237
return opp_table ;
1259
-
1260
- err :
1261
- dev_pm_opp_put_opp_table (opp_table );
1262
-
1263
- return ERR_PTR (ret );
1264
1238
}
1265
1239
EXPORT_SYMBOL_GPL (dev_pm_opp_set_prop_name );
1266
1240
@@ -1277,11 +1251,6 @@ void dev_pm_opp_put_prop_name(struct opp_table *opp_table)
1277
1251
/* Make sure there are no concurrent readers while updating opp_table */
1278
1252
WARN_ON (!list_empty (& opp_table -> opp_list ));
1279
1253
1280
- if (!opp_table -> prop_name ) {
1281
- pr_err ("%s: Doesn't have a prop-name\n" , __func__ );
1282
- return ;
1283
- }
1284
-
1285
1254
kfree (opp_table -> prop_name );
1286
1255
opp_table -> prop_name = NULL ;
1287
1256
@@ -1351,11 +1320,9 @@ struct opp_table *dev_pm_opp_set_regulators(struct device *dev,
1351
1320
goto err ;
1352
1321
}
1353
1322
1354
- /* Already have regulators set */
1355
- if (opp_table -> regulators ) {
1356
- ret = - EBUSY ;
1357
- goto err ;
1358
- }
1323
+ /* Another CPU that shares the OPP table has set the regulators ? */
1324
+ if (opp_table -> regulators )
1325
+ return opp_table ;
1359
1326
1360
1327
opp_table -> regulators = kmalloc_array (count ,
1361
1328
sizeof (* opp_table -> regulators ),
@@ -1409,10 +1376,8 @@ void dev_pm_opp_put_regulators(struct opp_table *opp_table)
1409
1376
{
1410
1377
int i ;
1411
1378
1412
- if (!opp_table -> regulators ) {
1413
- pr_err ("%s: Doesn't have regulators set\n" , __func__ );
1414
- return ;
1415
- }
1379
+ if (!opp_table -> regulators )
1380
+ goto put_opp_table ;
1416
1381
1417
1382
/* Make sure there are no concurrent readers while updating opp_table */
1418
1383
WARN_ON (!list_empty (& opp_table -> opp_list ));
@@ -1426,6 +1391,7 @@ void dev_pm_opp_put_regulators(struct opp_table *opp_table)
1426
1391
opp_table -> regulators = NULL ;
1427
1392
opp_table -> regulator_count = 0 ;
1428
1393
1394
+ put_opp_table :
1429
1395
dev_pm_opp_put_opp_table (opp_table );
1430
1396
}
1431
1397
EXPORT_SYMBOL_GPL (dev_pm_opp_put_regulators );
@@ -1511,7 +1477,6 @@ struct opp_table *dev_pm_opp_register_set_opp_helper(struct device *dev,
1511
1477
int (* set_opp )(struct dev_pm_set_opp_data * data ))
1512
1478
{
1513
1479
struct opp_table * opp_table ;
1514
- int ret ;
1515
1480
1516
1481
if (!set_opp )
1517
1482
return ERR_PTR (- EINVAL );
@@ -1522,24 +1487,15 @@ struct opp_table *dev_pm_opp_register_set_opp_helper(struct device *dev,
1522
1487
1523
1488
/* This should be called before OPPs are initialized */
1524
1489
if (WARN_ON (!list_empty (& opp_table -> opp_list ))) {
1525
- ret = - EBUSY ;
1526
- goto err ;
1490
+ dev_pm_opp_put_opp_table ( opp_table ) ;
1491
+ return ERR_PTR ( - EBUSY ) ;
1527
1492
}
1528
1493
1529
- /* Already have custom set_opp helper */
1530
- if (WARN_ON (opp_table -> set_opp )) {
1531
- ret = - EBUSY ;
1532
- goto err ;
1533
- }
1534
-
1535
- opp_table -> set_opp = set_opp ;
1494
+ /* Another CPU that shares the OPP table has set the helper ? */
1495
+ if (!opp_table -> set_opp )
1496
+ opp_table -> set_opp = set_opp ;
1536
1497
1537
1498
return opp_table ;
1538
-
1539
- err :
1540
- dev_pm_opp_put_opp_table (opp_table );
1541
-
1542
- return ERR_PTR (ret );
1543
1499
}
1544
1500
EXPORT_SYMBOL_GPL (dev_pm_opp_register_set_opp_helper );
1545
1501
@@ -1552,17 +1508,10 @@ EXPORT_SYMBOL_GPL(dev_pm_opp_register_set_opp_helper);
1552
1508
*/
1553
1509
void dev_pm_opp_unregister_set_opp_helper (struct opp_table * opp_table )
1554
1510
{
1555
- if (!opp_table -> set_opp ) {
1556
- pr_err ("%s: Doesn't have custom set_opp helper set\n" ,
1557
- __func__ );
1558
- return ;
1559
- }
1560
-
1561
1511
/* Make sure there are no concurrent readers while updating opp_table */
1562
1512
WARN_ON (!list_empty (& opp_table -> opp_list ));
1563
1513
1564
1514
opp_table -> set_opp = NULL ;
1565
-
1566
1515
dev_pm_opp_put_opp_table (opp_table );
1567
1516
}
1568
1517
EXPORT_SYMBOL_GPL (dev_pm_opp_unregister_set_opp_helper );
0 commit comments