-
Notifications
You must be signed in to change notification settings - Fork 1.7k
drivers: platform: linux: Remove use of /sys/class/gpio #2672
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good overall. Apart from these minor remarks, please provide more details in the commit message (what are you replacing the /sys/class/gpio interface with and the kernel version in which the old interface was deprecated).
drivers/platform/linux/linux_gpio.c
Outdated
else | ||
ret = write(linux_desc->value_fd, "0", 2); | ||
// Set Line Value | ||
memset(&line_value, 0, sizeof(line_value)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You can set the value of line_value
whenever you declare it:
struct gpio_v2_line_values line_value = {0};
Applies to multiple cases in this file, so please update all of them
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Addressed in commit 6b1a03f
drivers/platform/linux/linux_gpio.c
Outdated
if (line_info.flags & GPIO_V2_LINE_FLAG_OUTPUT) { | ||
*direction = NO_OS_GPIO_OUT; | ||
else | ||
} else if (line_info.flags & GPIO_V2_LINE_FLAG_INPUT) { | ||
*direction = NO_OS_GPIO_IN; | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We don't use braces in case the if statement contains just one line.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Addressed in commit 6b1a03f
drivers/platform/linux/linux_gpio.c
Outdated
// Set Line Value | ||
memset(&line_value, 0, sizeof(line_value)); | ||
line_value.bits = value; | ||
line_value.mask = 1; // Only set one line (or one GPIO) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The comment style should be /* */
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Addressed in commit 6b1a03f
Hi @CiprianRegus , I can only find this documentation stating that |
/sys/class/gpio is deprecated and was removed after 2020. It is replaced with GPIO character device. Signed-off-by: Jamila Macagba <[email protected]>
/sys/class/gpio is deprecated in newer Linux Kernel
Pull Request Description
Resolves #2517.
Replaces deprecated /sys/class/gpio for controlling GPIOs and using GPIO Character Device Userspace API instead.
PR Type
PR Checklist