@@ -114,6 +114,7 @@ static volatile unsigned char __iomem *via;
114
114
#define CB1_INT 0x10 /* transition on CB1 input */
115
115
116
116
static volatile enum pmu_state {
117
+ uninitialized = 0 ,
117
118
idle ,
118
119
sending ,
119
120
intack ,
@@ -274,7 +275,7 @@ int __init find_via_pmu(void)
274
275
u64 taddr ;
275
276
const u32 * reg ;
276
277
277
- if (via )
278
+ if (pmu_state != uninitialized )
278
279
return 1 ;
279
280
vias = of_find_node_by_name (NULL , "via-pmu" );
280
281
if (vias == NULL )
@@ -369,20 +370,19 @@ int __init find_via_pmu(void)
369
370
fail :
370
371
of_node_put (vias );
371
372
vias = NULL ;
373
+ pmu_state = uninitialized ;
372
374
return 0 ;
373
375
}
374
376
375
377
#ifdef CONFIG_ADB
376
378
static int pmu_probe (void )
377
379
{
378
- return vias == NULL ? - ENODEV : 0 ;
380
+ return pmu_state == uninitialized ? - ENODEV : 0 ;
379
381
}
380
382
381
383
static int pmu_init (void )
382
384
{
383
- if (vias == NULL )
384
- return - ENODEV ;
385
- return 0 ;
385
+ return pmu_state == uninitialized ? - ENODEV : 0 ;
386
386
}
387
387
#endif /* CONFIG_ADB */
388
388
@@ -397,7 +397,7 @@ static int __init via_pmu_start(void)
397
397
{
398
398
unsigned int irq ;
399
399
400
- if (vias == NULL )
400
+ if (pmu_state == uninitialized )
401
401
return - ENODEV ;
402
402
403
403
batt_req .complete = 1 ;
@@ -463,7 +463,7 @@ arch_initcall(via_pmu_start);
463
463
*/
464
464
static int __init via_pmu_dev_init (void )
465
465
{
466
- if (vias == NULL )
466
+ if (pmu_state == uninitialized )
467
467
return - ENODEV ;
468
468
469
469
#ifdef CONFIG_PMAC_BACKLIGHT
@@ -929,7 +929,7 @@ static int pmu_send_request(struct adb_request *req, int sync)
929
929
{
930
930
int i , ret ;
931
931
932
- if (( vias == NULL ) || ( !pmu_fully_inited ) ) {
932
+ if (pmu_state == uninitialized || !pmu_fully_inited ) {
933
933
req -> complete = 1 ;
934
934
return - ENXIO ;
935
935
}
@@ -1023,7 +1023,7 @@ static int __pmu_adb_autopoll(int devs)
1023
1023
1024
1024
static int pmu_adb_autopoll (int devs )
1025
1025
{
1026
- if (( vias == NULL ) || ( !pmu_fully_inited ) || !pmu_has_adb )
1026
+ if (pmu_state == uninitialized || !pmu_fully_inited || !pmu_has_adb )
1027
1027
return - ENXIO ;
1028
1028
1029
1029
adb_dev_map = devs ;
@@ -1036,7 +1036,7 @@ static int pmu_adb_reset_bus(void)
1036
1036
struct adb_request req ;
1037
1037
int save_autopoll = adb_dev_map ;
1038
1038
1039
- if (( vias == NULL ) || ( !pmu_fully_inited ) || !pmu_has_adb )
1039
+ if (pmu_state == uninitialized || !pmu_fully_inited || !pmu_has_adb )
1040
1040
return - ENXIO ;
1041
1041
1042
1042
/* anyone got a better idea?? */
@@ -1072,7 +1072,7 @@ pmu_request(struct adb_request *req, void (*done)(struct adb_request *),
1072
1072
va_list list ;
1073
1073
int i ;
1074
1074
1075
- if (vias == NULL )
1075
+ if (pmu_state == uninitialized )
1076
1076
return - ENXIO ;
1077
1077
1078
1078
if (nbytes < 0 || nbytes > 32 ) {
@@ -1097,7 +1097,7 @@ pmu_queue_request(struct adb_request *req)
1097
1097
unsigned long flags ;
1098
1098
int nsend ;
1099
1099
1100
- if (via == NULL ) {
1100
+ if (pmu_state == uninitialized ) {
1101
1101
req -> complete = 1 ;
1102
1102
return - ENXIO ;
1103
1103
}
@@ -1210,7 +1210,7 @@ pmu_start(void)
1210
1210
void
1211
1211
pmu_poll (void )
1212
1212
{
1213
- if (! via )
1213
+ if (pmu_state == uninitialized )
1214
1214
return ;
1215
1215
if (disable_poll )
1216
1216
return ;
@@ -1220,7 +1220,7 @@ pmu_poll(void)
1220
1220
void
1221
1221
pmu_poll_adb (void )
1222
1222
{
1223
- if (! via )
1223
+ if (pmu_state == uninitialized )
1224
1224
return ;
1225
1225
if (disable_poll )
1226
1226
return ;
@@ -1235,7 +1235,7 @@ pmu_poll_adb(void)
1235
1235
void
1236
1236
pmu_wait_complete (struct adb_request * req )
1237
1237
{
1238
- if (! via )
1238
+ if (pmu_state == uninitialized )
1239
1239
return ;
1240
1240
while ((pmu_state != idle && pmu_state != locked ) || !req -> complete )
1241
1241
via_pmu_interrupt (0 , NULL );
@@ -1251,7 +1251,7 @@ pmu_suspend(void)
1251
1251
{
1252
1252
unsigned long flags ;
1253
1253
1254
- if (! via )
1254
+ if (pmu_state == uninitialized )
1255
1255
return ;
1256
1256
1257
1257
spin_lock_irqsave (& pmu_lock , flags );
@@ -1282,7 +1282,7 @@ pmu_resume(void)
1282
1282
{
1283
1283
unsigned long flags ;
1284
1284
1285
- if (! via || ( pmu_suspended < 1 ) )
1285
+ if (pmu_state == uninitialized || pmu_suspended < 1 )
1286
1286
return ;
1287
1287
1288
1288
spin_lock_irqsave (& pmu_lock , flags );
@@ -1644,7 +1644,7 @@ pmu_enable_irled(int on)
1644
1644
{
1645
1645
struct adb_request req ;
1646
1646
1647
- if (vias == NULL )
1647
+ if (pmu_state == uninitialized )
1648
1648
return ;
1649
1649
if (pmu_kind == PMU_KEYLARGO_BASED )
1650
1650
return ;
@@ -1659,7 +1659,7 @@ pmu_restart(void)
1659
1659
{
1660
1660
struct adb_request req ;
1661
1661
1662
- if (via == NULL )
1662
+ if (pmu_state == uninitialized )
1663
1663
return ;
1664
1664
1665
1665
local_irq_disable ();
@@ -1684,7 +1684,7 @@ pmu_shutdown(void)
1684
1684
{
1685
1685
struct adb_request req ;
1686
1686
1687
- if (via == NULL )
1687
+ if (pmu_state == uninitialized )
1688
1688
return ;
1689
1689
1690
1690
local_irq_disable ();
@@ -1712,7 +1712,7 @@ pmu_shutdown(void)
1712
1712
int
1713
1713
pmu_present (void )
1714
1714
{
1715
- return via != NULL ;
1715
+ return pmu_state != uninitialized ;
1716
1716
}
1717
1717
1718
1718
#if defined(CONFIG_SUSPEND ) && defined(CONFIG_PPC32 )
@@ -2378,7 +2378,7 @@ static struct miscdevice pmu_device = {
2378
2378
2379
2379
static int pmu_device_init (void )
2380
2380
{
2381
- if (! via )
2381
+ if (pmu_state == uninitialized )
2382
2382
return 0 ;
2383
2383
if (misc_register (& pmu_device ) < 0 )
2384
2384
printk (KERN_ERR "via-pmu: cannot register misc device.\n" );
0 commit comments