Received: by 2002:a05:6a10:9afc:0:0:0:0 with SMTP id t28csp728862pxm; Fri, 25 Feb 2022 18:31:08 -0800 (PST) X-Google-Smtp-Source: ABdhPJwMtZYZ0es/3duGn+OOLJGZ1jsMPbKksWD5sfEcniUBcjabk2It5QVTr+gP49drAGEUsCVp X-Received: by 2002:a17:90a:c901:b0:1bc:bc42:5ea4 with SMTP id v1-20020a17090ac90100b001bcbc425ea4mr6077192pjt.115.1645842668217; Fri, 25 Feb 2022 18:31:08 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1645842668; cv=none; d=google.com; s=arc-20160816; b=zioxk0mEqhhAzAZmmalrRnTLdPl806dtbc+R3zVbhANdtIA8w49W6H2zTdJl68QM8p qvDP0ToyoM5NDVK18VDWRKpXdY4S92m8cWxasgoWiAUfzK5drtaW5bXaosAIazca+OKU xlCZfE2lIkxaAvj+2Q5HvCwXjp0PsfMWJO4l5kIxnYxc1E7RZlyB9eQ1cVsIWN2Yolu6 QeOF/GSUGZlWNcKwZHSoq0evDRB4hGOaVIedcY0uYS5ixMx8dhfwTwaTKRrrbnPXlUU5 zamBWi3Ep4w0+Mj4CFrI0mAmJiABr/2IoUeJJJ2st6QtTIlSLh09gwSEmuum6S7uBgzS MUcg== 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-disposition:mime-version :message-id:subject:cc:to:from:date:dkim-signature; bh=0tZtfGouG4EtZEb8PZNjVL6inSZjVvsrwXXyP0SyRZc=; b=xtQ1Q9WX75GJRBcGJwR8OvLiE8fW1KR2biHa51z3JpneZRsXjgntJlNHWibI4fLeR0 BowopeG5G+cOVhGp4VLAhA4+Zz6vOJa1j3KS4PNasnkXQyUujp4eaJXMzSXIDsBquvzx VGSpr2M0a1d2D5c3fFk+1UpDAJ5MoAbu1jXvMHLtNWkQcdO2RJcr08FdP4SfgSZBQirW NHgu+mnB70FBVxDOgj4KQ/m09f8YvPh2YzpWJSnT9eJ75JA+/NwhUXv8jJp5R6fuqD90 cFfiBxGm+DrCGEIfNCxQ2HB9fWshV+TkDa+yLEdLIH4XU0J4uIh5vne7R+4ojHLJRuSu tEHQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=aKNMEZYO; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 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 lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [23.128.96.19]) by mx.google.com with ESMTPS id e5-20020a17090301c500b0014d8a9ac31bsi3857849plh.539.2022.02.25.18.31.07 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 25 Feb 2022 18:31:08 -0800 (PST) Received-SPF: softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) client-ip=23.128.96.19; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=aKNMEZYO; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 1A2B52887D2; Fri, 25 Feb 2022 17:58:00 -0800 (PST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S243521AbiBYROS (ORCPT + 99 others); Fri, 25 Feb 2022 12:14:18 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55418 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S240804AbiBYROQ (ORCPT ); Fri, 25 Feb 2022 12:14:16 -0500 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A91AB1A8043; Fri, 25 Feb 2022 09:13:43 -0800 (PST) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 4E5EE61D73; Fri, 25 Feb 2022 17:13:43 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 6E452C340E7; Fri, 25 Feb 2022 17:13:42 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1645809222; bh=4sE4Gtevnk8/TCjMANbcRjCHG8DgJ5S+RZAsg3tQewo=; h=Date:From:To:Cc:Subject:In-Reply-To:From; b=aKNMEZYO9GYS47EsbtSGoBp7jQ6cq+PB2zbte+AwwqqiqpcVRMxGDM0F0Afex5ZJW 4rYESli2esu86LIUX6eb+GIiQqKG0aJoZCwpzqlHuXkixzO/1AezAk2443Z9c992ps XywAbCY1/AWyw1jhDZ3bHZQXnfC+/H1QPWErc949Yi5ixSLpl4/cO2POfTAAfrxKho CAVXpDY7lijl79zw4wxpFlP592n7RcY/q2RQ45t4e4X5U4/DfLgdvmThUjLUu/hMNF a6Vl3pNKPQMeAYVdX3MJ7TCbUyat1DVH9TvH+imzTBTV3gNbtHMVmiV6Fa05o9r3/n oKdbLx9yzFJlA== Date: Fri, 25 Feb 2022 11:13:41 -0600 From: Bjorn Helgaas To: Krzysztof Kozlowski 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 Subject: Re: [PATCH v2 05/11] pci: use helper for safer setting of driver_override Message-ID: <20220225171341.GA364850@bhelgaas> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <0aff95ff-5b79-8ae9-48fd-720a9f27cbce@canonical.com> X-Spam-Status: No, score=-2.3 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,MAILING_LIST_MULTI, RDNS_NONE,SPF_HELO_NONE,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 lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, Feb 25, 2022 at 10:36:20AM +0100, Krzysztof Kozlowski wrote: > 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. Thanks, I think that would be good! Bjorn