From patchwork Sun Sep 17 15:01:03 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?b?TWljaGHFgiBNaXJvc8WCYXc=?= X-Patchwork-Id: 9954853 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id C15E96039A for ; Sun, 17 Sep 2017 15:01:14 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id AD37C28B02 for ; Sun, 17 Sep 2017 15:01:14 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id A24D028B04; Sun, 17 Sep 2017 15:01:14 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.0 required=2.0 tests=BAYES_00,DKIM_ADSP_ALL, DKIM_SIGNED, RCVD_IN_DNSWL_HI, T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 849DF28B0A for ; Sun, 17 Sep 2017 15:01:07 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751656AbdIQPBG (ORCPT ); Sun, 17 Sep 2017 11:01:06 -0400 Received: from 78-11-180-123.static.ip.netia.com.pl ([78.11.180.123]:60054 "EHLO rere.qmqm.pl" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1751632AbdIQPBE (ORCPT ); Sun, 17 Sep 2017 11:01:04 -0400 Received: from remote.user (localhost [127.0.0.1]) by rere.qmqm.pl (Postfix) with ESMTPSA id 3xwC4v1zNXz7b; Sun, 17 Sep 2017 17:01:03 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=rere.qmqm.pl; s=1; t=1505660463; bh=TCX7vBRQkF4wMElACsoiiTP4OKNSQJaoAYL7bjyeI5Q=; h=Date:In-Reply-To:References:From:Subject:To:Cc:From; b=XMm4YKpPTLw1wkgmtocAVbY/n0QKuUdfbo8Pe16XY3Ucm5L5vKhzOR1t9+4/Mf2mb Uw8H8/S8cTnbPqzvTFR5JaY09Yp3TlXplDIQ7ZJIBy3LQZj4JtQpu/sk37E1y6oP32 qHRlvUlOYmbuObempWdCrTs2qNiQ+woCr6DWP31iIeaFt3mcyqTqjN84WkA5zqKiZV qhxc0cWQ5HsY4CMggzBDYe/AKsjRXvBWiz07it88yBaN7cXn/0vjMEuWNl2rkn6mfJ 6xhCzrayq1duYeIj3xuvZR8ZP/CeVBE4wHPrDS4IV9EsOZ5X/jTKsBH67aAKfCGl/D 01Olpt8CzV2TA== X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.99.2 at rere Date: Sun, 17 Sep 2017 17:01:03 +0200 Message-Id: <081710b9deaff7273ba1c736e9a3db42dc0d1c93.1505660069.git.mirq-linux@rere.qmqm.pl> In-Reply-To: References: From: =?UTF-8?q?Micha=C5=82=20Miros=C5=82aw?= Subject: [PATCH v3 4/8] iio: accel: kxcjk1013: make sysfs/sampling_frequency_avail dynamic MIME-Version: 1.0 To: Jonathan Cameron , Srinivas Pandruvada Cc: linux-iio@vger.kernel.org, Hartmut Knaack , Lars-Peter Clausen , Peter Meerwald-Stadler Sender: linux-iio-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-iio@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP In preparation for KXTF9 support, make sampling_frequency_avail attribute dynamic. Signed-off-by: Michał Mirosław --- drivers/iio/accel/kxcjk-1013.c | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/drivers/iio/accel/kxcjk-1013.c b/drivers/iio/accel/kxcjk-1013.c index 3022bc951dc2..9b4f953c5782 100644 --- a/drivers/iio/accel/kxcjk-1013.c +++ b/drivers/iio/accel/kxcjk-1013.c @@ -155,6 +155,9 @@ static const struct kx_odr_map samp_freq_table[] = { { 1600, 0, 0x07, 0x06 }, }; +static const char *const kxcjk1013_samp_freq_avail = + "0.781000 1.563000 3.125000 6.250000 12.500000 25 50 100 200 400 800 1600"; + /* Refer to section 4 of the specification */ static const struct { int odr_bits; @@ -879,13 +882,19 @@ static int kxcjk1013_buffer_postdisable(struct iio_dev *indio_dev) return kxcjk1013_set_power_state(data, false); } -static IIO_CONST_ATTR_SAMP_FREQ_AVAIL( - "0.781000 1.563000 3.125000 6.250000 12.500000 25 50 100 200 400 800 1600"); +static ssize_t kxcjk1013_get_samp_freq_avail(struct device *dev, + struct device_attribute *attr, + char *buf) +{ + return sprintf(buf, "%s\n", kxcjk1013_samp_freq_avail); +} + +static IIO_DEV_ATTR_SAMP_FREQ_AVAIL(kxcjk1013_get_samp_freq_avail); static IIO_CONST_ATTR(in_accel_scale_available, "0.009582 0.019163 0.038326"); static struct attribute *kxcjk1013_attributes[] = { - &iio_const_attr_sampling_frequency_available.dev_attr.attr, + &iio_dev_attr_sampling_frequency_available.dev_attr.attr, &iio_const_attr_in_accel_scale_available.dev_attr.attr, NULL, };