From patchwork Thu Jul 23 18:48:57 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Cristian Birsan X-Patchwork-Id: 11681537 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 61234138A for ; Thu, 23 Jul 2020 18:50:52 +0000 (UTC) Received: from merlin.infradead.org (merlin.infradead.org [205.233.59.134]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 39600206D8 for ; Thu, 23 Jul 2020 18:50:52 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="AdZvzC+w"; dkim=fail reason="signature verification failed" (2048-bit key) header.d=microchip.com header.i=@microchip.com header.b="SbxBnxPN" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 39600206D8 Authentication-Results: mail.kernel.org; dmarc=fail (p=quarantine dis=none) header.from=microchip.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=merlin.20170209; h=Sender:Content-Transfer-Encoding: Content-Type:Cc:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To:Message-ID:Date: Subject:To:From:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=gNtq+nHJvKKuxDaS4FVZsyePupgrLH1+B396U3qvUvA=; b=AdZvzC+w0jYKBajucOLXIDwvm 03+3TCY46ziKFNYECYG8I54sduo78lCdVoUJaJtn0V1PD9R1uq0XS3R2eqRPogr8/kfbHCjqK2DbZ P/DCC6BfpSwe7s7pPZtjLvhJgElcC+nzo4oh+Dtd8kJa4x+H47waovU0rKgeVZVC8/MmeUai/6AM1 mJzqppiSuxZwMrvYOlkDXH95Y7/Exd6g4a34Ce6qlbelH8aBZygYr/mA62WKvqo+iXYlxjRkWl0VN c/pbyBXAmB+FhZwzITo+U54xS44wBGNldtoQ7s0AiTCdgEiR6TPkuHQJOsKAgcAu+ts9jboyTJsgO E4NbqxRvQ==; Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1jygHT-0007yK-4E; Thu, 23 Jul 2020 18:49:23 +0000 Received: from esa6.microchip.iphmx.com ([216.71.154.253]) by merlin.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1jygHM-0007vk-JE for linux-arm-kernel@lists.infradead.org; Thu, 23 Jul 2020 18:49:17 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=microchip.com; i=@microchip.com; q=dns/txt; s=mchp; t=1595530156; x=1627066156; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=OP/6x1FWBOWYFD0Vizy3q/OtdHKjms+2XnvxpxgJNsU=; b=SbxBnxPNnKV/t2rITq8C9/Ua3GFA9TPJtayg9xHnSV4SgFEl2ELPnA5S wrV9QfDmE6GXX+PE5NB31sPF32wYOhhB+vuQTKtI1B9FEgrxcMrjzd9O8 VcMvJv7IGAnnsMe9yAv54lCa4GSAipu9zLSxp5tGhezhCZ65pxdhc1rMz yBAyBMDDQZFbT2lfo+45kp/bXL99EYdaFDYUID8UKVm3QyPRrMnsRcPBp eb8TOfvu+SQs/zdJnIMwB+0Oz0e5P48+iXbuJxM8lAis3UMAAalOH7pVC AzWdktlp7mnrHhlHXAI7EbXfAa43RAoVXd/dL4Of5iJUX2KFmzgcHWJg4 A==; IronPort-SDR: sapuqCwlsZIVzl004MwFqSN4O56pfFH31ChOcjpIggQrPyfV+d2c9nkyaNlp3kYvggHpVRuIHu 4mIAUUnt2NJUWCgYvmyU3ibOiN+na9VLgnLWkeLIPSh2YfFyZYFcQ3mpgdfLCYFBDZWx+4zdCf WBJnohVFfP8J2QgWK57owwaqCoHnkaXPDJF9BTqCWbRRucYv2tValNG0KmMiWckxG3zvlmMytK dn9zF0GeUDxN4CFh5bpP9Dyd6cZC24DzFhV7XKwOWQ848RtlqT8GY0uLxM+wXZvuZTq0aNX8qU vjo= X-IronPort-AV: E=Sophos;i="5.75,387,1589266800"; d="scan'208";a="20343895" Received: from smtpout.microchip.com (HELO email.microchip.com) ([198.175.253.82]) by esa6.microchip.iphmx.com with ESMTP/TLS/AES256-SHA256; 23 Jul 2020 11:49:14 -0700 Received: from chn-vm-ex01.mchp-main.com (10.10.85.143) by chn-vm-ex03.mchp-main.com (10.10.85.151) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.1979.3; Thu, 23 Jul 2020 11:49:15 -0700 Received: from cristi-P53.lan (10.10.115.15) by chn-vm-ex01.mchp-main.com (10.10.85.143) with Microsoft SMTP Server id 15.1.1979.3 via Frontend Transport; Thu, 23 Jul 2020 11:48:32 -0700 From: To: , , , , , , , , , , Subject: [PATCH v4 1/6] usb: gadget: udc: atmel: use of_find_matching_node_and_match Date: Thu, 23 Jul 2020 21:48:57 +0300 Message-ID: <20200723184902.416705-2-cristian.birsan@microchip.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20200723184902.416705-1-cristian.birsan@microchip.com> References: <20200723184902.416705-1-cristian.birsan@microchip.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20200723_144916_811332_717D696F X-CRM114-Status: GOOD ( 10.50 ) X-Spam-Score: -2.5 (--) X-Spam-Report: SpamAssassin version 3.4.4 on merlin.infradead.org summary: Content analysis details: (-2.5 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 RCVD_IN_MSPIKE_H2 RBL: Average reputation (+2) [216.71.154.253 listed in wl.mailspike.net] -2.3 RCVD_IN_DNSWL_MED RBL: Sender listed at https://www.dnswl.org/, medium trust [216.71.154.253 listed in list.dnswl.org] -0.0 SPF_HELO_PASS SPF: HELO matches SPF record -0.0 SPF_PASS SPF: sender matches SPF record -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.1 DKIM_VALID_EF Message has a valid DKIM or DK signature from envelope-from domain -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Claudiu Beznea Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org From: Claudiu Beznea Instead of trying to match every possible compatible use of_find_matching_node_and_match() and pass the compatible array. Signed-off-by: Claudiu Beznea Signed-off-by: Cristian Birsan --- drivers/usb/gadget/udc/atmel_usba_udc.c | 26 ++++++++++++++++++------- 1 file changed, 19 insertions(+), 7 deletions(-) diff --git a/drivers/usb/gadget/udc/atmel_usba_udc.c b/drivers/usb/gadget/udc/atmel_usba_udc.c index fa6793065c7c..4281242b5f9a 100644 --- a/drivers/usb/gadget/udc/atmel_usba_udc.c +++ b/drivers/usb/gadget/udc/atmel_usba_udc.c @@ -2112,11 +2112,19 @@ static const struct of_device_id atmel_udc_dt_ids[] = { MODULE_DEVICE_TABLE(of, atmel_udc_dt_ids); +static const struct of_device_id atmel_pmc_dt_ids[] = { + { .compatible = "atmel,at91sam9g45-pmc" }, + { .compatible = "atmel,at91sam9rl-pmc" }, + { .compatible = "atmel,at91sam9x5-pmc" }, + { /* sentinel */ } +}; + static struct usba_ep * atmel_udc_of_init(struct platform_device *pdev, struct usba_udc *udc) { struct device_node *np = pdev->dev.of_node; const struct of_device_id *match; + struct device_node *pp; int i, ret; struct usba_ep *eps, *ep; const struct usba_udc_config *udc_config; @@ -2127,13 +2135,17 @@ static struct usba_ep * atmel_udc_of_init(struct platform_device *pdev, udc_config = match->data; udc->errata = udc_config->errata; - udc->pmc = syscon_regmap_lookup_by_compatible("atmel,at91sam9g45-pmc"); - if (IS_ERR(udc->pmc)) - udc->pmc = syscon_regmap_lookup_by_compatible("atmel,at91sam9rl-pmc"); - if (IS_ERR(udc->pmc)) - udc->pmc = syscon_regmap_lookup_by_compatible("atmel,at91sam9x5-pmc"); - if (udc->errata && IS_ERR(udc->pmc)) - return ERR_CAST(udc->pmc); + if (udc->errata) { + pp = of_find_matching_node_and_match(NULL, atmel_pmc_dt_ids, + NULL); + if (!pp) + return ERR_PTR(-ENODEV); + + udc->pmc = syscon_node_to_regmap(pp); + of_node_put(pp); + if (IS_ERR(udc->pmc)) + return ERR_CAST(udc->pmc); + } udc->num_ep = 0;