Received: by 2002:a05:6a10:2726:0:0:0:0 with SMTP id ib38csp3493089pxb; Mon, 4 Apr 2022 18:44:56 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyBYjufW+LEzf0LRTxbolN0gmPwOjuEFjv6/MC0aT5DGLrK+8DxkJIpYBYe4LAVFPXQyM8J X-Received: by 2002:a63:2a04:0:b0:398:5225:8982 with SMTP id q4-20020a632a04000000b0039852258982mr872724pgq.394.1649123096112; Mon, 04 Apr 2022 18:44:56 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1649123096; cv=none; d=google.com; s=arc-20160816; b=V/+CnazM2E7ZJ6glY5fFCUlCtYkhZ8d3wvBXg64+MAuVebBhhQDdfzCp5fjbSjubsK Z8AePvcqkYDogpk8ibwLYQoEda5DUqGhSWX8loJCi8HgCID4s95DuPm7B9DR7DIOW+Jl npAIP2iKr6/mcbwikNHkvlrrSpiylk7PpPKJ7GW45Jq+y9han/gElOU015mI/Sa7OtRF UXESQ0/lsQXjDMRU37UMdY6ANX4KUUElMARvBaM0UpxqjvB5LZkNW5DBqr2YuTi6bWKC GzE9yo7CX1HEWzYWUS3DdPTABb7W5s+8N7pUPgAqdymXLdzMOtXyRTNJPU97LNUS9KBI OSZA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=rk4GrfXMwJbLvQiVana1UoJ1THyewcmBCMxkYGfguzc=; b=FUxkOzxbBZvOGHXqumNr25aXbKd3QH08UhNMpUZTl7ewpPr64IG9+WD59uoAcsRBSD V2dcIU1HdtB4x6OIAdq6vI7B+2uSM97iTmwY+t6xfyVIN8rXG5PcyiLytkKUJ+DuV2xe XMjGRvcyTWcPMUfG4QlS/J97nrrNCAD7m6SLnb7mgAcZoiO2QqxvlAA6ZZ5FEPlfQjug WvhmX7TgXKEReVskfw7s4EAcdiULFwqivNb3Bc90FaMhjX8hMLxdgLr1XSmEUXRazOVy kDmT6TKeG2EX2w1gSRVuSRK/VECUVMu1FwSlf+mrp9f9d1Stw1Qil4SC7CgW6b05PzYP d6Bw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=FOy7wrkM; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [2620:137:e000::1:18]) by mx.google.com with ESMTPS id x19-20020a633113000000b00398b6ba5236si12120594pgx.390.2022.04.04.18.44.55 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 04 Apr 2022 18:44:56 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) client-ip=2620:137:e000::1:18; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=FOy7wrkM; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id EEB992B1216; Mon, 4 Apr 2022 17:44:18 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1359832AbiDCSkS (ORCPT + 99 others); Sun, 3 Apr 2022 14:40:18 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45988 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1359779AbiDCSkM (ORCPT ); Sun, 3 Apr 2022 14:40:12 -0400 Received: from mail-wr1-x42b.google.com (mail-wr1-x42b.google.com [IPv6:2a00:1450:4864:20::42b]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 804F73968A for ; Sun, 3 Apr 2022 11:38:17 -0700 (PDT) Received: by mail-wr1-x42b.google.com with SMTP id b19so11375855wrh.11 for ; Sun, 03 Apr 2022 11:38:17 -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=FOy7wrkM6AFpKv1C1v3+v3vZInYqslvcX3X0qZ/d/qZkS0mnBH6ZuhAq4vb5nUH4Lv 5GMSTbQIQBcHsKdzQ4Lz71HkgeMyLLdWshbDnvvD5MBPPHvHWfgyLePsOj/WzE7X8qUD 0QcqruGEsJf3YHcbPiAc4sYoXUq9axTkirycJkbMbF1q6OwJMcYiz2VNbMfu7jI1cbI6 Q3TDvNKFVb3cOcOcujS+qKS+g/jn9/EESoIMIPyvIrI+5x3JJX7iOH5ErFJiIJHibCMW W1PVtY3ChFmH8A0a5epqg2flWs6AL7ROdi/w/syxuCNWDdJOcY/pI7LFGzCvK4+UrPDL yIsA== 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=2lCf5TWZJMefua8Ss6ZOaEHr4F+9ZpWXjxHIR3+ylr8c0dMSxI1ReOhQrVxISyLWzd YFTVo10yCS250NkUw42xwNRvWonWeNg6tvr37Tg8GnIpEOPdkZBr6vTYZ2Na6W/Mw+qr ykZxryUIxqyCsIL5W4Bd1G5J7RKPzH7lHLpRJEDCvpNmPgxtAl4SAyxN4jzros/H+X8n 5xcNRb2d1hyQZt/jW4tZZuTeTHqx8P/dnzdMSDCFqy+Gg4oM65a/Z9q8hp/iyQjBeSyM YIo6ThKmo4av9O+qXgf27wQZeWAV+QshaG81/9u2NYRjqlTzw10hLjgxHHjL8ad+fuBf haAg== X-Gm-Message-State: AOAM530QuZ54tnElXHgT7QJJexFvEFxx+b3C1dwlDaSCV9o21hxDndAo /zlFAvAXjKdfV13UDNutZ6iygQ== X-Received: by 2002:a5d:6208:0:b0:203:dde4:c76e with SMTP id y8-20020a5d6208000000b00203dde4c76emr14428098wru.273.1649011096017; Sun, 03 Apr 2022 11:38:16 -0700 (PDT) Received: from localhost.localdomain (xdsl-188-155-201-27.adslplus.ch. [188.155.201.27]) by smtp.gmail.com with ESMTPSA id l28-20020a05600c1d1c00b0038e72a95ec4sm593851wms.13.2022.04.03.11.38.14 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 03 Apr 2022 11:38:15 -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 v6 02/12] amba: Use driver_set_override() instead of open-coding Date: Sun, 3 Apr 2022 20:37:48 +0200 Message-Id: <20220403183758.192236-3-krzysztof.kozlowski@linaro.org> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20220403183758.192236-1-krzysztof.kozlowski@linaro.org> References: <20220403183758.192236-1-krzysztof.kozlowski@linaro.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-2.0 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,RDNS_NONE,SPF_HELO_NONE,T_SCC_BODY_TEXT_LINE autolearn=no 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 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 { -- 2.32.0