Received: by 2002:a05:6a10:9afc:0:0:0:0 with SMTP id t28csp1963674pxm; Sun, 27 Feb 2022 07:38:11 -0800 (PST) X-Google-Smtp-Source: ABdhPJwGDks4huA8Dnql2NmFnDlGV2KCgZzCsAOkmn0OgkoN9t8XsenBiJUM2uzDga6BzRz3grrq X-Received: by 2002:a63:f057:0:b0:370:23c6:dda with SMTP id s23-20020a63f057000000b0037023c60ddamr14013899pgj.504.1645976290770; Sun, 27 Feb 2022 07:38:10 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1645976290; cv=none; d=google.com; s=arc-20160816; b=LEc3iBB2E51SekHt+deG/EM5Ha76KtF0V+aJB8LTTwM8GBVG/1HkUYilVebnDKOUiI cFYLsxHoSHdyNErsezvoaGnExT7BIrssLSnlzLUx019Ep2/mG3NOb9an+FAYxAMrQ++M UqtBtAam8hbpwFAznKC0nG9UFqh5ZCXRkJ6AJiB+aGsC419JBNH+ehrviLhI2MQLdHrs BaxhB0+TbIBw02nv/7GFNmHicCvgkE3WEXFtqsI4Rc9IUmSVhOTCnvcA3X+qbocu56gj e5EHy+PUNDxpcHXDE7tL4YPDWEkSq2dWzNNIxcZn+L7gkIP3Z8s1Cti5lQXiFY5XPmeJ bAlg== 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=lHEHPtP6JAM6zCrRNeDTlRy/WZxSvWGZvNHgREr2xAI=; b=QU6fmBlsLknZxe1GZaDVhTXYzo9SwJzzOrL4cG7FtCMXrpzzM2//kz36Bym7u2uuc2 9pLjMVjTN+7eDbaZIbRRBziuXK47SZZeTYG+CS8NC2uGnqeCa7NlfyGQKRqcB9ZFL9z3 xvRdA+CLm5iPXrLBE5F51RcdYaWBBaZFCMF8w3lTZFnMcN6BnlpQ8AoU1nfIhu+HWxbm 5tqax9ce4Bk7iuvv4i/9HpjoAvTdR6etFueLGkD8Da8zHp7mDXzuPammsLC7hS8Hji00 wcsDAjqJVa/WJYzMPTzSsQ2DqIhP7dVJX4AGvrItq2/aMPcYKETJ8ZCw9tdx+rCVlw2r H8fw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@canonical.com header.s=20210705 header.b="l/moVZ6A"; 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 a24-20020a056a001d1800b004e1da0265c0si6389949pfx.265.2022.02.27.07.37.53; Sun, 27 Feb 2022 07:38:10 -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="l/moVZ6A"; 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 S231332AbiB0Nxn (ORCPT + 99 others); Sun, 27 Feb 2022 08:53:43 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39262 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231282AbiB0Nxf (ORCPT ); Sun, 27 Feb 2022 08:53:35 -0500 Received: from smtp-relay-internal-1.canonical.com (smtp-relay-internal-1.canonical.com [185.125.188.123]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2C51813E3F for ; Sun, 27 Feb 2022 05:52:51 -0800 (PST) Received: from mail-lf1-f71.google.com (mail-lf1-f71.google.com [209.85.167.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-1.canonical.com (Postfix) with ESMTPS id C30814030D for ; Sun, 27 Feb 2022 13:52:46 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=canonical.com; s=20210705; t=1645969966; bh=lHEHPtP6JAM6zCrRNeDTlRy/WZxSvWGZvNHgREr2xAI=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=l/moVZ6Adk/hdbzboYehbKdUP0zfndgA9NPqvxV/yHMq7mpX6z4ipsrPvZbSC1j0E 60A1vcN0DzpAWynhwkHTY4bq8JrVU8YDs61x4r3gnroAnMScQr1aVV5XMbmV49dr2t iy8KDHfQExdy3p0m52/AfRekPOON6CXLos2b0KDCVYu51NcZvA+nzIn1vFiHwSlckb LErOt80htc/Hlm1UWfWWsjlR7epau66bh0KmqIYyXQEZA3I4xd0U/mKcTyJbvubtnY ZygbbzvclpidKXzlKTpT3l2I7FKofmZAv0EWD/UsepHTVS1OMorLWSe2DlPg3aAyOS MKx3bsFdmIvnA== Received: by mail-lf1-f71.google.com with SMTP id o25-20020a05651205d900b0043e6c10892bso1394964lfo.14 for ; Sun, 27 Feb 2022 05:52:46 -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=lHEHPtP6JAM6zCrRNeDTlRy/WZxSvWGZvNHgREr2xAI=; b=ZW60U4B7fnewur0pOsLrWToTr3Nl++1lpy0QEnP/dUatsU67mm/elC0vAVRpX1917B 0J3b8DGDrmRG9Ey8fichvxXSdXQk0rHAwyxLRjWAeuO/bEfy+/Sa2DN1uIpgEwHNjjb/ cyEMpYRoKxWBOQVX65Xs6fnBGfJHp+07E4xCw6xxbBP91XsDV2XGyRHud6NMQKJRk3Wn uAFw5tTzxlNIIs4qJo7Dva018nPURkxu6UYoFweILJpYrILXn+qEsO00QcIbIZOtq4YP rGLIwKx61LQAXpAPlhQzIoGUIFfNUbETpOBse9HZXXxvCSkd7BtCg+sUtARenPmhK/kR QEVQ== X-Gm-Message-State: AOAM531BQksXh4qHihmYVwfkGOGosKZsqbCxoZrpcFl4nWrNbJ3tQF3E Dxo3/IDynsunogHIMqFVo3OuAWTlG8vVJiYlHqMmm0kBrOb4AeTfRZKE9Ko2C+TJFCOoeF1sIL3 VsX1RUUYqC6DsiWMieOc7cJagk7tIHuq+JlKZkOe5Yg== X-Received: by 2002:a17:906:d10c:b0:6cd:4aa2:cd62 with SMTP id b12-20020a170906d10c00b006cd4aa2cd62mr12751212ejz.229.1645969956012; Sun, 27 Feb 2022 05:52:36 -0800 (PST) X-Received: by 2002:a17:906:d10c:b0:6cd:4aa2:cd62 with SMTP id b12-20020a170906d10c00b006cd4aa2cd62mr12751178ejz.229.1645969955744; Sun, 27 Feb 2022 05:52:35 -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.34 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 27 Feb 2022 05:52:35 -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 03/11] fsl-mc: Use driver_set_override() instead of open-coding Date: Sun, 27 Feb 2022 14:52:06 +0100 Message-Id: <20220227135214.145599-4-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/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) \ -- 2.32.0