From patchwork Wed Mar 16 15:05:28 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Krzysztof Kozlowski X-Patchwork-Id: 12782772 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 AAAF6C433F5 for ; Wed, 16 Mar 2022 15:08:56 +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=OBndw7EMlpyd0c7XqpEFnAF82ncArc7vgVYgs/qtt1s=; b=vwHJgxAYRqPvmJ uRH2wSVfSCVAIf0T3C5rV6r3R2kOHOr2avgBUcqri6EfsTrc5E4cpYEMbmQSHKW6r+CuQuf8KVV40 udzAdDZKTEFh71nI5JW7VVk3jJj0kts2hv72KkZtEsZ+EGXpsxZjB4FjjC1qP2fioWzL/THZz7Ru1 gEO6cjLrdg9uqvZyspJl6cJblpiyi6blXYmpjex9wextiOeFMYkaNqq75YgZZqVS7mG/JtD4AkUra MocoAhwt9MZ5SPex6UU5s46bsTslC17Bw5kLTyVUzW3JHrZxIOSet2vdhc/x63i49xkqWkcTnuaVE kZY/vR0IClW47YnbnuHQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1nUVFC-00DPO5-Oy; Wed, 16 Mar 2022 15:07:23 +0000 Received: from smtp-relay-internal-0.canonical.com ([185.125.188.122]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1nUVEd-00DP8n-Bi for linux-arm-kernel@lists.infradead.org; Wed, 16 Mar 2022 15:06:48 +0000 Received: from mail-wr1-f70.google.com (mail-wr1-f70.google.com [209.85.221.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-0.canonical.com (Postfix) with ESMTPS id 94F313F312 for ; Wed, 16 Mar 2022 15:06:44 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=canonical.com; s=20210705; t=1647443204; bh=QAEyo1xXNWnC/wTobDlvVW3kuxucr7Y+nryukeY/7zA=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=jG0pbWhNnsvCLavoQQbQgKLfJAHOfNO1INVivJWaFWfXo/d4EOmRwljZ3Wl5zK25R lLPH7nZdXg9bD3dmM4b4g7QCPaXghLdIg76+/rdsBgf4Rpju/YDOJP9ijhtkybSo5R ODUoe2S8QY0Da082HZZQpCVEU2Fxlx5FYHufMA0nnA7AQ47TO7x9bgxbs+xXtTtSwf swfgMo5OsazM/e6A8Bmh6JdaIkTYANf5ix15yS1/1xosMUJPS5q6NLLOriSWypARGW M7dwaHfMoEI1qgB+9YDdbHJgcavZHSAP2BzxhbH1vtAnjQBGIwDCXKEKrdGw6msTqr WjEDXdbkBz8ow== Received: by mail-wr1-f70.google.com with SMTP id d17-20020adfc3d1000000b00203e2ff73a6so448036wrg.8 for ; Wed, 16 Mar 2022 08:06:44 -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=QAEyo1xXNWnC/wTobDlvVW3kuxucr7Y+nryukeY/7zA=; b=i0o6zuC4nkcyWm0OALsNHCee+Wjqt0x8xmeYHc4v5GmRZAeESn5xrqEapqz06/RxuM p+SM/Ipm0mhhu1ToijiJkFY8yDfLR5S0Dzrb/efYD7MmztT5SAn0pSYRHAydfbItQjgD SvoiXWlrPk06cK8Suck+by9gYL9ojjim+01rSPdU3oEjEJ5s6ASz/sr1nFALFOkdd0uA bXRr5mhXjqHkitcL+zrpMdF7TTUHovWfnJeqw+LCfD/VpRJMvxM2J/e2CS+dV5WarRIb NFJaBqcQ60HYuEyS4KgjZvPFe+TvmKYjXiTbfSxGr+XppNU1F3XqO0muQbwoeFUloLPY Z+Rw== X-Gm-Message-State: AOAM531VjziLmKyCN7o0y/TFc1Y455PTGcV8ST4VnudHs/UwR77R+3sE UR3GD5geWm9KRZF3MjeiCaHR9L/AxcG8wg2o5q1kyBAdApSdQXt48KKJlTBaqI3Usq84CK1ULR4 JJrDhc/O7mFjZSBKUgDrmxWsPBvd8bWMUUpXESn2OEvhm7dV0jau8 X-Received: by 2002:a5d:55c5:0:b0:1f0:7672:637d with SMTP id i5-20020a5d55c5000000b001f07672637dmr349039wrw.170.1647443202242; Wed, 16 Mar 2022 08:06:42 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxweeXNXzqSiK6jLHKTzxTuSJXVd/nxHPvdpHWEAERfetg3Sykd8n3TukHieLMV78+GWu3x+Q== X-Received: by 2002:a5d:55c5:0:b0:1f0:7672:637d with SMTP id i5-20020a5d55c5000000b001f07672637dmr349028wrw.170.1647443202062; Wed, 16 Mar 2022 08:06:42 -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.39 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 16 Mar 2022 08:06:41 -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 06/11] s390/cio: Use driver_set_override() instead of open-coding Date: Wed, 16 Mar 2022 16:05:28 +0100 Message-Id: <20220316150533.421349-7-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_080647_558013_A20144BF X-CRM114-Status: GOOD ( 17.85 ) 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 the 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 Acked-by: Vineeth Vijayan --- drivers/s390/cio/cio.h | 6 +++++- drivers/s390/cio/css.c | 28 ++++------------------------ 2 files changed, 9 insertions(+), 25 deletions(-) diff --git a/drivers/s390/cio/cio.h b/drivers/s390/cio/cio.h index 1cb9daf9c645..fa8df50bb49e 100644 --- a/drivers/s390/cio/cio.h +++ b/drivers/s390/cio/cio.h @@ -103,7 +103,11 @@ struct subchannel { struct work_struct todo_work; struct schib_config config; u64 dma_mask; - char *driver_override; /* Driver name to force a match */ + /* + * 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; } __attribute__ ((aligned(8))); DECLARE_PER_CPU_ALIGNED(struct irb, cio_irb); diff --git a/drivers/s390/cio/css.c b/drivers/s390/cio/css.c index fa8293335077..913b6ddd040b 100644 --- a/drivers/s390/cio/css.c +++ b/drivers/s390/cio/css.c @@ -338,31 +338,11 @@ static ssize_t driver_override_store(struct device *dev, const char *buf, size_t count) { struct subchannel *sch = to_subchannel(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 = sch->driver_override; - if (strlen(driver_override)) { - sch->driver_override = driver_override; - } else { - kfree(driver_override); - sch->driver_override = NULL; - } - device_unlock(dev); + int ret; - kfree(old); + ret = driver_set_override(dev, &sch->driver_override, buf, count); + if (ret) + return ret; return count; }