Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp1909539pxb; Fri, 5 Feb 2021 04:43:58 -0800 (PST) X-Google-Smtp-Source: ABdhPJzjL+c26vaVYG2Zho+LMlPRB0a3SNCagBUX3kZepB0dWs3rw+TkzDzjfRknhDHLgnuKKMYe X-Received: by 2002:aa7:c3c4:: with SMTP id l4mr3282132edr.255.1612529038483; Fri, 05 Feb 2021 04:43:58 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1612529038; cv=none; d=google.com; s=arc-20160816; b=GtUNB7Bs4mJC1Z+Hl50RXwxEGVwk0T2Skazp0HUppr0ZrjJ7nMACjxVBV861UvMO9q RvODXmzCv0cOxsAATnwhYt43ru/nJvkSCYrT1WM52KCxqsWUATi3iPBtSqKfmHXsA/Ai HBzocCzjzSKtqe2Whhq5/TERpdom5wWBoYqD981MwcZDXdR9naYrnDUKqxlyWbStv29Q c10ZBmmnKHaZlYXHJ+zKZytmlQW8D2mZ263nvG7bTcYC76oF2fJ4l5xqdPUYD49p+IMh nD6LsrYEwDgpkRTkXvi56HU8Qp6YPRDthy4YVJXB/orbreMUjyWIEcQZiY557ckFQ8v9 VMQw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :organization:references:in-reply-to:message-id:subject:cc:to:from :date; bh=DTAmbNFlzjy4uz+psSrPmDckSMQdF/yDS97hkkgmJvA=; b=UcaMD+vpbb3TBmmjla6Jw3Lxfmrpwu/sBK0mKD6iNN3C1fz2IN6MdsEh82oO5OjbVZ yrptmspnA647Oy4T28ASUIs7eLyvNk1z5euYjOZuJzDxuHlrUp58x5PfiY8oke0byN8x yBNvVWZtn2J4woEGKQfj/rzbHyVj22YL7wrGwYKzPTeDpz6z+32jHQBVvpJTjAbf5qzZ PcVvKs4voS2eN8A7B/SwukWetDzVob/UOkXVxbjpveNsASubxoVaq4CpKfl63TtZCFjK tMeNsI7Qf6zAOzNZ3iTMpzIb2CtZ/DmB0TerT6QKK6j+UJBxXPa/RNDQaDOeyTKE4JfU CMVA== ARC-Authentication-Results: i=1; mx.google.com; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id j23si5458633eje.347.2021.02.05.04.43.31; Fri, 05 Feb 2021 04:43:58 -0800 (PST) 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; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232139AbhBEMki (ORCPT + 99 others); Fri, 5 Feb 2021 07:40:38 -0500 Received: from frasgout.his.huawei.com ([185.176.79.56]:2507 "EHLO frasgout.his.huawei.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231934AbhBEMfY (ORCPT ); Fri, 5 Feb 2021 07:35:24 -0500 Received: from fraeml704-chm.china.huawei.com (unknown [172.18.147.201]) by frasgout.his.huawei.com (SkyGuard) with ESMTP id 4DXF9c4xztz67kls; Fri, 5 Feb 2021 20:29:56 +0800 (CST) Received: from lhreml710-chm.china.huawei.com (10.201.108.61) by fraeml704-chm.china.huawei.com (10.206.15.53) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.2106.2; Fri, 5 Feb 2021 13:34:40 +0100 Received: from localhost (10.47.29.206) by lhreml710-chm.china.huawei.com (10.201.108.61) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2106.2; Fri, 5 Feb 2021 12:34:40 +0000 Date: Fri, 5 Feb 2021 12:33:55 +0000 From: Jonathan Cameron To: Alexandru Ardelean CC: Alexandru Ardelean , LKML , linux-iio , Lars-Peter Clausen , "Hennerich, Michael" , Jonathan Cameron , Nuno =?ISO-8859-1?Q?S=E1?= , "Bogdan, Dragos" , "Rafael J. Wysocki" , "Greg Kroah-Hartman" Subject: Re: [PATCH v3 05/11] iio: buffer: group attr count and attr alloc Message-ID: <20210205123355.00006e06@Huawei.com> In-Reply-To: References: <20210201145105.20459-1-alexandru.ardelean@analog.com> <20210201145105.20459-6-alexandru.ardelean@analog.com> <20210204174942.000013b3@Huawei.com> Organization: Huawei Technologies Research and Development (UK) Ltd. X-Mailer: Claws Mail 3.17.4 (GTK+ 2.24.32; i686-w64-mingw32) MIME-Version: 1.0 Content-Type: text/plain; charset="US-ASCII" Content-Transfer-Encoding: 7bit X-Originating-IP: [10.47.29.206] X-ClientProxiedBy: lhreml726-chm.china.huawei.com (10.201.108.77) To lhreml710-chm.china.huawei.com (10.201.108.61) X-CFilter-Loop: Reflected Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org > > > > > > + attr = kcalloc(buffer_attrcount + ARRAY_SIZE(iio_buffer_attrs) + 1, > > > + sizeof(struct attribute *), GFP_KERNEL); > > > + if (!attr) { > > > + ret = -ENOMEM; > > > + goto error_free_scan_mask; > > > + } > > > + > > > + memcpy(attr, iio_buffer_attrs, sizeof(iio_buffer_attrs)); > > > + if (!buffer->access->set_length) > > > + attr[0] = &dev_attr_length_ro.attr; > > > + > > > + if (buffer->access->flags & INDIO_BUFFER_FLAG_FIXED_WATERMARK) > > > + attr[2] = &dev_attr_watermark_ro.attr; > > > > Again a comment for the future rather than now, but when we are copying > > 4 items and then looking at whether to change 2 of them it might be cleaner > > to just set them directly! Touch of bit rot here :) > > So, I've been on-and-off about how to deal with this one. > I wanted to clean it in various ways using new kernel sysfs APIs. > Maybe, also remove the readonly variants and use the is_visible() > property to set RO/RW modes. > But I also came to the conclusion that this is an idea to address later. > Trying to address this early-on confused me with other overlapping changes. Absolutely agree. It's not something to do in this series. Jonathan