Received: by 2002:a05:6a10:f347:0:0:0:0 with SMTP id d7csp2543204pxu; Mon, 14 Dec 2020 05:23:24 -0800 (PST) X-Google-Smtp-Source: ABdhPJyWNJNoIhE4cBHHgg9Rr6/KZaG6ZnjQDWX4ASUZcCxnsLFxd5oShEkbeWAX+yYPQzHWcuov X-Received: by 2002:a17:906:6713:: with SMTP id a19mr23116745ejp.468.1607952203838; Mon, 14 Dec 2020 05:23:23 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1607952203; cv=none; d=google.com; s=arc-20160816; b=K+m2ajJihbUJifejkK0zGly6Bbd+GcCsFdquAFywRBZZFAqY9lG2FxBdudkmkZhzYH L7uII41M2AC7qJxtgElkI93qfWBo/HzSTScAOCdJUrHap+HGI6d20K/vJ99/PqNtc8D1 ox/Q2uKmP16vVcpyBm7C5AMNPGDzXWOp574Gf9c7WbTWMKfFJfW8JqNDWQAb0LrZLYxA 1FbIoXxL+lI/3ItOCc+I0RaiKDP4NSuXAgCM670b+pPyuxxX4hJA8oPZ7T14qudHEoZw mlmtUs+/RqL3i4WVRcjVM49nlIyX2rW/FHNC0QjgEBkScqNaUu1jQJMl1m22RqFNwK92 fUsA== 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 :references:in-reply-to:message-id:subject:cc:to:from:date; bh=Rj2hdkIhp4x6ihU89DZf75tXV+A/IV/qDBQzvSiptac=; b=Tj/9GEG7qjPoQq8irhwCRc8LGfKnyF1UuiofxreV9mZYEIM7Ittwj/QMc+mmgxC0L1 7grgRQU8GxhpxvWLelkCeDMGSoGJKlmHmyK6XaNQIHEmuLgZ4xBF/ns+TAWc+HkCpq5i xtveIraU2ta0pLGN85yii4a+tp6ciLD4xdLliUw2z+ajR4jbiTfFgoAGopMYTvLNqGVk 0q7ed4n43Jqzz6vjeTWE/sNQZFvi0LP/UabNNBMOV6HYEIesta5YaZTkFg9Y3nNCnv6b N3qZANSu30yToFjaa+etGi8UKzylMSLxGUXXHqAkoAg1M8Z/vG3O7hFkYidbuT4WshEg eiHg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id y12si3408146ejq.432.2020.12.14.05.22.58; Mon, 14 Dec 2020 05:23:23 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2406273AbgLMRTQ (ORCPT + 99 others); Sun, 13 Dec 2020 12:19:16 -0500 Received: from mail.kernel.org ([198.145.29.99]:38586 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2405500AbgLMRSZ (ORCPT ); Sun, 13 Dec 2020 12:18:25 -0500 Received: from archlinux (cpc108967-cmbg20-2-0-cust86.5-4.cable.virginm.net [81.101.6.87]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id C3A582313B; Sun, 13 Dec 2020 17:17:43 +0000 (UTC) Date: Sun, 13 Dec 2020 17:17:40 +0000 From: Jonathan Cameron To: Andy Shevchenko Cc: Alexandre Belloni , Lars-Peter Clausen , Peter Meerwald-Stadler , linux-iio , devicetree , linux-arm Mailing List , Linux Kernel Mailing List Subject: Re: [PATCH 3/6] iio:pressure:ms5637: limit available sample frequencies Message-ID: <20201213171740.66079670@archlinux> In-Reply-To: References: <20201209234857.1521453-1-alexandre.belloni@bootlin.com> <20201209234857.1521453-4-alexandre.belloni@bootlin.com> X-Mailer: Claws Mail 3.17.8 (GTK+ 2.24.32; x86_64-pc-linux-gnu) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Sat, 12 Dec 2020 20:26:16 +0200 Andy Shevchenko wrote: > On Thu, Dec 10, 2020 at 2:03 AM Alexandre Belloni > wrote: > > > > Avoid exposing all the sampling frequencies for chip that only support a > > subset. > > > +static ssize_t ms5637_show_samp_freq(struct device *dev, struct device_attribute *attr, char *buf) > > +{ > > + struct iio_dev *indio_dev = dev_to_iio_dev(dev); > > + struct ms_tp_dev *dev_data = iio_priv(indio_dev); > > + int i, len = 0; > > + > > + for (i = 0; i <= dev_data->hw->max_res_index; i++) > > + len += scnprintf(buf + len, PAGE_SIZE - len, "%u ", ms5637_samp_freq[i]); > > Doesn't IIO core have a helper? read_avail() callback and matching masks provide the infrastructure to do this. It's not a huge saving in code by the time you've wired it up, but has the advantage that consumer drivers can get hold of the values. Mind you I'm not sure what consumers we are likely to get for pressure drivers any time soon. > Also, it's better to use sysfs_emit(). New one to me. Thanks. sysfs_emit_at() here I guess. Nice. Jonathan > > > + buf[len - 1] = '\n'; > > + > > + return len; > > +} >