From: Jonathan Cameron <jic23@kernel.org> To: Andy Shevchenko <andy.shevchenko@gmail.com> Cc: Alexandre Belloni <alexandre.belloni@bootlin.com>, Lars-Peter Clausen <lars@metafoo.de>, Peter Meerwald-Stadler <pmeerw@pmeerw.net>, linux-iio <linux-iio@vger.kernel.org>, devicetree <devicetree@vger.kernel.org>, linux-arm Mailing List <linux-arm-kernel@lists.infradead.org>, Linux Kernel Mailing List <linux-kernel@vger.kernel.org> Subject: Re: [PATCH 3/6] iio:pressure:ms5637: limit available sample frequencies Date: Sun, 13 Dec 2020 17:17:40 +0000 [thread overview] Message-ID: <20201213171740.66079670@archlinux> (raw) In-Reply-To: <CAHp75Vf7A7e4RC2_wjizsPiGn3EjSPhxq4RA2vSQ0BtKaU1T0Q@mail.gmail.com> On Sat, 12 Dec 2020 20:26:16 +0200 Andy Shevchenko <andy.shevchenko@gmail.com> wrote: > On Thu, Dec 10, 2020 at 2:03 AM Alexandre Belloni > <alexandre.belloni@bootlin.com> 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; > > +} >
WARNING: multiple messages have this Message-ID (diff)
From: Jonathan Cameron <jic23@kernel.org> To: Andy Shevchenko <andy.shevchenko@gmail.com> Cc: devicetree <devicetree@vger.kernel.org>, Alexandre Belloni <alexandre.belloni@bootlin.com>, Lars-Peter Clausen <lars@metafoo.de>, linux-iio <linux-iio@vger.kernel.org>, Linux Kernel Mailing List <linux-kernel@vger.kernel.org>, Peter Meerwald-Stadler <pmeerw@pmeerw.net>, linux-arm Mailing List <linux-arm-kernel@lists.infradead.org> Subject: Re: [PATCH 3/6] iio:pressure:ms5637: limit available sample frequencies Date: Sun, 13 Dec 2020 17:17:40 +0000 [thread overview] Message-ID: <20201213171740.66079670@archlinux> (raw) In-Reply-To: <CAHp75Vf7A7e4RC2_wjizsPiGn3EjSPhxq4RA2vSQ0BtKaU1T0Q@mail.gmail.com> On Sat, 12 Dec 2020 20:26:16 +0200 Andy Shevchenko <andy.shevchenko@gmail.com> wrote: > On Thu, Dec 10, 2020 at 2:03 AM Alexandre Belloni > <alexandre.belloni@bootlin.com> 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
next prev parent reply other threads:[~2020-12-13 17:19 UTC|newest] Thread overview: 34+ messages / expand[flat|nested] mbox.gz Atom feed top 2020-12-09 23:48 [PATCH 0/6] iio:pressure:ms5637: add ms5803 support Alexandre Belloni 2020-12-09 23:48 ` Alexandre Belloni 2020-12-09 23:48 ` [PATCH 1/6] iio:pressure:ms5637: switch to probe_new Alexandre Belloni 2020-12-09 23:48 ` Alexandre Belloni 2020-12-12 13:26 ` Andy Shevchenko 2020-12-12 13:26 ` Andy Shevchenko 2020-12-13 17:04 ` Jonathan Cameron 2020-12-13 17:04 ` Jonathan Cameron 2020-12-09 23:48 ` [PATCH 2/6] iio:pressure:ms5637: introduce hardware differentiation Alexandre Belloni 2020-12-09 23:48 ` Alexandre Belloni 2020-12-13 17:12 ` Jonathan Cameron 2020-12-13 17:12 ` Jonathan Cameron 2020-12-13 19:51 ` Alexandre Belloni 2020-12-13 19:51 ` Alexandre Belloni 2020-12-09 23:48 ` [PATCH 3/6] iio:pressure:ms5637: limit available sample frequencies Alexandre Belloni 2020-12-09 23:48 ` Alexandre Belloni 2020-12-12 18:26 ` Andy Shevchenko 2020-12-12 18:26 ` Andy Shevchenko 2020-12-13 17:17 ` Jonathan Cameron [this message] 2020-12-13 17:17 ` Jonathan Cameron 2020-12-09 23:48 ` [PATCH 4/6] iio:common:ms_sensors:ms_sensors_i2c: rework CRC calculation helper Alexandre Belloni 2020-12-09 23:48 ` Alexandre Belloni 2020-12-09 23:48 ` [PATCH 5/6] iio:common:ms_sensors:ms_sensors_i2c: add support for alternative PROM layout Alexandre Belloni 2020-12-09 23:48 ` Alexandre Belloni 2020-12-13 17:20 ` Jonathan Cameron 2020-12-13 17:20 ` Jonathan Cameron 2020-12-13 19:34 ` Alexandre Belloni 2020-12-13 19:34 ` Alexandre Belloni 2020-12-09 23:48 ` [PATCH 6/6] iio:pressure:ms5637: add ms5803 support Alexandre Belloni 2020-12-09 23:48 ` Alexandre Belloni 2020-12-11 3:34 ` Rob Herring 2020-12-11 3:34 ` Rob Herring 2020-12-11 8:08 ` Alexandre Belloni 2020-12-11 8:08 ` Alexandre Belloni
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=20201213171740.66079670@archlinux \ --to=jic23@kernel.org \ --cc=alexandre.belloni@bootlin.com \ --cc=andy.shevchenko@gmail.com \ --cc=devicetree@vger.kernel.org \ --cc=lars@metafoo.de \ --cc=linux-arm-kernel@lists.infradead.org \ --cc=linux-iio@vger.kernel.org \ --cc=linux-kernel@vger.kernel.org \ --cc=pmeerw@pmeerw.net \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: linkBe sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes, see mirroring instructions on how to clone and mirror all data and code used by this external index.