From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id F1EB9C433EF for ; Wed, 27 Apr 2022 15:40:26 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 1EC206B0072; Wed, 27 Apr 2022 11:40:26 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 1C21E6B0073; Wed, 27 Apr 2022 11:40:26 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 0B1AC6B0074; Wed, 27 Apr 2022 11:40:26 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (relay.a.hostedemail.com [64.99.140.24]) by kanga.kvack.org (Postfix) with ESMTP id 64BB26B0072 for ; Wed, 27 Apr 2022 11:40:24 -0400 (EDT) Received: from smtpin06.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay09.hostedemail.com (Postfix) with ESMTP id 2AEEB288A2 for ; Wed, 27 Apr 2022 15:40:24 +0000 (UTC) X-FDA: 79403070768.06.3E51B3C Received: from mga18.intel.com (mga18.intel.com [134.134.136.126]) by imf04.hostedemail.com (Postfix) with ESMTP id 1D32A40068 for ; Wed, 27 Apr 2022 15:40:17 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1651074022; x=1682610022; h=date:from:to:cc:subject:message-id:references: mime-version:in-reply-to; bh=30GJAH8LI0FeMcoTBydu3l8Pe3095VvppqBa8fGuspY=; b=MjLAx1CigfJDZyER2HJLoOqKqN6oi07dcDmF38kUDQA2f4IIwU9+G9yw ZG9WpaCd2X3Erlx/IJ5EpzPcdngw4MCDzPSYrZtbsXvalondV/kqzthX9 QW3jws9OrZTJNoanCIwguwwQEHEZ8tp08sghUIeFI1nf2mcRU/uRGxEBU twNFLCAs5y6ZSXns4fM7RtaRRjgqpT9JOFZEe2TNIWE/RFsaEhgvhVReb ldTRMMye3PtwoYMnplxtBYBkJKsJP69pvbOdXoen2ZL08X+rJTBBfV7L5 50SL5qA34DR9orIlmFeYQ5835PMWuBKULI2A7NRwf4Pb/qiRcaU5O7ZiJ g==; X-IronPort-AV: E=McAfee;i="6400,9594,10330"; a="247897681" X-IronPort-AV: E=Sophos;i="5.90,293,1643702400"; d="scan'208";a="247897681" Received: from orsmga004.jf.intel.com ([10.7.209.38]) by orsmga106.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 27 Apr 2022 08:13:50 -0700 X-IronPort-AV: E=Sophos;i="5.90,293,1643702400"; d="scan'208";a="680823122" Received: from smile.fi.intel.com ([10.237.72.54]) by orsmga004-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 27 Apr 2022 08:13:47 -0700 Received: from andy by smile.fi.intel.com with local (Exim 4.95) (envelope-from ) id 1njjMO-008sVO-0H; Wed, 27 Apr 2022 18:13:44 +0300 Date: Wed, 27 Apr 2022 18:13:43 +0300 From: Andy Shevchenko To: Jagdish Gediya Cc: linux-kernel@vger.kernel.org, linux-mm@kvack.org, willy@infradead.org, ying.huang@intel.com, dave.hansen@intel.com, Jonathan.Cameron@huawei.com, adobriyan@gmail.com, akpm@linux-foundation.org, rf@opensource.cirrus.com, pmladek@suse.com Subject: Re: [PATCH v3 1/2] lib/kstrtox.c: Add "false"/"true" support to kstrtobool() Message-ID: References: <20220426180203.70782-1-jvgediya@linux.ibm.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20220426180203.70782-1-jvgediya@linux.ibm.com> Organization: Intel Finland Oy - BIC 0357606-4 - Westendinkatu 7, 02160 Espoo X-Rspamd-Queue-Id: 1D32A40068 X-Stat-Signature: a8oygfdhxdu9u58t1aqtta1a6dup1zca Authentication-Results: imf04.hostedemail.com; dkim=pass header.d=intel.com header.s=Intel header.b=MjLAx1Ci; dmarc=pass (policy=none) header.from=intel.com; spf=none (imf04.hostedemail.com: domain of andriy.shevchenko@linux.intel.com has no SPF policy when checking 134.134.136.126) smtp.mailfrom=andriy.shevchenko@linux.intel.com X-Rspam-User: X-Rspamd-Server: rspam08 X-HE-Tag: 1651074017-959024 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: On Tue, Apr 26, 2022 at 11:32:02PM +0530, Jagdish Gediya wrote: > At many places in kernel, It is necessary to convert sysfs input > to corrosponding bool value e.g. "false" or "0" need to be converted corresponding > to bool false, "true" or "1" need to be converted to bool true, > places where such conversion is needed currently check the input > string manually, kstrtobool() can be utilized at such places but > currently it doesn't have support to accept "false"/"true". > > Add support to accept "false"/"true" as valid string in kstrtobool(). Andrew, this patch still needs a bit of work. > Signed-off-by: Jagdish Gediya > Reviewed-by: Matthew Wilcox (Oracle) > --- > Chnages in v2: > - kstrtobool to kstrtobool() in commit message. > - Split single patch into 2 > - Remove strcmp usage from kstrtobool() and instead compare 1st > character only. > > Changes in v3: > - Covert -> Convert in patch 2 subject > - Collected Reviewed-by: Matthew Wilcox (Oracle) > > lib/kstrtox.c | 6 +++++- > 1 file changed, 5 insertions(+), 1 deletion(-) > > diff --git a/lib/kstrtox.c b/lib/kstrtox.c > index 886510d248e5..465e31e4d70d 100644 > --- a/lib/kstrtox.c > +++ b/lib/kstrtox.c > @@ -340,7 +340,7 @@ EXPORT_SYMBOL(kstrtos8); > * @s: input string > * @res: result > * > - * This routine returns 0 iff the first character is one of 'Yy1Nn0', or > + * This routine returns 0 if the first character is one of 'YyTt1NnFf0', or s/if/iff/ please. It's _not_ a typo! > * [oO][NnFf] for "on" and "off". Otherwise it will return -EINVAL. Value > * pointed to by res is updated upon finding a match. > */ > @@ -353,11 +353,15 @@ int kstrtobool(const char *s, bool *res) > switch (s[0]) { > case 'y': > case 'Y': > + case 't': > + case 'T': > case '1': > *res = true; > return 0; > case 'n': > case 'N': > + case 'f': > + case 'F': > case '0': > *res = false; > return 0; > -- > 2.35.1 > -- With Best Regards, Andy Shevchenko