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 smtp3.osuosl.org (smtp3.osuosl.org [140.211.166.136]) (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 E0FC9C433EF for ; Wed, 23 Feb 2022 21:51:26 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by smtp3.osuosl.org (Postfix) with ESMTP id 8C254607FE; Wed, 23 Feb 2022 21:51:26 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Received: from smtp3.osuosl.org ([127.0.0.1]) by localhost (smtp3.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 3jycR8WmqYWk; Wed, 23 Feb 2022 21:51:25 +0000 (UTC) Received: from lists.linuxfoundation.org (lf-lists.osuosl.org [140.211.9.56]) by smtp3.osuosl.org (Postfix) with ESMTPS id 4771760B96; Wed, 23 Feb 2022 21:51:25 +0000 (UTC) Received: from lf-lists.osuosl.org (localhost [127.0.0.1]) by lists.linuxfoundation.org (Postfix) with ESMTP id 0174DC001A; Wed, 23 Feb 2022 21:51:25 +0000 (UTC) Received: from smtp2.osuosl.org (smtp2.osuosl.org [IPv6:2605:bc80:3010::133]) by lists.linuxfoundation.org (Postfix) with ESMTP id CA399C0011 for ; Wed, 23 Feb 2022 21:51:22 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by smtp2.osuosl.org (Postfix) with ESMTP id AF41E4022E for ; Wed, 23 Feb 2022 21:51:22 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Authentication-Results: smtp2.osuosl.org (amavisd-new); dkim=pass (2048-bit key) header.d=kernel.org Received: from smtp2.osuosl.org ([127.0.0.1]) by localhost (smtp2.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id l7RSqVpPkWcd for ; Wed, 23 Feb 2022 21:51:21 +0000 (UTC) X-Greylist: domain auto-whitelisted by SQLgrey-1.8.0 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by smtp2.osuosl.org (Postfix) with ESMTPS id 69C53400E4 for ; Wed, 23 Feb 2022 21:51:21 +0000 (UTC) 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 539DEB81F56; Wed, 23 Feb 2022 21:51:18 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id CE649C340E7; Wed, 23 Feb 2022 21:51:16 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1645653077; bh=EOsLY0xS49T9DSDZaspJWFLqMIPottB/vHuCZHn9gRc=; h=Date:From:To:Cc:Subject:In-Reply-To:From; b=ahhwtyxMEpCMobEOsqsInnTB54HNvEQ6GtBmi9Pbads3CBGXv3HugVhnSog9F8o/e ivV0EdPE2BUK6TnJhBe3j+4lVCC9rXDQnkWsSLE39We5LPQwqxPigAexZ79Cnl3s4B rNHqXxjoVaHLCkU5BuV7KvHty99EiDdh+MAzrJt5TYIBMGr8EWMQY7h5KZZAO+881E 5r9UAiifkq5EzBV8uygdBejuW3dyuB89wAaBBP3+AJgQ/rXohe9dKeUnXP0zdTaFkk lfm1EHCugtgIzsLPpr5/CugEAZ9J1veD7nNl57sP6l07KQOXA5tmaKZkJScpcbJRHQ wWzvXTETPgAfQ== Date: Wed, 23 Feb 2022 15:51:15 -0600 From: Bjorn Helgaas To: Krzysztof Kozlowski Subject: Re: [PATCH v2 05/11] pci: use helper for safer setting of driver_override Message-ID: <20220223215115.GA155125@bhelgaas> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20220223191310.347669-6-krzysztof.kozlowski@canonical.com> Cc: linux-hyperv@vger.kernel.org, Stuart Yoder , "Rafael J. Wysocki" , linux-pci@vger.kernel.org, linux-remoteproc@vger.kernel.org, alsa-devel@alsa-project.org, Bjorn Andersson , Srinivas Kandagatla , Vineeth Vijayan , Alexander Gordeev , Fabio Estevam , linux-clk@vger.kernel.org, linux-s390@vger.kernel.org, Wei Liu , Stephen Hemminger , Abel Vesa , "Michael S. Tsirkin" , Dexuan Cui , Linus Torvalds , Andy Gross , NXP Linux Team , Heiko Carstens , Vasily Gorbik , linux-arm-msm@vger.kernel.org, Sascha Hauer , linux-spi@vger.kernel.org, Mark Brown , Rasmus Villemoes , Bjorn Helgaas , virtualization@lists.linux-foundation.org, linux-arm-kernel@lists.infradead.org, Laurentiu Tudor , Mathieu Poirier , Greg Kroah-Hartman , Haiyang Zhang , Peter Oberparleiter , linux-kernel@vger.kernel.org, Sven Schnelle , Shawn Guo X-BeenThere: virtualization@lists.linux-foundation.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: Linux virtualization List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Errors-To: virtualization-bounces@lists.linux-foundation.org Sender: "Virtualization" 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. s/seting/setting/ > Signed-off-by: Krzysztof Kozlowski > --- > drivers/pci/pci-sysfs.c | 24 ++++-------------------- > 1 file changed, 4 insertions(+), 20 deletions(-) > > diff --git a/drivers/pci/pci-sysfs.c b/drivers/pci/pci-sysfs.c > index 602f0fb0b007..16a163d4623e 100644 > --- a/drivers/pci/pci-sysfs.c > +++ b/drivers/pci/pci-sysfs.c > @@ -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. > - 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 _______________________________________________ Virtualization mailing list Virtualization@lists.linux-foundation.org https://lists.linuxfoundation.org/mailman/listinfo/virtualization