From patchwork Wed Mar 16 15:05:24 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Krzysztof Kozlowski X-Patchwork-Id: 12782769 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 5FDF6C433EF for ; Wed, 16 Mar 2022 15:08:09 +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:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=TkfOW8ZE8Vg/NULLbxrT4SgldMk0a1Wl/KFmhMEoZgA=; b=aW1QrBTjZ8JQWf pfJx77fS6U4JvXUtz9QpkZ5swv2R6XGX1N8lBKLm6MDIRvWUMDA1xm6IrAUso0qC18ozBCx6aP12m LcMoFUZ56GBAvJWjWHo6doq1hNrPthZyfyWLud3hasoX/uh84f+ofGXZzJNQ9WFnn0j7Prv9B1naD vkSPUgFMmLjdRuYZlj73F23xYhK3yGdfmx8sgCI4ITHKL2GqzzZrbc2AC7DFS2CXVIREEN3Q1dgDu LePZNR/lnZ0VkppFLMrJcEo6Rz7kbGsvznQIdRBoMuP/CUL5Gu74kM0/QZ9udiaRc4nUnoCjTeBoc DE2Nq59jB64rl1Qcw+RQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1nUVEZ-00DP7t-JQ; Wed, 16 Mar 2022 15:06:43 +0000 Received: from smtp-relay-internal-0.canonical.com ([185.125.188.122]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1nUVEW-00DP6V-52 for linux-arm-kernel@lists.infradead.org; Wed, 16 Mar 2022 15:06:41 +0000 Received: from mail-wr1-f71.google.com (mail-wr1-f71.google.com [209.85.221.71]) (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-0.canonical.com (Postfix) with ESMTPS id B9D953F62D for ; Wed, 16 Mar 2022 15:06:31 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=canonical.com; s=20210705; t=1647443191; bh=LxSp3r31kTKgdYVIAcfNeHGsMIq2YcJzJF2DRNz1kEo=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=slsseQQsKbUN4GEr0QRJ7EpYsghZT45B9D7j2htUQ+XbZswCRpBHLyKCpAA1T13ah uvb5DJ7zr3ce1LF6SWwus9XHfGI3eyhh39y1oCcV2jgM2mqAlvFZrDK4tX0f/h+dgm SIrq+5gVG2F8mUIhptqtFoCN5/tbjQYcQJpSs4XMUnHVzGcWlj7rU43my0Ywj1Po00 mpbbG0vF75zAWbFe/rbW2zPHrx1EaJsOjgvE7yZUeFztihj4Ebi+8lXySAaVX+0n3Y uphcp90XM/YjOcqPCJUlyxAnkBYEIP8Ra7QJs9vuzCf++2QO4FwfgIg5IlUFC7t9Zh YTu5cj4Ce6Now== Received: by mail-wr1-f71.google.com with SMTP id a5-20020adfdd05000000b001f023fe32ffso652228wrm.18 for ; Wed, 16 Mar 2022 08:06:31 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=LxSp3r31kTKgdYVIAcfNeHGsMIq2YcJzJF2DRNz1kEo=; b=aX2nMruSNnrExuBPvifWFMs/JoTI8CCMHvVmwt+2SMkRhHtJKU2u3gpe9niww1BSlJ W/N4MfY3R8BrrNETsB4V4f4sy2Zx2xDiT27+vmT0h9zTRpQzzC8CTrK8619htvGmV1Y4 gPBKaZwDll4K9MhUhe/SmEyugk1DahbqH3QILp+prU4P+JCICXlhlqFSgOg2pFcI73+t u3XdT1YsddQ5/gQWDbCT6YqLo8AGUqpUDWji1frBG8Bm5YcyvnhA8OLnC5cwAr+dqHi3 yQ64u1puH/Q5fMAVsRiswx5fvdHCThQEk7E/wt1ijlyoeld6vUWBJEI/zyqCcJjIpqdH Rn/w== X-Gm-Message-State: AOAM532aRZdeJoHt4FrzU8a12u7jFnU7Tm1wSGvwLHqgyR8IABoKn3if DEARXyw+mLyzOV7/Vt8fUToUAYbw8w/viKxchw/H/eB18m9ekDmYmR50KHA1kS2ji8V0/mXSdkg vMSThpUfbX7oF67MEXhBzVAqGULZIvR9KrXxeORDXsQVBqbloBJBp X-Received: by 2002:a7b:c5d0:0:b0:355:482a:6f44 with SMTP id n16-20020a7bc5d0000000b00355482a6f44mr130539wmk.58.1647443190445; Wed, 16 Mar 2022 08:06:30 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzdXtZV1RU4W+D/CxNpLgNYuPn/wREOODQjEf3w6MZJYByf0aAfpBebBFJL0kKpQw0vNQJhuw== X-Received: by 2002:a7b:c5d0:0:b0:355:482a:6f44 with SMTP id n16-20020a7bc5d0000000b00355482a6f44mr130503wmk.58.1647443190091; Wed, 16 Mar 2022 08:06:30 -0700 (PDT) Received: from localhost.localdomain (78-11-189-27.static.ip.netia.com.pl. [78.11.189.27]) by smtp.gmail.com with ESMTPSA id p14-20020a5d59ae000000b00203dcc87d39sm3130155wrr.54.2022.03.16.08.06.26 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 16 Mar 2022 08:06:28 -0700 (PDT) From: Krzysztof Kozlowski To: Greg Kroah-Hartman , "Rafael J. Wysocki" Cc: Stuart Yoder , "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 , 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 , Andy Shevchenko , Krzysztof Kozlowski Subject: [PATCH v5 02/11] amba: Use driver_set_override() instead of open-coding Date: Wed, 16 Mar 2022 16:05:24 +0100 Message-Id: <20220316150533.421349-3-krzysztof.kozlowski@canonical.com> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20220316150533.421349-1-krzysztof.kozlowski@canonical.com> References: <20220316150533.421349-1-krzysztof.kozlowski@canonical.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20220316_080640_493007_2F03F4E8 X-CRM114-Status: GOOD ( 18.37 ) 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: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Use a helper to set driver_override to reduce the amount of duplicated code. Make the driver_override field const char, because it is not modified by the core and it matches other subsystems. Signed-off-by: Krzysztof Kozlowski --- drivers/amba/bus.c | 28 ++++------------------------ include/linux/amba/bus.h | 6 +++++- 2 files changed, 9 insertions(+), 25 deletions(-) diff --git a/drivers/amba/bus.c b/drivers/amba/bus.c index d3bd14aaabf6..f3d26d698b77 100644 --- a/drivers/amba/bus.c +++ b/drivers/amba/bus.c @@ -94,31 +94,11 @@ static ssize_t driver_override_store(struct device *_dev, const char *buf, size_t count) { struct amba_device *dev = to_amba_device(_dev); - char *driver_override, *old, *cp; - - /* We need to keep extra room for a newline */ - if (count >= (PAGE_SIZE - 1)) - return -EINVAL; - - 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 = dev->driver_override; - if (strlen(driver_override)) { - dev->driver_override = driver_override; - } else { - kfree(driver_override); - dev->driver_override = NULL; - } - device_unlock(_dev); + int ret; - kfree(old); + ret = driver_set_override(_dev, &dev->driver_override, buf, count); + if (ret) + return ret; return count; } diff --git a/include/linux/amba/bus.h b/include/linux/amba/bus.h index 6562f543c3e0..93799a72ff82 100644 --- a/include/linux/amba/bus.h +++ b/include/linux/amba/bus.h @@ -70,7 +70,11 @@ struct amba_device { unsigned int cid; struct amba_cs_uci_id uci; unsigned int irq[AMBA_NR_IRQS]; - char *driver_override; + /* + * Driver name to force a match. Do not set directly, because core + * frees it. Use driver_set_override() to set or clear it. + */ + const char *driver_override; }; struct amba_driver {