From nobody Mon Feb 9 09:18:11 2026 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 5F792C83F37 for ; Thu, 31 Aug 2023 20:47:48 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1347438AbjHaUrt (ORCPT ); Thu, 31 Aug 2023 16:47:49 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59446 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231715AbjHaUrr (ORCPT ); Thu, 31 Aug 2023 16:47:47 -0400 Received: from relmlie5.idc.renesas.com (relmlor1.renesas.com [210.160.252.171]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id AAE04CFE for ; Thu, 31 Aug 2023 13:47:43 -0700 (PDT) X-IronPort-AV: E=Sophos;i="6.02,217,1688396400"; d="scan'208";a="174635229" Received: from unknown (HELO relmlir6.idc.renesas.com) ([10.200.68.152]) by relmlie5.idc.renesas.com with ESMTP; 01 Sep 2023 05:47:43 +0900 Received: from localhost.localdomain (unknown [10.226.92.179]) by relmlir6.idc.renesas.com (Postfix) with ESMTP id 474AB402951B; Fri, 1 Sep 2023 05:47:40 +0900 (JST) From: Biju Das To: Jaroslav Kysela , Takashi Iwai Cc: Biju Das , Liam Girdwood , Mark Brown , =?UTF-8?q?Uwe=20Kleine-K=C3=B6nig?= , alsa-devel@alsa-project.org, linux-kernel@vger.kernel.org, Andy Shevchenko Subject: [PATCH v3 1/2] ASoC: ak4642: Minor cleanups in probe() Date: Thu, 31 Aug 2023 21:47:33 +0100 Message-Id: <20230831204734.104954-2-biju.das.jz@bp.renesas.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230831204734.104954-1-biju.das.jz@bp.renesas.com> References: <20230831204734.104954-1-biju.das.jz@bp.renesas.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" Some minor cleanups: Replace local variable np with dev_fwnode() Replace dev_err()->dev_err_probe(). Remove comma in the terminator entry for OF table. Drop a space in the terminator entry for ID table. Signed-off-by: Biju Das --- v3: * New patch. --- sound/soc/codecs/ak4642.c | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/sound/soc/codecs/ak4642.c b/sound/soc/codecs/ak4642.c index 2a8984c1fa9c..901014909c0f 100644 --- a/sound/soc/codecs/ak4642.c +++ b/sound/soc/codecs/ak4642.c @@ -633,13 +633,12 @@ static const struct i2c_device_id ak4642_i2c_id[]; static int ak4642_i2c_probe(struct i2c_client *i2c) { struct device *dev =3D &i2c->dev; - struct device_node *np =3D dev->of_node; const struct ak4642_drvdata *drvdata =3D NULL; struct regmap *regmap; struct ak4642_priv *priv; struct clk *mcko =3D NULL; =20 - if (np) { + if (dev_fwnode(dev)) { const struct of_device_id *of_id; =20 mcko =3D ak4642_of_parse_mcko(dev); @@ -655,10 +654,8 @@ static int ak4642_i2c_probe(struct i2c_client *i2c) drvdata =3D (const struct ak4642_drvdata *)id->driver_data; } =20 - if (!drvdata) { - dev_err(dev, "Unknown device type\n"); - return -EINVAL; - } + if (!drvdata) + return dev_err_probe(dev, -EINVAL, "Unknown device type\n"); =20 priv =3D devm_kzalloc(dev, sizeof(*priv), GFP_KERNEL); if (!priv) @@ -681,7 +678,7 @@ static const struct of_device_id ak4642_of_match[] =3D { { .compatible =3D "asahi-kasei,ak4642", .data =3D &ak4642_drvdata}, { .compatible =3D "asahi-kasei,ak4643", .data =3D &ak4643_drvdata}, { .compatible =3D "asahi-kasei,ak4648", .data =3D &ak4648_drvdata}, - {}, + {} }; MODULE_DEVICE_TABLE(of, ak4642_of_match); =20 @@ -689,7 +686,7 @@ static const struct i2c_device_id ak4642_i2c_id[] =3D { { "ak4642", (kernel_ulong_t)&ak4642_drvdata }, { "ak4643", (kernel_ulong_t)&ak4643_drvdata }, { "ak4648", (kernel_ulong_t)&ak4648_drvdata }, - { } + {} }; MODULE_DEVICE_TABLE(i2c, ak4642_i2c_id); =20 --=20 2.25.1 From nobody Mon Feb 9 09:18:11 2026 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 38454C83F2F for ; Thu, 31 Aug 2023 20:47:54 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1347452AbjHaUrw (ORCPT ); Thu, 31 Aug 2023 16:47:52 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59454 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1347445AbjHaUru (ORCPT ); Thu, 31 Aug 2023 16:47:50 -0400 Received: from relmlie6.idc.renesas.com (relmlor2.renesas.com [210.160.252.172]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 477AE1B0 for ; Thu, 31 Aug 2023 13:47:47 -0700 (PDT) X-IronPort-AV: E=Sophos;i="6.02,217,1688396400"; d="scan'208";a="178342519" Received: from unknown (HELO relmlir6.idc.renesas.com) ([10.200.68.152]) by relmlie6.idc.renesas.com with ESMTP; 01 Sep 2023 05:47:46 +0900 Received: from localhost.localdomain (unknown [10.226.92.179]) by relmlir6.idc.renesas.com (Postfix) with ESMTP id A0C594029216; Fri, 1 Sep 2023 05:47:43 +0900 (JST) From: Biju Das To: Jaroslav Kysela , Takashi Iwai Cc: Biju Das , Liam Girdwood , Mark Brown , =?UTF-8?q?Uwe=20Kleine-K=C3=B6nig?= , alsa-devel@alsa-project.org, linux-kernel@vger.kernel.org, Andy Shevchenko Subject: [PATCH v3 2/2] ASoC: ak4642: Simplify probe() Date: Thu, 31 Aug 2023 21:47:34 +0100 Message-Id: <20230831204734.104954-3-biju.das.jz@bp.renesas.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230831204734.104954-1-biju.das.jz@bp.renesas.com> References: <20230831204734.104954-1-biju.das.jz@bp.renesas.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" Simpilfy probe() by replacing of_device_get_match_data() and id lookup for retrieving match data by i2c_get_match_data(). Signed-off-by: Biju Das --- v2->v3: * Removing local variable np is handled in patch#1. v1->v2: * Removed forward declaration ak4642_of_match and ak4642_i2c_id. * Restored error EINVAL. * Used dev_fwnode() and replaced dev->of_node. * Removed comma in the terminator entry. --- sound/soc/codecs/ak4642.c | 15 ++------------- 1 file changed, 2 insertions(+), 13 deletions(-) diff --git a/sound/soc/codecs/ak4642.c b/sound/soc/codecs/ak4642.c index 901014909c0f..8a40c6b3f4d8 100644 --- a/sound/soc/codecs/ak4642.c +++ b/sound/soc/codecs/ak4642.c @@ -628,32 +628,21 @@ static struct clk *ak4642_of_parse_mcko(struct device= *dev) #define ak4642_of_parse_mcko(d) 0 #endif =20 -static const struct of_device_id ak4642_of_match[]; -static const struct i2c_device_id ak4642_i2c_id[]; static int ak4642_i2c_probe(struct i2c_client *i2c) { struct device *dev =3D &i2c->dev; - const struct ak4642_drvdata *drvdata =3D NULL; + const struct ak4642_drvdata *drvdata; struct regmap *regmap; struct ak4642_priv *priv; struct clk *mcko =3D NULL; =20 if (dev_fwnode(dev)) { - const struct of_device_id *of_id; - mcko =3D ak4642_of_parse_mcko(dev); if (IS_ERR(mcko)) mcko =3D NULL; - - of_id =3D of_match_device(ak4642_of_match, dev); - if (of_id) - drvdata =3D of_id->data; - } else { - const struct i2c_device_id *id =3D - i2c_match_id(ak4642_i2c_id, i2c); - drvdata =3D (const struct ak4642_drvdata *)id->driver_data; } =20 + drvdata =3D i2c_get_match_data(i2c); if (!drvdata) return dev_err_probe(dev, -EINVAL, "Unknown device type\n"); =20 --=20 2.25.1