From patchwork Tue Sep 8 05:40:09 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pratyush Yadav X-Patchwork-Id: 1359471 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.denx.de (client-ip=2a01:238:438b:c500:173d:9f52:ddab:ee01; helo=phobos.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Authentication-Results: ozlabs.org; dmarc=pass (p=quarantine dis=none) header.from=ti.com Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=ti.com header.i=@ti.com header.a=rsa-sha256 header.s=ti-com-17Q1 header.b=sqDxWe1J; dkim-atps=neutral Received: from phobos.denx.de (phobos.denx.de [IPv6:2a01:238:438b:c500:173d:9f52:ddab:ee01]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4BlvBl0BQfz9sR4 for ; Tue, 8 Sep 2020 15:40:46 +1000 (AEST) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 6260282537; Tue, 8 Sep 2020 07:40:25 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=quarantine dis=none) header.from=ti.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (1024-bit key; unprotected) header.d=ti.com header.i=@ti.com header.b="sqDxWe1J"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 6E0F582526; Tue, 8 Sep 2020 07:40:23 +0200 (CEST) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,SPF_HELO_NONE,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.2 Received: from fllv0015.ext.ti.com (fllv0015.ext.ti.com [198.47.19.141]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id 093B9824EC for ; Tue, 8 Sep 2020 07:40:18 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=quarantine dis=none) header.from=ti.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=p.yadav@ti.com Received: from lelv0265.itg.ti.com ([10.180.67.224]) by fllv0015.ext.ti.com (8.15.2/8.15.2) with ESMTP id 0885eFNT050455; Tue, 8 Sep 2020 00:40:15 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ti.com; s=ti-com-17Q1; t=1599543615; bh=CL+IUjam23kJvRPuIezMg/ddUB1vsLLBPCg0A7+ZwY8=; h=From:To:CC:Subject:Date; b=sqDxWe1Jp2RmcCP0D6w6+xuG2TB+FBcUKw8D0TyJoXI5b5ioQmbrVJXio8erMXRVs sn0imCFv+BFAxa+QtEEBhr3yIVn6atqoTdtDWOGDpCbn7HzUKOUC/sxAHAdFmdASUS xPxkG6Shrb77dD5WEyUGSt1SdJnGE9wIouuwELhA= Received: from DFLE105.ent.ti.com (dfle105.ent.ti.com [10.64.6.26]) by lelv0265.itg.ti.com (8.15.2/8.15.2) with ESMTPS id 0885eFbh114580 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=FAIL); Tue, 8 Sep 2020 00:40:15 -0500 Received: from DFLE113.ent.ti.com (10.64.6.34) by DFLE105.ent.ti.com (10.64.6.26) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.1979.3; Tue, 8 Sep 2020 00:40:14 -0500 Received: from lelv0326.itg.ti.com (10.180.67.84) by DFLE113.ent.ti.com (10.64.6.34) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.1979.3 via Frontend Transport; Tue, 8 Sep 2020 00:40:14 -0500 Received: from pratyush-OptiPlex-790.dhcp.ti.com (ileax41-snat.itg.ti.com [10.172.224.153]) by lelv0326.itg.ti.com (8.15.2/8.15.2) with ESMTP id 0885eCoS055935; Tue, 8 Sep 2020 00:40:13 -0500 From: Pratyush Yadav To: Tom Rini , CC: Pratyush Yadav , Simon Glass , Vignesh Raghavendra Subject: [PATCH v4 0/2] gpio: Add a managed API Date: Tue, 8 Sep 2020 11:10:09 +0530 Message-ID: <20200908054011.18125-1-p.yadav@ti.com> X-Mailer: git-send-email 2.28.0 MIME-Version: 1.0 X-EXCLAIMER-MD-CONFIG: e1e8a2fd-e40a-4ac6-ac9b-f7e9cc9ee180 X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.34 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.102.3 at phobos.denx.de X-Virus-Status: Clean Hi, This is a re-submission of Jean-Jacques' earlier work in October last year. It can be found at [0]. The goal is to facilitate porting drivers from the Linux kernel. Most of the series will be about adding managed APIs to existing infrastructure (GPIO, reset, regmap). This particular series is about GPIOs. It adds a managed API using the API as Linux. To make it 100% compatible with linux, there is a small deviation from u-boot's way of naming the gpio lists: the managed equivalent of gpio_request_by_name(..,"blabla-gpios", ...) is devm_gpiod_get_index(..., "blabla", ...) Travis CI run: https://travis-ci.org/github/prati0100/uboot/builds/725044296 Changes in v4: - Rebase on latest master and fix merge conflicts. - Move "another-test" node down the order to make sure dm_test_fdt_uclass_seq() continues to work. - Bump num_devices to 9 in dm_test_bus_children(), dm_test_fdt(), and dm_test_uclass_foreach() to fix broken tests. - s/DM_TESTF/UT_TESTF/g Changes in v3: - Add a blank line before return in devm_gpiod_get_index(). - Add Simon's Reviwed-by in both patches. Changes in v2: - The original series had a patch that checked for NULL pointers in the core GPIO functions. The checks were needed because of the addition of devm_gpiod_get_index_optional() which would return NULL when when no GPIO was assigned to the requested function. This is convenient for drivers that need to handle optional GPIOs. Simon argued that those should be behind a Kconfig option because of code size concerns. He also argued against implicit return in the macro that checked for the optional GPIOs. This submission removes the controversial patch so that base functionality can get merged. We still need to take a stance on who is responsible for the NULL check: the driver or the GPIO core? Do we want to trust drivers to take care of the NULL checks, or do we want to distrust them and make sure they don't send us anything bogus in the GPIO core. I will send a separate RFC of the NULL check patch and we can probably discuss the issue there. [0] https://patchwork.ozlabs.org/project/uboot/cover/20191001115130.18886-1-jjhiblot@ti.com/ Jean-Jacques Hiblot (2): drivers: gpio: Add a managed API to get a GPIO from the device-tree test: gpio: Add tests for the managed API arch/sandbox/dts/test.dts | 10 ++++ drivers/gpio/gpio-uclass.c | 71 ++++++++++++++++++++++++++ include/asm-generic/gpio.h | 47 +++++++++++++++++ test/dm/bus.c | 2 +- test/dm/gpio.c | 102 +++++++++++++++++++++++++++++++++++++ test/dm/test-fdt.c | 6 +-- 6 files changed, 234 insertions(+), 4 deletions(-) --- 2.28.0