Received: by 10.192.165.156 with SMTP id m28csp1233140imm; Mon, 16 Apr 2018 16:59:51 -0700 (PDT) X-Google-Smtp-Source: AIpwx4+mpz2YIQaC64C0nTYwnDVq7GXjQuDaoFiXqHS3JlwKS6bPj1XH2gbEh/kKrEl4IX9hNDq+ X-Received: by 10.99.37.70 with SMTP id l67mr14917801pgl.106.1523923191664; Mon, 16 Apr 2018 16:59:51 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1523923191; cv=none; d=google.com; s=arc-20160816; b=xe0Plz/7AxBVeQGLkV0LDHKe6I/WPlAObqJj8B/rAIUmlr2ok0S/CEExNREQ0Ca3V7 L/uDHrdpe7prDsV2WrWvrRt2YRNzhoaMEru6U+k+oEqCCnAKwy3/9KP8E0oBSP+q2Fox YF948LbDNs8DNNP6/HVN2lOEOd8FgbFtrdPHnwu4ygGAjp+jRE0Zxyi7Rq3ktDv4pt3m PpaFTJWt71e384s1G+uz41n76l1NymNIFblyLogrR0/6C9HBg31D5yc/qifwH3nop/ah 8adAkNT+bpw6C93zpHUtdnd7XoQv9O4oZceAQ9fkFqs3PATaQMRnr19aZTF4/hiNvgYk Nlug== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature:arc-authentication-results; bh=U18aBU2cY012rLM3UfQJyHe9XAnb1GGws6u2DOBFplA=; b=Tav7dWL8co4sRH9iK20mQgf7jcdQLWzhtk/bPhj8pxbE7mYwuepu7tdihF6nEI2kJk c5zeiGcpvXVh6YDkYAuZ41jwU9CyYXncO/WIc2FPTXFg/7hH4oh6maYEM5ThCNljyOSE 8ZwG6o8S2X5YtiFG1a/bpSD3VRZqWeEYPxw0oSy8ZzuwxyI3DS7+q4r2/GP+QVVfmmYp 9+rv6cqxyKgb6Lu6wxkdN77f4Umk50daCxppap9gQzu8D9RX09IKcfDE/GpipeOSMP8k 6epdTulDSC1ziy4zGAM5mgZK0XEMjxCBd043s5q3XdM/hTPzRxoPiTm0ZFs1TsidrHlS hI2g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=tw4LANWC; 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=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id g17si3642770pgv.372.2018.04.16.16.59.36; Mon, 16 Apr 2018 16:59:51 -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=@gmail.com header.s=20161025 header.b=tw4LANWC; 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=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751908AbeDPX62 (ORCPT + 99 others); Mon, 16 Apr 2018 19:58:28 -0400 Received: from mail-yb0-f196.google.com ([209.85.213.196]:37673 "EHLO mail-yb0-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751059AbeDPX60 (ORCPT ); Mon, 16 Apr 2018 19:58:26 -0400 Received: by mail-yb0-f196.google.com with SMTP id i13-v6so7733589ybl.4; Mon, 16 Apr 2018 16:58:25 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to:user-agent; bh=U18aBU2cY012rLM3UfQJyHe9XAnb1GGws6u2DOBFplA=; b=tw4LANWC4PvbhEuBunqteRg1KuVloht6n6CfCvVm74bPxqJO1SvqL9Jhj6xOI9DwgL ZCyELpjOF1eWU5jYGTmxERIyBi6xqJ+vkcJNp2CblNe+YD+MJ3okgCZJvHkkXxjQIvA0 IklW2juwmZZcSgP3F0w1qa5kZgy8wYYNSXHziKSYXV7ep67jLOSCjPwxDDMhEwmC7qN/ 08vLSmwSFuKqK3AJZWiwo3rY2nNQlGNJhIS38Bnz5m1u8OYdkX2fb6b17zCWRkIS8yYu 1OScH94F0OY2tBqErwe82ZH8jUfpaJqTl87MNj4b0gV0YjkvmHg0ub9R2lOIVDQIrY7E Qw4Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to:user-agent; bh=U18aBU2cY012rLM3UfQJyHe9XAnb1GGws6u2DOBFplA=; b=ic0Xtr6kGW9u/iseGZoqErI6iFmUxuUPDyFtDWFXrTay4O9pgKC1KIVNeSBTGyrspl bAYM3mNUq4n2VMbd7ELhfQ5YY2fLHoUj13b3iSiLmIL5uznehruez14vL6uf0gs4q81P CqtaT6bDPHgt7WXuT8uPK4RHJZ+IH2Et8BIAOtae+iGx9GeRMZw2OshBbtSQe+h3SA6S ctEOODk552+csx1NNPR/lzZNMh8dupmiGJq16UWYrl7Q9zEAwF6NvxXhaoeklG1a58D4 2PpUtyGt0ELNlSLfmbQr7cBQ9SijGMglQdVTB5fPDQKtfSOpq5rQlfBT1YwosXeLNv4h 0Aiw== X-Gm-Message-State: ALQs6tAzr9vXcHTZ827m7R6CakzAmH59JBU8rziHeoJ8pBkzZJaPnHhO tyQQeMztC0RYcjaJoMOOv5E= X-Received: by 2002:a25:778f:: with SMTP id s137-v6mr12847093ybc.509.1523923105267; Mon, 16 Apr 2018 16:58:25 -0700 (PDT) Received: from dtor-ws ([2620:0:1000:1511:8de6:27a8:ed13:2ef5]) by smtp.gmail.com with ESMTPSA id o9sm3661620ywm.75.2018.04.16.16.58.23 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 16 Apr 2018 16:58:24 -0700 (PDT) Date: Mon, 16 Apr 2018 16:58:21 -0700 From: Dmitry Torokhov To: Jonathan Cameron Cc: Eugen Hristev , ludovic.desroches@microchip.com, alexandre.belloni@bootlin.com, linux-arm-kernel@lists.infradead.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-iio@vger.kernel.org, linux-input@vger.kernel.org, nicolas.ferre@microchip.com, robh@kernel.org Subject: Re: [PATCH v3 06/11] iio: inkern: add module put/get on iio dev module when requesting channels Message-ID: <20180416235821.GF77055@dtor-ws> References: <1523350677-27106-1-git-send-email-eugen.hristev@microchip.com> <1523350677-27106-7-git-send-email-eugen.hristev@microchip.com> <20180415203321.1aaaf91e@archlinux> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20180415203321.1aaaf91e@archlinux> User-Agent: Mutt/1.9.2 (2017-12-15) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Sun, Apr 15, 2018 at 08:33:21PM +0100, Jonathan Cameron wrote: > On Tue, 10 Apr 2018 11:57:52 +0300 > Eugen Hristev wrote: > > > When requesting channels for a particular consumer device, > > besides requesting the device (incrementing the reference counter), also > > do it for the driver module of the iio dev. This will avoid the situation > > where the producer IIO device can be removed and the consumer is still > > present in the kernel. > > > > Signed-off-by: Eugen Hristev > > --- > > drivers/iio/inkern.c | 8 +++++++- > > 1 file changed, 7 insertions(+), 1 deletion(-) > > > > diff --git a/drivers/iio/inkern.c b/drivers/iio/inkern.c > > index ec98790..68d9b87 100644 > > --- a/drivers/iio/inkern.c > > +++ b/drivers/iio/inkern.c > > @@ -11,6 +11,7 @@ > > #include > > #include > > #include > > +#include > > > > #include > > #include "iio_core.h" > > @@ -152,6 +153,7 @@ static int __of_iio_channel_get(struct iio_channel *channel, > > if (index < 0) > > goto err_put; > > channel->channel = &indio_dev->channels[index]; > > + try_module_get(channel->indio_dev->driver_module); > > And if it fails? (the module we are trying to get is going away...) > > We should try and handle it I think. Be it by just erroring out of here. Even more, this has nothing to do with modules. A device can go away for any number of reasons (we unbind it manually via sysfs, we pull the USB plug from the host in case it is USB-connected device, we unload I2C adapter for the bus device resides on, we kick underlying PCI device) and we should be able to handle this in some fashion. Handling errors from reads and ignoring garbage is one of methods. FWIW this is a NACK from me. Thanks. -- Dmitry