Received: by 2002:a05:7412:9886:b0:f7:18da:975a with SMTP id ji6csp1997365rdb; Mon, 18 Dec 2023 07:20:35 -0800 (PST) X-Google-Smtp-Source: AGHT+IEKNDll4RSi1zhwlaMjHYyzpgBOqBW9sSPWNt1PN9DDPhF1ESTPc3uz2dXxF4YXzYK/Ozoa X-Received: by 2002:aa7:da53:0:b0:553:74d9:b8eb with SMTP id w19-20020aa7da53000000b0055374d9b8ebmr856769eds.7.1702912835155; Mon, 18 Dec 2023 07:20:35 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1702912835; cv=pass; d=google.com; s=arc-20160816; b=GM9HcSIGRIUYG1mpq3CjEm+45vkgxlLgkOv4esrwRCewOSabx7UeI8odgqEgzzcZM2 XOJIpJ7xiNuByFvBWclGI6wcR3GjkFhG4U1dOml28hbgHsdOcLLYt8ZyYIUV6HNaxl5h XDirHTuAh4UviO6uCWEDbEhfBsQMJzDdXbaOqjgi5KcUihOoSErPZ/iiVL+SBQy3zZLD 0xLsweljJNxsGrfQ76B/v0J+sUXHrMNk68KUAVCEl4W/ko7oyIUxNPZBRkKokei+hZcq Usy82F/f5s8irEoyeWXIDaHTLtp8B1UFrj1BxNJnNTK9oFjwC5TK+HFrNL1mdMdhFPEo 8s7A== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=mime-version:list-unsubscribe:list-subscribe:list-id:precedence :content-transfer-encoding:in-reply-to:from:references:cc:to :content-language:subject:user-agent:date:message-id:dkim-signature; bh=xlxwZZlJ+QDnZbxD7tSKZfSZw3p5CPt1Pm0y9FXpjLY=; fh=jWy5KXccCSvXr5fAcY6benBeepmTZslNJHx1nbgfHXA=; b=zjtu9SUbLCmDBn9AvpM++KssnE5feFQAZA1XugEHUl35TzqjXBQlsk6lJtY5k5yG/K xLxaRhXUFacUnDMQTW9o9Uv/z9l/tVSfQK5opGu6GbU0U6a7qQ11hgliXEo2jNDlV80A VtxCO8FjBLmHrXF1VWRYIFRUmD/AANShLOc0qxzxCQRI6Fj1tlg6HjRfbJLdMoqvwAoE bxVqZvgrUJbDYdAXw/8qwnNTwvo98sI97bICXRHpD6q1805iSqsxrP8mqP7qIbkaAqYV uZeWzrfP2tu3K91rE6kPTNV79fKT0CkMwCjavVNQfxxWJnmvu5VYuYUOGQj6lweXnvRi MR/w== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@axis.com header.s=selector1 header.b=Lp7gmxsE; arc=pass (i=1 spf=pass spfdomain=axis.com dkim=pass dkdomain=axis.com dmarc=pass fromdomain=axis.com); spf=pass (google.com: domain of linux-kernel+bounces-3921-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-3921-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=axis.com Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [2604:1380:4601:e00::3]) by mx.google.com with ESMTPS id n8-20020a05640205c800b00550f51cd678si8669303edx.4.2023.12.18.07.20.35 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 18 Dec 2023 07:20:35 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-3921-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) client-ip=2604:1380:4601:e00::3; Authentication-Results: mx.google.com; dkim=pass header.i=@axis.com header.s=selector1 header.b=Lp7gmxsE; arc=pass (i=1 spf=pass spfdomain=axis.com dkim=pass dkdomain=axis.com dmarc=pass fromdomain=axis.com); spf=pass (google.com: domain of linux-kernel+bounces-3921-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-3921-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=axis.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by am.mirrors.kernel.org (Postfix) with ESMTPS id B8DDD1F2351B for ; Mon, 18 Dec 2023 15:20:34 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 2306D4FF66; Mon, 18 Dec 2023 15:19:27 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=axis.com header.i=@axis.com header.b="Lp7gmxsE" X-Original-To: linux-kernel@vger.kernel.org Received: from EUR04-HE1-obe.outbound.protection.outlook.com (mail-he1eur04on2074.outbound.protection.outlook.com [40.107.7.74]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 86EED42385; Mon, 18 Dec 2023 15:19:23 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=axis.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=axis.com ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=BTG67uu1PZlPFsBrPEWfCDPrYh8PzUCRLkFmJ9HE6GVhsYtaGWp0HtxoU2JJp3svTfGDa5cZ/j1D0+gIhsEgHt4HwH/yPM2FZcoc9YiQ3ve7uzODV5BGrHwwi0cyQFdc6coP9WWWiDiIwtJQOOG7OiDF7A0kX87WuW/bEzW0JZT4YscvlPsuXPbUjyfQHRcKLu9dYNY0Sg1Fng5R2qy8a8Vox1aI13Vc3EBGxLWpntjBL+jzuZGwYzNhU5p71uUchKPm9/op2K0Ouj7LCLsSJcwfvRPVP8q6zbcp/Fc7MA3YqTeBsu6/4mmCnDqewhEnkm7d33X1V1IEpZQ41Ubyqg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=xlxwZZlJ+QDnZbxD7tSKZfSZw3p5CPt1Pm0y9FXpjLY=; b=kU/NNp34cuk5O7oGDRYiFL8pdbJMA+jvLNwJ94MPyPevwnNrwVHfjO7BH85woOvSoxAwtFMJrH3ngsPUZZGfJtBKPkIVU9cPZlEh0iiDl44MrznBBYiSsAsjo0m5K59hqvpH45OMrYCilZ3KHLZkj2kA42jxVOlMWYy4q8NJVTJirDgOJy9QXsCEovhaoh9cEI1RI630s+sxjwnIDVRiZAvV31FITvcP4gYZRtTjEo0yFUdc+ZIjqtzYeEYy22Ajn1lnx6U00TfzK5U/maTmDbnABouQCriXJfNHwWI+NQpyF1ZxP4164MmMmgpVgjCKLeDbXsoGomMQ9xhedg7GOQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=axis.com; dmarc=pass action=none header.from=axis.com; dkim=pass header.d=axis.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=axis.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=xlxwZZlJ+QDnZbxD7tSKZfSZw3p5CPt1Pm0y9FXpjLY=; b=Lp7gmxsECp28qqjMHjk5TMCpjXDHasRNgnlvJwCzPDR2cSiBRUTomFBwSf1zkv97kGz1yeRKbaUox1JbwH1OnD96oTx+OgL/y7iscJD6yo5MyKEem2wyghCZcyEPzHHjfh40z1jk2HQVt6wXjzgMq3ksJZKbx3aSrS9UtjCB0L0= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=axis.com; Received: from AS8PR02MB9529.eurprd02.prod.outlook.com (2603:10a6:20b:5a5::16) by DB3PR0202MB9250.eurprd02.prod.outlook.com (2603:10a6:10:43b::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7091.37; Mon, 18 Dec 2023 15:19:20 +0000 Received: from AS8PR02MB9529.eurprd02.prod.outlook.com ([fe80::1bda:1dbf:c056:e09]) by AS8PR02MB9529.eurprd02.prod.outlook.com ([fe80::1bda:1dbf:c056:e09%7]) with mapi id 15.20.7091.034; Mon, 18 Dec 2023 15:19:20 +0000 Message-ID: <45bb38c9-63f9-101e-60e5-36037699f11e@axis.com> Date: Mon, 18 Dec 2023 16:19:19 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.15.1 Subject: Re: [PATCH 2/2] iio: light: vcnl4000: Add ps high definition for vcnl4040 Content-Language: en-US To: Jonathan Cameron Cc: Lars-Peter Clausen , linux-iio@vger.kernel.org, linux-kernel@vger.kernel.org, kernel@axis.com References: <20231212-vcnl4000-ps-hd-v1-0-1c62a95828c0@axis.com> <20231212-vcnl4000-ps-hd-v1-2-1c62a95828c0@axis.com> <20231217141554.04c8863d@jic23-huawei> From: =?UTF-8?Q?M=c3=a5rten_Lindahl?= In-Reply-To: <20231217141554.04c8863d@jic23-huawei> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit X-ClientProxiedBy: MM0P280CA0096.SWEP280.PROD.OUTLOOK.COM (2603:10a6:190:9::31) To AS8PR02MB9529.eurprd02.prod.outlook.com (2603:10a6:20b:5a5::16) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: AS8PR02MB9529:EE_|DB3PR0202MB9250:EE_ X-MS-Office365-Filtering-Correlation-Id: 74ba9ce4-b493-4215-0cc8-08dbffdcb557 X-LD-Processed: 78703d3c-b907-432f-b066-88f7af9ca3af,ExtAddr X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: DSoFWw3s+KO7btS+cNIBxDEo3YbZLNjKefPX+1+dCSamC+Ee0jbFyHyq7YlayBMVuZPSlQu6Tw6uiPcdG0WWG4QPRMeSiaPyo7RTfM543fGYF1BldLElZFHNu4aLi4bF9fG5WJM0FqTIVpoVX1X40jm2Q9WvPrwfc4hVFpqhDQCp/ffen9E2e+4IhoAKCHPBXMkG/K1AZr9zfMMNdlglq1AK0F3spTtDnHidlxH1Xnx65AuDoy0Vld4T4RiO9+ZtLYZnJ309lm3/xNFEHc21HQo1n0NE+hE2hmNo/pKHG3FYSgv5rVEgJz1GDg5IunAS0bYfNuRQkqCu0pMbR1nRDl9AK5gecAS65UHglqxpzoROr1SrHBttoN15ZBrZbFGZCHA77oiWFcmLTH3EaHWHaE4iG8RzSl15LN1cyzGPB6BWHb5/zKgsHPS+v9yDFWS/nrBh/xlloqiCD0HXOhjHLEF5UZvAMAaHZDFTaOQD3HFHluxv+ve7GodSvmy1p/0KsgO13fD+3QzHggSsPQQkWmSpNohits/F0ylK0aPowviomSIxZ82j5f1HC0epxYGRPWd43aqwOzjvX60CaEeO+Mw/OwPu4J4Ox7WLeebLIHdg7o8qzTj8hLwd7o7SKUaauc2KS86s1wdSD6OMtl/l9g== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:AS8PR02MB9529.eurprd02.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230031)(396003)(366004)(376002)(346002)(136003)(39850400004)(230922051799003)(64100799003)(1800799012)(451199024)(186009)(316002)(6916009)(66556008)(66946007)(4326008)(8676002)(8936002)(66476007)(31686004)(66574015)(2616005)(83380400001)(107886003)(26005)(38100700002)(5660300002)(41300700001)(31696002)(36756003)(53546011)(6506007)(6512007)(2906002)(478600001)(6486002)(45980500001)(43740500002);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-Chun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U29QQ0hyK3ZR?= =?utf-8?B?U0ZIUlRrM2pBL1RCUmhTdGFidVFGZnZlakVIUlV1SElTcGZIRXRyYUx2V3Ju?= =?utf-8?B?Y0Z1S1RNd1R5SEJxUkE4aWlVbUlNODRiQW9KWTJQcjhpcjFkanJGNlNXOHRT?= =?utf-8?B?b1Vna3lQSHpSYUNva3NjMysrd2k3Vjg3QklnVXFsdVlxdUUyOGZaQ1hlL2dB?= =?utf-8?B?RjVPMUxPMWNJb0ZkOGdZb0lnR2tyL1lOMDRIS2JGRWhDc2VkM3FEQUVONWdj?= =?utf-8?B?eE5lYTBBVzltQjIrdFFpTElvakYyVEtTNTFLQUxrbTRacEN6eVJJVDRvb2lP?= =?utf-8?B?UkxHQ21SdlRnOGNneTJlaXZONi9sTW9rRHNwS3lUOU9YbThXV3d2MVZPQjBn?= =?utf-8?Q?S33qRKBYgBS4YbPUd5Env5HtH?= X-OriginatorOrg: axis.com X-MS-Exchange-CrossTenant-Network-Message-Id: 74ba9ce4-b493-4215-0cc8-08dbffdcb557 X-MS-Exchange-CrossTenant-AuthSource: AS8PR02MB9529.eurprd02.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 18 Dec 2023 15:19:20.4395 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 78703d3c-b907-432f-b066-88f7af9ca3af X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: wWoV8FnSNaj2KB96wroCnRxkzhLNgn7EX/c1/qCqXRiiQRam1FjetO0/VlmbREGVNdCTBObWjsAkPfEY8AEmow== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DB3PR0202MB9250 On 12/17/23 15:15, Jonathan Cameron wrote: > On Fri, 15 Dec 2023 13:43:05 +0100 > Mårten Lindahl wrote: > >> The vcnl4040 proximity sensor defaults to 12 bit data resolution, but >> the chip also supports 16 bit data resolution, which is called proximity >> high definition (PS_HD). >> >> Add read/write attribute for proximity resolution, and read attribute >> for available proximity resolution values for the vcnl4040 chip. >> >> Signed-off-by: Mårten Lindahl Hi Jonathan! > I'll review this on basis the usecase is clear (see reply to cover letter) I'll skip this patch (see reply to cover letter comment) Your are right about the paired register manipulation. Better to read/write byte instead of word. Kind regards Mårten > > The manipulation of the CONF1 and CONF2 registers in a pair is rather odd given you > only want to change one bit here. > > Why is that done? >> --- >> drivers/iio/light/vcnl4000.c | 87 +++++++++++++++++++++++++++++++++++++++++++- >> 1 file changed, 85 insertions(+), 2 deletions(-) >> >> diff --git a/drivers/iio/light/vcnl4000.c b/drivers/iio/light/vcnl4000.c >> index fdf763a04b0b..2addff635b79 100644 >> --- a/drivers/iio/light/vcnl4000.c >> +++ b/drivers/iio/light/vcnl4000.c >> @@ -90,6 +90,7 @@ >> #define VCNL4040_PS_CONF1_PS_SHUTDOWN BIT(0) >> #define VCNL4040_PS_CONF2_PS_IT GENMASK(3, 1) /* Proximity integration time */ >> #define VCNL4040_CONF1_PS_PERS GENMASK(5, 4) /* Proximity interrupt persistence setting */ >> +#define VCNL4040_PS_CONF2_PS_HD BIT(11) /* Proximity high definition */ >> #define VCNL4040_PS_CONF2_PS_INT GENMASK(9, 8) /* Proximity interrupt mode */ >> #define VCNL4040_PS_CONF3_MPS GENMASK(6, 5) /* Proximity multi pulse number */ >> #define VCNL4040_PS_MS_LED_I GENMASK(10, 8) /* Proximity current */ >> @@ -170,6 +171,11 @@ static const int vcnl4040_ps_calibbias_ua[][2] = { >> {0, 200000}, >> }; >> >> +static const int vcnl4040_ps_resolutions[2] = { >> + 12, >> + 16 >> +}; >> + >> static const int vcnl4040_als_persistence[] = {1, 2, 4, 8}; >> static const int vcnl4040_ps_persistence[] = {1, 2, 3, 4}; >> static const int vcnl4040_ps_oversampling_ratio[] = {1, 2, 4, 8}; >> @@ -880,6 +886,54 @@ static ssize_t vcnl4040_write_ps_calibbias(struct vcnl4000_data *data, int val) >> return ret; >> } >> >> +static ssize_t vcnl4040_read_ps_resolution(struct vcnl4000_data *data, int *val, int *val2) >> +{ >> + int ret; >> + >> + ret = i2c_smbus_read_word_data(data->client, VCNL4200_PS_CONF1); > The field seems to be in PS_CONF2. So you are reading a word and I guess that > gets you two registers. Can we not do a byte read to get just CONF2? >> + if (ret < 0) >> + return ret; >> + >> + ret = FIELD_GET(VCNL4040_PS_CONF2_PS_HD, ret); >> + if (ret >= ARRAY_SIZE(vcnl4040_ps_resolutions)) >> + return -EINVAL; >> + >> + *val = vcnl4040_ps_resolutions[ret]; >> + *val2 = 0; >> + >> + return ret; >> +} >> + >> +static ssize_t vcnl4040_write_ps_resolution(struct vcnl4000_data *data, int val) >> +{ >> + unsigned int i; >> + int ret; >> + u16 regval; >> + >> + for (i = 0; i < ARRAY_SIZE(vcnl4040_ps_resolutions); i++) { >> + if (val == vcnl4040_ps_resolutions[i]) >> + break; >> + } >> + >> + if (i >= ARRAY_SIZE(vcnl4040_ps_resolutions)) >> + return -EINVAL; >> + >> + mutex_lock(&data->vcnl4000_lock); >> + >> + ret = i2c_smbus_read_word_data(data->client, VCNL4200_PS_CONF1); >> + if (ret < 0) >> + goto out_unlock; >> + >> + regval = (ret & ~VCNL4040_PS_CONF2_PS_HD); >> + regval |= FIELD_PREP(VCNL4040_PS_CONF2_PS_HD, i); >> + ret = i2c_smbus_write_word_data(data->client, VCNL4200_PS_CONF1, >> + regval); >> + >> +out_unlock: >> + mutex_unlock(&data->vcnl4000_lock); >> + return ret; >> +} > c),