Received: by 2002:a25:6193:0:0:0:0:0 with SMTP id v141csp1455101ybb; Thu, 26 Mar 2020 00:45:14 -0700 (PDT) X-Google-Smtp-Source: ADFU+vs5JoCAccXQI55kblaYBIFKWTcakrN9bWtJ7F4lHa4vJwsyKOmruAH7i36L4i/6ASly3EyI X-Received: by 2002:aca:61d4:: with SMTP id v203mr981953oib.72.1585208714440; Thu, 26 Mar 2020 00:45:14 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1585208714; cv=none; d=google.com; s=arc-20160816; b=lObomOd0ry7pb74Nxiy8/d3HAY+1ylJShlxNhZcTTu9GUueJA4yJkg9SvudrhQW97q NPB14V+JTBK4lKOAvt/A4JgFutvr+Au62n19OsRhIEjOslPkq5OafKR6XzlRlkI/s51v k2BnuiMgWi5Hvrwi4ISSo9duRdUoNdQFfHz0FqpCtkG63dbwaH9daQodcvseDlPbIvIw U6z2SG1JboEX+H8JB3y6rKll93Y4+tH28jFe0AU8tTALnUPFM86xoHyahcdtKt2CYD4E 7WcCZcAiXfY3Qm51FHBYDQzKlmqMMChK4gy37jZcsrrN/ACyZuvZo+3GEROjEMn6mhVH Zzug== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-language :content-transfer-encoding:in-reply-to:mime-version:user-agent:date :message-id:from:references:cc:to:subject:dkim-signature; bh=7QaSOnUI/EJ9EDvESN5tQ9P5eS5ryHrNNO2QCFGCfgE=; b=TuQeVXSG2M4tf14iSXyXlQ+AnKEu0xZaENVKewT8m1HQJGjvvOc3Ny4oOJYv7DENcK bFwTFzdIIDTJfpYWq20wWaIn4vH099f06OBWpKkrWf5tMemtij4X+uyJ9d1IAKRH296C VhBWdFO8scTvh5fVdyouqfKqy2EDHthlKEPJZckW3r8j8JUyXa5pv2O11UXCTHc2tULd iNsC3zv+vS7BUH29dT++7cLk3jHqpUOTgyfgDngvKH4knx6kwnkrG3KZAGWw1NaPYN8C 1D1OF7Snbgajnwg7zdZzcliWkQL49x5se3oLzmxH+3g7HHDwMObBRkS/F4oVXH6y5H30 Im9Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@metafoo.de header.s=default2002 header.b=kIn+QipP; 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=fail (p=NONE sp=NONE dis=NONE) header.from=metafoo.de Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id e24si748016otq.2.2020.03.26.00.45.01; Thu, 26 Mar 2020 00:45:14 -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=fail header.i=@metafoo.de header.s=default2002 header.b=kIn+QipP; 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=fail (p=NONE sp=NONE dis=NONE) header.from=metafoo.de Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727647AbgCZHod (ORCPT + 99 others); Thu, 26 Mar 2020 03:44:33 -0400 Received: from www381.your-server.de ([78.46.137.84]:44578 "EHLO www381.your-server.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726138AbgCZHod (ORCPT ); Thu, 26 Mar 2020 03:44:33 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=metafoo.de; s=default2002; h=Content-Transfer-Encoding:Content-Type:In-Reply-To: MIME-Version:Date:Message-ID:From:References:Cc:To:Subject:Sender:Reply-To: Content-ID:Content-Description:Resent-Date:Resent-From:Resent-Sender: Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help:List-Unsubscribe: List-Subscribe:List-Post:List-Owner:List-Archive; bh=7QaSOnUI/EJ9EDvESN5tQ9P5eS5ryHrNNO2QCFGCfgE=; b=kIn+QipPmKOmt9KAXvkAPNMj+N nTaZfUZg/QRXeFcrZhVE6wy8BSDPN+0h1536BsnqNbvWn/Z2fSFULxf/smYkg2P5UX/Wkwut0Yjup e7ldLzIcwNvrfXrmMyyJZgrbXqLb+zpfHR4icixEcxKFtKO1z89ZctVm2/t1BnT+Kw85U2Cl3zWkN P2V9efiqkew0tyZNuTZbPvxtVDJT2N0AWZOyEGcVDJ3iF03oRXpKmFgF9IR17UCui3XLynZ52aQnV NQ8WmZ4P0Mj/Y1GtRodL/fNmPzCi0G940emMCpukffeFVKJiIFwmoVFDMJ1Slx+7cCZP6swK1tBbb /QqVNfag==; Received: from sslproxy01.your-server.de ([78.46.139.224]) by www381.your-server.de with esmtpsa (TLSv1.2:DHE-RSA-AES256-GCM-SHA384:256) (Exim 4.89_1) (envelope-from ) id 1jHNBk-0007A6-6o; Thu, 26 Mar 2020 08:44:28 +0100 Received: from [82.135.74.79] (helo=[192.168.178.20]) by sslproxy01.your-server.de with esmtpsa (TLSv1.3:TLS_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1jHNBj-000HsL-T0; Thu, 26 Mar 2020 08:44:27 +0100 Subject: Re: [PATCH v2] iio: buffer: Don't allow buffers without any channels enabled to be activated To: "Ardelean, Alexandru" , "andy.shevchenko@gmail.com" Cc: "pmeerw@pmeerw.ne" , "jic23@kernel.org" , "linux-kernel@vger.kernel.org" , "linux-iio@vger.kernel.org" , "knaack.h@gmx.de" References: <20200320104031.31701-1-alexandru.ardelean@analog.com> <20200325100112.85107-1-alexandru.ardelean@analog.com> <62b90724f16fa3a2c54b7e7f2321587a328d7209.camel@analog.com> From: Lars-Peter Clausen Message-ID: Date: Thu, 26 Mar 2020 08:44:27 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.6.0 MIME-Version: 1.0 In-Reply-To: <62b90724f16fa3a2c54b7e7f2321587a328d7209.camel@analog.com> Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit Content-Language: en-US X-Authenticated-Sender: lars@metafoo.de X-Virus-Scanned: Clear (ClamAV 0.102.2/25762/Wed Mar 25 14:09:24 2020) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 3/26/20 8:42 AM, Ardelean, Alexandru wrote: > On Wed, 2020-03-25 at 17:57 +0200, Andy Shevchenko wrote: >> [External] >> >> On Wed, Mar 25, 2020 at 12:02 PM Alexandru Ardelean >> wrote: >>> From: Lars-Peter Clausen >>> >>> Before activating a buffer make sure that at least one channel is enabled. >>> Activating a buffer with 0 channels enabled doesn't make too much sense and >>> disallowing this case makes sure that individual driver don't have to add >>> special case code to handle it. >>> >>> Currently, without this patch enabling a buffer is possible and no error is >>> produced. With this patch -EINVAL is returned. >>> >>> An example of execution with this patch and some instrumented print-code: >>> root@analog:~# cd /sys/bus/iio/devices/iio\:device3/buffer >>> root@analog:/sys/bus/iio/devices/iio:device3/buffer# echo 1 > enable >>> 0: iio_verify_update 748 indio_dev->masklength 2 *insert_buffer- >>>> scan_mask 00000000 >>> 1: iio_verify_update 753 >>> 2:__iio_update_buffers 1115 ret -22 >>> 3: iio_buffer_store_enable 1241 ret -22 >>> -bash: echo: write error: Invalid argument >>> 1, 2 & 3 are exit-error paths. 0 the first print in iio_verify_update() >>> rergardless of error path. >>> >>> Without this patch (and same instrumented print-code): >>> root@analog:~# cd /sys/bus/iio/devices/iio\:device3/buffer >>> root@analog:/sys/bus/iio/devices/iio:device3/buffer# echo 1 > enable >>> 0: iio_verify_update 748 indio_dev->masklength 2 *insert_buffer- >>>> scan_mask 00000000 >>> root@analog:/sys/bus/iio/devices/iio:device3/buffer# >>> Buffer is enabled with no error. >>> >>> Signed-off-by: Lars-Peter Clausen >>> Signed-off-by: Alexandru Ardelean >>> --- >>> >>> Changelog v1 -> v2: >>> * moved check in iio_verify_update() >>> * added dev_dbg() message; should help some folks understand the message >>> * documented steps to reproduce >>> * added Fixes tag; hopefully the tag is the good one; if needed, it can be >>> dropped; this has been around for ~8 years; no idea if it's worth >>> backporting >> Where? > stable/fixes/lts-kernels > don't have a really good clue about where these things need backporting; What Andy means is that there is no Fixes tag :)