Received: by 2002:a6b:fb09:0:0:0:0:0 with SMTP id h9csp2901929iog; Mon, 27 Jun 2022 05:25:03 -0700 (PDT) X-Google-Smtp-Source: AGRyM1sa+jlMkOBfYZpIIOdlwSxDkU+viFBAHf1kFgzpuWfTIfN2BQ7z0swKp2Wk/2q4025Sb3kL X-Received: by 2002:aa7:999a:0:b0:525:6023:8c03 with SMTP id k26-20020aa7999a000000b0052560238c03mr14654489pfh.86.1656332703427; Mon, 27 Jun 2022 05:25:03 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1656332703; cv=none; d=google.com; s=arc-20160816; b=h7/I9wXqPThxUZj4x7uPqyoIn+C4aF4qKjvMZQkcRev50XF4xL/5C3s8WbUENSRbgQ LhA8xnkpUic+d2VT+exlBe46L2zOyXJW3Pw4ppLr3ALQ5PitXHAkPMf/C3gZHmFGse8h m5noEVz8+sAbFSbOT9j1dWuiUqPA8Hr+1em4SmhnEYLGaadefkk6d7CQErpkONBFHM0U L8Mxly0TWy9CJvb71wHK/H6ILo7ggb644QcRpjmd5iTlFM+w2Aa0aSkpdk9g+FGRomFE o/5mgrkg3kE/ig1TgcIZwRObROs/MsPPEAfguuQ8WEfrO/KKsnXVRPgBA7K606JnJqDW bZbQ== 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=HiDie9+T9fY4S+9nsSOe2LVeCPR5LNNSwxGYzsZJmSM=; b=xTPrMVOI/739L33c/KzCKOqXPSHfCQcVvH26ZR7uZ0YZ0QA4m5xuk2i/HTzo8+59YB ByPKZwOH+uM1YAGmPZCQHve7UvurHejmA6Vmpe9aXwZmL6TzgKV1GAWsm9t4UKVkp2k8 nWdB59PdtFoW/rWZSkSrgyHgjlyPX7qS0fqX07v2wPK0t/uAB0tSCLNcpMfM3C4jCw5x hefQmvdBUzAHa/QGszzENz68WjrOzneFbyFpmEOKv2t1p+bYqQouUwcnznOl/bJFpC3R Jy2OtbFQ8bxtLFVvoDW+j7ckWD62XmqZ42WetfJybubT5SMo6E4pzlRfDhmkSNrAjGuw zfNw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=nIT9RDDo; 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 7-20020a630807000000b0040c74303959si13392112pgi.67.2022.06.27.05.24.51; Mon, 27 Jun 2022 05:25:03 -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=nIT9RDDo; 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 S234911AbiF0L0q (ORCPT + 99 others); Mon, 27 Jun 2022 07:26:46 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45340 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234886AbiF0LZv (ORCPT ); Mon, 27 Jun 2022 07:25:51 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 89AC1658C; Mon, 27 Jun 2022 04:25:40 -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 245CD61456; Mon, 27 Jun 2022 11:25:40 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id D8E6EC36AEF; Mon, 27 Jun 2022 11:25:38 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1656329139; bh=Jj2MpJhgOYgpnYmCUyynlb6JE4n+GizxYB1VAY7mPs4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=nIT9RDDoMZEPYWNHUc2acrmNg6TNaDgnEKJPfalKmulfsNQ2Mxr6otQhbD0CBksog bb3JV1f7WbzsyvPL+o/ivEoxcNUKSu2ju3FdZFk6Gh1OiOXQHhBujvfeYatfbGknNh DQvqd4phGH3va8onRx7nekA+cffAYwR4qomClfjA= 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.10 063/102] iio: mma8452: fix probe fail when device tree compatible is used. Date: Mon, 27 Jun 2022 13:21:14 +0200 Message-Id: <20220627111935.341374641@linuxfoundation.org> X-Mailer: git-send-email 2.36.1 In-Reply-To: <20220627111933.455024953@linuxfoundation.org> References: <20220627111933.455024953@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 e7e280282774..67463be797de 100644 --- a/drivers/iio/accel/mma8452.c +++ b/drivers/iio/accel/mma8452.c @@ -1542,11 +1542,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; + } } data->vdd_reg = devm_regulator_get(&client->dev, "vdd"); -- 2.35.1