Received: by 2002:a05:7412:3784:b0:e2:908c:2ebd with SMTP id jk4csp1208768rdb; Mon, 2 Oct 2023 02:32:34 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEuiFsLMuU3g5alSVCdYm8MFPcsMN6PB0aY9ucmnFLBqwlqZJ1phHioi6NE/yn9BsIzLYae X-Received: by 2002:a05:6a00:2442:b0:690:449f:5e96 with SMTP id d2-20020a056a00244200b00690449f5e96mr9488551pfj.33.1696239153910; Mon, 02 Oct 2023 02:32:33 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1696239153; cv=none; d=google.com; s=arc-20160816; b=v6bRpMmxTW7NIY94vWNcdVfn/IhA6W+sMzsNiUibFFNJ/szfMu8Bz02xReefEQtf6J iXaBZA/FMUxV7FuaXnymYGY+3zbLiTn57JPKRQplAh3qJEFpJ1HqXeQcAc1IKXf2gl3D ELrKY/ox/bkYN8PdTR5KeyEFwJaxe5k72A/T6f5QWpwdYxAMVTdjJ07yUY+hmCZeqQKl 21F22OL4ZoyP9VGuKt4aF2dzqdlb/jIRjiHHN4KWxO+sba/xffK26LFpVRxCeqq1Facb +XoAhvYPGOsebGydBbNedECmo9X/oYYwykQMhFFmmkeT+bDRbsyZ1R/V0zUc5ucsGEuh +qVQ== 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 :organization:references:in-reply-to:message-id:subject:cc:to:from :date; bh=RvLGnBm45Qptotb7vr7JGsB89ThHoQurkUGV4CK1vWU=; fh=lUrXLF8Vzqr7+krox1pYVjqaW9pSjcVYYHAwx+wk4cU=; b=U2gBH2Y7NJdLdcmaUhrOoFPx7vz4PmPN09uzmYQ6gAES+6vkOXXV4psP5BXl+EXaLS HdkmHv7d/CLNwAYWhDbzXkSLd8I9IgvKYfOJBb/0KWrfpBtQiZPsPBjM4yFxPlvkM0UK 2CYR+r78VQUz95dwN7h44rX0XskcmVrMiJb4QsMlTZaF6ymBl48dGBeSj5Tux1P2+73/ 79lFojD7sYrRNbTHqWImnILHgR4eYtjvtgIBz0rX88pC2zkHcOOmCvEdLZ+WkpxfRrBB IBrzstVPNeCwlIHDQjZNNkjhf4sW+CfDO41YFN+Y//lNRLAX+vccP/28w7RVW/DA3uFK S3PA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:2 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=huawei.com Return-Path: Received: from agentk.vger.email (agentk.vger.email. [2620:137:e000::3:2]) by mx.google.com with ESMTPS id a193-20020a6390ca000000b005648d3f2031si7573382pge.362.2023.10.02.02.32.33 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 02 Oct 2023 02:32:33 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:2 as permitted sender) client-ip=2620:137:e000::3:2; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:2 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=huawei.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by agentk.vger.email (Postfix) with ESMTP id 8A4138090792; Mon, 2 Oct 2023 02:28:05 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at agentk.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236084AbjJBJ15 convert rfc822-to-8bit (ORCPT + 99 others); Mon, 2 Oct 2023 05:27:57 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45096 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236033AbjJBJ14 (ORCPT ); Mon, 2 Oct 2023 05:27:56 -0400 Received: from frasgout.his.huawei.com (frasgout.his.huawei.com [185.176.79.56]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0A2A183; Mon, 2 Oct 2023 02:27:52 -0700 (PDT) Received: from lhrpeml500005.china.huawei.com (unknown [172.18.147.207]) by frasgout.his.huawei.com (SkyGuard) with ESMTP id 4RzbDT4GGgz6K63t; Mon, 2 Oct 2023 17:26:17 +0800 (CST) Received: from localhost (10.202.227.76) by lhrpeml500005.china.huawei.com (7.191.163.240) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.31; Mon, 2 Oct 2023 10:27:46 +0100 Date: Mon, 2 Oct 2023 10:27:45 +0100 From: Jonathan Cameron To: =?ISO-8859-1?Q?Andr=E9?= Apitzsch CC: Jonathan Cameron , Lars-Peter Clausen , Andy Shevchenko , Biju Das , , Subject: Re: [PATCH] iio: magnetometer: ak8975: Fix 'Unexpected device' error Message-ID: <20231002102745.0000540b@Huawei.com> In-Reply-To: <20231001-ak_magnetometer-v1-1-09bf3b8798a3@apitzsch.eu> References: <20231001-ak_magnetometer-v1-1-09bf3b8798a3@apitzsch.eu> Organization: Huawei Technologies Research and Development (UK) Ltd. X-Mailer: Claws Mail 4.1.0 (GTK 3.24.33; x86_64-w64-mingw32) MIME-Version: 1.0 Content-Type: text/plain; charset="ISO-8859-1" Content-Transfer-Encoding: 8BIT X-Originating-IP: [10.202.227.76] X-ClientProxiedBy: lhrpeml500006.china.huawei.com (7.191.161.198) To lhrpeml500005.china.huawei.com (7.191.163.240) X-CFilter-Loop: Reflected X-Spam-Status: No, score=-0.8 required=5.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on agentk.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (agentk.vger.email [0.0.0.0]); Mon, 02 Oct 2023 02:28:05 -0700 (PDT) On Sun, 1 Oct 2023 18:09:56 +0200 Andr? Apitzsch wrote: > Explicity specify array indices to fix mapping between > asahi_compass_chipset and ak_def_array. > While at it, remove unneeded AKXXXX. > > Fixes: 4f9ea93afde1 ("iio: magnetometer: ak8975: Convert enum->pointer for data in the match tables") > Signed-off-by: Andr? Apitzsch > --- > drivers/iio/magnetometer/ak8975.c | 11 +++++------ > 1 file changed, 5 insertions(+), 6 deletions(-) > > diff --git a/drivers/iio/magnetometer/ak8975.c b/drivers/iio/magnetometer/ak8975.c > index 8cfceb007936..dd466c5fa621 100644 > --- a/drivers/iio/magnetometer/ak8975.c > +++ b/drivers/iio/magnetometer/ak8975.c > @@ -204,7 +204,6 @@ static long ak09912_raw_to_gauss(u16 data) > > /* Compatible Asahi Kasei Compass parts */ > enum asahi_compass_chipset { > - AKXXXX = 0, When we see this 'spacer' it is normally there to avoid a confusion between 'not defined' and set too the first element. So look at device_get_match_data() implementation and how we tell if it worked. That will return 0 if we have an AK8975 which is then detected as a failure to match. https://elixir.bootlin.com/linux/v6.6-rc3/source/drivers/iio/magnetometer/ak8975.c#L932 So we need the spacer until someone converts this driver to use pointers instead for both of and ACPI tables. I also don't like that the of path here is falling back to the i2c_device_id match. The data should be set in ak8975_of_match[] as well. Jonathan > AK8975, > AK8963, > AK09911, > @@ -248,7 +247,7 @@ struct ak_def { > }; > > static const struct ak_def ak_def_array[] = { > - { > + [AK8975] = { > .type = AK8975, > .raw_to_gauss = ak8975_raw_to_gauss, > .range = 4096, > @@ -273,7 +272,7 @@ static const struct ak_def ak_def_array[] = { > AK8975_REG_HYL, > AK8975_REG_HZL}, > }, > - { > + [AK8963] = { > .type = AK8963, > .raw_to_gauss = ak8963_09911_raw_to_gauss, > .range = 8190, > @@ -298,7 +297,7 @@ static const struct ak_def ak_def_array[] = { > AK8975_REG_HYL, > AK8975_REG_HZL}, > }, > - { > + [AK09911] = { > .type = AK09911, > .raw_to_gauss = ak8963_09911_raw_to_gauss, > .range = 8192, > @@ -323,7 +322,7 @@ static const struct ak_def ak_def_array[] = { > AK09912_REG_HYL, > AK09912_REG_HZL}, > }, > - { > + [AK09912] = { > .type = AK09912, > .raw_to_gauss = ak09912_raw_to_gauss, > .range = 32752, > @@ -348,7 +347,7 @@ static const struct ak_def ak_def_array[] = { > AK09912_REG_HYL, > AK09912_REG_HZL}, > }, > - { > + [AK09916] = { > .type = AK09916, > .raw_to_gauss = ak09912_raw_to_gauss, > .range = 32752, > > --- > base-commit: df964ce9ef9fea10cf131bf6bad8658fde7956f6 > change-id: 20231001-ak_magnetometer-b063098082dd > > Best regards,