From patchwork Tue Apr 19 11:34:25 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Krzysztof Kozlowski X-Patchwork-Id: 565332 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 alsa0.perex.cz (alsa0.perex.cz [77.48.224.243]) (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 16648C433F5 for ; Tue, 19 Apr 2022 11:58:27 +0000 (UTC) Received: from alsa1.perex.cz (alsa1.perex.cz [207.180.221.201]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by alsa0.perex.cz (Postfix) with ESMTPS id 5208718A9; Tue, 19 Apr 2022 13:57:35 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz 5208718A9 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1650369505; bh=VQQnZlkcY+VmV+z768TlQ5fTxzt1y4izYA4C08NiH/A=; h=From:To:Subject:Date:In-Reply-To:References:Cc:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From; b=ouqbXSuJwu8otzwp7AQx//kuflsTT2mf+92Q9DljuTWlL+3bB6rsB4K+WzKUqmcmW fEn3o64KUYsfFGbglfbEvVKrUj1EcT1fgcg6vnb/56ABRf9dxEMNn3tOKvodhF2v2y OgM/a9YCRfRvx/q4bLXD14QM0ocbii9rCxJV3QeA= Received: from alsa1.perex.cz (localhost.localdomain [127.0.0.1]) by alsa1.perex.cz (Postfix) with ESMTP id 0F83BF805A9; Tue, 19 Apr 2022 13:52:36 +0200 (CEST) Received: by alsa1.perex.cz (Postfix, from userid 50401) id BBEE4F804FB; Tue, 19 Apr 2022 13:35:02 +0200 (CEST) Received: from mail-ej1-x62c.google.com (mail-ej1-x62c.google.com [IPv6:2a00:1450:4864:20::62c]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by alsa1.perex.cz (Postfix) with ESMTPS id 1FFD7F80121 for ; Tue, 19 Apr 2022 13:34:52 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz 1FFD7F80121 Authentication-Results: alsa1.perex.cz; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="bZcovbSW" Received: by mail-ej1-x62c.google.com with SMTP id bv19so32282787ejb.6 for ; Tue, 19 Apr 2022 04:34:52 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=rk4GrfXMwJbLvQiVana1UoJ1THyewcmBCMxkYGfguzc=; b=bZcovbSWF6o2arWzTigSJRHioa/LpdZ+Sy6qfFHoDdZg4zOpttbt+cEt7sC0+KAMgc kjFI6Xl5Qkk0tuWaxpLC9pt627FKQYXBUqbpErU4FCXACI/FX/49UmrIKZGC/VVQ/yNl thkwNFCClHLlC3MLJ3KmifplRZUWh88lwO4mY+6j9uINEwu9Zkkn4y42snAbFDPzpryZ 0iUqZU1KszkYfoNGB78yr1y3hU2ztgm1ciO2lgnILN72uHpo+U1B5f6kPrA2dA0oYM6P 007wp/Ik4Iv1jaN4vnouaRv15VbqVpPeIVN4Ud0vWErJzstfVcug/keSU4SnpnBrAXKK 0Usg== 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=rk4GrfXMwJbLvQiVana1UoJ1THyewcmBCMxkYGfguzc=; b=u8N//di7vTGQN+7NfjVjy4d/Z8+Mxzc6QIgZWPEie/FYDk3989u9HyuFM599uVnX8k xPFwNvEVE82wv67F8UyaiGiTtGokeNS/GJPjjGqdO3K552HpS5IQJsiQ2FkyGrlkKVTx ejOQ42DqxmzdVsBoM62Ad3QNLXolyl0KnogTr8mQx8/KXy0glnxquAMBxsIvdoZEd5Xr 3r5NtxTDU/BE7wxIKUi5nb4NdkdavnBy4vEDIcZi38GLbCgJR/a7wh9LS/iXCncA+230 Vch2LkQXsZVLxivNqjJ7Lb7WP4sNY2PWFnHNosOINsB0EL0AAwGGbw8oHr1WZevPpWko zlgg== X-Gm-Message-State: AOAM531NWdmAm1UD6xwAO82qDEb4uAckxsDySSwwtmCpHjVpba/d6InH bMKQKE7lKcdub8/DsY3vnUkReQ== X-Google-Smtp-Source: ABdhPJzbytfn6U4klzpcMgwS7vfB8ICxKj/t5N2gXKEuUopbN5DyDh0kRWezTKeQA3rJF5XGiwm0+g== X-Received: by 2002:a17:907:1c85:b0:6e8:da11:85cb with SMTP id nb5-20020a1709071c8500b006e8da1185cbmr12859129ejc.678.1650368090686; Tue, 19 Apr 2022 04:34:50 -0700 (PDT) Received: from localhost.localdomain (xdsl-188-155-176-92.adslplus.ch. [188.155.176.92]) by smtp.gmail.com with ESMTPSA id ce21-20020a170906b25500b006e89869cbf9sm5608802ejb.105.2022.04.19.04.34.49 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 19 Apr 2022 04:34:50 -0700 (PDT) From: Krzysztof Kozlowski To: Greg Kroah-Hartman , "Rafael J. Wysocki" Subject: [PATCH v7 02/12] amba: Use driver_set_override() instead of open-coding Date: Tue, 19 Apr 2022 13:34:25 +0200 Message-Id: <20220419113435.246203-3-krzysztof.kozlowski@linaro.org> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20220419113435.246203-1-krzysztof.kozlowski@linaro.org> References: <20220419113435.246203-1-krzysztof.kozlowski@linaro.org> MIME-Version: 1.0 X-Mailman-Approved-At: Tue, 19 Apr 2022 13:52:23 +0200 Cc: linux-hyperv@vger.kernel.org, Stuart Yoder , linux-pci@vger.kernel.org, linux-remoteproc@vger.kernel.org, alsa-devel@alsa-project.org, Peter Oberparleiter , Vineeth Vijayan , Alexander Gordeev , "K. Y. Srinivasan" , linux-clk@vger.kernel.org, linux-s390@vger.kernel.org, Wei Liu , Stephen Hemminger , Dexuan Cui , Andy Shevchenko , Andy Gross , NXP Linux Team , Christian Borntraeger , virtualization@lists.linux-foundation.org, Heiko Carstens , Vasily Gorbik , linux-arm-msm@vger.kernel.org, Haiyang Zhang , Rasmus Villemoes , Bjorn Helgaas , Bjorn Andersson , linux-arm-kernel@lists.infradead.org, Mathieu Poirier , linux-kernel@vger.kernel.org, linux-spi@vger.kernel.org, Krzysztof Kozlowski , Sven Schnelle , Linus Torvalds X-BeenThere: alsa-devel@alsa-project.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: "Alsa-devel mailing list for ALSA developers - http://www.alsa-project.org" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: alsa-devel-bounces@alsa-project.org Sender: "Alsa-devel" 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 {