Received: by 2002:a05:6a10:9afc:0:0:0:0 with SMTP id t28csp1060766pxm; Wed, 23 Feb 2022 17:06:10 -0800 (PST) X-Google-Smtp-Source: ABdhPJw2dAwe2b67hSgw71J0kUYntEfTu4H3KvbvJ5au+WaBu8qCSGAGiCm3M9DI74fMemhHmQpU X-Received: by 2002:a17:902:9348:b0:14d:8ee9:329f with SMTP id g8-20020a170902934800b0014d8ee9329fmr457800plp.80.1645664770533; Wed, 23 Feb 2022 17:06:10 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1645664770; cv=none; d=google.com; s=arc-20160816; b=YSTcQcy9hWBGhlDgBaGbnOTMezj0W00WxMDHcyZ8IUoc3uQr9EN9sDUqXhro8yCHrT oA/3ye1fjm5tXmW/tEWfqSYN5ofyJaL+nwQ0Fk8LF0O352mV2JQJ1XXy3CjlPBS4qjdf 2z62XpkOmm1jtYH1oF5Bo29wkwT8OK6zGLoca+nVWQYRGRoH0AynNTbnRgLGBPwbQNiH DHOueB/2B/Y31yLZpHKgCI77xKaAYLV5duq5GR1RCszbWrmTN3/Pm3kKuFTsEkus4Gue 8ZITJQJtl2MvFIwQhmGUd1G6C5wsbqp1lAqpyc2dJBtYErnE5pWsIOaUDkp0iOEMUO20 1j5g== 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=LVTUc3MQKm3wlxFAC/sgeUbfnDUu72JEK+Io+owOVDU=; b=Oxt+IFslFlAYgVG5cHin3H2rYilhOp8TNOAK7tW9yiMV4MoBAOph94LLcqS10Mi+Wr dngeYwwahtIofswxuhCZpaonSv4V7muxU/EPONmG2sUq5F0qqoBTOEih9s3jfFziwjnQ mcD929zUgPiyxPgJgMvdsEcFVTpqEV0ersMLbFBFSrclyPvt+gfh7kQfVGbmSrhxookl /NvIXVoXq++nQhvUSbJb+vC3PIziZlcqs7RQ9szApB0AgDBFa8j7SItSfdK892qkXyyW wTMNEEAbNZPZkcMIUdQ0F30rCQYOl6o1ll5IYWQXfKea4SX2Tgz5ikNho99zLrE7yDiy kYzQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=ahhwtyxM; 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 q195si1063530pgq.607.2022.02.23.17.06.10 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 23 Feb 2022 17:06:10 -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=ahhwtyxM; 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 F0D5C10E57D; Wed, 23 Feb 2022 16:55:59 -0800 (PST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S241892AbiBWVvt (ORCPT + 99 others); Wed, 23 Feb 2022 16:51:49 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49924 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235875AbiBWVvs (ORCPT ); Wed, 23 Feb 2022 16:51:48 -0500 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A30E65044C; Wed, 23 Feb 2022 13:51:19 -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 ams.source.kernel.org (Postfix) with ESMTPS id 56978B821BE; 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 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: <20220223215115.GA155125@bhelgaas> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20220223191310.347669-6-krzysztof.kozlowski@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 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