From patchwork Mon Jul 17 13:48:06 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Biju Das X-Patchwork-Id: 13315802 X-Patchwork-Delegate: geert@linux-m68k.org 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 39425C001DF for ; Mon, 17 Jul 2023 13:48:18 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231330AbjGQNsR (ORCPT ); Mon, 17 Jul 2023 09:48:17 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54600 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231714AbjGQNsQ (ORCPT ); Mon, 17 Jul 2023 09:48:16 -0400 Received: from relmlie5.idc.renesas.com (relmlor1.renesas.com [210.160.252.171]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 11877A6; Mon, 17 Jul 2023 06:48:14 -0700 (PDT) X-IronPort-AV: E=Sophos;i="6.01,211,1684767600"; d="scan'208";a="169508546" Received: from unknown (HELO relmlir5.idc.renesas.com) ([10.200.68.151]) by relmlie5.idc.renesas.com with ESMTP; 17 Jul 2023 22:48:14 +0900 Received: from localhost.localdomain (unknown [10.226.92.210]) by relmlir5.idc.renesas.com (Postfix) with ESMTP id 95430400CF1C; Mon, 17 Jul 2023 22:48:12 +0900 (JST) From: Biju Das To: Peter Rosin Cc: Biju Das , Michael Hennerich , linux-i2c@vger.kernel.org, Geert Uytterhoeven , Prabhakar Mahadev Lad , linux-renesas-soc@vger.kernel.org Subject: [PATCH v2 1/2] i2c: mux: ltc4306: Simplify probe() Date: Mon, 17 Jul 2023 14:48:06 +0100 Message-Id: <20230717134807.265302-2-biju.das.jz@bp.renesas.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230717134807.265302-1-biju.das.jz@bp.renesas.com> References: <20230717134807.265302-1-biju.das.jz@bp.renesas.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-renesas-soc@vger.kernel.org The ltc4306_id[].driver_data could store a pointer to the chips, like for DT-based matching, making I2C and DT-based matching more similar. After that, we can simplify the probe() by replacing of_device_get_ match_data() and i2c_match_id() by i2c_get_match_data() as we have similar I2C and DT-based matching table. Signed-off-by: Biju Das Reviewed-by: Geert Uytterhoeven --- v1->v2: * Added Rb tag from Geert. --- drivers/i2c/muxes/i2c-mux-ltc4306.c | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/drivers/i2c/muxes/i2c-mux-ltc4306.c b/drivers/i2c/muxes/i2c-mux-ltc4306.c index 5a03031519be..c7dfd5eba413 100644 --- a/drivers/i2c/muxes/i2c-mux-ltc4306.c +++ b/drivers/i2c/muxes/i2c-mux-ltc4306.c @@ -192,8 +192,8 @@ static int ltc4306_deselect_mux(struct i2c_mux_core *muxc, u32 chan) } static const struct i2c_device_id ltc4306_id[] = { - { "ltc4305", ltc_4305 }, - { "ltc4306", ltc_4306 }, + { "ltc4305", .driver_data = (kernel_ulong_t)&chips[ltc_4305] }, + { "ltc4306", .driver_data = (kernel_ulong_t)&chips[ltc_4306] }, { } }; MODULE_DEVICE_TABLE(i2c, ltc4306_id); @@ -216,10 +216,9 @@ static int ltc4306_probe(struct i2c_client *client) unsigned int val = 0; int num, ret; - chip = of_device_get_match_data(&client->dev); - + chip = i2c_get_match_data(client); if (!chip) - chip = &chips[i2c_match_id(ltc4306_id, client)->driver_data]; + return -ENODEV; idle_disc = device_property_read_bool(&client->dev, "i2c-mux-idle-disconnect"); From patchwork Mon Jul 17 13:48:07 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Biju Das X-Patchwork-Id: 13315803 X-Patchwork-Delegate: geert@linux-m68k.org 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 04F6BEB64DC for ; Mon, 17 Jul 2023 13:48:21 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231750AbjGQNsU (ORCPT ); Mon, 17 Jul 2023 09:48:20 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54740 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231491AbjGQNsU (ORCPT ); Mon, 17 Jul 2023 09:48:20 -0400 Received: from relmlie6.idc.renesas.com (relmlor2.renesas.com [210.160.252.172]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 4FCBFFF; Mon, 17 Jul 2023 06:48:18 -0700 (PDT) X-IronPort-AV: E=Sophos;i="6.01,211,1684767600"; d="scan'208";a="173153396" Received: from unknown (HELO relmlir5.idc.renesas.com) ([10.200.68.151]) by relmlie6.idc.renesas.com with ESMTP; 17 Jul 2023 22:48:17 +0900 Received: from localhost.localdomain (unknown [10.226.92.210]) by relmlir5.idc.renesas.com (Postfix) with ESMTP id 598D7400CF1A; Mon, 17 Jul 2023 22:48:15 +0900 (JST) From: Biju Das To: Peter Rosin Cc: Biju Das , Michael Hennerich , linux-i2c@vger.kernel.org, Geert Uytterhoeven , Prabhakar Mahadev Lad , linux-renesas-soc@vger.kernel.org Subject: [PATCH v2 2/2] i2c: mux: ltc4306: Drop enum ltc_type and split chips[] Date: Mon, 17 Jul 2023 14:48:07 +0100 Message-Id: <20230717134807.265302-3-biju.das.jz@bp.renesas.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230717134807.265302-1-biju.das.jz@bp.renesas.com> References: <20230717134807.265302-1-biju.das.jz@bp.renesas.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-renesas-soc@vger.kernel.org Drop enum ltc_type and split the array chips[] as individual variables, and make lines shorter by referring to e.g. <c_4305_chip instead of &chips[ltc_4305]. Suggested-by: Geert Uytterhoeven Signed-off-by: Biju Das Reviewed-by: Andi Shyti --- v2: * New patch --- drivers/i2c/muxes/i2c-mux-ltc4306.c | 28 +++++++++++----------------- 1 file changed, 11 insertions(+), 17 deletions(-) diff --git a/drivers/i2c/muxes/i2c-mux-ltc4306.c b/drivers/i2c/muxes/i2c-mux-ltc4306.c index c7dfd5eba413..c4f090e8d6db 100644 --- a/drivers/i2c/muxes/i2c-mux-ltc4306.c +++ b/drivers/i2c/muxes/i2c-mux-ltc4306.c @@ -34,11 +34,6 @@ #define LTC_GPIO_ALL_INPUT 0xC0 #define LTC_SWITCH_MASK 0xF0 -enum ltc_type { - ltc_4305, - ltc_4306, -}; - struct chip_desc { u8 nchans; u8 num_gpios; @@ -50,14 +45,13 @@ struct ltc4306 { const struct chip_desc *chip; }; -static const struct chip_desc chips[] = { - [ltc_4305] = { - .nchans = LTC4305_MAX_NCHANS, - }, - [ltc_4306] = { - .nchans = LTC4306_MAX_NCHANS, - .num_gpios = 2, - }, +static const struct chip_desc ltc_4305_chip = { + .nchans = LTC4305_MAX_NCHANS +}; + +static const struct chip_desc ltc_4306_chip = { + .nchans = LTC4306_MAX_NCHANS, + .num_gpios = 2 }; static bool ltc4306_is_volatile_reg(struct device *dev, unsigned int reg) @@ -192,15 +186,15 @@ static int ltc4306_deselect_mux(struct i2c_mux_core *muxc, u32 chan) } static const struct i2c_device_id ltc4306_id[] = { - { "ltc4305", .driver_data = (kernel_ulong_t)&chips[ltc_4305] }, - { "ltc4306", .driver_data = (kernel_ulong_t)&chips[ltc_4306] }, + { "ltc4305", .driver_data = (kernel_ulong_t)<c_4305_chip }, + { "ltc4306", .driver_data = (kernel_ulong_t)<c_4306_chip }, { } }; MODULE_DEVICE_TABLE(i2c, ltc4306_id); static const struct of_device_id ltc4306_of_match[] = { - { .compatible = "lltc,ltc4305", .data = &chips[ltc_4305] }, - { .compatible = "lltc,ltc4306", .data = &chips[ltc_4306] }, + { .compatible = "lltc,ltc4305", .data = <c_4305_chip }, + { .compatible = "lltc,ltc4306", .data = <c_4306_chip }, { } }; MODULE_DEVICE_TABLE(of, ltc4306_of_match);