Received: by 2002:a6b:fb09:0:0:0:0:0 with SMTP id h9csp2910341iog; Mon, 27 Jun 2022 05:35:06 -0700 (PDT) X-Google-Smtp-Source: AGRyM1u1nsr3T7FPO6VUvIBvC/66AD+ClgWQuVyuyjbr0eOTZrrgC4vwnihOLnce3LbB0NaiqdVk X-Received: by 2002:a05:6402:540c:b0:434:d965:f8a with SMTP id ev12-20020a056402540c00b00434d9650f8amr16485203edb.30.1656333306381; Mon, 27 Jun 2022 05:35:06 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1656333306; cv=none; d=google.com; s=arc-20160816; b=pzQm1owvLvfMLkIMal6zUHlLOKkCQYcIPDIXqSiRY1Xcn8N4Qj+S81FEtV5XMCOxDZ FEzUq1cqVKf6hqU+mZ0d4Uqk2UM7GxH27XepWRDF4luHqRiyqAjZRsuFpnOu2sHJMOml afeH+i6ZtNaI0JqVNtXq4gHw4/PBt9er1iJAmuKf1vLzJJItUDKHn409SkJQbDUWOf1Z c3WP1zcRx/UoMeaG634NGXlr5mljtipAykL6/3WfRBMe2vNntvlWt1w1IIxRto46SsjC +CtdaKrUq3pbwLfFvsqGsY4tKSorwidwwnShr4gOBc4yzgcKfC5fCyIjHb1yXL3rrOvA ViRA== 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 :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=Bmr+Xn/dX43cnt+ZyfOVkFnuJmTpHkFF28Na7PxoeeE=; b=kdUn1Q/D2txOHr0Iu/dZRVcApERbeV1ep9mFKj/TpwvZzAVWOTuRQFusd7W4mBwWfz 2CmCpTEK2eT8mrWQ/g7i5M8lh9xsefCrCLZqsr5cCUlP3hlZtB64dM+DaaZfO5ruuPBs FvE3coCKQluYXQ75apJe8xpM2stu3gjmQLUwX2dfleT3g/VkCd7WCqPe6jcB6f3DHqXQ QrimRLEWHrcdm6hM8EjXBMvpIQbRh2aE0ndZk3Zsq1gf8ax10aE1pJspbKvwUnofH9KH VkEk3t6FsE5Lz6yADycRyazlHBRoNG85too9yyFoHIflGDIaX6jm9VtggOYixBH8MtZy f1Gg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=uyUUAVIj; 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=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id v4-20020a170906380400b00722e5217355si8902200ejc.607.2022.06.27.05.34.41; Mon, 27 Jun 2022 05:35:06 -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; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=uyUUAVIj; 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=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239256AbiF0Lzi (ORCPT + 99 others); Mon, 27 Jun 2022 07:55:38 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50026 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238588AbiF0Lss (ORCPT ); Mon, 27 Jun 2022 07:48:48 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 707E2D100; Mon, 27 Jun 2022 04:42:37 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 02493611C9; Mon, 27 Jun 2022 11:42:37 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 0D350C3411D; Mon, 27 Jun 2022 11:42:35 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1656330156; bh=VS9xJwq5vrJSu3Sg10kO6/gABDXtsbDYzCr9Qs2oxFk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=uyUUAVIj5uazDOY8K5AdFQce5DJV9e08A7Jsk9kDjVScQb6QDfOR+9DU4jtCevsDM Q2g08cmJYFQkAthTP1FNziwcXtAFzn4qAdysO6+V2xQZR4U0crMhVyRUvEr6e23iYU e5Hs1EXa/A2SvN+9nM1QXbuSa4FAXYlzi02mENJw= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Haibo Chen , Jonathan Cameron , Sasha Levin Subject: [PATCH 5.18 104/181] iio: mma8452: fix probe fail when device tree compatible is used. Date: Mon, 27 Jun 2022 13:21:17 +0200 Message-Id: <20220627111947.715254494@linuxfoundation.org> X-Mailer: git-send-email 2.36.1 In-Reply-To: <20220627111944.553492442@linuxfoundation.org> References: <20220627111944.553492442@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-7.5 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE 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 From: Haibo Chen [ Upstream commit fe18894930a025617114aa8ca0adbf94d5bffe89 ] Correct the logic for the probe. First check of_match_table, if not meet, then check i2c_driver.id_table. If both not meet, then return fail. Fixes: a47ac019e7e8 ("iio: mma8452: Fix probe failing when an i2c_device_id is used") Signed-off-by: Haibo Chen Link: https://lore.kernel.org/r/1650876060-17577-1-git-send-email-haibo.chen@nxp.com Signed-off-by: Jonathan Cameron Signed-off-by: Sasha Levin --- drivers/iio/accel/mma8452.c | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/drivers/iio/accel/mma8452.c b/drivers/iio/accel/mma8452.c index 9c02c681c84c..4156d216c640 100644 --- a/drivers/iio/accel/mma8452.c +++ b/drivers/iio/accel/mma8452.c @@ -1556,11 +1556,13 @@ static int mma8452_probe(struct i2c_client *client, mutex_init(&data->lock); data->chip_info = device_get_match_data(&client->dev); - if (!data->chip_info && id) { - data->chip_info = &mma_chip_info_table[id->driver_data]; - } else { - dev_err(&client->dev, "unknown device model\n"); - return -ENODEV; + if (!data->chip_info) { + if (id) { + data->chip_info = &mma_chip_info_table[id->driver_data]; + } else { + dev_err(&client->dev, "unknown device model\n"); + return -ENODEV; + } } ret = iio_read_mount_matrix(&client->dev, &data->orientation); -- 2.35.1