Received: by 2002:a05:7412:419a:b0:f3:1519:9f41 with SMTP id i26csp251028rdh; Thu, 23 Nov 2023 03:06:20 -0800 (PST) X-Google-Smtp-Source: AGHT+IHPFlqyf3euMERRwXCMTqAANJzWPT5rKLuh54awoRLzFl/ecSFCMdldxhz1nZX4FmWecSoh X-Received: by 2002:a05:6830:e8c:b0:6d6:3f13:4c0f with SMTP id dp12-20020a0568300e8c00b006d63f134c0fmr5594736otb.29.1700737580139; Thu, 23 Nov 2023 03:06:20 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1700737580; cv=none; d=google.com; s=arc-20160816; b=tQ1yfZfDxOgfFF3VqqEnpxHtlkN7chytqT/wTLHjfwGj6t44gDyDjZ823SgkqWsUen MF2SdXqOupd9QHIyaEkcYW+/beiYsgvnS6O3UlhwZ1nzdW6l9rnS9g6ABA2g7i8TXkEP bP5xvh8FlpC+7nvZfMOaYF9caB3e1x5Cty5yHFSg200+ft+UupAQjMzBL1dvRWMipU2S T2oMqqMcTaUJiOTrW7OcUNt8cgh5Jss2yf3KVKfaCyiMSp6hHcH/obpkU1Y6lHXNKxxh XxmpyFVdkM4qMc3FuQgqKp3arTr5h/2P86/43Us6XE65gqYRwbGSfTKGialBFHqi/A1x 75VQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-transfer-encoding :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature; bh=YIc0lZUPTTJcY/gWadARuSB0TUUgQWnT/WDmhlMq4h0=; fh=K7JTbn/6Fr0rUOW8D40pbqlaV128T0M3u3cYivjljvU=; b=ulK8plwxXXDmZv+TB3V2qOqoSWGQAKsOtBS0HFzFQuBh5XhYuxQdrRIO+rpELAnGMv cSJuBDADs7F0x5fNykT9hrR7dv8Do/RmxBhugofecijoiYvHC1y7b8pnUNikc1YsztP0 pXy3jQI93EUU9+oeR31EGdxOFpW9UIpWT8dj/jgbsYKHyhu8paIHInJ0xymNEvX47AFh KZwTCv8HY3T64QmhGC1Dz+5Vp7j5w7zJW4z5qaPxLJiOoenk8FmztURU0TqUVZg8xMgq ze5+dk9SvpBLsiimkUl9no3Pd/kCqWCuXv1IPGZMXCz4X2zukPUlaTc9RO2n9QmEZwVQ kzQQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=WLVP+wUG; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.36 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from pete.vger.email (pete.vger.email. [23.128.96.36]) by mx.google.com with ESMTPS id be14-20020a656e4e000000b005bd27920754si1222214pgb.204.2023.11.23.03.06.19 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 23 Nov 2023 03:06:20 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.36 as permitted sender) client-ip=23.128.96.36; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=WLVP+wUG; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.36 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by pete.vger.email (Postfix) with ESMTP id 7DF1280755A9; Thu, 23 Nov 2023 03:06:16 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at pete.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1344964AbjKWLFk (ORCPT + 99 others); Thu, 23 Nov 2023 06:05:40 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54652 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1344982AbjKWLFf (ORCPT ); Thu, 23 Nov 2023 06:05:35 -0500 Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8FEB0D5C for ; Thu, 23 Nov 2023 03:05:42 -0800 (PST) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 0E19CC433C8; Thu, 23 Nov 2023 11:05:40 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1700737542; bh=yqetw7zosrQdLVs1wXRaQ09UgUlARXEo96Fo2p9Et0M=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=WLVP+wUGQg/KxAZFdxBrNZT5f8T7HhXpezp0CWAGFwL50Y5dvr2mz9b+x4oiB5oDu 4XPPiMay8e8kIOFCWpwEukgKOfjFhGpuhZObam4eMbAWXgcHw8tknT6FOsVzwVaQIe 11RcPm1vthHATIY/h5oI8d4CeaGEgc4WcRVRJ+8XNHWXe2P94KYktC3G4kCF6KD8D0 /OZ6wy/ulEXVI5sSh/tPegkqsVcGcQ0QBS/T9Llf5zLp3oW+Z92xpYKC9CRZQtRnTn OGPgsRlZFDfUPtcQvC0gUuf1/e+5JuFyw4eKMGdY4XJaqLpm6aVE3yBAYndEInJVZC jnoQ4Od1T9o9g== Date: Thu, 23 Nov 2023 11:05:38 +0000 From: Lee Jones To: Andy Shevchenko Cc: Linus Walleij , linux-leds@vger.kernel.org, linux-kernel@vger.kernel.org, Pavel Machek Subject: Re: [PATCH v1 2/4] leds: trigger: gpio: Convert to use kstrtox() Message-ID: <20231123110538.GA1243364@google.com> References: <20231103195310.948327-1-andriy.shevchenko@linux.intel.com> <20231103195310.948327-2-andriy.shevchenko@linux.intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <20231103195310.948327-2-andriy.shevchenko@linux.intel.com> X-Spam-Status: No, score=-1.3 required=5.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on pete.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (pete.vger.email [0.0.0.0]); Thu, 23 Nov 2023 03:06:16 -0800 (PST) On Fri, 03 Nov 2023, Andy Shevchenko wrote: > sscanf() is a heavy one and moreover requires additional boundary checks. > Convert driver to use kstrtou8() in gpio_trig_inverted_store(). > > Signed-off-by: Andy Shevchenko > --- > drivers/leds/trigger/ledtrig-gpio.c | 10 ++++------ > 1 file changed, 4 insertions(+), 6 deletions(-) > > diff --git a/drivers/leds/trigger/ledtrig-gpio.c b/drivers/leds/trigger/ledtrig-gpio.c > index d91ae7fde3cf..8a30f9228186 100644 > --- a/drivers/leds/trigger/ledtrig-gpio.c > +++ b/drivers/leds/trigger/ledtrig-gpio.c > @@ -53,14 +53,12 @@ static ssize_t gpio_trig_brightness_store(struct device *dev, > struct device_attribute *attr, const char *buf, size_t n) > { > struct gpio_trig_data *gpio_data = led_trigger_get_drvdata(dev); > - unsigned desired_brightness; > + u8 desired_brightness; > int ret; > > - ret = sscanf(buf, "%u", &desired_brightness); > - if (ret < 1 || desired_brightness > 255) { > - dev_err(dev, "invalid value\n"); > - return -EINVAL; > - } > + ret = kstrtou8(buf, 10, &desired_brightness); Where does 10 come from? > + if (ret) > + return ret; > > gpio_data->desired_brightness = desired_brightness; > > -- > 2.40.0.1.gaa8946217a0b > -- Lee Jones [李琼斯]