BigW Consortium Gitlab
Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
M
mangoh-drivers
Project
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
Forest Godfrey
mangoh-drivers
Commits
497117a7
Commit
497117a7
authored
Nov 02, 2018
by
David Frey
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Perform error checks in expander kernel module
parent
af97a009
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
49 additions
and
15 deletions
+49
-15
expander.c
linux_kernel_modules/expander/expander.c
+49
-15
No files found.
linux_kernel_modules/expander/expander.c
View file @
497117a7
...
...
@@ -61,22 +61,35 @@ CREATE_SYSFS_DEFN(tri_led_grn, TRI_LED_GRN);
CREATE_SYSFS_DEFN
(
buzzer
,
BUZZER
);
static
void
gpio_initial_status
(
struct
platform_device
*
pdev
,
static
int
gpio_initial_status
(
struct
platform_device
*
pdev
,
struct
device_attribute
*
attr
,
int
function_number
,
int
function_val
,
atomic_t
*
atomic_val
)
{
int
ret
=
0
;
struct
expander_device
*
exp
=
dev_get_drvdata
(
&
pdev
->
dev
);
devm_gpio_request
(
&
pdev
->
dev
,
exp
->
gpio_expander_base
+
function_number
,
dev_name
(
&
pdev
->
dev
));
const
int
gpio_num
=
exp
->
gpio_expander_base
+
function_number
;
ret
=
devm_gpio_request_one
(
&
pdev
->
dev
,
gpio_num
,
(
GPIOF_DIR_OUT
|
(
function_val
?
GPIOF_INIT_HIGH
:
GPIOF_INIT_LOW
)),
attr
->
attr
.
name
);
if
(
ret
!=
0
)
{
dev_err
(
&
pdev
->
dev
,
"Couldn't request GPIO %d
\n
"
,
gpio_num
);
return
ret
;
}
atomic_set
(
atomic_val
,
function_val
);
gpio_direction_output
(
exp
->
gpio_expander_base
+
function_number
,
function_val
);
ret
=
device_create_file
(
&
pdev
->
dev
,
attr
);
if
(
ret
!=
0
)
{
dev_err
(
&
pdev
->
dev
,
"Couldn't create sysfs file for %s
\n
"
,
attr
->
attr
.
name
);
return
ret
;
}
device_create_file
(
&
pdev
->
dev
,
attr
)
;
return
ret
;
}
static
void
gpio_final_status
(
struct
platform_device
*
pdev
,
...
...
@@ -114,23 +127,44 @@ static int expander_probe(struct platform_device *pdev)
dev
->
pdev
=
pdev
;
dev
->
gpio_expander_base
=
pdata
->
gpio_expander_base
;
platform_set_drvdata
(
pdev
,
dev
);
gpio_initial_status
(
pdev
,
&
dev_attr_generic_led
,
GENERIC_LED
,
0
,
ret
=
gpio_initial_status
(
pdev
,
&
dev_attr_generic_led
,
GENERIC_LED
,
0
,
&
dev
->
generic_led_val
);
gpio_initial_status
(
pdev
,
&
dev_attr_pcm_sel
,
PCM_SEL
,
0
,
if
(
ret
!=
0
)
goto
done
;
ret
=
gpio_initial_status
(
pdev
,
&
dev_attr_pcm_sel
,
PCM_SEL
,
0
,
&
dev
->
pcm_sel_val
);
gpio_initial_status
(
pdev
,
&
dev_attr_sdio_sel
,
SDIO_SEL
,
0
,
if
(
ret
!=
0
)
goto
done
;
ret
=
gpio_initial_status
(
pdev
,
&
dev_attr_sdio_sel
,
SDIO_SEL
,
0
,
&
dev
->
sdio_sel_val
);
gpio_initial_status
(
pdev
,
&
dev_attr_tri_led_blu
,
TRI_LED_BLU
,
0
,
if
(
ret
!=
0
)
goto
done
;
ret
=
gpio_initial_status
(
pdev
,
&
dev_attr_tri_led_blu
,
TRI_LED_BLU
,
0
,
&
dev
->
tri_led_blu_val
);
gpio_initial_status
(
pdev
,
&
dev_attr_tri_led_red
,
TRI_LED_RED
,
0
,
if
(
ret
!=
0
)
goto
done
;
ret
=
gpio_initial_status
(
pdev
,
&
dev_attr_tri_led_red
,
TRI_LED_RED
,
0
,
&
dev
->
tri_led_red_val
);
gpio_initial_status
(
pdev
,
&
dev_attr_tri_led_grn
,
TRI_LED_GRN
,
0
,
if
(
ret
!=
0
)
goto
done
;
ret
=
gpio_initial_status
(
pdev
,
&
dev_attr_tri_led_grn
,
TRI_LED_GRN
,
0
,
&
dev
->
tri_led_grn_val
);
gpio_initial_status
(
pdev
,
&
dev_attr_buzzer
,
BUZZER
,
0
,
if
(
ret
!=
0
)
goto
done
;
ret
=
gpio_initial_status
(
pdev
,
&
dev_attr_buzzer
,
BUZZER
,
0
,
&
dev
->
buzzer_val
);
if
(
ret
!=
0
)
goto
done
;
platform_set_drvdata
(
pdev
,
dev
);
done:
return
ret
;
...
...
@@ -140,7 +174,7 @@ static int expander_remove(struct platform_device *pdev)
{
dev_info
(
&
pdev
->
dev
,
"%s(): remove
\n
"
,
__func__
);
/* remove sysfs files & set final state values for gpio expander*/
/* remove sysfs files & set final state values for gpio expander
*/
gpio_final_status
(
pdev
,
&
dev_attr_generic_led
,
GENERIC_LED
,
0
);
gpio_final_status
(
pdev
,
&
dev_attr_pcm_sel
,
PCM_SEL
,
0
);
gpio_final_status
(
pdev
,
&
dev_attr_sdio_sel
,
SDIO_SEL
,
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