Received: by 2002:a05:7412:8d08:b0:f9:2d0a:d759 with SMTP id bj8csp164177rdb; Sun, 17 Dec 2023 06:43:01 -0800 (PST) X-Google-Smtp-Source: AGHT+IHIsoAMqjVVP1dY8lPvk3ncdMfyp7W2ecOZeImhROB4Jl1u6f9DMESH5WSFGmEKTSb4xS98 X-Received: by 2002:a17:902:d509:b0:1d0:c0d3:5b8 with SMTP id b9-20020a170902d50900b001d0c0d305b8mr18062894plg.71.1702824181579; Sun, 17 Dec 2023 06:43:01 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1702824181; cv=none; d=google.com; s=arc-20160816; b=Rh9gUFD6oYwsYHe0vcJKy8J+1nvYkoB6lw4LxnHkZhw1xluYm/wamwo/x6nI0iCJX8 IS3MmYnrjfmPoY4I6dhalXymQAaT9oUr56OuUqnxnLH7ZcYGnPYGISVe3vp5GSJZTK9F umOUs8ETi0EXY07U8qMymW5BOhim9csZuMj/tzqUcHyn2ArOiA9FFeHiVqDJNbae0laE wAb4rc8Lh5Gx2l48/8Ye6/7xXrTpx/g2ZJWNUr+IWziTKDV0zTLmqjzqKPAjCW+jSnYR YM9md8z8SR7JxRYpadU4WMWMG0wskFNxrZw6T3mF1SmcxyUHXPFKlvHvfsJ0OkJJQRxJ Xdng== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :subject:cc:to:from:date:dkim-signature; bh=EpiMBUBChzu/+1QtfhQ6c0J3+468FwqWKhK75UHaQH4=; fh=Y4KR3L5aZukuZxws5E2cnuOwGDRy9ktlOjXgaGCPrGs=; b=heYjubKQgJV1QRPIwXxbPHbp180WTEeYOkSCXF+mL+hxllkdGFlCtZiYHvcvBBQH/l vTblj6IrxfA+jqKts1WGqqjiJ3rvYDM3cy4vFmgKS6BzqLVNpZOITKarcegg2cVe25+c ksIzvQxdfUebKx7RSrG/fvoYAFyesNx6n1LC99vH5iIHox4fBeLdD9nP0ujHc6NfsFt2 60+o2oM4ulDyqxFwizcD+vWn2UMOxH/wNZMgEi11XYxduVNE8YO80894YeoVHj4sUA5n lzG7i1uNqN8V5qfIOBA1EbcRTxsHTS1LVaCWdfwkXeZRUi81w5rTJa7Y0HGJwPi0zi1J lb/Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=DxvLuPbn; spf=pass (google.com: domain of linux-kernel+bounces-2649-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-2649-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [139.178.88.99]) by mx.google.com with ESMTPS id y13-20020a170902b48d00b001d067cf31c5si16303226plr.197.2023.12.17.06.43.01 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 17 Dec 2023 06:43:01 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-2649-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) client-ip=139.178.88.99; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=DxvLuPbn; spf=pass (google.com: domain of linux-kernel+bounces-2649-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-2649-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org 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 sv.mirrors.kernel.org (Postfix) with ESMTPS id E77A0283102 for ; Sun, 17 Dec 2023 14:41:05 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 6FBC644C77; Sun, 17 Dec 2023 14:40:55 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="DxvLuPbn" X-Original-To: linux-kernel@vger.kernel.org Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (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 96C8044397; Sun, 17 Dec 2023 14:40:54 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id E542BC433C7; Sun, 17 Dec 2023 14:40:50 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1702824054; bh=1khrOZaRj2KF8KpFgTKDYoPsimZYPVswOCKbdLmQpwY=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=DxvLuPbnfJwoxdOrjelMj4pfEOqdqcEL3QYH5XTvsHporeriDbMto9pqg0zGdRP0B emnsRwtQ+r1jwYQYtxHb+Bp+IZG82pahORO/Tyx5Z2zUMg1qM9Mcrsp1mzMsHFttyy TMFvMOQEu1fg2Bp83ZFg2DLIblnXbEa91e9KG3iq5XVIVhwT6JTY328hSIlDvSQV/l rxbTVgKtB26cWZwjMzVIBKaYwjpk+L41SissU7MI8F6fGqTidkdSBV9NKKr7f3C+Ji 19ykWo0ehINO0yYZ25+QBJcuCEO4gfC+Wv5JQns712jQiP0/CeQHRBxSLSYAwMqmdJ C5zFMc/RGdVHQ== Date: Sun, 17 Dec 2023 14:40:39 +0000 From: Jonathan Cameron To: Yauhen Kharuzhy Cc: linux-input@vger.kernel.org, linux-iio@vger.kernel.org, Srinivas Pandruvada , linux-kernel@vger.kernel.org, Jiri Kosina , Basavaraj Natikar Subject: Re: [PATCH] iio: hid-sensor-als: Don't stop probing at non-supported attribute Message-ID: <20231217144039.5c971685@jic23-huawei> In-Reply-To: <20231216114229.652020-1-jekhor@gmail.com> References: <20231216114229.652020-1-jekhor@gmail.com> X-Mailer: Claws Mail 4.2.0 (GTK 3.24.38; x86_64-pc-linux-gnu) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit On Sat, 16 Dec 2023 13:42:29 +0200 Yauhen Kharuzhy wrote: > Some ambient light sensors don't support color temperature and > chromaticity attributes. The driver stops probing if it finds this. > > To support sensors without of color temperature and chromaticity > attributes, just skip them at probing if they weren't found. > > Tested at Lenovo Yogabook YB1-X91L tablet. > > Signed-off-by: Yauhen Kharuzhy i reviewed this one as as well as Srinivas' as that had issues that need solving. This one just seems to half paper over the problem It won't update the channels etc but the set of channels provided to userspace are still garbage. So better than before, but not fixing the issue fully. Jonathan > --- > drivers/iio/light/hid-sensor-als.c | 39 ++++++++++++++++++------------ > 1 file changed, 23 insertions(+), 16 deletions(-) > > diff --git a/drivers/iio/light/hid-sensor-als.c b/drivers/iio/light/hid-sensor-als.c > index f17304b54468..b711bac3bb2b 100644 > --- a/drivers/iio/light/hid-sensor-als.c > +++ b/drivers/iio/light/hid-sensor-als.c > @@ -314,8 +314,11 @@ static int als_parse_report(struct platform_device *pdev, > usage_id, > HID_USAGE_SENSOR_LIGHT_ILLUM, > &st->als[i]); > - if (ret < 0) > + if (ret < 0) { > + dev_err(&pdev->dev, > + "Failed to setup Illuminance attribute\n"); > return ret; > + } Unrelated change. For a fix we should look to keep things minimal. > als_adjust_channel_bit_mask(channels, i, st->als[i].size); > > dev_dbg(&pdev->dev, "als %x:%x\n", st->als[i].index, > @@ -326,14 +329,16 @@ static int als_parse_report(struct platform_device *pdev, > usage_id, > HID_USAGE_SENSOR_LIGHT_COLOR_TEMPERATURE, > &st->als[CHANNEL_SCAN_INDEX_COLOR_TEMP]); > - if (ret < 0) > - return ret; > - als_adjust_channel_bit_mask(channels, CHANNEL_SCAN_INDEX_COLOR_TEMP, > - st->als[CHANNEL_SCAN_INDEX_COLOR_TEMP].size); > + if (!ret) { > + dev_info(&pdev->dev, "Color temperature is supported\n"); I'd argue we shouldn't print a message on this. Use the availability of channels after driver is probed to figure this out if needed. > + als_adjust_channel_bit_mask(channels, > + CHANNEL_SCAN_INDEX_COLOR_TEMP, > + st->als[CHANNEL_SCAN_INDEX_COLOR_TEMP].size); > > - dev_dbg(&pdev->dev, "als %x:%x\n", > - st->als[CHANNEL_SCAN_INDEX_COLOR_TEMP].index, > - st->als[CHANNEL_SCAN_INDEX_COLOR_TEMP].report_id); > + dev_dbg(&pdev->dev, "als %x:%x\n", > + st->als[CHANNEL_SCAN_INDEX_COLOR_TEMP].index, > + st->als[CHANNEL_SCAN_INDEX_COLOR_TEMP].report_id); > + } > > for (i = 0; i < 2; i++) { > int next_scan_index = CHANNEL_SCAN_INDEX_CHROMATICITY_X + i; > @@ -342,23 +347,25 @@ static int als_parse_report(struct platform_device *pdev, > HID_INPUT_REPORT, usage_id, > HID_USAGE_SENSOR_LIGHT_CHROMATICITY_X + i, > &st->als[next_scan_index]); > - if (ret < 0) > - return ret; > - > - als_adjust_channel_bit_mask(channels, > + if (!ret) { > + dev_info(&pdev->dev, > + "Light chromaticity %c is supported\n", > + i ? 'Y' : 'X'); > + als_adjust_channel_bit_mask(channels, > CHANNEL_SCAN_INDEX_CHROMATICITY_X + i, > st->als[next_scan_index].size); > > - dev_dbg(&pdev->dev, "als %x:%x\n", > - st->als[next_scan_index].index, > - st->als[next_scan_index].report_id); > + dev_dbg(&pdev->dev, "als %x:%x\n", > + st->als[next_scan_index].index, > + st->als[next_scan_index].report_id); > + } > } > > st->scale_precision = hid_sensor_format_scale(usage_id, > &st->als[CHANNEL_SCAN_INDEX_INTENSITY], > &st->scale_pre_decml, &st->scale_post_decml); > > - return ret; > + return 0; > } > > /* Function to initialize the processing for usage id */