From patchwork Sat Mar 12 13:28:51 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Krzysztof Kozlowski X-Patchwork-Id: 12778835 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 615B1C433EF for ; Sat, 12 Mar 2022 13:33:38 +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=ByqpYddNHAxZzzUamKHZ7/bwiJOL5t7v9r8NoW85kig=; b=jkxiSrMBR8BLy8 HOZKczaOUQZIOv4NVEUwRVtAGSMN9KddC7ehUnNP4+d3nq6oR3FozzeKWEprL9LVA2eUxXwtsFU+Q CUfJo3UzdtnIdZP25i0X5d5XOxl8Xk+8lumQI66BcH8POKMNeKvVHvGv7sJLgs84eXnksaw6NAAMf ZNgzjZMlUWde9/Mv/t6b/LeqBX5cEE+eaLqrFdx6ddmZtz0zWRTMnyGqGNYsGpQXk3DRR2Dgwwr0X RQeQvAg/hg+rsCKYDOeIihkoUTnAmG6fq/kKH3MKLpP94aVdVeGR+O5EI6gRFEFlTObVJ9st9OmID du99QyWhDMNVP8r8DVyA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1nT1qq-001Mnu-En; Sat, 12 Mar 2022 13:32:09 +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 1nT1oQ-001Lbm-Gq for linux-arm-kernel@lists.infradead.org; Sat, 12 Mar 2022 13:29:40 +0000 Received: from mail-ed1-f72.google.com (mail-ed1-f72.google.com [209.85.208.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 503333F60E for ; Sat, 12 Mar 2022 13:29:37 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=canonical.com; s=20210705; t=1647091777; bh=Z+Z1CBBLpVo7KqzVCsMaZv4r7Tw7oQzghpWsDjTy8tg=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=Z4naJ0pmkwXhPculRf9Jf1RwFVtC23chtSIpwyikYk1Ow8QbQ3nF9iT8db2XfILqT WM+1FnGSE1rEmA4tVnKdSSUzHx8ergEn8+NRHtgpes/Q8xCKFMXkyLckNZaVIM6JEQ CzCxibJOOxj6AlIJ0cxpQSsSewNMgfeApfeL0hfwi/BNihsdiFIWGqYGDfvPa/2MN+ NBNJOkHYmkxoHzi7xgHSnL2dtOrF+tEFIKzEcYNcHR3MhYO029wFGs8zfBxEgszJTT Dv2DeIeBqPe/TUTLEByg2bC+uqXJgE4y4vUw5pDhQiOXcUbZyaqRfwe1gn7CjUcJF3 uD9qoZHc/JRWw== Received: by mail-ed1-f72.google.com with SMTP id cm27-20020a0564020c9b00b004137effc24bso6152173edb.10 for ; Sat, 12 Mar 2022 05:29:37 -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=Z+Z1CBBLpVo7KqzVCsMaZv4r7Tw7oQzghpWsDjTy8tg=; b=B3wYeOLvTMIQkVBwj/15Qb6EDt3XEown+G0Ht+cxeM6IxHyBf3aupCowZy4SOQJ5jE WFRG0WYpuhO5pwF4sH6YEFCStW76hh8w7r2ALJx+YNK3elBnFGv1ly6JS/W11FK5anop L2DkgH+6jQ26FADGTLqAD5gKTLVufbTtgYrAaBuv5/wvNsSSXKOz2sQJ1fBpES3xb6Z0 J4TuyiKp0fU9q9JMenkDuQgAVtBbgQQ2KR48B1MPNbaw3m7pR8vg9caQkG8XK9oLXWNV qlbxt0bHOhm5JK766fEnooHtWYJhXyMChMu7xxI5R1J8AdimdwhL43RYe11bWWy6vJBE E0oA== X-Gm-Message-State: AOAM532FgyEfGBIyn1sCTU0E1Jv0xG31H6lOXEFJnj5U0/naTDo04/0c mO2GWnv+iOj8DhXMHtLV21BNvdTa94YUr59SJid+SCh8jF3DJX1sQWVu1y2kPnmtuWN0tXCmfUW mDPuuDvPc2MSfZA5+32UEeN8gY1m9HalME3tWVt1bwjMOpNHgqHIQ X-Received: by 2002:a05:6000:1a8e:b0:202:8714:d312 with SMTP id f14-20020a0560001a8e00b002028714d312mr10815850wry.683.1647091763744; Sat, 12 Mar 2022 05:29:23 -0800 (PST) X-Google-Smtp-Source: ABdhPJwjYZfFJ+GUQwy/f/MdbbiQp6L99Sn+ofXO+Q8l7XBFVGS1E/0dNsBqx+eOeH3/7jrINWLOsQ== X-Received: by 2002:a05:6000:1a8e:b0:202:8714:d312 with SMTP id f14-20020a0560001a8e00b002028714d312mr10815805wry.683.1647091763553; Sat, 12 Mar 2022 05:29:23 -0800 (PST) Received: from localhost.localdomain (xdsl-188-155-174-239.adslplus.ch. [188.155.174.239]) by smtp.gmail.com with ESMTPSA id p22-20020a1c5456000000b00389e7e62800sm5751550wmi.8.2022.03.12.05.29.22 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 12 Mar 2022 05:29:23 -0800 (PST) From: Krzysztof Kozlowski To: Greg Kroah-Hartman , "Rafael J. Wysocki" Cc: 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 , Rasmus Villemoes , Krzysztof Kozlowski Subject: [PATCH v4 06/11] s390/cio: Use driver_set_override() instead of open-coding Date: Sat, 12 Mar 2022 14:28:51 +0100 Message-Id: <20220312132856.65163-7-krzysztof.kozlowski@canonical.com> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20220312132856.65163-1-krzysztof.kozlowski@canonical.com> References: <20220312132856.65163-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-20220312_052938_768632_A7C5C0E4 X-CRM114-Status: GOOD ( 19.00 ) 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 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; }