Commit 9e902c59 authored by Andy Shevchenko's avatar Andy Shevchenko Committed by Greg Kroah-Hartman
Browse files

USB: typec: Re-use DEFINE_SHOW_ATTRIBUTE() macro



...instead of open coding file operations followed by custom ->open()
callbacks per each attribute.

Signed-off-by: default avatarAndy Shevchenko <andriy.shevchenko@linux.intel.com>
Reviewed-by: default avatarGuenter Roeck <linux@roeck-us.net>
Reviewed-by: default avatarHeikki Krogerus <heikki.krogerus@linux.intel.com>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent e23500dd
Loading
Loading
Loading
Loading
+3 −14
Original line number Original line Diff line number Diff line
@@ -199,7 +199,7 @@ static void fusb302_log(struct fusb302_chip *chip, const char *fmt, ...)
	va_end(args);
	va_end(args);
}
}


static int fusb302_seq_show(struct seq_file *s, void *v)
static int fusb302_debug_show(struct seq_file *s, void *v)
{
{
	struct fusb302_chip *chip = (struct fusb302_chip *)s->private;
	struct fusb302_chip *chip = (struct fusb302_chip *)s->private;
	int tail;
	int tail;
@@ -216,18 +216,7 @@ static int fusb302_seq_show(struct seq_file *s, void *v)


	return 0;
	return 0;
}
}

DEFINE_SHOW_ATTRIBUTE(fusb302_debug);
static int fusb302_debug_open(struct inode *inode, struct file *file)
{
	return single_open(file, fusb302_seq_show, inode->i_private);
}

static const struct file_operations fusb302_debug_operations = {
	.open		= fusb302_debug_open,
	.llseek		= seq_lseek,
	.read		= seq_read,
	.release	= single_release,
};


static struct dentry *rootdir;
static struct dentry *rootdir;


@@ -242,7 +231,7 @@ static int fusb302_debugfs_init(struct fusb302_chip *chip)


	chip->dentry = debugfs_create_file(dev_name(chip->dev),
	chip->dentry = debugfs_create_file(dev_name(chip->dev),
					   S_IFREG | 0444, rootdir,
					   S_IFREG | 0444, rootdir,
					   chip, &fusb302_debug_operations);
					   chip, &fusb302_debug_fops);


	return 0;
	return 0;
}
}
+3 −14
Original line number Original line Diff line number Diff line
@@ -506,7 +506,7 @@ static void tcpm_log_source_caps(struct tcpm_port *port)
	}
	}
}
}


static int tcpm_seq_show(struct seq_file *s, void *v)
static int tcpm_debug_show(struct seq_file *s, void *v)
{
{
	struct tcpm_port *port = (struct tcpm_port *)s->private;
	struct tcpm_port *port = (struct tcpm_port *)s->private;
	int tail;
	int tail;
@@ -523,18 +523,7 @@ static int tcpm_seq_show(struct seq_file *s, void *v)


	return 0;
	return 0;
}
}

DEFINE_SHOW_ATTRIBUTE(tcpm_debug);
static int tcpm_debug_open(struct inode *inode, struct file *file)
{
	return single_open(file, tcpm_seq_show, inode->i_private);
}

static const struct file_operations tcpm_debug_operations = {
	.open		= tcpm_debug_open,
	.llseek		= seq_lseek,
	.read		= seq_read,
	.release	= single_release,
};


static struct dentry *rootdir;
static struct dentry *rootdir;


@@ -550,7 +539,7 @@ static int tcpm_debugfs_init(struct tcpm_port *port)


	port->dentry = debugfs_create_file(dev_name(port->dev),
	port->dentry = debugfs_create_file(dev_name(port->dev),
					   S_IFREG | 0444, rootdir,
					   S_IFREG | 0444, rootdir,
					   port, &tcpm_debug_operations);
					   port, &tcpm_debug_fops);


	return 0;
	return 0;
}
}