From patchwork Mon Aug 28 17:40:19 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Biju Das X-Patchwork-Id: 137073 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:a7d1:0:b0:3f2:4152:657d with SMTP id p17csp3535306vqm; Mon, 28 Aug 2023 12:24:05 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEshr2iWIA7gd4x1buYzfQmkJLp/bR9hUInXK6rBrEQRsa4Z48836UU56IV8LEG6JQ3lk4T X-Received: by 2002:a17:907:b609:b0:9a5:852f:10c0 with SMTP id vl9-20020a170907b60900b009a5852f10c0mr6076605ejc.47.1693250645590; Mon, 28 Aug 2023 12:24:05 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1693250645; cv=none; d=google.com; s=arc-20160816; b=DfjYhYHoxA0p+UZ11o1js/EZkR8DehteSQG1Qhknbg1wIBEAXij53dL/lFxud0/7QL RJMJfXYHfmd16AjEpNJBDRUzmrruN1xLCCPYpAXj2mwHwPT8NwECS2iSlmCohIhYG3vD Cu2Zj1Rct9uuw0xGFDua7g4e89o8HvwWc8+4VCIgWJY2ykP5ADtxsqDVYBVnEdeMpoV9 P48AXomb31ng+r9/2bswh4PBAlHYPYUyEv3LEpqc4L1V75srWpLPEcVwVGAtda2JFHZ+ +k0CVdX68TRgs32BRcjz7IBmzaC+yMwf4Vctd69JHJzvRw/WR89OdXuBPvlVl5Qq6dOu LVsA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from; bh=27vzBJ3twioTLKReQw4I0We72oS5DepVuW+l7DRqvNc=; fh=fh4R+AXLz0jBLhEx5B9bAcbO+7lfDJyCvG2AoIP9F18=; b=JiojlZWXOs9GrSmpBM21i3pIKqCayvLgmqq7iPGBB8fL1JxH8vs/SK9lOaWBE6Crsu 8tn7Rlnj5FPaGsLxZRtvnUC4oU5m2UT7Jjfo/yOQQCzDmyw+R1k3QLvENXndifJiG4hP xcEr0iZzNWuHNTqqADhSn+5rBj4Avlc89vNUDJKxMhpkS5RvklnLMLwNH+EMfwtmtTOG xCIyWiZrW4RnaqnDqpBT1Jw5+rEnUu1lHUNyO1I9f3aIqSpN4DNAdxZPJQXy8LJLWpaH Gaa+9L9H6WPS9pVpZVogpRSJFa08IuzZxlm+FZHDZYY00EPSwLplJAx2Ve/L8LHJO9Re tA3A== 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:20 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 out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id qk12-20020a170906d9cc00b009a1b305102bsi4850368ejb.131.2023.08.28.12.23.28; Mon, 28 Aug 2023 12:24:05 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=renesas.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232858AbjH1RlE (ORCPT + 99 others); Mon, 28 Aug 2023 13:41:04 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47526 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232904AbjH1Rka (ORCPT ); Mon, 28 Aug 2023 13:40:30 -0400 Received: from relmlie6.idc.renesas.com (relmlor2.renesas.com [210.160.252.172]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 6A237A6 for ; Mon, 28 Aug 2023 10:40:26 -0700 (PDT) X-IronPort-AV: E=Sophos;i="6.02,208,1688396400"; d="scan'208";a="177944208" Received: from unknown (HELO relmlir5.idc.renesas.com) ([10.200.68.151]) by relmlie6.idc.renesas.com with ESMTP; 29 Aug 2023 02:40:25 +0900 Received: from localhost.localdomain (unknown [10.226.92.234]) by relmlir5.idc.renesas.com (Postfix) with ESMTP id 39ED54009BED; Tue, 29 Aug 2023 02:40:21 +0900 (JST) From: Biju Das To: Jaroslav Kysela , Takashi Iwai Cc: Biju Das , Liam Girdwood , Mark Brown , Charles Keepax , =?utf-8?q?Uwe_Kleine-K?= =?utf-8?q?=C3=B6nig?= , patches@opensource.cirrus.com, alsa-devel@alsa-project.org, linux-kernel@vger.kernel.org, Andy Shevchenko Subject: [PATCH v2] ASoC: wm8580: Simplify probe() Date: Mon, 28 Aug 2023 18:40:19 +0100 Message-Id: <20230828174019.119250-1-biju.das.jz@bp.renesas.com> X-Mailer: git-send-email 2.25.1 MIME-Version: 1.0 X-Spam-Status: No, score=-1.9 required=5.0 tests=AC_FROM_MANY_DOTS,BAYES_00, RCVD_IN_DNSWL_BLOCKED,SPF_HELO_NONE,SPF_PASS autolearn=ham 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 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1775501989101410864 X-GMAIL-MSGID: 1775501989101410864 Simplify probe() by replacing of_match_device->i2c_get_match_data() and extend matching support for ID table. While at it, remove comma in the terminator entry and simplify probe() by replacing dev_err->dev_err_probe(). Signed-off-by: Biju Das Acked-by: Charles Keepax --- Note: This patch is only compile tested. v1->v2: * Added Ack from Charles Keepax. * Removed comma in the terminator entry. * Restored original error code -EINVAL --- sound/soc/codecs/wm8580.c | 26 ++++++++++---------------- 1 file changed, 10 insertions(+), 16 deletions(-) diff --git a/sound/soc/codecs/wm8580.c b/sound/soc/codecs/wm8580.c index 6d22f7d40ec2..28c0ba348634 100644 --- a/sound/soc/codecs/wm8580.c +++ b/sound/soc/codecs/wm8580.c @@ -988,16 +988,8 @@ static const struct wm8580_driver_data wm8581_data = { .num_dacs = 4, }; -static const struct of_device_id wm8580_of_match[] = { - { .compatible = "wlf,wm8580", .data = &wm8580_data }, - { .compatible = "wlf,wm8581", .data = &wm8581_data }, - { }, -}; -MODULE_DEVICE_TABLE(of, wm8580_of_match); - static int wm8580_i2c_probe(struct i2c_client *i2c) { - const struct of_device_id *of_id; struct wm8580_priv *wm8580; int ret, i; @@ -1022,14 +1014,9 @@ static int wm8580_i2c_probe(struct i2c_client *i2c) i2c_set_clientdata(i2c, wm8580); - of_id = of_match_device(wm8580_of_match, &i2c->dev); - if (of_id) - wm8580->drvdata = of_id->data; - - if (!wm8580->drvdata) { - dev_err(&i2c->dev, "failed to find driver data\n"); - return -EINVAL; - } + wm8580->drvdata = i2c_get_match_data(i2c); + if (!wm8580->drvdata) + return dev_err_probe(&i2c->dev, -EINVAL, "failed to find driver data\n"); ret = devm_snd_soc_register_component(&i2c->dev, &soc_component_dev_wm8580, wm8580_dai, ARRAY_SIZE(wm8580_dai)); @@ -1037,6 +1024,13 @@ static int wm8580_i2c_probe(struct i2c_client *i2c) return ret; } +static const struct of_device_id wm8580_of_match[] = { + { .compatible = "wlf,wm8580", .data = &wm8580_data }, + { .compatible = "wlf,wm8581", .data = &wm8581_data }, + { } +}; +MODULE_DEVICE_TABLE(of, wm8580_of_match); + static const struct i2c_device_id wm8580_i2c_id[] = { { "wm8580", (kernel_ulong_t)&wm8580_data }, { "wm8581", (kernel_ulong_t)&wm8581_data },