Received: by 2002:a05:6a10:2726:0:0:0:0 with SMTP id ib38csp3527268pxb; Mon, 4 Apr 2022 20:00:25 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwVCjGCBDz5y1u71+tJDnQzIgT9ZVgH2xpMUtZf8v9aGK7qZmv0N1x69C4/IyWdTc4FB299 X-Received: by 2002:a17:90b:1281:b0:1ca:b7e8:1084 with SMTP id fw1-20020a17090b128100b001cab7e81084mr1554315pjb.196.1649127625623; Mon, 04 Apr 2022 20:00:25 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1649127625; cv=none; d=google.com; s=arc-20160816; b=Acw2OPJyDFR2pCAJgMlG8xvgRQIIWCzQ+/Dh9TCNErdhjBldkj2qBSq3UmHQNsS6qZ nqEonW+7AoXGQ3gom1c0jrduEspkKcjbZNLmpNRwCgTH+lAKq+fPzngrMwzB1mucXMqx V+LN8GJM8V0dUJ6io2TM97ItsQy25yG5akrjOlyhWMp6hdSWcNC0Mp9GGm5GRcoi3cgB vbtayIOQbYPVRD6Abkh4wLdMz/t/mtA+0GiIQVM+2S6H81cXB9I9Ld6Mc8e2N4DRmV+v y9Ar/ob2guTvOb64uyTK+XmP7K2bw1zT3oY7nuQon4G2kloVqpQGR1iShLXmcN5fqjRI nKxw== 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=38ZdSROX5+RqupZAHBAG40n0Dr6hAO3z18g5N59SQU4=; b=syNipIJbXgcUZ9iidSoo9pELrOIKIVHMoxUFJx8kDtWVPjDlzgvJOFI1qSGZnCS+Sl +lBH0n9D46SObf5EllsZdGUhbFeVdFzVvTGJbh28XGyDYyIHcTythenEFgq+QmvJGWKk moxLzhrucA/B3sHAOGw+YQhOUy/DwlMfy4D0ZuGA2iePuFtJOW8NpPsp/sV1CUxKJO/W abtkvW0B3WFr6ChJ/xEYy5qQV1ofFNFhp7mlyAqn8ynxxLlk5FYUKhkEQ8hKiIOkBclS c1iERVYLGbG6ns5k8IhRs2tGN+z/j1z7DqU1RyrZmiHFOStbbMLrxe8pW3EME8hRQCj4 fNWQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="ei5TWh/R"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [2620:137:e000::1:18]) by mx.google.com with ESMTPS id j14-20020a170903024e00b00153b2d16507si12999946plh.271.2022.04.04.20.00.25 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 04 Apr 2022 20:00:25 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) client-ip=2620:137:e000::1:18; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="ei5TWh/R"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id E48852EBA71; Mon, 4 Apr 2022 18:24:44 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234779AbiDCSkn (ORCPT + 99 others); Sun, 3 Apr 2022 14:40:43 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46754 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1359849AbiDCSk1 (ORCPT ); Sun, 3 Apr 2022 14:40:27 -0400 Received: from mail-wr1-x42f.google.com (mail-wr1-x42f.google.com [IPv6:2a00:1450:4864:20::42f]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9FD9136313 for ; Sun, 3 Apr 2022 11:38:25 -0700 (PDT) Received: by mail-wr1-x42f.google.com with SMTP id d3so597037wrb.7 for ; Sun, 03 Apr 2022 11:38:25 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=38ZdSROX5+RqupZAHBAG40n0Dr6hAO3z18g5N59SQU4=; b=ei5TWh/RyCQlwp3y422jw5QGl7/k0WXUWEblAev+CNFeP2X9EgGX+8M7Z2XNdCZAi7 CbDCIj5EC3m3v+TpRB9RoVCI7jYOQoKBkGDSqAV1goSlans7oohCfu3xUfOoRSnxxSl0 kcPELnt6468fgPhQxCMCI7fSY15NKLkDTny24r9YgN+Cg9ssR11eT2LTynDMo3THlFhs EcfmWm7eKYXMnBaJjguVcr63Gnbs67lF+XA2drS+tPN7YRUYY8h2cG7Wy4H4amtI+1CW +f886YTVoclbfHwndOskF26DKchSgx6oq+exaYD/b4FyyFDVu6DcRTdqHe3WRCnOG1Y5 CskQ== 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=38ZdSROX5+RqupZAHBAG40n0Dr6hAO3z18g5N59SQU4=; b=PmJUikw2jyl4kXVUG/yOaDaY0BcZI/3etSkAgDLiqtEHPdVd3O15C5L1NZ8dVpRoiq eEtUa2NNOYbUxggbf/CnL+Z+Kgpexdce3PT59bBwoD9lXet5KwHOkZY3AYwPZQWRGO+T tuc1IpFVaZOAFBxFjsZJBNOjO9sAJ/u79UEE+0EaCYNRR58vxwRzrfDj7nRCbNDvVMgs V4NFcFJF/kA90iRsl5SaD926MbWMbXyH4mcrbXFN916k9y/lwmF0GTBQ09PVfNkWtFsB /CxcGbohHNQMwpaBK2JOQMb9QaqsXqBZ7td6IlhzEvK3oPZBPQuXBmUECazyATUTN22H 3afQ== X-Gm-Message-State: AOAM530dq60xImfNSVO3yiYavBOW2tpViKmdVvle4V99pOBw3a1ZPqGz 9E1e2mGNzwYXaRJpQ8XeEmddzw== X-Received: by 2002:a5d:59a1:0:b0:204:1777:fc08 with SMTP id p1-20020a5d59a1000000b002041777fc08mr14640454wrr.545.1649011104054; Sun, 03 Apr 2022 11:38:24 -0700 (PDT) Received: from localhost.localdomain (xdsl-188-155-201-27.adslplus.ch. [188.155.201.27]) by smtp.gmail.com with ESMTPSA id l28-20020a05600c1d1c00b0038e72a95ec4sm593851wms.13.2022.04.03.11.38.22 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 03 Apr 2022 11:38:23 -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 v6 06/12] s390/cio: Use driver_set_override() instead of open-coding Date: Sun, 3 Apr 2022 20:37:52 +0200 Message-Id: <20220403183758.192236-7-krzysztof.kozlowski@linaro.org> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20220403183758.192236-1-krzysztof.kozlowski@linaro.org> References: <20220403183758.192236-1-krzysztof.kozlowski@linaro.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-2.0 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,RDNS_NONE,SPF_HELO_NONE,T_SCC_BODY_TEXT_LINE autolearn=no 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 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; } -- 2.32.0