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 bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 67A25C433F5 for ; Fri, 25 Feb 2022 09:37:44 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:In-Reply-To:From:References:Cc:To: Subject:MIME-Version:Date:Message-ID:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=CW0FgM5SS3/o2IxuYHE0NCQ8wT9cRtM41CjC45altsU=; b=CP9P6QVxtK1t0E HRLYmDOiEYMBFRSnSd6csGP0Mya6GgB2C9KFbwYwi7PFgr5q5xzHUl18Bic7/p7G1t6CTKQ4AvFPw h/7rGpyf8hoCaM/tgyIWJBwhBoio51BloUMfdJ/8VdxwXKxHT4RIAO1RU1/Q1NnhSuJ82337G02yK 1TpfFH27TLwwtdu4LOm5P4jNHZUq9ePIHLaEV8J5qpu2p+Y5pa8Kh1xf5180RA+KFFYbUZpXOJ5w8 1LWk+hQets6FFPyIucT9HKRdmoFZDD9d4BWXuhXVbcMK65gO/7kruBKA1fQoBdIqQeXwrcab+GjZF iRUqcV2USE75d6vLyG5g==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1nNX1c-004CPq-11; Fri, 25 Feb 2022 09:36:32 +0000 Received: from smtp-relay-internal-0.canonical.com ([185.125.188.122]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1nNX1V-004COo-Q3 for linux-arm-kernel@lists.infradead.org; Fri, 25 Feb 2022 09:36:28 +0000 Received: from mail-ed1-f69.google.com (mail-ed1-f69.google.com [209.85.208.69]) (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-0.canonical.com (Postfix) with ESMTPS id 631F54001E for ; Fri, 25 Feb 2022 09:36:23 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=canonical.com; s=20210705; t=1645781783; bh=mwBGuSv1vzWcEgYl2MgCXz9QnnQmXLrpGmSTa9ywwuI=; h=Message-ID:Date:MIME-Version:Subject:To:Cc:References:From: In-Reply-To:Content-Type; b=r9eAB7z4Au066qpDSZhT/9tLha4EycFEcDpSDYbGUKhKjIf6GqDyx0qOB4yMtdJ0g 84ewarQUNcMrY1MhjENr9hz+gZwZhthQsFtTnD8l2MUdO2beuYmflKwP1Pn8smPDxq ATilhUpWEAjVu80vT+V8eS3udpxyBM4152O0envOSLXto9+dUtvR1CNRWwYztBzb1O wyxvFAljpddatUQCLUt3LTK8FXE0MoodphirVw10CK9HYuGFqRXyvBqmzy9+kbqXYP RKSppOkDReF4VnmoAhKPnhqTr8mJl1Jdn05HngR7ByJe7btYmeRO/EdxDHyG0Hqlaq OY6Od5OYf5hbA== Received: by mail-ed1-f69.google.com with SMTP id s7-20020a508dc7000000b0040f29ccd65aso2077487edh.1 for ; Fri, 25 Feb 2022 01:36:23 -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=I/55aWsJleA6HjdneCd9C21YpDF02Gj5cuVNeqL8JC0sC6QSmzCc2Lw1z318GUNA5B cMXtxyR9hNtwBNq1sRCKHH7ye3FCo/9n5VKdyh0dUMWRiA5f8alsKGq7nXSOPP4/BTFB xy5pWqkffGb3c7+2d46i92FXcPGxBa9QgOiQIyrFXvMeHilU8dpVNlzg1yxTNVLPnafP plvQ2hB/DTNnIuclh/8IR7ld5oeh8wz34lVUu3tTVE976adaL3u8A1EhoissTgNVVHpE gWJPw3ZJzfIqENkInxPcxZ89kbkmoiheKy7oMUiOQtbG5bn6vxQ75v3eUVaLd6x+Xg0m 71zg== X-Gm-Message-State: AOAM530EYohVyQNvV1hPHVgqN8dkj0rRdBoVC89vRFXnTur+wU7d4vpJ hbNxoVyEkXigUMqJxfNSKCOwDhoO0RnF7CoiiMb9oatSsmRTaAQ4key3IKxUKHBDsN70DdSiSvP pEgM2I9VEKQwFISfamTJ/P3rDhTUakdV/wow48jxx2yB3gV26h/Wj X-Received: by 2002:a17:906:4cca:b0:6ce:6a06:bf7 with SMTP id q10-20020a1709064cca00b006ce6a060bf7mr5644772ejt.109.1645781782638; 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> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20220225_013626_089238_3B59ACD3 X-CRM114-Status: GOOD ( 23.22 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.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 _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel