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
23033fa8
Commit
23033fa8
authored
Feb 14, 2018
by
David Frey
Committed by
David Clark
Feb 21, 2018
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix indentation in LED kernel module
parent
d0fd2bf8
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
56 additions
and
62 deletions
+56
-62
led.c
linux_kernel_modules/led/led.c
+56
-62
No files found.
linux_kernel_modules/led/led.c
View file @
23033fa8
...
...
@@ -7,106 +7,100 @@
struct
led_device
{
struct
platform_device
*
pdev
;
atomic_t
val
;
int
gpio
;
atomic_t
val
;
int
gpio
;
};
static
ssize_t
led_show
(
struct
device
*
dev
,
struct
device_attribute
*
attr
,
char
*
buf
)
static
ssize_t
led_show
(
struct
device
*
dev
,
struct
device_attribute
*
attr
,
char
*
buf
)
{
struct
led_device
*
led
=
dev_get_drvdata
(
dev
);
return
sprintf
(
buf
,
"%d
\n
"
,
atomic_read
(
&
led
->
val
));
struct
led_device
*
led
=
dev_get_drvdata
(
dev
);
return
sprintf
(
buf
,
"%d
\n
"
,
atomic_read
(
&
led
->
val
));
}
static
int
led_store
(
struct
device
*
dev
,
struct
device_attribute
*
attr
,
const
char
*
buf
,
size_t
count
)
static
int
led_store
(
struct
device
*
dev
,
struct
device_attribute
*
attr
,
const
char
*
buf
,
size_t
count
)
{
struct
led_device
*
led
=
dev_get_drvdata
(
dev
);
unsigned
int
val
;
int
ret
;
struct
led_device
*
led
=
dev_get_drvdata
(
dev
);
unsigned
int
val
;
int
ret
;
ret
=
kstrtoint
(
buf
,
10
,
&
val
);
if
(
ret
||
val
>
1
)
ret
=
kstrtoint
(
buf
,
10
,
&
val
);
if
(
ret
||
val
>
1
)
return
-
EINVAL
;
gpio_set_value_cansleep
(
led
->
gpio
,
val
);
atomic_set
(
&
led
->
val
,
val
);
return
count
;
gpio_set_value_cansleep
(
led
->
gpio
,
val
);
atomic_set
(
&
led
->
val
,
val
);
return
count
;
}
static
DEVICE_ATTR_RW
(
led
);
static
int
led_probe
(
struct
platform_device
*
pdev
)
{
struct
led_platform_data
*
pdata
=
dev_get_platdata
(
&
pdev
->
dev
);
struct
led_device
*
dev
;
struct
led_platform_data
*
pdata
=
dev_get_platdata
(
&
pdev
->
dev
);
struct
led_device
*
dev
;
int
ret
=
0
;
dev_info
(
&
pdev
->
dev
,
"%s(): probe
\n
"
,
__func__
);
dev_info
(
&
pdev
->
dev
,
"%s(): probe
\n
"
,
__func__
);
dev
=
kzalloc
(
sizeof
(
struct
led_device
),
GFP_KERNEL
);
dev
=
kzalloc
(
sizeof
(
struct
led_device
),
GFP_KERNEL
);
if
(
!
dev
)
goto
err_out
;
dev
->
pdev
=
pdev
;
atomic_set
(
&
dev
->
val
,
0
);
pdata
=
dev_get_platdata
(
&
pdev
->
dev
);
dev
->
gpio
=
pdata
->
gpio
;
ret
=
gpio_request
(
dev
->
gpio
,
dev_name
(
&
pdev
->
dev
));
if
(
ret
)
{
dev_err
(
&
pdev
->
dev
,
"failed to request LED gpio
\n
"
);
goto
err_out
;
}
ret
=
gpio_direction_output
(
dev
->
gpio
,
atomic_read
(
&
dev
->
val
));
if
(
ret
)
{
dev_err
(
&
pdev
->
dev
,
"failed to set LED gpio as output
\n
"
);
goto
free_gpio
;
}
ret
=
device_create_file
(
&
pdev
->
dev
,
&
dev_attr_led
);
atomic_set
(
&
dev
->
val
,
0
);
pdata
=
dev_get_platdata
(
&
pdev
->
dev
);
dev
->
gpio
=
pdata
->
gpio
;
ret
=
gpio_request
(
dev
->
gpio
,
dev_name
(
&
pdev
->
dev
));
if
(
ret
)
{
dev_err
(
&
pdev
->
dev
,
"failed to create led sysfs entry
\n
"
);
goto
free_gpio
;
}
dev_err
(
&
pdev
->
dev
,
"failed to request LED gpio
\n
"
);
goto
err_out
;
}
platform_set_drvdata
(
pdev
,
dev
);
return
0
;
ret
=
gpio_direction_output
(
dev
->
gpio
,
atomic_read
(
&
dev
->
val
));
if
(
ret
)
{
dev_err
(
&
pdev
->
dev
,
"failed to set LED gpio as output
\n
"
);
goto
free_gpio
;
}
ret
=
device_create_file
(
&
pdev
->
dev
,
&
dev_attr_led
);
if
(
ret
)
{
dev_err
(
&
pdev
->
dev
,
"failed to create led sysfs entry
\n
"
);
goto
free_gpio
;
}
platform_set_drvdata
(
pdev
,
dev
);
return
0
;
free_gpio:
gpio_direction_input
(
dev
->
gpio
);
gpio_free
(
dev
->
gpio
);
gpio_direction_input
(
dev
->
gpio
);
gpio_free
(
dev
->
gpio
);
err_out:
if
(
dev
)
kfree
(
dev
);
return
ret
;
return
ret
;
}
static
int
led_remove
(
struct
platform_device
*
pdev
)
{
struct
led_device
*
dev
=
platform_get_drvdata
(
pdev
);
int
ret
;
struct
led_device
*
dev
=
platform_get_drvdata
(
pdev
);
int
ret
;
dev_info
(
&
pdev
->
dev
,
"%s(): remove
\n
"
,
__func__
);
dev_info
(
&
pdev
->
dev
,
"%s(): remove
\n
"
,
__func__
);
/* remove sysfs files */
/* remove sysfs files */
device_remove_file
(
&
pdev
->
dev
,
&
dev_attr_led
);
ret
=
gpio_direction_input
(
dev
->
gpio
);
if
(
ret
)
{
dev_err
(
&
pdev
->
dev
,
"failed to set LED gpio as input
\n
"
);
}
gpio_free
(
dev
->
gpio
);
kfree
(
dev
);
ret
=
gpio_direction_input
(
dev
->
gpio
);
if
(
ret
)
dev_err
(
&
pdev
->
dev
,
"failed to set LED gpio as input
\n
"
);
gpio_free
(
dev
->
gpio
);
kfree
(
dev
);
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