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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 05F09C433F5 for ; Fri, 25 Feb 2022 09:36:44 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234262AbiBYJhO (ORCPT ); Fri, 25 Feb 2022 04:37:14 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33210 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239163AbiBYJhK (ORCPT ); Fri, 25 Feb 2022 04:37:10 -0500 Received: from smtp-relay-internal-1.canonical.com (smtp-relay-internal-1.canonical.com [185.125.188.123]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C2A556383 for ; Fri, 25 Feb 2022 01:36:34 -0800 (PST) Received: from mail-lf1-f72.google.com (mail-lf1-f72.google.com [209.85.167.72]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by smtp-relay-internal-1.canonical.com (Postfix) with ESMTPS id 9ACFA3FCA7 for ; Fri, 25 Feb 2022 09:36:33 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=canonical.com; s=20210705; t=1645781793; bh=mwBGuSv1vzWcEgYl2MgCXz9QnnQmXLrpGmSTa9ywwuI=; h=Message-ID:Date:MIME-Version:Subject:To:Cc:References:From: In-Reply-To:Content-Type; b=qk45lsTpLT74Z731Io80odzcwBaoFTxG+Ex9+UdRPhdmJoGO9vW6y4Mb2oCr/hm3P a3qd6+kEXaJtSUP9Zl/ZtXqLzBxM3SABsJxlR5a8Il+l1tZX8I88h/yKKSUUV6I01g DRFJxqp7rC4/ai+ha0dw0AHBcOvES48XJhLinWjnK6HIYzDvQdZv8YY+X82rBA815f dmRZwh/gCIT80u78M+aOlLhHR7VlFPIT54eSAKS0o1ICxbK2oej410Ty4oKK942k66 7iCUwLl8iMrf0pv37dqGhyIPijzTANBJE7OHXSNGASwWf0nUHLabKJoDTXWAK/SRre c8UfUrM4p9Awg== Received: by mail-lf1-f72.google.com with SMTP id e8-20020ac25468000000b00443973fc878so771667lfn.23 for ; Fri, 25 Feb 2022 01:36:33 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:message-id:date:mime-version:user-agent:subject :content-language:to:cc:references:from:in-reply-to :content-transfer-encoding; bh=mwBGuSv1vzWcEgYl2MgCXz9QnnQmXLrpGmSTa9ywwuI=; b=COGFLSe+DfIMvE+nFrTI/yAeQHB/VOD0YVyavPpyvqEGZmO0ohY5LK/pBGzXKXW3qj DROhn3tL92nI1WjL17xeBnuoE3SYGMNgRjkyo8vVWWlqM3mEXynJKbHaLPzC9c3j3ump nbA0PZpIw5Tly3Sr3AIB6L/MWYvOYXMx5JEWZ1apmln7nIQ/NU3mR+yZzaQo4kcs1+zg wTZT69sblUMPG/6Wn2wNzAQ13i+MVfQ74yFhwbzi6IIpQiD0D/VnsCsYWxnNJg7gyPB2 3fZGtA/v8PTs4yPsqHy5YByLUvtXAupoS33BP28FXCioEVGgxEkGpABTAV7R2fH7zFDG Hlsw== X-Gm-Message-State: AOAM530+yLDctqDqcj04xFHiyHk/o7/VpRWRzL4nxpH7V3X07QzPMcou 0d54yHyzm41hY/SpZ+dk2b96+RarSe1xOKxQeNYzmysnHDELykB7JYmpX/jKvH3xL/cuUI4vIpi rDvYKgbI5ChUMrCpurImq4aGbefyzFUxvsePOhAI= X-Received: by 2002:a17:906:4cca:b0:6ce:6a06:bf7 with SMTP id q10-20020a1709064cca00b006ce6a060bf7mr5644777ejt.109.1645781782639; Fri, 25 Feb 2022 01:36:22 -0800 (PST) X-Google-Smtp-Source: ABdhPJxvGXs5zpBbIxYfXArg3HJWTHPHMBjqJChT5RpHzF7M3/UrStNiNcxogS5o2fNS3FLp8Ip6Ag== X-Received: by 2002:a17:906:4cca:b0:6ce:6a06:bf7 with SMTP id q10-20020a1709064cca00b006ce6a060bf7mr5644737ejt.109.1645781782424; Fri, 25 Feb 2022 01:36:22 -0800 (PST) Received: from [192.168.0.130] (xdsl-188-155-181-108.adslplus.ch. [188.155.181.108]) by smtp.gmail.com with ESMTPSA id bo9-20020a170906d04900b006ce6b8e05c1sm773655ejb.150.2022.02.25.01.36.20 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Fri, 25 Feb 2022 01:36:21 -0800 (PST) Message-ID: <0aff95ff-5b79-8ae9-48fd-720a9f27cbce@canonical.com> Date: Fri, 25 Feb 2022 10:36:20 +0100 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.5.0 Subject: Re: [PATCH v2 05/11] pci: use helper for safer setting of driver_override Content-Language: en-US To: Bjorn Helgaas Cc: Greg Kroah-Hartman , "Rafael J. Wysocki" , Stuart Yoder , Laurentiu Tudor , Abel Vesa , Shawn Guo , Sascha Hauer , Fabio Estevam , "K. Y. Srinivasan" , Haiyang Zhang , Stephen Hemminger , Wei Liu , Dexuan Cui , Bjorn Helgaas , Bjorn Andersson , Mathieu Poirier , Vineeth Vijayan , Peter Oberparleiter , Heiko Carstens , Vasily Gorbik , Alexander Gordeev , Christian Borntraeger , Sven Schnelle , Andy Gross , Srinivas Kandagatla , Mark Brown , "Michael S. Tsirkin" , Jason Wang , linux-kernel@vger.kernel.org, linux-clk@vger.kernel.org, NXP Linux Team , linux-arm-kernel@lists.infradead.org, linux-hyperv@vger.kernel.org, linux-pci@vger.kernel.org, linux-remoteproc@vger.kernel.org, linux-s390@vger.kernel.org, linux-arm-msm@vger.kernel.org, alsa-devel@alsa-project.org, linux-spi@vger.kernel.org, virtualization@lists.linux-foundation.org, Linus Torvalds , Rasmus Villemoes References: <20220224235206.GA302751@bhelgaas> From: Krzysztof Kozlowski In-Reply-To: <20220224235206.GA302751@bhelgaas> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit Precedence: bulk List-ID: X-Mailing-List: linux-s390@vger.kernel.org On 25/02/2022 00:52, Bjorn Helgaas wrote: > On Thu, Feb 24, 2022 at 08:49:15AM +0100, Krzysztof Kozlowski wrote: >> On 23/02/2022 22:51, Bjorn Helgaas wrote: >>> In subject, to match drivers/pci/ convention, do something like: >>> >>> PCI: Use driver_set_override() instead of open-coding >>> >>> On Wed, Feb 23, 2022 at 08:13:04PM +0100, Krzysztof Kozlowski wrote: >>>> Use a helper for seting driver_override to reduce amount of duplicated >>>> code. >>>> @@ -567,31 +567,15 @@ static ssize_t driver_override_store(struct device *dev, >>>> const char *buf, size_t count) >>>> { >>>> struct pci_dev *pdev = to_pci_dev(dev); >>>> - char *driver_override, *old, *cp; >>>> + int ret; >>>> >>>> /* We need to keep extra room for a newline */ >>>> if (count >= (PAGE_SIZE - 1)) >>>> return -EINVAL; >>> >>> This check makes no sense in the new function. Michael alluded to >>> this as well. >> >> I am not sure if I got your comment properly. You mean here: >> 1. Move this check to driver_set_override()? >> 2. Remove the check entirely? > > I was mistaken about the purpose of the comment and the check. I > thought it had to do with *this* function, and this function doesn't > add a newline, and there's no obvious connection with PAGE_SIZE. > > But looking closer, I think the "extra room for a newline" is really > to make sure that *driver_override_show()* can add a newline and have > it still fit within the PAGE_SIZE sysfs limit. > > Most driver_override_*() functions have the same comment, so maybe > this was obvious to everybody except me :) I do see that spi.c adds > "when displaying value" at the end, which helps a lot. > > Sorry for the wild goose chase. I think I will move this check anyway to driver_set_override() helper, because there is no particular benefit to have duplicated all over. The helper will receive "count" argument so can perform all checks. Best regards, Krzysztof