Received: by 2002:a25:1985:0:0:0:0:0 with SMTP id 127csp2768673ybz; Sun, 3 May 2020 08:52:56 -0700 (PDT) X-Google-Smtp-Source: APiQypLUyWQFJNpLJRiWmFv2iRdTMgm/6HSmeyhZFqNeGcWxA1SCN3oW8SfA7hjRQKslwbmCjdiv X-Received: by 2002:a17:907:2069:: with SMTP id qp9mr11916845ejb.137.1588521175807; Sun, 03 May 2020 08:52:55 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1588521175; cv=none; d=google.com; s=arc-20160816; b=dr3QcvRO0zo0QhBDCkR1ca3nuwS92T96Lx+uK4Qdi/PRvS2+OHd514wock0oLuZBCI lRrhwe802t+hSREQUrbyzk9rp4scC+Jo9ZGL8yelKnslvWfWN1bfC2JiadT6JjgLYV0T t8W+sYzHWKbflfaPiPlA2Z2n3WZCx8LZUeIRfxZfw5LLO0HULPQ3OkeINcl8ubdoS8PX ltpmGmoHXsRCPohb7ElaB5SrnuKlt1EZckASzwpBXiehbtXnLmX6qfnVwsYi0L2tz5UI qnWRIOk5bZqmqzMW1keFiWCJA78YVNSmHGKe4EAR3fy+EiD5P9+7aCnyPnZV9C5GChNr o6bg== 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:subject:cc:to:from:date :dkim-signature; bh=RAp5EPmF5qRE4wRiVgsYHmwlqO+l9Badsb3+gxVOI78=; b=ynm2zMlrAzS5DoT+a6zVQUCXTfCRAY4XzClEN7TAALEQA+lEuPSamL22psGJI05XM5 yfsa7Wtyo0v+KSa0vpRJdOGxtwgyHk3oWqASIRHSPcJLS+LXdAAnvvMrDpvQ4bcID71C +y1l1PFMpDQjPIhAlW5bydsLrd25biuDugsP5pZwZVBr+ZRVhTLvbIXuX6c+R1jKmnqV wiSNYWriOMHgpWQj/RcmdPvcoyFsQoQA3g1rISKIvH9h+7ij6Apfb1sqi8gQFizYJF/j /vdrbl+V6vFHKmz/V4e/cAluKHXMN8B0p1YNXYEW3Gf/42ShTOckk+EAPTFtCLEeEZxm K4sQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=hiDzOyLI; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id g16si5084851ejf.272.2020.05.03.08.52.32; Sun, 03 May 2020 08:52:55 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=hiDzOyLI; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728813AbgECPvL (ORCPT + 99 others); Sun, 3 May 2020 11:51:11 -0400 Received: from mail.kernel.org ([198.145.29.99]:33354 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728207AbgECPvL (ORCPT ); Sun, 3 May 2020 11:51:11 -0400 Received: from archlinux (cpc149474-cmbg20-2-0-cust94.5-4.cable.virginm.net [82.4.196.95]) (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 584EF206EB; Sun, 3 May 2020 15:51:09 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1588521070; bh=MoYkt8nJNSYHxeNV4ctvv8LFowIxDvxKKgf3MIzhfcA=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=hiDzOyLI23KoKwV6kZszpJJDvJURTVrqGvMNbf4WeHS9st6i18dVI0EmLTcd7qFMN lrSXhUvBnf1DfoNUqWa9SubjBBBoc0eHDY0Sg6eJnfL76eudfLBhuwfBi6Wa+fh/FI 1aMoaOElwL6H9giB6XBPqUh9U6Cluvorc7Dp9QJU= Date: Sun, 3 May 2020 16:51:05 +0100 From: Jonathan Cameron To: Alexandru Ardelean Cc: , , , Subject: Re: [PATCH v6 0/6] iio: core,buffer: re-organize chardev creation Message-ID: <20200503165105.74047af8@archlinux> In-Reply-To: <20200427131100.50845-1-alexandru.ardelean@analog.com> References: <20200427131100.50845-1-alexandru.ardelean@analog.com> X-Mailer: Claws Mail 3.17.5 (GTK+ 2.24.32; x86_64-pc-linux-gnu) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, 27 Apr 2020 16:10:54 +0300 Alexandru Ardelean wrote: > The main intent is to be able to add more chardevs per IIO device, one > for each buffer. To get there, some rework is needed. > This tries to re-organize the init of the chardev. Hmm. I'd like this set to sit and ideally gather a few acks before I move ahead with it. The protections against problems around remove have always been somewhat fiddly and I suspect don't cover everything. I'm fairly sure taking the exist lock is 'sufficient' but I'm not actually sure it's necessary. We only otherwise take it for place where the inkern interface is in use so we can race against removal of a provider driver. We don't have such heavy weight protections in the buffer code and I'll be honest I can't remember why. Original patch mentions that it was about avoiding taking additional new references to the struct iio_dev. We aren't doing that as such here so perhaps we don't need to take the lock.. Lars, I suspect you may have been involved in that stuff originally so I'd appreciate you taking a quick look at this if you have time! Thanks, Jonathan > > > Changelog v5 -> v6: > - patch 'iio: core: register chardev only if needed' > - sort file_operations fields for iio_event_fileops > - patch 'iio: buffer,event: duplicate chardev creation for buffers & events' > - fixed-up '**/' -> '*/' for 2 block comments > - sorted file_operations for iio_buffer_fileops, after move > - removed 'indio_dev->chrdev = NULL' on IIO device unregister > - added comment about 'indio_dev->info' NULL check in > iio_device_event_ioctl() > - patch 'iio: core: add simple centralized mechanism for ioctl() handlers' > - re-using lock 'indio_dev->info_exist_lock' for new ioctl register > mechanism in iio_device_ioctl() > - simplified exit condition from the loop; only need to check > `ret != IIO_IOCTL_UNHANDLED` to continue looping; > everything else is just return/break > - patch 'iio: core: use new common ioctl() mechanism' > - the comment for 'indio_dev->info' NULL check is being moved here to > highlight why the null-check is being removed; or where it's being > moved > > Changelog v4 -> v5: > - dropped patch 'iio: Use an early return in iio_device_alloc to simplify code.' > is applied upstream > > Changelog v3 -> v4: > - added patch [1] 'iio: Use an early return in iio_device_alloc to simplify code.' > it's main purpose is so that this patch applies: > [2]'iio: core: add simple centralized mechanism for ioctl() handlers' > depending on the final version of patch [1], patch [2] needs some > minor fixup > - added patch 'iio: core,buffer: wrap iio_buffer_put() call into iio_buffers_put()' > - patch 'iio: core: register buffer fileops only if buffer present' > is now: 'iio: core: register chardev only if needed' > - dropped 'iio: buffer: move sysfs alloc/free in industrialio-buffer.c' > it's likely we won't be doing this patch anymore > - patches: > 'iio: buffer: move iio buffer chrdev in industrialio-buffer.c' > 'iio: event: move event-only chardev in industrialio-event.c' > have been merged into 'iio: buffer,event: duplicate chardev creation for buffers & events' > since now, the logic is a bit different, and 'indio_dev->chrdev' is > now a reference to either the buffer's chrdev & or the events-only > chrdev > - added simple mechanism to register ioctl() handlers for IIO device > which is currently used only by events mechanism > > Changelog v2 -> v3: > * removed double init in > 'iio: event: move event-only chardev in industrialio-event.c' > > Changelog v1 -> v2: > * re-reviewed some exit-paths and cleanup some potential leaks on those > exit paths: > - for 'iio: buffer: move iio buffer chrdev in industrialio-buffer.c' > add iio_device_buffers_put() helper and calling iio_buffers_uninit() > on device un-regsiter > - for 'move sysfs alloc/free in industrialio-buffer.c' > call 'iio_buffer_free_sysfs_and_mask()' on exit path if > cdev_device_add() fails > - for 'move event-only chardev in industrialio-event.c' > check if event_interface is NULL in > iio_device_unregister_event_chrdev() > > Alexandru Ardelean (6): > iio: buffer: add back-ref from iio_buffer to iio_dev > iio: core,buffer: wrap iio_buffer_put() call into iio_buffers_put() > iio: core: register chardev only if needed > iio: buffer,event: duplicate chardev creation for buffers & events > iio: core: add simple centralized mechanism for ioctl() handlers > iio: core: use new common ioctl() mechanism > > drivers/iio/iio_core.h | 29 +++++--- > drivers/iio/industrialio-buffer.c | 102 ++++++++++++++++++++++++-- > drivers/iio/industrialio-core.c | 116 +++++++++++++----------------- > drivers/iio/industrialio-event.c | 100 +++++++++++++++++++++++++- > include/linux/iio/buffer_impl.h | 10 +++ > include/linux/iio/iio.h | 8 +-- > 6 files changed, 276 insertions(+), 89 deletions(-) >