From patchwork Wed Nov 9 00:26:45 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dmitry Torokhov X-Patchwork-Id: 622969 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 3258CC433FE for ; Wed, 9 Nov 2022 00:26:59 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229560AbiKIA06 (ORCPT ); Tue, 8 Nov 2022 19:26:58 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59980 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229464AbiKIA05 (ORCPT ); Tue, 8 Nov 2022 19:26:57 -0500 Received: from mail-pg1-x533.google.com (mail-pg1-x533.google.com [IPv6:2607:f8b0:4864:20::533]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 396B122B09; Tue, 8 Nov 2022 16:26:56 -0800 (PST) Received: by mail-pg1-x533.google.com with SMTP id h193so14781016pgc.10; Tue, 08 Nov 2022 16:26:56 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=rd9e65C2L1MaGoFoYCg3309gq69yAsyo4bc99h0REBg=; b=WQBHB3EEgLGD0Peb3Dhu47EhbgvWkkxuf1lWtGGP8WDJf1zJ+j7532pEa8XkD3Br0a tFURJP63+WH0aCBjMN2xh0aladptn8+OXNq2wozfp4tJnVvDCTYeKNCIZKjHumK6R+xG 3ogLAn2pZzFxj60wVZBR3LbSs7xT0sb2sC+Y3+Scf/soJCBgPfgr8lTM/CLb2ygFhWdi mx7sYiKtVmO57xiA5zPghz+dqHEqdk6J5TB9enRv0XjEI4ylO9Bw6IMylrZHal3noXTi sJm2WbZavHoH1XCuSr7juxktPPoDRKO/WUnauXua9sNAzDO+BstlgVWpSavU03zR/KlY ndsw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=rd9e65C2L1MaGoFoYCg3309gq69yAsyo4bc99h0REBg=; b=4gE3GA4bmQwZFF72AWtiOW26rdF8YLHKm86OYiLNPcbSYkZ/xsLYJMoUsSqF6NXhjw 4eF/gxwXURiyX7cnVzSm09s6Dy3sHGSXlnhCfFlV7xCfksqWO8LKFyaaivZivVJ6+bQZ QnG3319blQRvj4bF1sMDJpbJasPA7hROU0A5Id3B91sOslfP3kq7eHGwP8d9kSmd+PbC JNILUKaiOeFUay+mV6uZh6kkHNT7z3MpkAsyRWGJGHDmsR6UaOBuc8zvOjOx6p0QtGqB VK5YJVThSUQ1nZFMkI5KpGA+hQ3ft6WolvzMVJWuH1Q4yafpTPeaFWioxLvYzGldgbOV 8ylA== X-Gm-Message-State: ACrzQf1zKGga6HzXt82ry67DjM0JqBPgXlQMjsOAdpbU6AQyrhbk8KTw Bf8FKiPXBmM8WOwjMaFFDPI= X-Google-Smtp-Source: AMsMyM6Otpg0/E8uz/jT/dsjwExFbpKYWzWZzV86jIj5kCV7qSDIXiqfisx61m+Uq69f7bKJUY0KLA== X-Received: by 2002:a05:6a00:1504:b0:56d:1ee8:973e with SMTP id q4-20020a056a00150400b0056d1ee8973emr36325685pfu.30.1667953615481; Tue, 08 Nov 2022 16:26:55 -0800 (PST) Received: from dtor-ws.mtv.corp.google.com ([2620:15c:9d:2:9f46:7242:26:f220]) by smtp.gmail.com with ESMTPSA id i65-20020a626d44000000b0056bd737fdf3sm6907324pfc.123.2022.11.08.16.26.54 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 08 Nov 2022 16:26:54 -0800 (PST) From: Dmitry Torokhov To: Linus Walleij , Andy Shevchenko , Bartosz Golaszewski Cc: linux-acpi@vger.kernel.org, linux-gpio@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v2 0/6] Add support for software nodes to gpiolib Date: Tue, 8 Nov 2022 16:26:45 -0800 Message-Id: <20221031-gpiolib-swnode-v2-0-81f55af5fa0e@gmail.com> X-Mailer: git-send-email 2.38.1.431.g37b22c650d-goog MIME-Version: 1.0 X-Mailer: b4 0.11.0-dev-28747 Precedence: bulk List-ID: X-Mailing-List: linux-acpi@vger.kernel.org This series attempts to add support for software nodes to gpiolib, using software node references. This allows us to convert more drivers to the generic device properties and drop support for custom platform data. To describe a GPIO via software nodes we can create the following data items: /* Node representing the GPIO controller/GPIO bank */ static const struct software_node gpio_bank_b_node = { .name = "B", }; /* * Properties that will be assigned to a software node assigned to * the device that used platform data. */ static const struct property_entry simone_key_enter_props[] = { PROPERTY_ENTRY_U32("linux,code", KEY_ENTER), PROPERTY_ENTRY_STRING("label", "enter"), PROPERTY_ENTRY_REF("gpios", &gpio_bank_b_node, 123, GPIO_ACTIVE_LOW), { } }; The code in gpiolib handling software nodes uses the name in the software node representing GPIO controller to locate the actual instance of GPIO controller. To: Linus Walleij To: Bartosz Golaszewski To: Andy Shevchenko Cc: linux-gpio@vger.kernel.org Cc: linux-kernel@vger.kernel.org Cc: linux-acpi@vger.kernel.org --- Changes in v2: - reworked the series to be independent of other in-flight patches. That meant keeping devm_gpiod_get_from_of_node() for now. - removed handling of secondary nodes, it deserves a separate patch series - fixed refcounting when handling swnodes (Andy) - added include/linux/gpio/property.h with PROPERTY_ENTRY_GPIO (Andy) - addressed most of the rest of Andy's comments - collected reviewed-by and acked-by - Link to v1: https://lore.kernel.org/r/20221031-gpiolib-swnode-v1-0-a0ab48d229c7@gmail.com --- Dmitry Torokhov (6): gpiolib: of: change of_find_gpio() to accept device node gpiolib: acpi: change acpi_find_gpio() to accept firmware node gpiolib: acpi: teach acpi_find_gpio() to handle data-only nodes gpiolib: acpi: avoid leaking ACPI details into upper gpiolib layers gpiolib: consolidate GPIO lookups gpiolib: add support for software nodes drivers/gpio/Makefile | 1 + drivers/gpio/gpiolib-acpi.c | 132 ++++++++++++++----------- drivers/gpio/gpiolib-acpi.h | 54 +---------- drivers/gpio/gpiolib-of.c | 7 +- drivers/gpio/gpiolib-of.h | 4 +- drivers/gpio/gpiolib-swnode.c | 128 ++++++++++++++++++++++++ drivers/gpio/gpiolib-swnode.h | 14 +++ drivers/gpio/gpiolib.c | 219 +++++++++++++++++------------------------- include/linux/gpio/property.h | 11 +++ 9 files changed, 329 insertions(+), 241 deletions(-) --- base-commit: b6fc3fddade7a194bd141a49f2689e50f796ef46 change-id: 20221031-gpiolib-swnode-948203f49b23