Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752669AbYJTBVd (ORCPT ); Sun, 19 Oct 2008 21:21:33 -0400 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S1751991AbYJTBVY (ORCPT ); Sun, 19 Oct 2008 21:21:24 -0400 Received: from cn.fujitsu.com ([222.73.24.84]:61156 "EHLO song.cn.fujitsu.com" rhost-flags-OK-FAIL-OK-OK) by vger.kernel.org with ESMTP id S1751172AbYJTBVX (ORCPT ); Sun, 19 Oct 2008 21:21:23 -0400 Message-ID: <14EBD9064A77422F95930B2F3B2FD9DB@zhaoleiwin> From: "Zhaolei" To: "Alan Stern" Cc: , , References: <4F580DA88E8146FC8BDA0789613AB813@zhaoleiwin> Subject: Re: [PATCH] Fix debugfs_create_file's error checking method for usb/gadget/ Date: Mon, 20 Oct 2008 09:19:58 +0800 MIME-Version: 1.0 Content-Type: text/plain; charset="ISO-8859-1" X-Priority: 3 X-MSMail-Priority: Normal X-Mailer: Microsoft Outlook Express 6.00.2900.5512 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.5579 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Transfer-Encoding: 8bit X-MIME-Autoconverted: from base64 to 8bit by alpha id m9K1Lbdq009919 Content-Length: 2111 Lines: 56 From: "Alan Stern" To: "Zhaolei" Cc: ; ; 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 >> --- >> 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?+???????+%?????ݶ??w??{.n?+????{??G?????{ay?ʇڙ?,j??f???h?????????z_??(?階?ݢj"???m??????G????????????&???~???iO???z??v?^?m???? ????????I?