Received: by 2002:a05:6a10:9afc:0:0:0:0 with SMTP id t28csp1316512pxm; Thu, 24 Feb 2022 00:14:12 -0800 (PST) X-Google-Smtp-Source: ABdhPJz5H8RgIRemSHVGJZWYTOrXwtY6p0hZ9P+hKTYSoFJxCri6cCdmH6ywlcgU4vhFZo29l0tZ X-Received: by 2002:a17:906:c318:b0:6cf:d118:59d8 with SMTP id s24-20020a170906c31800b006cfd11859d8mr1326460ejz.112.1645690451974; Thu, 24 Feb 2022 00:14:11 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1645690451; cv=none; d=google.com; s=arc-20160816; b=EsbTco/hkl9PMerFSjHQ10cQAXwOkYRASiY2oz7kMmy/iip0HquBbT0tW7CNlnR8ZS NREvadT2FAm2Mz+/yruYmJEbJS12QZUX6Hg5vmcAF3LmC5kkfCnpo5pJ4uDH/9cT6P0a Z0g4JuggzHXbwy7Gc1/iiMJWKm8CUtB34CulbCqtLpJYG6y1WvEEnYfca4zCkIqK+xv0 Iwvv3iHgVXozJJyEykOAmSdPKivno0+Er0+f4ST79ttr9Gsc3fcawnDJXa8EaNTYtl3h PokRXWxICXwMKDEWylchmJNLWOHy8pXUlEaZ5v0QENSwoZsqlXyxM+e7MMumcI8S/o3R 8G7g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to:from :references:cc:to:content-language:subject:user-agent:mime-version :date:message-id:dkim-signature; bh=tIIHXtnNxTvsUSqBUvFfmiqo64/DEPmMQ0dgIpM1aoU=; b=xuyZvoI9ABeIIeZzqt2788U5H+EhLCzuHwjfDKHGHpG8AApkSa+E3O6MfQlHJiYpMY r31KRAoIaDvvA6h0h6zZhcVFvXfTyA4qdkCnXMYehiecIkjslS3yjErKRptExRdACxXN lXVH06gJiToYezx653nxIDCAAZtBN8Icm1s7jfdKfvWgRPd+hYuTtcJy4K0c5qt9kE51 rudxIzBwSGf9b7mgOSlQ3JIQHpcfcmW9L1b6mKKUeBMNzO9sebuvfqmv9CY9Ljmy8Tyw PWkuFmqymQfwFu93MHhX3uS4sN/Ra8IlfATq92h6OBWSE+l/SMfrxhcqwlQqaqlk9VvP gixg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@canonical.com header.s=20210705 header.b=YpEXb4n4; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=canonical.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id g25si1054717edr.183.2022.02.24.00.13.48; Thu, 24 Feb 2022 00:14:11 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@canonical.com header.s=20210705 header.b=YpEXb4n4; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=canonical.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230496AbiBXHuB (ORCPT + 99 others); Thu, 24 Feb 2022 02:50:01 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36584 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230446AbiBXHt6 (ORCPT ); Thu, 24 Feb 2022 02:49:58 -0500 Received: from smtp-relay-internal-1.canonical.com (smtp-relay-internal-1.canonical.com [185.125.188.123]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A7AD617CC61 for ; Wed, 23 Feb 2022 23:49:28 -0800 (PST) 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-1.canonical.com (Postfix) with ESMTPS id 794923F1BC for ; Thu, 24 Feb 2022 07:49:27 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=canonical.com; s=20210705; t=1645688967; bh=tIIHXtnNxTvsUSqBUvFfmiqo64/DEPmMQ0dgIpM1aoU=; h=Message-ID:Date:MIME-Version:Subject:To:Cc:References:From: In-Reply-To:Content-Type; b=YpEXb4n41C0VFLtYmr1fnR1n54QsPYCran0ax0dJevvKreA5A0KGjmGuIA3F1afG+ ekHHgz2A+VvYN251k13Qxe6TSqhG01sZGymFg8CrzPeRCCTe7KV11MX/i3np+WyExb 5iODgpN+sYno+8AI2YYG9whPqJNJp4eNB3hKXg0W3pTQSrAa9rAyaF0JIFW/NWNT7d FJKZPUMp/Ts2DxQ+u1+12uk6cQBhScqrsp+ZaDPw2cyxJWiT0RH4HZka30ua0wygPq +xbrcBHL7lYkjlXPQz6xlfKd/2BwtVn8cp/1huOy1flRUYI5ULPF6e8zdZL0DC0yCI cOMbJalBVL4NA== Received: by mail-ed1-f69.google.com with SMTP id n7-20020a05640205c700b0040b7be76147so358394edx.10 for ; Wed, 23 Feb 2022 23:49:27 -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=tIIHXtnNxTvsUSqBUvFfmiqo64/DEPmMQ0dgIpM1aoU=; b=idWwlrr9HE1OlEYEFUa2VkRsT0zi50+cWUUkITYS2vb8yzVZki4AedYyu49/Ah1uTS KTbipOybZrg1u+VYTJqvvr/YGNoL5gsMol1mhJhj0DuzWVTB956BZBChT2eNHdKUNYps 7CETKGNTyRK4o0400cmUveC+q7eu4rfMQGEZFxyldBZ8k01Rcw3/cjNHuE7OBhCSAR7Y Y35wipgA8V5zNH3KKk6L7iZpQ51v2WX7hcuPgvTZUJZm1x2Jtv0+BTHtqIPCXDbZC3tf rQxRWw3oiXYUtZdoqRX98O/K7ifBoomJHd44ZmCu6wXCjZjbjkIc5aPT3nJKH3OrDPgS yW0Q== X-Gm-Message-State: AOAM5333ZOpqaMjOzawqJ+P5B/yzN2A76t4P03KKLlozsFWTPqwzlMdm IrRWjvJu9PJUJaDS15TqRvjUXFnoCp8TmZYvxf/KAQYzmyQvaBinrpBl/YHNjqpdDZYizGOzmoR WxCfmkjZclLt0R0C4zRxQgt2qp+4nnOZ8GObgnSAxhw== X-Received: by 2002:a05:6402:177b:b0:413:2822:1705 with SMTP id da27-20020a056402177b00b0041328221705mr1116386edb.270.1645688957130; Wed, 23 Feb 2022 23:49:17 -0800 (PST) X-Received: by 2002:a05:6402:177b:b0:413:2822:1705 with SMTP id da27-20020a056402177b00b0041328221705mr1116367edb.270.1645688956871; Wed, 23 Feb 2022 23:49:16 -0800 (PST) Received: from [192.168.0.127] (xdsl-188-155-181-108.adslplus.ch. [188.155.181.108]) by smtp.gmail.com with ESMTPSA id s15sm954628ejm.70.2022.02.23.23.49.15 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Wed, 23 Feb 2022 23:49:16 -0800 (PST) Message-ID: Date: Thu, 24 Feb 2022 08:49:15 +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: <20220223215115.GA155125@bhelgaas> From: Krzysztof Kozlowski In-Reply-To: <20220223215115.GA155125@bhelgaas> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,NICE_REPLY_A, RCVD_IN_DNSWL_MED,SPF_HELO_NONE,SPF_PASS,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 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. > > 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. 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? > >> - 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