From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-5.5 required=3.0 tests=BAYES_00,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS,USER_AGENT_SANE_2 autolearn=no autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 3E2F3C4361B for ; Sun, 13 Dec 2020 17:19:37 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id F3DED23380 for ; Sun, 13 Dec 2020 17:19:36 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2406374AbgLMRTV (ORCPT ); Sun, 13 Dec 2020 12:19:21 -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; > > +} > From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-5.5 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS, USER_AGENT_SANE_2 autolearn=no autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 71CA1C433FE for ; Sun, 13 Dec 2020 17:18:56 +0000 (UTC) Received: from merlin.infradead.org (merlin.infradead.org [205.233.59.134]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 3C96D21D95 for ; Sun, 13 Dec 2020 17:18:56 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 3C96D21D95 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=kernel.org Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=merlin.20170209; h=Sender:Content-Transfer-Encoding: Content-Type:Cc:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To:Message-ID: Subject:To:From:Date:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=msgYQ0DfUqT2SNVf+/ky4JjH4x5D0/ZtGBarIJWmDN4=; b=M38dI8dli9XX6aoeEWhDKCIea 0svwckc1n7bI2GH6qq/cJIyRUONtlp3FaNdvDMN/ssfA7gcY/3lwZVuX3cZA97h4siNpKuFixKO0P +sOKyk++b5pBJpZBNKoPeWrf71ykYaVo6kVC0Mjq+MLJoy2WcVSBw5Gy8F39k3QhzSukvrObGZOxa /STpcFip6konID9SM6zaoROvvBIg8+g2fDT9scUkJ7BSPhpziPOAv2U69dx4pLBk9I3IHf3D3xBys 4kI5GZEG0uKeXwSGhqU6n2s5PcVCucnKCIPhcRDsiaR2RMtqqgJxQ3CkXFaZltdDEDO7/4GdRf9dg auJWXcc3Q==; Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1koV0H-0004zP-2H; Sun, 13 Dec 2020 17:17:49 +0000 Received: from mail.kernel.org ([198.145.29.99]) by merlin.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1koV0E-0004yB-6x for linux-arm-kernel@lists.infradead.org; Sun, 13 Dec 2020 17:17:47 +0000 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 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 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20201213_121746_433679_6F60F916 X-CRM114-Status: GOOD ( 18.62 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: devicetree , Alexandre Belloni , Lars-Peter Clausen , linux-iio , Linux Kernel Mailing List , Peter Meerwald-Stadler , linux-arm Mailing List Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.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; > > +} > _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel