Received: by 2002:ad5:4acb:0:0:0:0:0 with SMTP id n11csp4085726imw; Tue, 12 Jul 2022 01:10:31 -0700 (PDT) X-Google-Smtp-Source: AGRyM1tg8rgN2CwGOZPinRqbCNYxVQsuy7bRrqG0Tlb59wOpcG1Lli5kexW8nL2d0qrt0u9hj4Sw X-Received: by 2002:a05:6402:1bda:b0:43a:55d7:9f2f with SMTP id ch26-20020a0564021bda00b0043a55d79f2fmr29536658edb.360.1657613431291; Tue, 12 Jul 2022 01:10:31 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1657613431; cv=none; d=google.com; s=arc-20160816; b=k3mgCKHCMciEVWzN1qjrIKNRRZ2NbxrsVZlczmx8QN328+BtVYCkYqz07Z+AXCg4ya ebXT0pqnPVIfhKB3hoxMajLKKJIBSwBCVl+tFH8qzdierhcDMatJfW4prnAfeHaE7Joe w6xd/Utb48UO/HtGXpOJK6gH6kC0jijqaa1jeO2zQ0a9u0t3nQWd36zuIelKj8Y+V92C r4W9yusNET4ZL8RkIm+IfWy/jGCtGi2b8DFVb6eQTSKFimeWUKt+QozgO1VzBHmAaqqz nayAoWkyfehpvC8f0FXUqhTLXgihFRzXrqfsyCbhyH/X7UjtdPJHdKScJGvDluBrO8Ef vL9w== 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 :message-id:date:subject:cc:to:from:dkim-signature; bh=uXpg/iY82hEm9tokQdYtqJ4gX8iwUMDbB/yvs2d8omo=; b=EgfZ0wDL4ih1o7wpM+Tf2G0vbI5tpOn0QYsMtb/CHF79An4AbL6L0TZhv4RKsVTRNk y2hEDqpOP8vjJkjlOc17HkLH2nzcMSHgrFOjSzH98EVgQmyW3BPwDslS1kyr7lZPBTKH OjO91R/h2tO+srjlm67bxvq/1XjB1McmLMLwLPfbE3+P5Xc4mnCRP4J/YV8u5OOwmWE6 lr659KFKm3FM93v5CyqSuBS7ogT68Zd9E6tvFECsLt0yjp0nK04eoF+Kwxl1FC255SOX pEz12FzS0gd5D+WrQMOD48EQA36Fj7GejkjM8teYdebXLiw5Kuf7Zhw1srWga0SdESQt WZgg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@bgdev-pl.20210112.gappssmtp.com header.s=20210112 header.b=hfD3Z60V; 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 Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id s4-20020a170906354400b0072a6e7a054dsi12344538eja.975.2022.07.12.01.10.01; Tue, 12 Jul 2022 01:10:31 -0700 (PDT) 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=@bgdev-pl.20210112.gappssmtp.com header.s=20210112 header.b=hfD3Z60V; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230269AbiGLHl0 (ORCPT + 99 others); Tue, 12 Jul 2022 03:41:26 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43654 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232402AbiGLHlM (ORCPT ); Tue, 12 Jul 2022 03:41:12 -0400 Received: from mail-wr1-x42e.google.com (mail-wr1-x42e.google.com [IPv6:2a00:1450:4864:20::42e]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E20979B185 for ; Tue, 12 Jul 2022 00:41:02 -0700 (PDT) Received: by mail-wr1-x42e.google.com with SMTP id bk26so9917397wrb.11 for ; Tue, 12 Jul 2022 00:41:02 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bgdev-pl.20210112.gappssmtp.com; s=20210112; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=uXpg/iY82hEm9tokQdYtqJ4gX8iwUMDbB/yvs2d8omo=; b=hfD3Z60Vyp2ebK1/oVLfYekTLjmEM4uokftPm7qlCpAyugRjZ8+NglNPS0HCz3ro8s RhRCfmEUjEBKhEgOfOLPmgJeZ7mH/qZU2ZDSPlC+OW2FeHoiUMrKFWZBvJ1nzm0prWqC tAH4mHgrNRPIX1Cgqv0zxcR983u9EKacVJLurjU2HnM4R/O/GLvC26nmf9nez9Inx76N kVyCHCWUwB0xf/9G0Haq9lDHtkto1yudX6xB+1OZsraKscQvym+psv7AXupqBnLldzYH Jz6qZwRzKF4lpQDRYFqQ86IwVEVyxwJfLrvZkp2lsd5vpaYh8FTkz/CzDwvrUsq4YCm4 VOiw== 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:mime-version :content-transfer-encoding; bh=uXpg/iY82hEm9tokQdYtqJ4gX8iwUMDbB/yvs2d8omo=; b=A3tCj34jpmYWvfvQEOBf9rfQhGGh19uXeW/1ZNq8nIMhjViI/IbAheyCVsJ6YcetKW uoCYoa5m4VGw/X1GqKEi7KDbqB0VXH1Kb3gopVHt0r/r6Z8nyzSBAQtB/dmSUxJvaXBC pSW8W7oSgGmPPCtjjvJqWRxyctaRgQwW2oeNpO5I2dI2J/MJJqXPJHMqbocFxzhECj/i Q9NKG+CTZufbslolZX5RWKjItVL/0ijfSxCu+BQNDfuax4PVux3pFIs+g9LOP2qvD2Ew QlP+SyBKC3T6k00uYZJucHd56YO/LWNuQFVQTEVfxwSnrfXSbNv2rb3C/OfA0uTMXpHT pTuA== X-Gm-Message-State: AJIora+tZ1a8KA8ztI8Q0yuaq4U0UPfzBQfgBaq3GnnPbdqlW6pOg1jg YTDjE59383I1ktL2PgXxekL5Jg== X-Received: by 2002:adf:f345:0:b0:21d:6a26:6d8f with SMTP id e5-20020adff345000000b0021d6a266d8fmr21114628wrp.538.1657611660742; Tue, 12 Jul 2022 00:41:00 -0700 (PDT) Received: from brgl-uxlite.home ([2a01:cb1d:334:ac00:f331:f20b:d10:e79e]) by smtp.gmail.com with ESMTPSA id m9-20020a056000024900b0021d9207e6f1sm7725462wrz.34.2022.07.12.00.41.00 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 12 Jul 2022 00:41:00 -0700 (PDT) From: Bartosz Golaszewski To: Linus Walleij , Andy Shevchenko , Kent Gibson Cc: linux-gpio@vger.kernel.org, linux-kernel@vger.kernel.org, Bartosz Golaszewski , stable@vger.kernel.org Subject: [PATCH v2] gpio: sim: fix the chip_name configfs item Date: Tue, 12 Jul 2022 09:40:55 +0200 Message-Id: <20220712074055.10588-1-brgl@bgdev.pl> X-Mailer: git-send-email 2.34.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_NONE, T_SCC_BODY_TEXT_LINE autolearn=ham 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 The chip_name configs attribute always displays the device name of the first GPIO bank because the logic of the relevant function is simply wrong. Fix it by correctly comparing the bank's swnode against the GPIO device's children. Fixes: cb8c474e79be ("gpio: sim: new testing module") Cc: stable@vger.kernel.org Reported-by: Kent Gibson Signed-off-by: Bartosz Golaszewski --- v1 -> v2: - use device_match_fwnode for shorter code drivers/gpio/gpio-sim.c | 16 +++++----------- 1 file changed, 5 insertions(+), 11 deletions(-) diff --git a/drivers/gpio/gpio-sim.c b/drivers/gpio/gpio-sim.c index 98109839102f..1020c2feb249 100644 --- a/drivers/gpio/gpio-sim.c +++ b/drivers/gpio/gpio-sim.c @@ -991,28 +991,22 @@ static struct configfs_attribute *gpio_sim_device_config_attrs[] = { }; struct gpio_sim_chip_name_ctx { - struct gpio_sim_device *dev; + struct fwnode_handle *swnode; char *page; }; static int gpio_sim_emit_chip_name(struct device *dev, void *data) { struct gpio_sim_chip_name_ctx *ctx = data; - struct fwnode_handle *swnode; - struct gpio_sim_bank *bank; /* This would be the sysfs device exported in /sys/class/gpio. */ if (dev->class) return 0; - swnode = dev_fwnode(dev); + if (device_match_fwnode(dev, ctx->swnode)) + return sprintf(ctx->page, "%s\n", dev_name(dev)); - list_for_each_entry(bank, &ctx->dev->bank_list, siblings) { - if (bank->swnode == swnode) - return sprintf(ctx->page, "%s\n", dev_name(dev)); - } - - return -ENODATA; + return 0; } static ssize_t gpio_sim_bank_config_chip_name_show(struct config_item *item, @@ -1020,7 +1014,7 @@ static ssize_t gpio_sim_bank_config_chip_name_show(struct config_item *item, { struct gpio_sim_bank *bank = to_gpio_sim_bank(item); struct gpio_sim_device *dev = gpio_sim_bank_get_device(bank); - struct gpio_sim_chip_name_ctx ctx = { dev, page }; + struct gpio_sim_chip_name_ctx ctx = { bank->swnode, page }; int ret; mutex_lock(&dev->lock); -- 2.34.1