Received: by 2002:a25:6193:0:0:0:0:0 with SMTP id v141csp5238835ybb; Tue, 24 Mar 2020 13:30:32 -0700 (PDT) X-Google-Smtp-Source: ADFU+vuS79rziqYZgG8R/YKQ+KZYGAWTJlgeUbESuXdrcB8JnySsUrUH2X60I0VWS4uDT/BQnyfT X-Received: by 2002:a4a:3150:: with SMTP id v16mr51937oog.71.1585081832190; Tue, 24 Mar 2020 13:30:32 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1585081832; cv=none; d=google.com; s=arc-20160816; b=DP/9CarqoOj75l2pA/UC5dbSodQ9Uwts0rAmUFnSlYfKhj926juCPdFpvUUqW1z7Ym C8UEQaL0iDVDX/frfs8AFXJlTMRjX7bRPX4u0hBWtspuiuQRo4eRKCq1ce2UPeE5l+Ad Nkn8fHfC40IN7w2NOv8ZF2wZ+9XTzx94kRGd0sqNMzX4NwedJ5Xiar2Tm6MJLuPDIntN +qlj0pr6oSEx6oogfmAHQKCchYgQgC1GJxSogvDfzIwj9u1+j8hDx3JZyocmOOjNLioC rRLvE5UutTUG99oOLF2f12ie2sAuIC7+4S9b9zA/3cNB6Ndgb9D1wpxveqTiuNY7fCre iMZg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=ZigHEZ9wEtW9T2r5IUfNO5JfwDcLltP6YCkvQNLzMZg=; b=G+Fyq+ryTaTWTBTt9gi7DsO2njg4Eh8OUsUtsXWvewyHJncFtBhw3spTKKlR2CJhMT f/T/dGtBHupZ6Yejc2ZvBC0CKzUON+kJcsbIeuNtsW9WOot7pFeRU4rbm+YrHcjdn79J rVJJ3PvYjYNhAsPPHqO8jQIvqlHvniOgB8Cx8ZC6kpnpuuzsQ1uVZqXO3KpK+4w4rsqf DuMq0mEYR75oF/7v1MtyN44GcgCLNwg/prXsjDVDKndxqmHoGGh8dWSp9MA46ltGgvjr vFcYHnBNnnBb1S5Pzcyr0fsEdn+wIOQEaddHJabO4Jee3Tf7FbOq8+ni+d9spHhzSmx0 FSLQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=EEj5rKgf; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id v130si9616254oib.115.2020.03.24.13.30.16; Tue, 24 Mar 2020 13:30:32 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=EEj5rKgf; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728322AbgCXU2Y (ORCPT + 99 others); Tue, 24 Mar 2020 16:28:24 -0400 Received: from mail-pf1-f196.google.com ([209.85.210.196]:39143 "EHLO mail-pf1-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727910AbgCXU1x (ORCPT ); Tue, 24 Mar 2020 16:27:53 -0400 Received: by mail-pf1-f196.google.com with SMTP id d25so9886167pfn.6 for ; Tue, 24 Mar 2020 13:27:52 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=ZigHEZ9wEtW9T2r5IUfNO5JfwDcLltP6YCkvQNLzMZg=; b=EEj5rKgfO0GiydsW11KRCtfxlT6VWJWdckQbFJAHocKf9zxE4sh7bI+ssRJReWY5z+ NxlCQ7c95xJJJHBpzr4JznrxpF1Ugd+4ZaUHlfueHs3/NwQBCrXZ6lWOrabQWVYc+cB3 NxO81PWs+9IL3pXbOF6sghze+pvWw45GjQCIE= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=ZigHEZ9wEtW9T2r5IUfNO5JfwDcLltP6YCkvQNLzMZg=; b=kl0KUXDvTbiiEq6aRnf0+5WDglgfO2/S0w3UXJDZD7opc106a39wLFEvpdWS7RR2EV h0zaMWA/Dzbm0lKzO8JEcLQDRTrN2FAwlyQMSTrFl1JvrPDox2Je5mJfbEmz+VSri4At PmFoLuJA75VDrs2CUz27uc4SCxhs7ILDaCelKIpHQof7D+pwyJj2/xygVQIXmXo68Zoi Ezq32iDdwZXgvHWP4QC5kUu1+BR94AX64R6/HyielwLk5IkUWUZlCGbJM5msAjpHfkNb ZSmT62XtYTUETuViojuSsAn8XEc7DwCtJ2w5WtCDbrFcx5sZyN719uBuiw/P0OXsgZ6v QTmw== X-Gm-Message-State: ANhLgQ0a0oSJ+pQjduMPtgQxsHq6sVKaevQuXMNT4xJwP7/Xf5fS+oEY mfkRJB1BgK+DARXHBzb0gRttaA== X-Received: by 2002:a63:4f0c:: with SMTP id d12mr26233420pgb.199.1585081672376; Tue, 24 Mar 2020 13:27:52 -0700 (PDT) Received: from localhost ([2620:15c:202:1:4cc0:7eee:97c9:3c1a]) by smtp.gmail.com with ESMTPSA id o33sm2993992pje.19.2020.03.24.13.27.51 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Tue, 24 Mar 2020 13:27:51 -0700 (PDT) From: Gwendal Grignou To: bleung@chromium.org, enric.balletbo@collabora.com, Jonathan.Cameron@huawei.com Cc: linux-iio@vger.kernel.org, linux-kernel@vger.kernel.org, Gwendal Grignou Subject: [PATCH v6 05/11] iio: expose iio_device_set_clock Date: Tue, 24 Mar 2020 13:27:30 -0700 Message-Id: <20200324202736.243314-6-gwendal@chromium.org> X-Mailer: git-send-email 2.25.1.696.g5e7596f4ac-goog In-Reply-To: <20200324202736.243314-1-gwendal@chromium.org> References: <20200324202736.243314-1-gwendal@chromium.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Some IIO devices may want to override the default (realtime) to another clock source by default. It can beneficial when timestamps coming from the hardware or underlying drivers are already in that format. It can always be overridden by attribute current_timestamp_clock. Reviewed-by: Jonathan Cameron Signed-off-by: Gwendal Grignou --- Changes in v6: - No changes. Changes in v5: - New in v5. drivers/iio/industrialio-core.c | 8 +++++++- include/linux/iio/iio.h | 2 ++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/drivers/iio/industrialio-core.c b/drivers/iio/industrialio-core.c index 65ff0d0670188..26e963483bab0 100644 --- a/drivers/iio/industrialio-core.c +++ b/drivers/iio/industrialio-core.c @@ -189,7 +189,12 @@ ssize_t iio_read_const_attr(struct device *dev, } EXPORT_SYMBOL(iio_read_const_attr); -static int iio_device_set_clock(struct iio_dev *indio_dev, clockid_t clock_id) +/** + * iio_device_set_clock() - Set current timestamping clock for the device + * @indio_dev: IIO device structure containing the device + * @clock_id: timestamping clock posix identifier to set. + */ +int iio_device_set_clock(struct iio_dev *indio_dev, clockid_t clock_id) { int ret; const struct iio_event_interface *ev_int = indio_dev->event_interface; @@ -207,6 +212,7 @@ static int iio_device_set_clock(struct iio_dev *indio_dev, clockid_t clock_id) return 0; } +EXPORT_SYMBOL(iio_device_set_clock); /** * iio_get_time_ns() - utility function to get a time stamp for events etc diff --git a/include/linux/iio/iio.h b/include/linux/iio/iio.h index 862ce0019eba5..b18f34a8901f3 100644 --- a/include/linux/iio/iio.h +++ b/include/linux/iio/iio.h @@ -627,6 +627,8 @@ static inline clockid_t iio_device_get_clock(const struct iio_dev *indio_dev) return indio_dev->clock_id; } +int iio_device_set_clock(struct iio_dev *indio_dev, clockid_t clock_id); + /** * dev_to_iio_dev() - Get IIO device struct from a device struct * @dev: The device embedded in the IIO device -- 2.25.1.696.g5e7596f4ac-goog