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 218E7C433F5 for ; Thu, 24 Feb 2022 23:53:33 +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:MIME-Version:Message-ID: Subject:Cc:To:From:Date:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:References: List-Owner; bh=hTlBZ+jhS8482slqkWMctejoDY3UL362MvqKKxTnVCk=; b=PZ381wIphGGWwD 9hscwCxc/IEAQNdqc2UP1t4Zd3iCUM4WQFz01Hce8IyKxpuJJwozU/2dfgvCUwyoj+WU6f1dSaXOz Cuqfb8DlamSaUZA702DMQ4tw86jRQTAJzVgSEpQkebVBNzokxW9mT6hJRSryzIdvAT9TWw6FGSwj+ Rda5qI8Geu5JG0bC35ytkpdfxIkis7JJckzZFs55q2ooYqSOqbK9wc7PqI7+8sFKGFwE3SBThUTrh Gi/52m0QGue1czeNPgWC6fi9jxoqbJ3b6UKSR05VMU6rCJd6ZEA2yVzazGhXknIdCuM/N7TXjdyVY Q9akt8Y3gTRwQXRjIA5A==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1nNNuA-002iqf-Jl; Thu, 24 Feb 2022 23:52:14 +0000 Received: from ams.source.kernel.org ([2604:1380:4601:e00::1]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1nNNu6-002ipK-UN for linux-arm-kernel@lists.infradead.org; Thu, 24 Feb 2022 23:52:12 +0000 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 ams.source.kernel.org (Postfix) with ESMTPS id 4D79BB828B7; Thu, 24 Feb 2022 23:52:09 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id AD98FC340E9; Thu, 24 Feb 2022 23:52:07 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1645746728; bh=zVAGv3GzIY0CmGHccO6MTpPuZ0cGji1luXzfksNlM2M=; h=Date:From:To:Cc:Subject:In-Reply-To:From; b=kCSNhdmjCNFp4p3nEZo05DvtkYaTYatl89i6A6bnh2GoE1LafejZW2+LdT+xyn9p9 vFysfr3uU3CN1goYGDWRGNKLLknLWL4gwXq4LwSu/xs2AfSKORCBht3dm2YESZuJkC QTihOOdWAM03oTBu5HCC9wQYShduFbcLphU9XZZOZ2w+HR8xeoLGBBRX0Da60zkFuO Gw55uOtn72xOyN5dsOgPR66lVXrDqagidhgfw1lK88dhzevhVz/lXIRWDLrY+G2rDT B2vC1ShfZifdcQml58IDHz2aBNdppV0ayqFTRcbx14EaEZyzuuUqWcpsrE30jKvDVw +pVWnNSGt5bFQ== Date: Thu, 24 Feb 2022 17:52:06 -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: <20220224235206.GA302751@bhelgaas> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20220224_155211_294741_4ACB257D X-CRM114-Status: GOOD ( 29.36 ) 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 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. > >> - driver_override = kstrndup(buf, count, GFP_KERNEL); > >> - if (!driver_override) > >> - return -ENOMEM; > >> - > >> - cp = strchr(driver_override, '\n'); > >> - if (cp) > >> - *cp = '\0'; > >> - > >> - device_lock(dev); > >> - old = pdev->driver_override; > >> - if (strlen(driver_override)) { > >> - pdev->driver_override = driver_override; > >> - } else { > >> - kfree(driver_override); > >> - pdev->driver_override = NULL; > >> - } > >> - device_unlock(dev); > >> - > >> - kfree(old); > >> + ret = driver_set_override(dev, &pdev->driver_override, buf); > >> + if (ret) > >> + return ret; > >> > >> return count; > >> } > >> -- > >> 2.32.0 > >> > >> > >> _______________________________________________ > >> linux-arm-kernel mailing list > >> linux-arm-kernel@lists.infradead.org > >> http://lists.infradead.org/mailman/listinfo/linux-arm-kernel > > > Best regards, > Krzysztof > > _______________________________________________ > linux-arm-kernel mailing list > linux-arm-kernel@lists.infradead.org > http://lists.infradead.org/mailman/listinfo/linux-arm-kernel _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel