From patchwork Sun Feb 27 13:52:09 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Krzysztof Kozlowski X-Patchwork-Id: 12761771 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 9D635C433EF for ; Sun, 27 Feb 2022 13:56:36 +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=KAMXaRn8wJZmw6gXgglUkl6/uz8cDEmfMxqY01M3lMA=; b=n6hotMIBHFASRx MbIrw0ye0Usdu/Dgy+hp+sWuPjIQDnN/7rJr5KitS7m00wnkXByJ8nukQrGIM1rXEdq+yJh6wQ6AN anpTfBanJAma5g4sMAg2rFSf8p3eUDnkdptwydEwRAu9Ch53YL6FdDMRc8F1x1NfNIVyCBptSRkTi IzhjZzuCS7G4zZVsEgPJ6DYMPgs4FfWKqIDkll0l/EhNgfCWLFDPzCOHj0O2PgZSS6SpZBtpZZFal SD1Mj+yGaxQg5di2aZkKQqf7OTz5Zctc8QD1/Z3lZTCzYGgpl09xN0vJbSIQdzuIX3U3MC+yE51/Q Ig2aOYP2jchazgdebBVQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1nOK0z-009Ik2-A4; Sun, 27 Feb 2022 13:55:10 +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 1nOJyp-009HqR-At for linux-arm-kernel@lists.infradead.org; Sun, 27 Feb 2022 13:52:56 +0000 Received: from mail-wr1-f72.google.com (mail-wr1-f72.google.com [209.85.221.72]) (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 1B6BF3FCAC for ; Sun, 27 Feb 2022 13:52:54 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=canonical.com; s=20210705; t=1645969974; bh=kn+qF0tdCo1etTHWEFOqoxtrhJ+rC4czu2ZZy5+SihI=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=nyhmvtgoeBJVI19ApvjC5eRn4gTlMGnBHCtcWYx+mUVs2f2uHR2BKxXQLM5mcEjfQ M+RthwrocRrUZHBPpn8hstVh22m3pLMShqSy+T5erElGeS4KgbeQpnyuT+w2N8DUVx CWyLADY3k+0D5JztlksGPQpftFGmBJ3hM/Rkr8NcM01MhYFh0yZZcGvv9r5Gb3Pvfn 8M2/eDhrxZr1HJOkaX7ikHxTCPpC7O/5ixJMrZKrJLcHJKSV/Plef1rBfRg2KTa6i0 DuQk06xD4KsOP8f+Qb50jvuvEl7MRGOEQSWko+ICvAZQW2VEDTYk7hmPYGOuP60ucE X2XP6B1Q91DRA== Received: by mail-wr1-f72.google.com with SMTP id b7-20020a05600003c700b001efac398af7so79908wrg.22 for ; Sun, 27 Feb 2022 05:52:54 -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=kn+qF0tdCo1etTHWEFOqoxtrhJ+rC4czu2ZZy5+SihI=; b=s5Vgj0bwPMF7wSjABVjRq60FeLrMZjAJoRsP4AowdhZQrc1itK63kMM0TsCLQwKYdj oCNhzlHMEsGgsL3KJhC/cbrbgow+mOIRPWDfVMDinln39SRhFYE6f71knsQJNreLY0+u l/Eswb6wDQXIvwT7uSVLBdG87xYpUH5+pvUSBj3VPG7mrRVqA6kGDYwHDqbnbHojGD1H HIfcUbOgrIjimQqZJat95dLvKnFa2KrWK+Nv8sZ2tBP6G7EOPiKUsoKfzac/ZXN5tRNa M7LiPDMs0mdunuVf7hGzXGUzhExTpgsVKzVwZyaeri3EtIVDkaehOpUC/goBsiUc2oqo 5E2g== X-Gm-Message-State: AOAM533sH3B7tfJjCs9yyBFRcP5g+t1U1VDpdJrNpG8zFtf60uJc8Utz CJtJd9QvD9ighN3LR9mDDgSycd+9A9FMM7EB406us0TlR7jiYHVzEhP7SWCxck0jSYNHnH38xwb BZUBZc93xR0sawFfTU/1FWWoTNXQml6Epi/4ghUlGpZZYjrZyLc/b X-Received: by 2002:aa7:c4da:0:b0:410:bb1d:8232 with SMTP id p26-20020aa7c4da000000b00410bb1d8232mr15075935edr.333.1645969961200; Sun, 27 Feb 2022 05:52:41 -0800 (PST) X-Google-Smtp-Source: ABdhPJyhg/i5aHofZaz+ahzc6dFTcb8xbpOjhh0OtL6Jhkm85pFdhXbdMsjLVRzYgEWWn1QmpSdqKg== X-Received: by 2002:aa7:c4da:0:b0:410:bb1d:8232 with SMTP id p26-20020aa7c4da000000b00410bb1d8232mr15075900edr.333.1645969960978; Sun, 27 Feb 2022 05:52:40 -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.39 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 27 Feb 2022 05:52:40 -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 06/11] s390: cio: Use driver_set_override() instead of open-coding Date: Sun, 27 Feb 2022 14:52:09 +0100 Message-Id: <20220227135214.145599-7-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 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20220227_055255_557615_4C2E87DF X-CRM114-Status: GOOD ( 18.70 ) 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 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 Acked-by: Vineeth Vijayan --- drivers/s390/cio/cio.h | 7 ++++++- drivers/s390/cio/css.c | 28 ++++------------------------ 2 files changed, 10 insertions(+), 25 deletions(-) diff --git a/drivers/s390/cio/cio.h b/drivers/s390/cio/cio.h index 1cb9daf9c645..e110c10613e8 100644 --- a/drivers/s390/cio/cio.h +++ b/drivers/s390/cio/cio.h @@ -103,7 +103,12 @@ 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; }