Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751300AbbKJTDs (ORCPT ); Tue, 10 Nov 2015 14:03:48 -0500 Received: from mail-pa0-f48.google.com ([209.85.220.48]:35763 "EHLO mail-pa0-f48.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750765AbbKJTDq (ORCPT ); Tue, 10 Nov 2015 14:03:46 -0500 Date: Tue, 10 Nov 2015 11:03:43 -0800 From: Brian Norris To: Joe Perches Cc: Saurabh Sengar , andy.shevchenko@gmail.com, joern@lazybastard.org, dwmw2@infradead.org, linux-mtd@lists.infradead.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH] mtd: phram: error handling Message-ID: <20151110190343.GR12143@google.com> References: <1447050198-20562-1-git-send-email-saurabh.truth@gmail.com> <20151110182047.GP12143@google.com> <1447180387.2701.68.camel@perches.com> <20151110183956.GQ12143@google.com> <1447181155.2701.72.camel@perches.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1447181155.2701.72.camel@perches.com> User-Agent: Mutt/1.5.21 (2010-09-15) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 2289 Lines: 60 On Tue, Nov 10, 2015 at 10:45:55AM -0800, Joe Perches wrote: > On Tue, 2015-11-10 at 10:39 -0800, Brian Norris wrote: > > On Tue, Nov 10, 2015 at 10:33:07AM -0800, Joe Perches wrote: > > > Expand parse_err macro with hidden flow in-place. > > > Remove the now unused parse_err macro. > [] > > I think -EINVAL makes more sense than 1. That > > could be a subsequent patch, I suppose. > > That means you have to trace all the callers > to verify that converting 1 to -22 is acceptable. It's fairly simple. Module initialization and module parameter calls both *should* follow 0/negative error conventions. For module init, see in kernel/module.c: /* Start the module */ if (mod->init != NULL) ret = do_one_initcall(mod->init); if (ret < 0) { goto fail_free_freeinit; } if (ret > 0) { pr_warn("%s: '%s'->init suspiciously returned %d, it should " "follow 0/-E convention\n" "%s: loading module anyway...\n", __func__, mod->name, ret, __func__); dump_stack(); } and in include/linux/moduleparam.h: struct kernel_param_ops { ... /* Returns 0, or -errno. arg is in kp->arg. */ int (*set)(const char *val, const struct kernel_param *kp); ... }; And for built-in modules, the return code is ignored (see do_initcall_level()). So I think the only question is whether we should actually be reporting these errors on module insertion and on the module parameter call. I'd say "definitely" to the latter and "yes" to the former, since the init function already handles the case of an empty input (so the module can be loaded with a blank command line without tripping on an -EINVAL parameter check). IOW, to use -EINVAL would be to actually enforce the error handling that was intended in the first place. But that should be done in a separate patch, and with an actual tester (since I doubt either you or Saurabh are testing this driver). Brian -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/