[PATCH 17/23] gpio: mockup: rename and move around debugfs callbacks

From: Bartosz Golaszewski
Date: Fri Sep 04 2020 - 11:48:49 EST


From: Bartosz Golaszewski <bgolaszewski@xxxxxxxxxxxx>

We will soon introduce new debugfs attributes for dynamically created
chips. We'll reuse the gpio_mockup_debugfs_open() helper for them but
the relevant write callbacks will of course be different.

Let's rename gpio_mockup_debugfs_write() to
gpio_mockup_debugfs_pull_write() to avoid confusion with new write
callbacks and move gpio_mockup_debugfs_open() higher up in the code to
separate it from the pull/value attribute which will no longer be the
only user.

Signed-off-by: Bartosz Golaszewski <bgolaszewski@xxxxxxxxxxxx>
---
drivers/gpio/gpio-mockup.c | 26 +++++++++++++-------------
1 file changed, 13 insertions(+), 13 deletions(-)

diff --git a/drivers/gpio/gpio-mockup.c b/drivers/gpio/gpio-mockup.c
index eb94ddac5fee..29fbf007ab26 100644
--- a/drivers/gpio/gpio-mockup.c
+++ b/drivers/gpio/gpio-mockup.c
@@ -262,9 +262,14 @@ static void gpio_mockup_free(struct gpio_chip *gc, unsigned int offset)
__gpio_mockup_set(chip, offset, chip->lines[offset].pull);
}

-static ssize_t gpio_mockup_debugfs_read(struct file *file,
- char __user *usr_buf,
- size_t size, loff_t *ppos)
+static int gpio_mockup_debugfs_open(struct inode *inode, struct file *file)
+{
+ return single_open(file, NULL, inode->i_private);
+}
+
+static ssize_t gpio_mockup_debugfs_value_read(struct file *file,
+ char __user *usr_buf,
+ size_t size, loff_t *ppos)
{
struct gpio_mockup_dbgfs_private *priv;
struct gpio_mockup_chip *chip;
@@ -287,9 +292,9 @@ static ssize_t gpio_mockup_debugfs_read(struct file *file,
return simple_read_from_buffer(usr_buf, size, ppos, buf, cnt);
}

-static ssize_t gpio_mockup_debugfs_write(struct file *file,
- const char __user *usr_buf,
- size_t size, loff_t *ppos)
+static ssize_t gpio_mockup_debugfs_pull_write(struct file *file,
+ const char __user *usr_buf,
+ size_t size, loff_t *ppos)
{
struct gpio_mockup_dbgfs_private *priv;
int rv, val;
@@ -313,11 +318,6 @@ static ssize_t gpio_mockup_debugfs_write(struct file *file,
return size;
}

-static int gpio_mockup_debugfs_open(struct inode *inode, struct file *file)
-{
- return single_open(file, NULL, inode->i_private);
-}
-
/*
* Each mockup chip is represented by a directory named after the chip's device
* name under /sys/kernel/debug/gpio-mockup/. Each line is represented by
@@ -342,8 +342,8 @@ static int gpio_mockup_debugfs_open(struct inode *inode, struct file *file)
static const struct file_operations gpio_mockup_debugfs_ops = {
.owner = THIS_MODULE,
.open = gpio_mockup_debugfs_open,
- .read = gpio_mockup_debugfs_read,
- .write = gpio_mockup_debugfs_write,
+ .read = gpio_mockup_debugfs_value_read,
+ .write = gpio_mockup_debugfs_pull_write,
.llseek = no_llseek,
.release = single_release,
};
--
2.26.1