From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752016AbdJYUGq (ORCPT ); Wed, 25 Oct 2017 16:06:46 -0400 Received: from mail-qt0-f195.google.com ([209.85.216.195]:52180 "EHLO mail-qt0-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751933AbdJYUGo (ORCPT ); Wed, 25 Oct 2017 16:06:44 -0400 X-Google-Smtp-Source: ABhQp+T0BjbHYd1Y44vtY27NY1fNbW4YZUlpAIzsYVbEpnHH/CwpfPVQwPySUgApQKx6izyg4r67bXn4y8TiGt5JIxQ= MIME-Version: 1.0 In-Reply-To: <2465945.6cfLQGiipl@aspire.rjw.lan> References: <2245486.jYtPfSLF5g@aspire.rjw.lan> <20171024055409.GA5805@intel.com> <2465945.6cfLQGiipl@aspire.rjw.lan> From: Andy Shevchenko Date: Wed, 25 Oct 2017 23:06:42 +0300 Message-ID: Subject: Re: [PATCH] PM / QoS: Fix device resume latency PM QoS To: "Rafael J. Wysocki" Cc: ramesh.thomas@intel.com, Linux PM , LKML , Reinette Chatre , Alex Shi , Ulf Hansson Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Oct 24, 2017 at 11:49 AM, Rafael J. Wysocki wrote: > On Tuesday, October 24, 2017 7:54:09 AM CEST Ramesh Thomas wrote: >> On 2017-10-20 at 13:27:34 +0200, Rafael J. Wysocki wrote: >> > static ssize_t pm_qos_resume_latency_store(struct device *dev, >> > @@ -228,11 +235,19 @@ static ssize_t pm_qos_resume_latency_sto >> > s32 value; >> > int ret; >> > + if (!kstrtos32(buf, 0, &value)) { >> > + /* >> > + * Prevent users from writing negative or "no constraint" values >> > + * directly. >> > + */ >> > + if (value < 0 || value == PM_QOS_RESUME_LATENCY_NO_CONSTRAINT) >> > + return -EINVAL; >> > + if (value == 0) >> > + value = PM_QOS_RESUME_LATENCY_NO_CONSTRAINT; >> > + } else if (!strcmp(buf, "n/a") || !strcmp(buf, "n/a\n")) { >> >> Can the 2 checks for "n/a" be combined by checking first 3 characters? > > No, because "n/asomething" would then match too. If I don't missed anything, kernfs is aware of \n which means the first check is enough. Am I correct? -- With Best Regards, Andy Shevchenko