* [02/22,v2] USB: typec: fsusb302: no need to check return value of debugfs_create_dir()
@ 2018-05-31 11:08 Greg Kroah-Hartman
0 siblings, 0 replies; 3+ messages in thread
From: Greg Kroah-Hartman @ 2018-05-31 11:08 UTC (permalink / raw)
To: linux-usb
Cc: Heikki Krogerus, Guenter Roeck, Hans de Goede, Andy Shevchenko,
Adam Thomson
When calling debugfs functions, there is no need to ever check the
return value. The function can work or not, but the code logic should
never do something different based on this.
Clean up the fsusb302 driver to not care if the root directory was
created, as the code should work properly either way.
Cc: Heikki Krogerus <heikki.krogerus@linux.intel.com>
Cc: Guenter Roeck <linux@roeck-us.net>
Cc: Hans de Goede <hdegoede@redhat.com>
Cc: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Cc: Adam Thomson <Adam.Thomson.Opensource@diasemi.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
v2: changes based on review from Guenter, we still need to keep
chip->dentry and the removal of the rootdir is properly reference
counted, making this patch a lot smaller.
drivers/usb/typec/fusb302/fusb302.c | 15 ++++-----------
1 file changed, 4 insertions(+), 11 deletions(-)
diff --git a/drivers/usb/typec/fusb302/fusb302.c b/drivers/usb/typec/fusb302/fusb302.c
index 9c1eba9ea004..1e68da10bf17 100644
--- a/drivers/usb/typec/fusb302/fusb302.c
+++ b/drivers/usb/typec/fusb302/fusb302.c
@@ -215,20 +215,15 @@ DEFINE_SHOW_ATTRIBUTE(fusb302_debug);
static struct dentry *rootdir;
-static int fusb302_debugfs_init(struct fusb302_chip *chip)
+static void fusb302_debugfs_init(struct fusb302_chip *chip)
{
mutex_init(&chip->logbuffer_lock);
- if (!rootdir) {
+ if (!rootdir)
rootdir = debugfs_create_dir("fusb302", NULL);
- if (!rootdir)
- return -ENOMEM;
- }
chip->dentry = debugfs_create_file(dev_name(chip->dev),
S_IFREG | 0444, rootdir,
chip, &fusb302_debug_fops);
-
- return 0;
}
static void fusb302_debugfs_exit(struct fusb302_chip *chip)
@@ -241,7 +236,7 @@ static void fusb302_debugfs_exit(struct fusb302_chip *chip)
static void fusb302_log(const struct fusb302_chip *chip,
const char *fmt, ...) { }
-static int fusb302_debugfs_init(const struct fusb302_chip *chip) { return 0; }
+static void fusb302_debugfs_init(const struct fusb302_chip *chip) { }
static void fusb302_debugfs_exit(const struct fusb302_chip *chip) { }
#endif
@@ -1773,9 +1768,7 @@ static int fusb302_probe(struct i2c_client *client,
return -EPROBE_DEFER;
}
- ret = fusb302_debugfs_init(chip);
- if (ret < 0)
- return ret;
+ fusb302_debugfs_init(chip);
chip->wq = create_singlethread_workqueue(dev_name(chip->dev));
if (!chip->wq) {
^ permalink raw reply related [flat|nested] 3+ messages in thread
* [02/22,v2] USB: typec: fsusb302: no need to check return value of debugfs_create_dir()
@ 2018-05-31 13:16 Guenter Roeck
0 siblings, 0 replies; 3+ messages in thread
From: Guenter Roeck @ 2018-05-31 13:16 UTC (permalink / raw)
To: Greg Kroah-Hartman, linux-usb
Cc: Heikki Krogerus, Hans de Goede, Andy Shevchenko, Adam Thomson
On 05/31/2018 04:08 AM, Greg Kroah-Hartman wrote:
> When calling debugfs functions, there is no need to ever check the
> return value. The function can work or not, but the code logic should
> never do something different based on this.
>
> Clean up the fsusb302 driver to not care if the root directory was
> created, as the code should work properly either way.
>
> Cc: Heikki Krogerus <heikki.krogerus@linux.intel.com>
> Cc: Guenter Roeck <linux@roeck-us.net>
> Cc: Hans de Goede <hdegoede@redhat.com>
> Cc: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
> Cc: Adam Thomson <Adam.Thomson.Opensource@diasemi.com>
> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Reviewed-by: Guenter Roeck <linux@roeck-us.net>
> ---
>
> v2: changes based on review from Guenter, we still need to keep
> chip->dentry and the removal of the rootdir is properly reference
> counted, making this patch a lot smaller.
>
> drivers/usb/typec/fusb302/fusb302.c | 15 ++++-----------
> 1 file changed, 4 insertions(+), 11 deletions(-)
>
> diff --git a/drivers/usb/typec/fusb302/fusb302.c b/drivers/usb/typec/fusb302/fusb302.c
> index 9c1eba9ea004..1e68da10bf17 100644
> --- a/drivers/usb/typec/fusb302/fusb302.c
> +++ b/drivers/usb/typec/fusb302/fusb302.c
> @@ -215,20 +215,15 @@ DEFINE_SHOW_ATTRIBUTE(fusb302_debug);
>
> static struct dentry *rootdir;
>
> -static int fusb302_debugfs_init(struct fusb302_chip *chip)
> +static void fusb302_debugfs_init(struct fusb302_chip *chip)
> {
> mutex_init(&chip->logbuffer_lock);
> - if (!rootdir) {
> + if (!rootdir)
> rootdir = debugfs_create_dir("fusb302", NULL);
> - if (!rootdir)
> - return -ENOMEM;
> - }
>
> chip->dentry = debugfs_create_file(dev_name(chip->dev),
> S_IFREG | 0444, rootdir,
> chip, &fusb302_debug_fops);
> -
> - return 0;
> }
>
> static void fusb302_debugfs_exit(struct fusb302_chip *chip)
> @@ -241,7 +236,7 @@ static void fusb302_debugfs_exit(struct fusb302_chip *chip)
>
> static void fusb302_log(const struct fusb302_chip *chip,
> const char *fmt, ...) { }
> -static int fusb302_debugfs_init(const struct fusb302_chip *chip) { return 0; }
> +static void fusb302_debugfs_init(const struct fusb302_chip *chip) { }
> static void fusb302_debugfs_exit(const struct fusb302_chip *chip) { }
>
> #endif
> @@ -1773,9 +1768,7 @@ static int fusb302_probe(struct i2c_client *client,
> return -EPROBE_DEFER;
> }
>
> - ret = fusb302_debugfs_init(chip);
> - if (ret < 0)
> - return ret;
> + fusb302_debugfs_init(chip);
>
> chip->wq = create_singlethread_workqueue(dev_name(chip->dev));
> if (!chip->wq) {
>
---
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
^ permalink raw reply [flat|nested] 3+ messages in thread
* [02/22,v2] USB: typec: fsusb302: no need to check return value of debugfs_create_dir()
@ 2018-05-31 14:03 Greg Kroah-Hartman
0 siblings, 0 replies; 3+ messages in thread
From: Greg Kroah-Hartman @ 2018-05-31 14:03 UTC (permalink / raw)
To: Guenter Roeck
Cc: linux-usb, Heikki Krogerus, Hans de Goede, Andy Shevchenko,
Adam Thomson
On Thu, May 31, 2018 at 06:16:27AM -0700, Guenter Roeck wrote:
> On 05/31/2018 04:08 AM, Greg Kroah-Hartman wrote:
> > When calling debugfs functions, there is no need to ever check the
> > return value. The function can work or not, but the code logic should
> > never do something different based on this.
> >
> > Clean up the fsusb302 driver to not care if the root directory was
> > created, as the code should work properly either way.
> >
> > Cc: Heikki Krogerus <heikki.krogerus@linux.intel.com>
> > Cc: Guenter Roeck <linux@roeck-us.net>
> > Cc: Hans de Goede <hdegoede@redhat.com>
> > Cc: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
> > Cc: Adam Thomson <Adam.Thomson.Opensource@diasemi.com>
> > Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
>
> Reviewed-by: Guenter Roeck <linux@roeck-us.net>
Thanks for the review.
greg k-h
---
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2018-05-31 14:03 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2018-05-31 14:03 [02/22,v2] USB: typec: fsusb302: no need to check return value of debugfs_create_dir() Greg Kroah-Hartman
-- strict thread matches above, loose matches on Subject: below --
2018-05-31 13:16 Guenter Roeck
2018-05-31 11:08 Greg Kroah-Hartman
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).