Received: by 2002:a05:6a10:9afc:0:0:0:0 with SMTP id t28csp1998655pxm; Sun, 27 Feb 2022 08:30:10 -0800 (PST) X-Google-Smtp-Source: ABdhPJzMMGbIV+LdIQFzeQdYQxM1O5oujGXOB/OHuX/JmlEICsvtvWaLXM7T9zzHiDXqtDWO6eLK X-Received: by 2002:a17:90a:9ee:b0:1bd:267c:cc23 with SMTP id 101-20020a17090a09ee00b001bd267ccc23mr5712152pjo.2.1645979410360; Sun, 27 Feb 2022 08:30:10 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1645979410; cv=none; d=google.com; s=arc-20160816; b=Dhg8GswqRsJw8eW0wdwakkJoICpBqR/R8AufjP8puuEfVa6B0RbEimJE8pDPS4rgzS AeZ6ZLKezJvSqzzRkb+CfyiUK3RrgoKjnyuI7nGTMD06SG4WpthhJSdy1Ri19sxCVJtz BXYQy0JjgAn4MQxtXElIoi2dAWQVD3OUhwFpX0aFbaR5/mYSUDGd/43yzF0lelXkqtDf pdMmUogZsLF8bgHINHQ01JEaQRvow65h3BtMeaQCx/VqII9oOuZU/2qcVUOGLvfI3vJU zY6ND/Z1omVl81OsHq23NsM+CnX0jk/7l+3xY9v5KykF2keo84WCQJpEJjeXlErNBzKW iJmw== 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=kn+qF0tdCo1etTHWEFOqoxtrhJ+rC4czu2ZZy5+SihI=; b=SzhgvfyHwQY/Nkirfyr3iEeffrCCw5BfxBPkxMroToNGG+n06BhbRF0f1/hzmPmtzo JPRd/AYQOMdRKXG4WSPMuLSSg6P/2aIgLLIP8KJxReKV/b9OMZDvZwWMvr6Z2ucQ7Qn5 dmFV8PPv9u8y7ir7D+4W+HZIiV2v+DOiNsL59zd3DvZr4XQNWsr3SoI9olaT4jAVijWF ZlIzf1ZYU1sNq7o5dblR57YSw/Hh3eqAQfK3bSHx2xCyFanmLsdXyA9frC+LfAR94mDK A01heZGLuZ1F6LAbtwqL1FTDGdZMeBSdxbRZlE+yi45u0/jOT2qRdDOabobpWWjc4iHG Yd7Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@canonical.com header.s=20210705 header.b="g/n18Jae"; 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 k15-20020a633d0f000000b0037272282a88si8589042pga.713.2022.02.27.08.29.55; Sun, 27 Feb 2022 08:30: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="g/n18Jae"; 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 S231336AbiB0Nxv (ORCPT + 99 others); Sun, 27 Feb 2022 08:53:51 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38836 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231374AbiB0Nxj (ORCPT ); Sun, 27 Feb 2022 08:53:39 -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 3A9B313EBF for ; Sun, 27 Feb 2022 05:52:58 -0800 (PST) Received: from mail-wm1-f72.google.com (mail-wm1-f72.google.com [209.85.128.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-1.canonical.com (Postfix) with ESMTPS id A06DB3FCA4 for ; Sun, 27 Feb 2022 13:52:56 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=canonical.com; s=20210705; t=1645969976; bh=kn+qF0tdCo1etTHWEFOqoxtrhJ+rC4czu2ZZy5+SihI=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=g/n18JaeGinQORgtY4QcJ7kbbEjJy11fkB2WKTLa4LCYT5O9lgnD/mEK6pUfczZhX N3WJaQ3tCLgOMKGl+2rwA+LyWJh+3Aj4XoJ2v61bnSzhVSQQiuxmbCUGz149qH7moH 8PbB1Cz8jXgPDKXESb2szR3pC497Ojy6zHdNgMgXii6yM/wUJTuyAjFmvaO0sOMBwg BWcz6pLXfg8BgZ/Dgrumz91dlekNljjeEQ1TE1RT0CSWOgNPLUs0+xMC3w2sTnlYu3 d1mEESwt5CymrNuB2Q/knreChKGNY0B5uZmtodCVQlAVL4qcnNWwLtFxIPrbCZDrRy hVvZIKA88kfNA== Received: by mail-wm1-f72.google.com with SMTP id 187-20020a1c19c4000000b0037cc0d56524so4918167wmz.2 for ; Sun, 27 Feb 2022 05:52:56 -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=Iz3p8E4sfpKYntqF8drEZ5xkUQeDb4k6sXvygR5cndX6gbmsvCNtQuzw1raaFWylUF 82YW+Ji0gNtDde5Qfoxi7iPGSPZNrWD/Dq16lzesPRkDvefoavsJJm7HoFiGyYm3/AYI UfTFE59Lx+ezOPrZdZ6ViRt/7X20RXuTrsykMYXuTNikkaGp9TBUOw1d6V2FR9aSDPfy sbqoB/2yBHy7PsnGcfe3FNLfwDbfSkg2HkJbjCz5QEEFUFf2mcsaJU7NKq07fejm7Y6w pCS4elBJLQDizmCPkkyto5lRRk2sml2fgkMKLla8GbsSmWFGsSA+aLBfa0lbY2BL6Ith OMvA== X-Gm-Message-State: AOAM531DvCdHJvaz1KPaQZM0drZWOeOmM2UVtNr2Yz9Hsfr7x04sLn0J eGgBbKYwdofi7tUkAW1t/XBRkW59TGp4C1Ikv2Bfvn/MM++GJv/Nup2BbQpNFOVdfOeTfcmtv4X Da4UYjA3WUTLvjWQlb+2VKBHRlR1dd7xHBkU1RMnWDQ== X-Received: by 2002:aa7:c4da:0:b0:410:bb1d:8232 with SMTP id p26-20020aa7c4da000000b00410bb1d8232mr15075950edr.333.1645969961202; Sun, 27 Feb 2022 05:52:41 -0800 (PST) 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 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/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; } -- 2.32.0