LKML Archive on lore.kernel.org help / color / mirror / Atom feed
* [PATCH] Fix debugfs_create_file's error checking method for usb/gadget/ @ 2008-10-17 12:54 Zhaolei 2008-10-17 15:18 ` Alan Stern 0 siblings, 1 reply; 6+ messages in thread From: Zhaolei @ 2008-10-17 12:54 UTC (permalink / raw) To: linux-kernel; +Cc: dbrownell, linux-usb Hi, debugfs_create_file() returns NULL if an error occurs, returns -ENODEV when debugfs is not enabled in the kernel. Signed-off-by: Zhao Lei <zhaolei@cn.fujitsu.com> --- drivers/usb/gadget/s3c2410_udc.c | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-) diff --git a/drivers/usb/gadget/s3c2410_udc.c b/drivers/usb/gadget/s3c2410_udc.c index 29d13eb..4ba50ef 100644 --- a/drivers/usb/gadget/s3c2410_udc.c +++ b/drivers/usb/gadget/s3c2410_udc.c @@ -1894,7 +1894,7 @@ static int s3c2410_udc_probe(struct platform_device *pdev) udc->regs_info = debugfs_create_file("registers", S_IRUGO, s3c2410_udc_debugfs_root, udc, &s3c2410_udc_debugfs_fops); - if (IS_ERR(udc->regs_info)) { + if (IS_ERR(udc->regs_info) || !udc->regs_info) { dev_warn(dev, "debugfs file creation failed %ld\n", PTR_ERR(udc->regs_info)); udc->regs_info = NULL; -- 1.5.5.3 ^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] Fix debugfs_create_file's error checking method for usb/gadget/ 2008-10-17 12:54 [PATCH] Fix debugfs_create_file's error checking method for usb/gadget/ Zhaolei @ 2008-10-17 15:18 ` Alan Stern 2008-10-20 1:15 ` Zhaolei 0 siblings, 1 reply; 6+ messages in thread From: Alan Stern @ 2008-10-17 15:18 UTC (permalink / raw) To: Zhaolei; +Cc: linux-kernel, dbrownell, linux-usb On Fri, 17 Oct 2008, Zhaolei wrote: > Hi, > > debugfs_create_file() returns NULL if an error occurs, returns -ENODEV > when debugfs is not enabled in the kernel. > > Signed-off-by: Zhao Lei <zhaolei@cn.fujitsu.com> > --- > drivers/usb/gadget/s3c2410_udc.c | 2 +- > 1 files changed, 1 insertions(+), 1 deletions(-) > > diff --git a/drivers/usb/gadget/s3c2410_udc.c b/drivers/usb/gadget/s3c2410_udc.c > index 29d13eb..4ba50ef 100644 > --- a/drivers/usb/gadget/s3c2410_udc.c > +++ b/drivers/usb/gadget/s3c2410_udc.c > @@ -1894,7 +1894,7 @@ static int s3c2410_udc_probe(struct platform_device *pdev) > udc->regs_info = debugfs_create_file("registers", S_IRUGO, > s3c2410_udc_debugfs_root, > udc, &s3c2410_udc_debugfs_fops); > - if (IS_ERR(udc->regs_info)) { > + if (IS_ERR(udc->regs_info) || !udc->regs_info) { > dev_warn(dev, "debugfs file creation failed %ld\n", > PTR_ERR(udc->regs_info)); > udc->regs_info = NULL; In fact the original code and your patch are both wrong. The test should simply be: if (!udc->regs_info) { dev_warn(dev, "debugfs file creation failed\n"); (The line setting udc->regs_info to NULL can then be removed.) The driver should be able to work even if debugfs isn't enabled in the kernel. Alan Stern ^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] Fix debugfs_create_file's error checking method for usb/gadget/ 2008-10-17 15:18 ` Alan Stern @ 2008-10-20 1:15 ` Zhaolei 2008-10-20 1:19 ` Zhaolei 2008-10-20 3:46 ` Greg KH 0 siblings, 2 replies; 6+ messages in thread From: Zhaolei @ 2008-10-20 1:15 UTC (permalink / raw) To: Alan Stern; +Cc: linux-kernel, dbrownell, linux-usb From: "Alan Stern" <stern@rowland.harvard.edu> To: "Zhaolei" <zhaolei@cn.fujitsu.com> Cc: <linux-kernel@vger.kernel.org>; <dbrownell@users.sourceforge.net>; <linux-usb@vger.kernel.org> Sent: Friday, October 17, 2008 11:18 PM Subject: Re: [PATCH] Fix debugfs_create_file's error checking method for usb/gadget/ > On Fri, 17 Oct 2008, Zhaolei wrote: > >> Hi, >> >> debugfs_create_file() returns NULL if an error occurs, returns -ENODEV >> when debugfs is not enabled in the kernel. >> >> Signed-off-by: Zhao Lei <zhaolei@cn.fujitsu.com> >> --- >> drivers/usb/gadget/s3c2410_udc.c | 2 +- >> 1 files changed, 1 insertions(+), 1 deletions(-) >> >> diff --git a/drivers/usb/gadget/s3c2410_udc.c b/drivers/usb/gadget/s3c2410_udc.c >> index 29d13eb..4ba50ef 100644 >> --- a/drivers/usb/gadget/s3c2410_udc.c >> +++ b/drivers/usb/gadget/s3c2410_udc.c >> @@ -1894,7 +1894,7 @@ static int s3c2410_udc_probe(struct platform_device *pdev) >> udc->regs_info = debugfs_create_file("registers", S_IRUGO, >> s3c2410_udc_debugfs_root, >> udc, &s3c2410_udc_debugfs_fops); >> - if (IS_ERR(udc->regs_info)) { >> + if (IS_ERR(udc->regs_info) || !udc->regs_info) { >> dev_warn(dev, "debugfs file creation failed %ld\n", >> PTR_ERR(udc->regs_info)); >> udc->regs_info = NULL; > > In fact the original code and your patch are both wrong. The test > should simply be: > > if (!udc->regs_info) { > dev_warn(dev, "debugfs file creation failed\n"); > Hello, Alan Stern If we only check if (!udc->regs_info), that is no problem except that we can't see dev_warn when debugfs isn't enabled in the kernel. It this warning message is not necessary, I agree with you. Thanks! > (The line setting udc->regs_info to NULL can then be removed.) > > The driver should be able to work even if debugfs isn't enabled in the > kernel. > > Alan Stern > > >ÿôèº{.nÇ+·®+%Ëÿ±éݶ\x17¥wÿº{.nÇ+·¥{±þG«éÿ{ayº\x1dÊÚë,j\a¢f£¢·hïêÿêçz_è®\x03(éÝ¢j"ú\x1a¶^[m§ÿÿ¾\a«þG«éÿ¢¸?¨èÚ&£ø§~á¶iOæ¬z·vØ^\x14\x04\x1a¶^[m§ÿÿÃ\fÿ¶ìÿ¢¸?I¥ ^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] Fix debugfs_create_file's error checking method for usb/gadget/ 2008-10-20 1:15 ` Zhaolei @ 2008-10-20 1:19 ` Zhaolei 2008-10-20 3:46 ` Greg KH 1 sibling, 0 replies; 6+ messages in thread From: Zhaolei @ 2008-10-20 1:19 UTC (permalink / raw) To: Alan Stern; +Cc: linux-kernel, dbrownell, linux-usb From: "Alan Stern" <stern@rowland.harvard.edu> To: "Zhaolei" <zhaolei@cn.fujitsu.com> Cc: <linux-kernel@vger.kernel.org>; <dbrownell@users.sourceforge.net>; <linux-usb@vger.kernel.org> Sent: Friday, October 17, 2008 11:18 PM Subject: Re: [PATCH] Fix debugfs_create_file's error checking method for usb/gadget/ > On Fri, 17 Oct 2008, Zhaolei wrote: > >> Hi, >> >> debugfs_create_file() returns NULL if an error occurs, returns -ENODEV >> when debugfs is not enabled in the kernel. >> >> Signed-off-by: Zhao Lei <zhaolei@cn.fujitsu.com> >> --- >> drivers/usb/gadget/s3c2410_udc.c | 2 +- >> 1 files changed, 1 insertions(+), 1 deletions(-) >> >> diff --git a/drivers/usb/gadget/s3c2410_udc.c b/drivers/usb/gadget/s3c2410_udc.c >> index 29d13eb..4ba50ef 100644 >> --- a/drivers/usb/gadget/s3c2410_udc.c >> +++ b/drivers/usb/gadget/s3c2410_udc.c >> @@ -1894,7 +1894,7 @@ static int s3c2410_udc_probe(struct platform_device *pdev) >> udc->regs_info = debugfs_create_file("registers", S_IRUGO, >> s3c2410_udc_debugfs_root, >> udc, &s3c2410_udc_debugfs_fops); >> - if (IS_ERR(udc->regs_info)) { >> + if (IS_ERR(udc->regs_info) || !udc->regs_info) { >> dev_warn(dev, "debugfs file creation failed %ld\n", >> PTR_ERR(udc->regs_info)); >> udc->regs_info = NULL; > > In fact the original code and your patch are both wrong. The test > should simply be: > > if (!udc->regs_info) { > dev_warn(dev, "debugfs file creation failed\n"); > Hello, Alan Stern If we only check if (!udc->regs_info), that is no problem except that we can't see dev_warn when debugfs isn't enabled in the kernel. It this warning message is not necessary, I agree with you. ->If this warning message is not necessary, I agree with you. Thanks! > (The line setting udc->regs_info to NULL can then be removed.) > > The driver should be able to work even if debugfs isn't enabled in the > kernel. > > Alan Stern > > >N²rys²¶v-ºn?S'z¶¡}²zjv¾'z?z¢s~?ÿz®¢T¢¢"jy.A¶ÿ¶®'ÿôèº{.nÇ+·®+%Ëÿ±éݶ\x17¥wÿº{.nÇ+·¥{±þG«éÿ{ayº\x1dÊÚë,j\a¢f£¢·hïêÿêçz_è®\x03(éÝ¢j"ú\x1a¶^[m§ÿÿ¾\a«þG«éÿ¢¸?¨èÚ&£ø§~á¶iOæ¬z·vØ^\x14\x04\x1a¶^[m§ÿÿÃ\fÿ¶ìÿ¢¸?I¥ ^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] Fix debugfs_create_file's error checking method for usb/gadget/ 2008-10-20 1:15 ` Zhaolei 2008-10-20 1:19 ` Zhaolei @ 2008-10-20 3:46 ` Greg KH 2008-10-20 10:53 ` [PATCH v2] " Zhaolei 1 sibling, 1 reply; 6+ messages in thread From: Greg KH @ 2008-10-20 3:46 UTC (permalink / raw) To: Zhaolei; +Cc: Alan Stern, linux-kernel, dbrownell, linux-usb On Mon, Oct 20, 2008 at 09:15:16AM +0800, Zhaolei wrote: > From: "Alan Stern" <stern@rowland.harvard.edu> > To: "Zhaolei" <zhaolei@cn.fujitsu.com> > Cc: <linux-kernel@vger.kernel.org>; <dbrownell@users.sourceforge.net>; <linux-usb@vger.kernel.org> > Sent: Friday, October 17, 2008 11:18 PM > Subject: Re: [PATCH] Fix debugfs_create_file's error checking method for usb/gadget/ > > > > On Fri, 17 Oct 2008, Zhaolei wrote: > > > >> Hi, > >> > >> debugfs_create_file() returns NULL if an error occurs, returns -ENODEV > >> when debugfs is not enabled in the kernel. > >> > >> Signed-off-by: Zhao Lei <zhaolei@cn.fujitsu.com> > >> --- > >> drivers/usb/gadget/s3c2410_udc.c | 2 +- > >> 1 files changed, 1 insertions(+), 1 deletions(-) > >> > >> diff --git a/drivers/usb/gadget/s3c2410_udc.c b/drivers/usb/gadget/s3c2410_udc.c > >> index 29d13eb..4ba50ef 100644 > >> --- a/drivers/usb/gadget/s3c2410_udc.c > >> +++ b/drivers/usb/gadget/s3c2410_udc.c > >> @@ -1894,7 +1894,7 @@ static int s3c2410_udc_probe(struct platform_device *pdev) > >> udc->regs_info = debugfs_create_file("registers", S_IRUGO, > >> s3c2410_udc_debugfs_root, > >> udc, &s3c2410_udc_debugfs_fops); > >> - if (IS_ERR(udc->regs_info)) { > >> + if (IS_ERR(udc->regs_info) || !udc->regs_info) { > >> dev_warn(dev, "debugfs file creation failed %ld\n", > >> PTR_ERR(udc->regs_info)); > >> udc->regs_info = NULL; > > > > In fact the original code and your patch are both wrong. The test > > should simply be: > > > > if (!udc->regs_info) { > > dev_warn(dev, "debugfs file creation failed\n"); > > > Hello, Alan Stern > > If we only check if (!udc->regs_info), that is no problem except that we > can't see dev_warn when debugfs isn't enabled in the kernel. > It this warning message is not necessary, I agree with you. Why would you want to see that message if debugfs wasn't selected? You shouldn't need to see it, that is why the debugfs code doesn't return NULL if it is compiled out. I did it that way to make all callers much simpler :) thanks, greg k-h ^ permalink raw reply [flat|nested] 6+ messages in thread
* [PATCH v2] Fix debugfs_create_file's error checking method for usb/gadget/ 2008-10-20 3:46 ` Greg KH @ 2008-10-20 10:53 ` Zhaolei 0 siblings, 0 replies; 6+ messages in thread From: Zhaolei @ 2008-10-20 10:53 UTC (permalink / raw) To: Greg KH; +Cc: Alan Stern, linux-kernel, dbrownell, linux-usb debugfs_create_file() returns NULL if an error occurs, returns -ENODEV when debugfs is not enabled in the kernel. Signed-off-by: Zhao Lei <zhaolei@cn.fujitsu.com> --- drivers/usb/gadget/s3c2410_udc.c | 7 ++----- 1 files changed, 2 insertions(+), 5 deletions(-) diff --git a/drivers/usb/gadget/s3c2410_udc.c b/drivers/usb/gadget/s3c2410_udc.c index 48f51b1..00ba06b 100644 --- a/drivers/usb/gadget/s3c2410_udc.c +++ b/drivers/usb/gadget/s3c2410_udc.c @@ -1894,11 +1894,8 @@ static int s3c2410_udc_probe(struct platform_device *pdev) udc->regs_info = debugfs_create_file("registers", S_IRUGO, s3c2410_udc_debugfs_root, udc, &s3c2410_udc_debugfs_fops); - if (IS_ERR(udc->regs_info)) { - dev_warn(dev, "debugfs file creation failed %ld\n", - PTR_ERR(udc->regs_info)); - udc->regs_info = NULL; - } + if (!udc->regs_info) + dev_warn(dev, "debugfs file creation failed\n"); } dev_dbg(dev, "probe ok\n"); -- 1.5.5.3 ^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2008-10-20 10:54 UTC | newest] Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed) -- links below jump to the message on this page -- 2008-10-17 12:54 [PATCH] Fix debugfs_create_file's error checking method for usb/gadget/ Zhaolei 2008-10-17 15:18 ` Alan Stern 2008-10-20 1:15 ` Zhaolei 2008-10-20 1:19 ` Zhaolei 2008-10-20 3:46 ` Greg KH 2008-10-20 10:53 ` [PATCH v2] " Zhaolei
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).