Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1757157AbbDPJBt (ORCPT ); Thu, 16 Apr 2015 05:01:49 -0400 Received: from mga11.intel.com ([192.55.52.93]:44666 "EHLO mga11.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1757001AbbDPJBb (ORCPT ); Thu, 16 Apr 2015 05:01:31 -0400 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.11,586,1422950400"; d="scan'208";a="710065543" From: Robert Dolca To: linux-iio@vger.kernel.org, Jonathan Cameron Cc: linux-kernel@vger.kernel.org, Hartmut Knaack , Lars-Peter Clausen , Peter Meerwald , Robert Dolca , Denis CIOCCA Subject: [PATCH RFC 2/3] iio: Improve iio_trigger_register_with_dev to register trigger after device Date: Thu, 16 Apr 2015 12:01:07 +0300 Message-Id: <1429174868-11953-3-git-send-email-robert.dolca@intel.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1429174868-11953-1-git-send-email-robert.dolca@intel.com> References: <1429174868-11953-1-git-send-email-robert.dolca@intel.com> Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 2329 Lines: 74 Until now calling iio_trigger_register_with_dev after registering the IIO device added the trigger to the device's trigger list and saved a reference to the device in the trigger's struct but it did not create the symlink. In order to know if the device was registered or not this patch adds a flag in the dev_iio struct and checks it when iio_trigger_register_with_dev is called. Signed-off-by: Robert Dolca --- drivers/iio/industrialio-core.c | 4 ++++ drivers/iio/industrialio-trigger.c | 6 ++++++ include/linux/iio/iio.h | 1 + 3 files changed, 11 insertions(+) diff --git a/drivers/iio/industrialio-core.c b/drivers/iio/industrialio-core.c index 94bcd54..04862a4 100644 --- a/drivers/iio/industrialio-core.c +++ b/drivers/iio/industrialio-core.c @@ -1233,6 +1233,8 @@ int iio_device_register(struct iio_dev *indio_dev) goto error_cdev_del; } + indio_dev->registered = true; + return 0; error_cdev_del: cdev_del(&indio_dev->chrdev); @@ -1281,6 +1283,8 @@ void iio_device_unregister(struct iio_dev *indio_dev) mutex_unlock(&indio_dev->info_exist_lock); iio_buffer_free_sysfs_and_mask(indio_dev); + + indio_dev->registered = false; } EXPORT_SYMBOL(iio_device_unregister); diff --git a/drivers/iio/industrialio-trigger.c b/drivers/iio/industrialio-trigger.c index cebdd10..d4118fe 100644 --- a/drivers/iio/industrialio-trigger.c +++ b/drivers/iio/industrialio-trigger.c @@ -69,6 +69,12 @@ int iio_trigger_register_with_dev(struct iio_dev *indio_dev, trig_info->indio_dev = indio_dev; list_add(&trig_info->indio_dev_list, &indio_dev->triggers); + if (indio_dev->registered) { + ret = iio_trigger_link(trig_info); + if (ret < 0) + goto error; + } + return 0; error: return ret; diff --git a/include/linux/iio/iio.h b/include/linux/iio/iio.h index 9ff54ef..3f704ae 100644 --- a/include/linux/iio/iio.h +++ b/include/linux/iio/iio.h @@ -496,6 +496,7 @@ struct iio_dev { unsigned cached_reg_addr; #endif struct list_head triggers; + bool registered; }; const struct iio_chan_spec -- 1.9.1 -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/