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
b83643eb
Commit
b83643eb
authored
Apr 20, 2012
by
Dmitry Torokhov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Input: matrix-keypad - undo GPIO setup if input_register_device fails
Signed-off-by:
Dmitry Torokhov
<
dtor@mail.ru
>
parent
01111fcd
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
30 additions
and
23 deletions
+30
-23
drivers/input/keyboard/matrix_keypad.c
drivers/input/keyboard/matrix_keypad.c
+30
-23
No files found.
drivers/input/keyboard/matrix_keypad.c
View file @
b83643eb
...
...
@@ -299,11 +299,11 @@ static int matrix_keypad_resume(struct device *dev)
static
SIMPLE_DEV_PM_OPS
(
matrix_keypad_pm_ops
,
matrix_keypad_suspend
,
matrix_keypad_resume
);
static
int
__devinit
init_matrix
_gpio
(
struct
platform_device
*
pdev
,
struct
matrix_keypad
*
keypad
)
static
int
__devinit
matrix_keypad_init
_gpio
(
struct
platform_device
*
pdev
,
struct
matrix_keypad
*
keypad
)
{
const
struct
matrix_keypad_platform_data
*
pdata
=
keypad
->
pdata
;
int
i
,
err
=
-
EINVAL
;
int
i
,
err
;
/* initialized strobe lines as outputs, activated */
for
(
i
=
0
;
i
<
pdata
->
num_col_gpios
;
i
++
)
{
...
...
@@ -349,8 +349,7 @@ static int __devinit init_matrix_gpio(struct platform_device *pdev,
"matrix-keypad"
,
keypad
);
if
(
err
)
{
dev_err
(
&
pdev
->
dev
,
"Unable to acquire interrupt "
"for GPIO line %i
\n
"
,
"Unable to acquire interrupt for GPIO line %i
\n
"
,
pdata
->
row_gpios
[
i
]);
goto
err_free_irqs
;
}
...
...
@@ -376,6 +375,25 @@ static int __devinit init_matrix_gpio(struct platform_device *pdev,
return
err
;
}
static
void
matrix_keypad_free_gpio
(
struct
matrix_keypad
*
keypad
)
{
const
struct
matrix_keypad_platform_data
*
pdata
=
keypad
->
pdata
;
int
i
;
if
(
pdata
->
clustered_irq
>
0
)
{
free_irq
(
pdata
->
clustered_irq
,
keypad
);
}
else
{
for
(
i
=
0
;
i
<
pdata
->
num_row_gpios
;
i
++
)
free_irq
(
gpio_to_irq
(
pdata
->
row_gpios
[
i
]),
keypad
);
}
for
(
i
=
0
;
i
<
pdata
->
num_row_gpios
;
i
++
)
gpio_free
(
pdata
->
row_gpios
[
i
]);
for
(
i
=
0
;
i
<
pdata
->
num_col_gpios
;
i
++
)
gpio_free
(
pdata
->
col_gpios
[
i
]);
}
static
int
__devinit
matrix_keypad_probe
(
struct
platform_device
*
pdev
)
{
const
struct
matrix_keypad_platform_data
*
pdata
;
...
...
@@ -435,19 +453,21 @@ static int __devinit matrix_keypad_probe(struct platform_device *pdev)
input_set_capability
(
input_dev
,
EV_MSC
,
MSC_SCAN
);
input_set_drvdata
(
input_dev
,
keypad
);
err
=
init_matrix
_gpio
(
pdev
,
keypad
);
err
=
matrix_keypad_init
_gpio
(
pdev
,
keypad
);
if
(
err
)
goto
err_free_mem
;
err
=
input_register_device
(
keypad
->
input_dev
);
if
(
err
)
goto
err_free_
mem
;
goto
err_free_
gpio
;
device_init_wakeup
(
&
pdev
->
dev
,
pdata
->
wakeup
);
platform_set_drvdata
(
pdev
,
keypad
);
return
0
;
err_free_gpio:
matrix_keypad_free_gpio
(
keypad
);
err_free_mem:
input_free_device
(
input_dev
);
kfree
(
keypad
);
...
...
@@ -457,28 +477,15 @@ static int __devinit matrix_keypad_probe(struct platform_device *pdev)
static
int
__devexit
matrix_keypad_remove
(
struct
platform_device
*
pdev
)
{
struct
matrix_keypad
*
keypad
=
platform_get_drvdata
(
pdev
);
const
struct
matrix_keypad_platform_data
*
pdata
=
keypad
->
pdata
;
int
i
;
device_init_wakeup
(
&
pdev
->
dev
,
0
);
if
(
pdata
->
clustered_irq
>
0
)
{
free_irq
(
pdata
->
clustered_irq
,
keypad
);
}
else
{
for
(
i
=
0
;
i
<
pdata
->
num_row_gpios
;
i
++
)
free_irq
(
gpio_to_irq
(
pdata
->
row_gpios
[
i
]),
keypad
);
}
for
(
i
=
0
;
i
<
pdata
->
num_row_gpios
;
i
++
)
gpio_free
(
pdata
->
row_gpios
[
i
]);
for
(
i
=
0
;
i
<
pdata
->
num_col_gpios
;
i
++
)
gpio_free
(
pdata
->
col_gpios
[
i
]);
matrix_keypad_free_gpio
(
keypad
);
input_unregister_device
(
keypad
->
input_dev
);
platform_set_drvdata
(
pdev
,
NULL
);
kfree
(
keypad
);
platform_set_drvdata
(
pdev
,
NULL
);
return
0
;
}
...
...
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