Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
L
linux
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
linux
Commits
c3caebad
Commit
c3caebad
authored
Jan 13, 2008
by
Anton Vorontsov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
pda_power: implement polling
Signed-off-by:
Anton Vorontsov
<
cbou@mail.ru
>
parent
bfde2662
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
46 additions
and
1 deletion
+46
-1
drivers/power/pda_power.c
drivers/power/pda_power.c
+45
-1
include/linux/pda_power.h
include/linux/pda_power.h
+1
-0
No files found.
drivers/power/pda_power.c
View file @
c3caebad
...
@@ -32,6 +32,8 @@ static struct pda_power_pdata *pdata;
...
@@ -32,6 +32,8 @@ static struct pda_power_pdata *pdata;
static
struct
resource
*
ac_irq
,
*
usb_irq
;
static
struct
resource
*
ac_irq
,
*
usb_irq
;
static
struct
timer_list
charger_timer
;
static
struct
timer_list
charger_timer
;
static
struct
timer_list
supply_timer
;
static
struct
timer_list
supply_timer
;
static
struct
timer_list
polling_timer
;
static
int
polling
;
enum
{
enum
{
PDA_PSY_OFFLINE
=
0
,
PDA_PSY_OFFLINE
=
0
,
...
@@ -167,6 +169,31 @@ static irqreturn_t power_changed_isr(int irq, void *power_supply)
...
@@ -167,6 +169,31 @@ static irqreturn_t power_changed_isr(int irq, void *power_supply)
return
IRQ_HANDLED
;
return
IRQ_HANDLED
;
}
}
static
void
polling_timer_func
(
unsigned
long
unused
)
{
int
changed
=
0
;
dev_dbg
(
dev
,
"polling...
\n
"
);
update_status
();
if
(
!
ac_irq
&&
new_ac_status
!=
ac_status
)
{
ac_status
=
PDA_PSY_TO_CHANGE
;
changed
=
1
;
}
if
(
!
usb_irq
&&
new_usb_status
!=
usb_status
)
{
usb_status
=
PDA_PSY_TO_CHANGE
;
changed
=
1
;
}
if
(
changed
)
psy_changed
();
mod_timer
(
&
polling_timer
,
jiffies
+
msecs_to_jiffies
(
pdata
->
polling_interval
));
}
static
int
pda_power_probe
(
struct
platform_device
*
pdev
)
static
int
pda_power_probe
(
struct
platform_device
*
pdev
)
{
{
int
ret
=
0
;
int
ret
=
0
;
...
@@ -191,6 +218,9 @@ static int pda_power_probe(struct platform_device *pdev)
...
@@ -191,6 +218,9 @@ static int pda_power_probe(struct platform_device *pdev)
if
(
!
pdata
->
wait_for_charger
)
if
(
!
pdata
->
wait_for_charger
)
pdata
->
wait_for_charger
=
500
;
pdata
->
wait_for_charger
=
500
;
if
(
!
pdata
->
polling_interval
)
pdata
->
polling_interval
=
2000
;
setup_timer
(
&
charger_timer
,
charger_timer_func
,
0
);
setup_timer
(
&
charger_timer
,
charger_timer_func
,
0
);
setup_timer
(
&
supply_timer
,
supply_timer_func
,
0
);
setup_timer
(
&
supply_timer
,
supply_timer_func
,
0
);
...
@@ -220,6 +250,8 @@ static int pda_power_probe(struct platform_device *pdev)
...
@@ -220,6 +250,8 @@ static int pda_power_probe(struct platform_device *pdev)
dev_err
(
dev
,
"request ac irq failed
\n
"
);
dev_err
(
dev
,
"request ac irq failed
\n
"
);
goto
ac_irq_failed
;
goto
ac_irq_failed
;
}
}
}
else
{
polling
=
1
;
}
}
}
}
...
@@ -239,10 +271,20 @@ static int pda_power_probe(struct platform_device *pdev)
...
@@ -239,10 +271,20 @@ static int pda_power_probe(struct platform_device *pdev)
dev_err
(
dev
,
"request usb irq failed
\n
"
);
dev_err
(
dev
,
"request usb irq failed
\n
"
);
goto
usb_irq_failed
;
goto
usb_irq_failed
;
}
}
}
else
{
polling
=
1
;
}
}
}
}
device_init_wakeup
(
&
pdev
->
dev
,
1
);
if
(
polling
)
{
dev_dbg
(
dev
,
"will poll for status
\n
"
);
setup_timer
(
&
polling_timer
,
polling_timer_func
,
0
);
mod_timer
(
&
polling_timer
,
jiffies
+
msecs_to_jiffies
(
pdata
->
polling_interval
));
}
if
(
ac_irq
||
usb_irq
)
device_init_wakeup
(
&
pdev
->
dev
,
1
);
return
0
;
return
0
;
...
@@ -267,6 +309,8 @@ static int pda_power_remove(struct platform_device *pdev)
...
@@ -267,6 +309,8 @@ static int pda_power_remove(struct platform_device *pdev)
if
(
pdata
->
is_ac_online
&&
ac_irq
)
if
(
pdata
->
is_ac_online
&&
ac_irq
)
free_irq
(
ac_irq
->
start
,
&
pda_psy_ac
);
free_irq
(
ac_irq
->
start
,
&
pda_psy_ac
);
if
(
polling
)
del_timer_sync
(
&
polling_timer
);
del_timer_sync
(
&
charger_timer
);
del_timer_sync
(
&
charger_timer
);
del_timer_sync
(
&
supply_timer
);
del_timer_sync
(
&
supply_timer
);
...
...
include/linux/pda_power.h
View file @
c3caebad
...
@@ -26,6 +26,7 @@ struct pda_power_pdata {
...
@@ -26,6 +26,7 @@ struct pda_power_pdata {
unsigned
int
wait_for_status
;
/* msecs, default is 500 */
unsigned
int
wait_for_status
;
/* msecs, default is 500 */
unsigned
int
wait_for_charger
;
/* msecs, default is 500 */
unsigned
int
wait_for_charger
;
/* msecs, default is 500 */
unsigned
int
polling_interval
;
/* msecs, default is 2000 */
};
};
#endif
/* __PDA_POWER_H__ */
#endif
/* __PDA_POWER_H__ */
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment