From patchwork Wed Mar 16 15:05: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: 12782773 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 6B8F1C433F5 for ; Wed, 16 Mar 2022 15:08:59 +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=LstuRjR69DFcrPIJmdWh0CaU3es9VmLGJ8F6kTrJQnI=; b=2FHnTvF2c4+Bkh l2JmvfzuZtFwjzZGnU6QSv7cQfOVl4Tc1lM56wbBTyz2Pptk4+lM8x4Qwz3JkRY8RsUeoibD5VSqC H2Zzjs/a64JoPBY3s5kv0zOoT3gm34VqOHH3jAo635kRQcREcMQLDA+Sws5b4MOF/1amf7zuDjj18 nJ5OUB2a3Fc9SttOFl+Edy2kNZQid2z3JLki28qaznis2gFHVaSi5vwcAOmm0MYkzutwWE2uDR1hL kd8bqIWgbfnLNZD10oqpUsqGGAzIdy4+uO5uA4fPX1BiFQ6KuTH9XekCCjcRfZ0uxF3+xWVmrHBjj wDrRYqnx7qoQw8jeNPGA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1nUVFP-00DPSD-D4; Wed, 16 Mar 2022 15:07:35 +0000 Received: from smtp-relay-internal-1.canonical.com ([185.125.188.123]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1nUVEe-00DP9E-02 for linux-arm-kernel@lists.infradead.org; Wed, 16 Mar 2022 15:06:50 +0000 Received: from mail-lj1-f198.google.com (mail-lj1-f198.google.com [209.85.208.198]) (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 2B0BA3FFD9 for ; Wed, 16 Mar 2022 15:06:46 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=canonical.com; s=20210705; t=1647443206; bh=BsP1eItj+J1d4aDzpqEMBIF5j1znYVUHQj+VHIPIFgg=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=JIa8/hazMwGOABZ85wT4M5sDJs3EzPKKXBj5Q7yOXlAYEUcGT9kwsVm2qpSoeMdt/ gBSU5gMyUCAhGWnJ7ehO6V3/DtAYaNNu7uH40h1m4oisjepzxNW5Zx6HrwIMbbDk18 OesbyJaCadgweVPhGKHxDBHBoZVdFHfwMziMIJTo8IL65zeCbU025GLwZ6BP4Yzs/r oVOc4FkvB7W8YtUVaiIMnOGNeYsBh0Zf9CNj1tTJOVppmBHGsKjf22SuF4g4cqJ2vh p6Ngc1IzxgC4fkesL+e4GhhXV5umsUsLDeuH/zSCPLL2cLd8f/M5tTZ0WGl6CvAA8I rdddI+jKDrwmw== Received: by mail-lj1-f198.google.com with SMTP id v9-20020a2e9909000000b00247ecf60956so1022525lji.12 for ; Wed, 16 Mar 2022 08:06:46 -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=BsP1eItj+J1d4aDzpqEMBIF5j1znYVUHQj+VHIPIFgg=; b=QQYy2CilJwvucou3ua3GhZFfqkBrJf0AhpTEjq/ks6REOGoV7VC+BqI5Eb3hBbqPYb bOoFfPBTf2GExCjhgrIUWzXWpSEB+DaRbDbl0vVP+YMWfLm8nblSs2+NMBfeyuL4p7mI duRiY6RZH9leRtY5qH18ovF7lpzyb4bwqJzMjgCtxU1ASXjMBilAf6UY31ORrllpSqbW ZojZJqdgNJwdcCOGnJgijaa7VzLb9ujhumNsyeadnV14tTn6C9Vb810Pv0uCHEdv9PIs ar5/fF/bkhYdWPY8HH3Aw0r+M2bUYGJ8RDuMQHSSW7to+M1Mx+tniTyPiJdfDVtmdaWZ lHqQ== X-Gm-Message-State: AOAM5332tm7IsM5vcM0Z+iu6vP2Qk9o3rbT3rNt2zniSSdzEL4NJkuMZ AKV6FBqJwr0EojTBD4x2e/LQOsEXMVzPs7XZ0E/2O5tOB6d+Im6vYWVbDuQqvFuLypo1RJvJIls SkJHGgpa38oolqzodmBx8uDOsAPCx2EdYBp7HXfP3skZknf0X/NFj X-Received: by 2002:adf:f68d:0:b0:203:7b96:a7ff with SMTP id v13-20020adff68d000000b002037b96a7ffmr326846wrp.101.1647443193785; Wed, 16 Mar 2022 08:06:33 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxoarwZUHPsM12itXV7mRUexTXGgAuLA6KWe3K/HjtbGdnXbQ8PTTCIoN4L2QaZn0F+apvl9w== X-Received: by 2002:adf:f68d:0:b0:203:7b96:a7ff with SMTP id v13-20020adff68d000000b002037b96a7ffmr326805wrp.101.1647443193616; Wed, 16 Mar 2022 08:06:33 -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.30 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 16 Mar 2022 08:06:32 -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 03/11] fsl-mc: Use driver_set_override() instead of open-coding Date: Wed, 16 Mar 2022 16:05:25 +0100 Message-Id: <20220316150533.421349-4-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_080648_198923_3CA68EFC X-CRM114-Status: GOOD ( 17.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/bus/fsl-mc/fsl-mc-bus.c | 25 ++++--------------------- include/linux/fsl/mc.h | 6 ++++-- 2 files changed, 8 insertions(+), 23 deletions(-) diff --git a/drivers/bus/fsl-mc/fsl-mc-bus.c b/drivers/bus/fsl-mc/fsl-mc-bus.c index 8fd4a356a86e..ba01c7f4de92 100644 --- a/drivers/bus/fsl-mc/fsl-mc-bus.c +++ b/drivers/bus/fsl-mc/fsl-mc-bus.c @@ -166,31 +166,14 @@ static ssize_t driver_override_store(struct device *dev, const char *buf, size_t count) { struct fsl_mc_device *mc_dev = to_fsl_mc_device(dev); - char *driver_override, *old = mc_dev->driver_override; - char *cp; + int ret; if (WARN_ON(dev->bus != &fsl_mc_bus_type)) return -EINVAL; - 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'; - - if (strlen(driver_override)) { - mc_dev->driver_override = driver_override; - } else { - kfree(driver_override); - mc_dev->driver_override = NULL; - } - - kfree(old); + ret = driver_set_override(dev, &mc_dev->driver_override, buf, count); + if (ret) + return ret; return count; } diff --git a/include/linux/fsl/mc.h b/include/linux/fsl/mc.h index 7b6c42bfb660..7a87ab9eba99 100644 --- a/include/linux/fsl/mc.h +++ b/include/linux/fsl/mc.h @@ -170,7 +170,9 @@ struct fsl_mc_obj_desc { * @regions: pointer to array of MMIO region entries * @irqs: pointer to array of pointers to interrupts allocated to this device * @resource: generic resource associated with this MC object device, if any. - * @driver_override: driver name to force a match + * @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. * * Generic device object for MC object devices that are "attached" to a * MC bus. @@ -204,7 +206,7 @@ struct fsl_mc_device { struct fsl_mc_device_irq **irqs; struct fsl_mc_resource *resource; struct device_link *consumer_link; - char *driver_override; + const char *driver_override; }; #define to_fsl_mc_device(_dev) \