From patchwork Wed Feb 23 19:13:02 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Krzysztof Kozlowski X-Patchwork-Id: 12757399 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id EC7A2C4167B for ; Wed, 23 Feb 2022 19:14:28 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S244241AbiBWTOz (ORCPT ); Wed, 23 Feb 2022 14:14:55 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56352 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S244240AbiBWTOx (ORCPT ); Wed, 23 Feb 2022 14:14:53 -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 738C140E6A for ; Wed, 23 Feb 2022 11:14:25 -0800 (PST) Received: from mail-ej1-f70.google.com (mail-ej1-f70.google.com [209.85.218.70]) (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 417343FC9F for ; Wed, 23 Feb 2022 19:14:20 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=canonical.com; s=20210705; t=1645643660; bh=fyZde4QL+5WSjtUcZmZyQ9LOCmYULjkOm0dq/nBIuzo=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=qBQokoKPizZLZ2UnvkN5VQded3OZUDYY/lI3AaUtyPCslWX9C8iYDV79FjJVKWgsR S6DYndF+9pGS3EYK+tASbPwfg0i6rPObQ0OGnIUxWoqIphXizAE5TDRt00hwmM8NLH VHo0WpxTX0P3aIHQQUhLqDYj7BPdKiQ9zHYhymZR3lq9HC9HmnQsezrvHNBImknJ2x zobPILGpeX5aE/Up+rM51f2ebl7NLC9uUuxOgHVyJdCoY6/ByyuFzqKg27kicoh7WY FLg5r2wwE/jCCkn8vhSzl42QHXKp9fTuQOhm7eE850mUKEAdODehcNpKh7HgpxCoNf QH/ky5jmbWxZQ== Received: by mail-ej1-f70.google.com with SMTP id m4-20020a170906160400b006be3f85906eso7480070ejd.23 for ; Wed, 23 Feb 2022 11:14:20 -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=fyZde4QL+5WSjtUcZmZyQ9LOCmYULjkOm0dq/nBIuzo=; b=fbmimx3IScidxyZVrer+dxypoKpFcJGkWSYK1QuEmVivxgyLW4V4gHZkPBQ7rMdw2T 5qhX9tRSowh1ZjZrHibFrPbvxjjOjyvXtL96loYwINmI1QjoL5CcKwXNO/zi8wB6ljzs 0DvEZ5tDRncV2qoFHHyClPmLBClevMNRQKaoA3HaZpar4worTgDGrs8gyS9kbGBuHKSU H4fYVuUDxLBatMaVXKTNWh9yL/r05GNqkn2hFefZWfr2rELVsG96ueKxjbxOxN07pCL8 t5lBnKvrramgEqsEpjxfxl54qQIwiAo7QjBtdHFUt7N/4lIp4E6fg9pUKuJGSvRuBjHP SQZA== X-Gm-Message-State: AOAM531vYKsoj5fG+h6L0b94irYxmaOvTVAp+KQHo00/yhsv2FB6Oj6P iXrGwLgzlexOFnoy+cqcygzvUVbkldDszoW9IG1BAoYXgZ2VJRo54sCuKpGkVSNRf7RW8NdusMu gjGRphp4iONu2MwRW+9Mjq7DOAI+gSM2TxaDc9A== X-Received: by 2002:a17:906:a384:b0:6ce:c3f4:c59a with SMTP id k4-20020a170906a38400b006cec3f4c59amr870074ejz.580.1645643635869; Wed, 23 Feb 2022 11:13:55 -0800 (PST) X-Google-Smtp-Source: ABdhPJwQC18HONgcYdOr4fLdW/4QMQU7ra3n8dm0IepMHQhTlzr1OkJDjXXGMuSAKvUFTDXd0c3row== X-Received: by 2002:a17:906:a384:b0:6ce:c3f4:c59a with SMTP id k4-20020a170906a38400b006cec3f4c59amr870048ejz.580.1645643635630; Wed, 23 Feb 2022 11:13:55 -0800 (PST) Received: from localhost.localdomain (xdsl-188-155-181-108.adslplus.ch. [188.155.181.108]) by smtp.gmail.com with ESMTPSA id q5sm212611ejc.115.2022.02.23.11.13.53 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 23 Feb 2022 11:13:54 -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 v2 03/11] fsl-mc: use helper for safer setting of driver_override Date: Wed, 23 Feb 2022 20:13:02 +0100 Message-Id: <20220223191310.347669-4-krzysztof.kozlowski@canonical.com> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20220223191310.347669-1-krzysztof.kozlowski@canonical.com> References: <20220223191310.347669-1-krzysztof.kozlowski@canonical.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-clk@vger.kernel.org Use a helper for seting driver_override to reduce amount of duplicated code. Signed-off-by: Krzysztof Kozlowski --- drivers/bus/fsl-mc/fsl-mc-bus.c | 22 ++++------------------ 1 file changed, 4 insertions(+), 18 deletions(-) diff --git a/drivers/bus/fsl-mc/fsl-mc-bus.c b/drivers/bus/fsl-mc/fsl-mc-bus.c index 8fd4a356a86e..d93f4f680f82 100644 --- a/drivers/bus/fsl-mc/fsl-mc-bus.c +++ b/drivers/bus/fsl-mc/fsl-mc-bus.c @@ -166,8 +166,7 @@ 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; @@ -175,22 +174,9 @@ static ssize_t driver_override_store(struct device *dev, 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); + if (ret) + return ret; return count; }