Received: by 2002:a05:6a10:1a4d:0:0:0:0 with SMTP id nk13csp2307461pxb; Wed, 9 Feb 2022 15:45:59 -0800 (PST) X-Google-Smtp-Source: ABdhPJzIwntUaR9i5aCfpcxsJTyI5lmpPfEpl9TPiAAS1YOqu9KNPOrfaWjd7zTXy/0NrgUkLOrp X-Received: by 2002:a17:90b:1d91:: with SMTP id pf17mr6245175pjb.160.1644450359755; Wed, 09 Feb 2022 15:45:59 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1644450359; cv=none; d=google.com; s=arc-20160816; b=kFTrFKulJepWBe8qerXiWn2kaLTG+NJbk1zcWbn8gKBOyiQ1d8HtBdpBhL57/LOxEa 71q3xG5yT7bxIkvYALAVULYyHrMhauqU7LY/hjPrZ7GJGOkUST0wkuC35XMZXQTm9MJ1 1CxHKn+FRuMCS7kndjsIP/ihkQuFl94qXzi+ZBJNk533ZtJkU6feIivcmaoK8mi/T2lx zH5R/OYMzQkw+9J+EU5SAZBLXay7Js9tFrCkw9lDWSBIDVpmDJbXoKsNL/Ryr0hbuRpa mhBYoetvwXjfgm1a6XNilIJeJq1NshhBbl+5chTtJAq5zSL8hIwnAUIqABdw16V44gs8 5zww== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:message-id:date:subject:cc:to:from; bh=QKym36JYf05OuaSkglUMSCk7EVVKYWvaOjPWY8gOdZI=; b=SYkC3HtBvpP9uKpFk9k/ijdVE2TYAK3RjGVWdnHb/73dibZQLCRNAY+sPWY7CI96AE Oqyv6CbK4XtDSnbUsTUxT4L+iaBxmFh0QApJc0StIBtQvYLAr3sfqnpc7vmn+mauGXFW PGO6FVshguuEViAwIxLBzzA00B7ApvxdXftRkHPBb+wC22vqbzlHshEZDmnLjC96627O jRUrqjtZC2FX4cavgDSM0oBHExgVeILhMSflOLpGhtEidckoMVkFZ7O2IjnOqqkwmAyl omcvEPmx4czGaL75lNxKUvPvCow1My0BmD4Ee0WcsKKp92eGZw27Zzz9MGuP19wUNvG1 bCvw== ARC-Authentication-Results: i=1; mx.google.com; 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=fail (p=NONE sp=NONE dis=NONE) header.from=renesas.com Return-Path: Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [2620:137:e000::1:18]) by mx.google.com with ESMTPS id d68si17268356pgc.193.2022.02.09.15.45.59 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 09 Feb 2022 15:45:59 -0800 (PST) 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; 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=fail (p=NONE sp=NONE dis=NONE) header.from=renesas.com Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 31BE1E06C43E; Wed, 9 Feb 2022 15:28:21 -0800 (PST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229738AbiBIX2H (ORCPT + 99 others); Wed, 9 Feb 2022 18:28:07 -0500 Received: from gmail-smtp-in.l.google.com ([23.128.96.19]:44550 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229591AbiBIX2D (ORCPT ); Wed, 9 Feb 2022 18:28:03 -0500 X-Greylist: delayed 304 seconds by postgrey-1.37 at lindbergh.monkeyblade.net; Wed, 09 Feb 2022 15:27:58 PST Received: from relmlie6.idc.renesas.com (relmlor2.renesas.com [210.160.252.172]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 1A1D9E057C0C for ; Wed, 9 Feb 2022 15:27:57 -0800 (PST) X-IronPort-AV: E=Sophos;i="5.88,356,1635174000"; d="scan'208";a="110784889" Received: from unknown (HELO relmlir5.idc.renesas.com) ([10.200.68.151]) by relmlie6.idc.renesas.com with ESMTP; 10 Feb 2022 08:22:44 +0900 Received: from localhost.localdomain (unknown [10.226.36.204]) by relmlir5.idc.renesas.com (Postfix) with ESMTP id 592F84004CFB; Thu, 10 Feb 2022 08:22:42 +0900 (JST) From: Lad Prabhakar To: Geert Uytterhoeven , Chris Brandt , Philipp Zabel , linux-renesas-soc@vger.kernel.org Cc: linux-i2c@vger.kernel.org, linux-kernel@vger.kernel.org, Prabhakar , Biju Das , Lad Prabhakar Subject: [PATCH] i2c: riic: Simplify reset handling Date: Wed, 9 Feb 2022 23:22:32 +0000 Message-Id: <20220209232232.18461-1-prabhakar.mahadev-lad.rj@bp.renesas.com> X-Mailer: git-send-email 2.17.1 X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00, 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 Read reset phandle as optional instead of exclusive so that all the DT's passing the reset phandle can be used to assert/deassert the reset line. With this change we don't have to differentiate the RZ/G2L SoC. With the above changes we no longer need the "renesas,riic-r9a07g044" compatible string, so drop it from riic_i2c_dt_ids[]. No changes are required to the r9a07g044.dtsi as we already have "renesas,riic-rz" as a fallback compatible string. While at it, check the return code of reset_control_deassert() as it might fail and also add a devres action to assert the reset line. Signed-off-by: Lad Prabhakar --- drivers/i2c/busses/i2c-riic.c | 34 +++++++++++++++++----------------- 1 file changed, 17 insertions(+), 17 deletions(-) diff --git a/drivers/i2c/busses/i2c-riic.c b/drivers/i2c/busses/i2c-riic.c index 8dfd27dc6149..cded77e06670 100644 --- a/drivers/i2c/busses/i2c-riic.c +++ b/drivers/i2c/busses/i2c-riic.c @@ -88,11 +88,6 @@ #define RIIC_INIT_MSG -1 -enum riic_type { - RIIC_RZ_A, - RIIC_RZ_G2L, -}; - struct riic_dev { void __iomem *base; u8 *buf; @@ -396,6 +391,11 @@ static struct riic_irq_desc riic_irqs[] = { { .res_num = 5, .isr = riic_tend_isr, .name = "riic-nack" }, }; +static void riic_reset_control_assert(void *data) +{ + reset_control_assert(data); +} + static int riic_i2c_probe(struct platform_device *pdev) { struct riic_dev *riic; @@ -404,7 +404,6 @@ static int riic_i2c_probe(struct platform_device *pdev) struct i2c_timings i2c_t; struct reset_control *rstc; int i, ret; - enum riic_type type; riic = devm_kzalloc(&pdev->dev, sizeof(*riic), GFP_KERNEL); if (!riic) @@ -421,16 +420,18 @@ static int riic_i2c_probe(struct platform_device *pdev) return PTR_ERR(riic->clk); } - type = (enum riic_type)of_device_get_match_data(&pdev->dev); - if (type == RIIC_RZ_G2L) { - rstc = devm_reset_control_get_exclusive(&pdev->dev, NULL); - if (IS_ERR(rstc)) { - dev_err(&pdev->dev, "Error: missing reset ctrl\n"); - return PTR_ERR(rstc); - } + rstc = devm_reset_control_get_optional_exclusive(&pdev->dev, NULL); + if (IS_ERR(rstc)) + return dev_err_probe(&pdev->dev, PTR_ERR(rstc), + "Error: missing reset ctrl\n"); - reset_control_deassert(rstc); - } + ret = reset_control_deassert(rstc); + if (ret) + return ret; + + ret = devm_add_action_or_reset(&pdev->dev, riic_reset_control_assert, rstc); + if (ret) + return ret; for (i = 0; i < ARRAY_SIZE(riic_irqs); i++) { ret = platform_get_irq(pdev, riic_irqs[i].res_num); @@ -492,8 +493,7 @@ static int riic_i2c_remove(struct platform_device *pdev) } static const struct of_device_id riic_i2c_dt_ids[] = { - { .compatible = "renesas,riic-r9a07g044", .data = (void *)RIIC_RZ_G2L }, - { .compatible = "renesas,riic-rz", .data = (void *)RIIC_RZ_A }, + { .compatible = "renesas,riic-rz", }, { /* Sentinel */ }, }; -- 2.17.1