Received: by 2002:a05:6a10:9afc:0:0:0:0 with SMTP id t28csp1930067pxm; Sun, 27 Feb 2022 06:51:26 -0800 (PST) X-Google-Smtp-Source: ABdhPJymGBeu2zS4ZE66Vs5UXe7JPOFGEtzb1aU5W+42aNHu2360Thcgq9ObxL4O7zf8jFlmWEpU X-Received: by 2002:aa7:c251:0:b0:404:769b:adb3 with SMTP id y17-20020aa7c251000000b00404769badb3mr15534514edo.98.1645973486619; Sun, 27 Feb 2022 06:51:26 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1645973486; cv=none; d=google.com; s=arc-20160816; b=IeEnFFzmhQxvqY+DI2TemMLI2zCpP7dLFVdm66P8Nr+agtV2S0MNeWLMEDlWiWR2oS tMkxZ7n9DRvAlRsScr9gnoXdye8GTbGG/NVBEB6MckpHwf1thPwU1DCSqJV6CTM+eWvL 9uHRXBJk5t61bu5gMeTOlnS5wJQxIC1pTCMZyO5A+Ip0e6lVWgUhsf216G93bGGECfxP 4XGB5ZlJX2MH6PjNc/bJxNxuQ0Ny/EFCpJkCQ/adsZl0K093TcOe9K35vQ0SAPfv56iM 9/pUTBbXiA9hcRlljxF3cSYbj7kNDJRGK8tmvRVPpx3bJfMsLZ6VOMX1Qu7Gg7TYg1Nt SCUw== 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=m4/zffFNkZQ1c8QkZX27EHIqdt+D+lrYYYcC+6RBnKM=; b=rr1Gy/G2+EO5f/g9LPuaxmGJoo9Wrp5Cy/HArlqipnUWc+hKyUv6GRRxyE/O56vCfW kp+XYghWj1A1H/7TJ26iqt5I6h9yequB9qgUYjRIxtWkHOPsyTU/Yu2NluPV7jbhnAae +PsJhOkvS2V1XhK8INYz33vA40VL01dGi25WypvHhuIG30CQk4JNn4eOiaa5UDlExZbk FcM0urQcN3StAAd6YJJmoZ13B/AOzZvBPADxdfBaESXpeqRPEwHBOR8YS/msUOOjV31M lhNi0wnBMghBnWzwLeoliGsd8KLvTaV2bRtW4igeJMW31XYSGuUkxRb+VeTT6wLcng2N igKQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@canonical.com header.s=20210705 header.b=oxTHKuiz; 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 o9-20020aa7d3c9000000b004108135d23dsi5054444edr.337.2022.02.27.06.50.52; Sun, 27 Feb 2022 06:51:26 -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=oxTHKuiz; 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 S231356AbiB0Nxi (ORCPT + 99 others); Sun, 27 Feb 2022 08:53:38 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38842 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231297AbiB0Nxa (ORCPT ); Sun, 27 Feb 2022 08:53:30 -0500 Received: from smtp-relay-internal-0.canonical.com (smtp-relay-internal-0.canonical.com [185.125.188.122]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2D83713F02 for ; Sun, 27 Feb 2022 05:52:52 -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-0.canonical.com (Postfix) with ESMTPS id CAE1240813 for ; Sun, 27 Feb 2022 13:52:34 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=canonical.com; s=20210705; t=1645969954; bh=m4/zffFNkZQ1c8QkZX27EHIqdt+D+lrYYYcC+6RBnKM=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=oxTHKuizKnfVrMj+ob15reDKgFyQGVThIe6lFkgledhCWWerBcS4wlg2oLYhIG1Le zh2NWcWeQPeEHdTe3A6dJW8Z4i/KAFzVHokYwn8TEfP3u0mPo3Ut9Wsys9GfpyJQrr btrqe0tHJcsACxOZ7tke6amglpbi1721YVRq1AIyCODdEXONE0pwMt9b3BU4sTZSQ7 8fZnwQJl2Xg7hEIAk/XcYJqu2Gis3Ry9YbH57FHnW1M7XrV0rS0FGc1zzyVBJzEJdn NszgSCTalQiNKV0ga0bq2lbV7AKgT8HCaxk3s0TPEGYEPHcxcPzjOltcld2zk8pLHq aXKqvrZIgh/9g== Received: by mail-ed1-f69.google.com with SMTP id y10-20020a056402358a00b00410deddea4cso4231268edc.16 for ; Sun, 27 Feb 2022 05:52:34 -0800 (PST) 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=m4/zffFNkZQ1c8QkZX27EHIqdt+D+lrYYYcC+6RBnKM=; b=7OMSg2+7aufGqIAp5eSgWskCjIkJ+Kph5SCEUuZRab9/iwite2ymoC1vfS2utTleOb Wm+MG9jOUqwSIIuo97Vx8RBpcpLCUIuwrxpOwhTWjfPo4Xp1N5hAXcmKNPgxClfqtqPx MjiEOCOuAsRpQYAwPgGv6ZW5vvkr0XCfZACox+dMilyq++7NGmnyo9ASF1HlN/yKJOm4 ZkF1+XqkC/mkh6VTdPHYis9vbCbeudcnDbPyVune57wQ3z0IZkknzv9xe1XijFdx4dAk ItSesYF7gNQZXgm5T7FMZ6vabgd86x5NIjmCwSy0AL3/SG6ISDICVMbbi+bJugpXfwFW B62A== X-Gm-Message-State: AOAM533MB+u9fL966sNPvXQJc8aEuArH0bHOfkuA5zmgsp9tbI46Di83 ouLSRMLJHMJmN3g6FYzOFkeNnhei7ydc1I5DzHFDthNow1a8NRnp7eJ93c8AgVqxMkkFIoaulpR GFXBVUbDjcLNx89Qt73OkbNTVOxa/NsTvqmRKjge1Qw== X-Received: by 2002:a17:906:4a09:b0:6d0:7f19:d738 with SMTP id w9-20020a1709064a0900b006d07f19d738mr12036149eju.76.1645969954374; Sun, 27 Feb 2022 05:52:34 -0800 (PST) X-Received: by 2002:a17:906:4a09:b0:6d0:7f19:d738 with SMTP id w9-20020a1709064a0900b006d07f19d738mr12036129eju.76.1645969954167; Sun, 27 Feb 2022 05:52:34 -0800 (PST) Received: from localhost.localdomain (xdsl-188-155-181-108.adslplus.ch. [188.155.181.108]) by smtp.gmail.com with ESMTPSA id r22-20020a17090638d600b006d584aaa9c9sm3393333ejd.133.2022.02.27.05.52.32 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 27 Feb 2022 05:52:33 -0800 (PST) From: Krzysztof Kozlowski To: 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 Cc: Rasmus Villemoes , Krzysztof Kozlowski Subject: [PATCH v3 02/11] amba: Use driver_set_override() instead of open-coding Date: Sun, 27 Feb 2022 14:52:05 +0100 Message-Id: <20220227135214.145599-3-krzysztof.kozlowski@canonical.com> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20220227135214.145599-1-krzysztof.kozlowski@canonical.com> References: <20220227135214.145599-1-krzysztof.kozlowski@canonical.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-4.8 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,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 Use a helper for seting driver_override to reduce 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 | 7 ++++++- 2 files changed, 10 insertions(+), 25 deletions(-) diff --git a/drivers/amba/bus.c b/drivers/amba/bus.c index e1a5eca3ae3c..9dffa17f50c0 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 6c7f47846971..7c703cb7a3cf 100644 --- a/include/linux/amba/bus.h +++ b/include/linux/amba/bus.h @@ -70,7 +70,12 @@ 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