From patchwork Fri Nov 11 22:19:02 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dmitry Torokhov X-Patchwork-Id: 13040890 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 18A1AC43217 for ; Fri, 11 Nov 2022 22:19:35 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233972AbiKKWTe (ORCPT ); Fri, 11 Nov 2022 17:19:34 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45376 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234608AbiKKWTU (ORCPT ); Fri, 11 Nov 2022 17:19:20 -0500 Received: from mail-pf1-x430.google.com (mail-pf1-x430.google.com [IPv6:2607:f8b0:4864:20::430]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3001F5FD2; Fri, 11 Nov 2022 14:19:13 -0800 (PST) Received: by mail-pf1-x430.google.com with SMTP id k15so6019431pfg.2; Fri, 11 Nov 2022 14:19:13 -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=qpOJ3rVA6/X/I77P5ZYNEkOM6gDrKnPiFfbCrZsQZMA=; b=XE6EYDIOkSdUYCCkxzHig/4KE/tiDWG4nsgOB2EDTcVmrCrTie510lmRWzfa0kISyz 3bVIXO8ps4aJODpuCy6rhvMiD2jTbn6JmGtjlG/mJGw55ieWX6wObKsXxoTX5s/uSknu T6PFeVnEriM6jgc9x16ugI4uDuuittNi8fz6UFBnI3D43Fmh0Rf/r2SMYnBghX42kzXg 9nM+FzdhzA/Ojtav6NC7n59CXYm2uR/TVSNjRBRF7oDx2e3OTns8t9qz4CkrLyeaQVug kqk6TuQ1JNFzeVfOgYCcwegj/vT74SG4LuRTfxGM4Dv9Vw8sEwQKsiJCQ44hlBKxaVUF G7YA== 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=qpOJ3rVA6/X/I77P5ZYNEkOM6gDrKnPiFfbCrZsQZMA=; b=4rGUwo0rK7TPgvPoYrP5yTZgsLSjgi0FkUt5yGlKDefctY7ThQcuwvNukU0LlSebAu DlD8LDJZu0ZNwa+WSrvT1zradbeQo75KiG2h22mcCg8mkf8g0qae+J1SdreNtX7nsvtC 2sbyx1xV5D/5CyO3xDW1Yoo4urwElp2RqYI1AJASIQ1c8iLShPaFkMSYEMwkQ5OTDvio rvPaTLH9WHE1iFzfKq0SkQnsUP7ZNXHXWTp9YEvHesMn4+SmBlcwed26gvUtTSvNAp2t SAvuDR7sGQlzI6a4PFNR7hzQg/OmuQZlAUbXmxkZHi96xhlrE0bW1Kb5m7leYqZ+X6Ab Bb6A== X-Gm-Message-State: ANoB5pmPaOdI/tayKx0HjFtgdqcQlK+BaMb3QXhHjEakKHBPtL8h4lJQ khzeL93ZD66Lt7b54XDWU/U= X-Google-Smtp-Source: AA0mqf5FbHSSuKQXc103+x9LY5avOvdjIamoZrDgVoWi41Dax+7GKRM3/IL3tz+xbYezWfj39Vx/hA== X-Received: by 2002:a63:fd41:0:b0:470:71df:7ec5 with SMTP id m1-20020a63fd41000000b0047071df7ec5mr3396016pgj.272.1668205152501; Fri, 11 Nov 2022 14:19:12 -0800 (PST) Received: from dtor-ws.mtv.corp.google.com ([2620:15c:9d:2:de05:ad1e:65ae:ea4d]) by smtp.gmail.com with ESMTPSA id q9-20020a170902bd8900b00180daa59314sm2201109pls.125.2022.11.11.14.19.11 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 11 Nov 2022 14:19:11 -0800 (PST) From: Dmitry Torokhov To: Bartosz Golaszewski , Andy Shevchenko , Linus Walleij Cc: linux-gpio@vger.kernel.org, linux-kernel@vger.kernel.org, linux-acpi@vger.kernel.org Subject: [PATCH v4 0/6] Add support for software nodes to gpiolib Date: Fri, 11 Nov 2022 14:19:02 -0800 Message-Id: <20221031-gpiolib-swnode-v4-0-6c1671890027@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 v4: - Rebased on top of next-20221111 - Added Andy's reviewed-by for patch #6 - Link to v3: https://lore.kernel.org/r/20221031-gpiolib-swnode-v3-0-0282162b0fa4@gmail.com Changes in v3: - Addressed more Andy's comments - Link to v2: https://lore.kernel.org/r/20221031-gpiolib-swnode-v2-0-81f55af5fa0e@gmail.com 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 | 123 +++++++++++++++++++++++++ drivers/gpio/gpiolib-swnode.h | 14 +++ drivers/gpio/gpiolib.c | 209 ++++++++++++++++-------------------------- include/linux/gpio/property.h | 11 +++ 9 files changed, 315 insertions(+), 240 deletions(-) --- base-commit: f8f60f322f0640c8edda2942ca5f84b7a27c417a change-id: 20221031-gpiolib-swnode-948203f49b23