Received: by 2002:a05:6358:16cd:b0:dc:6189:e246 with SMTP id r13csp1061804rwl; Fri, 4 Nov 2022 09:19:38 -0700 (PDT) X-Google-Smtp-Source: AMsMyM7HNG8c9c/q7APtANtmpHCZ8lhcQl8rtbZOKIKNsMQK6hLXZN4WA0DVrs2o8xip/P1MiArP X-Received: by 2002:a17:90a:cb03:b0:214:219:b2b9 with SMTP id z3-20020a17090acb0300b002140219b2b9mr23352104pjt.191.1667578778445; Fri, 04 Nov 2022 09:19:38 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1667578778; cv=none; d=google.com; s=arc-20160816; b=lsZ/L1ZPrXXxkN94yxi902e6LyXWeEQI80BVW/X5I6Db1NJb3DWjE8yGZ4G7wHc77V b7KSqwoPJT3aKIkPVKCA8jyv6skC55ssX4r0OBvLNdikLkjfRGCJ80dBKUImlWE4HoMU 37suWdHuQ35GooWxsqGBPJHsP9WtqNzwj8ZK2UMixYk8Z0VAgZOn66U9zcppbtR5xqoQ CDRPkTQgD0dOjEzfA6WCmx0ALCitwmacJCa76Kfv5YuXmzSjTFLugA0H2mxzoovb297a Z1V4krkAnpFlFYd5yEOCzPYN2g8Igfo8IkLfQMdSoLLedVh68O9cbJMW/7odfzb3ZVBa pAAA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to:from :references:cc:to:content-language:subject:user-agent:mime-version :date:message-id:dkim-signature; bh=6NoSX3BVV3kiCbJwtR4l3s5YnE/t3fuWL9SzgTYEmWU=; b=RsyQKt+d8yHlo4kl7GbQHmHANcJ21eqIkYxGvLTJhBFCZYaQlaZnHyhrH5GFIiEiFo ir5UL9I+g8uKIyp87lf81zhrceiMIv+Ye7SlDTceiHAoTDvBvkM5HRecI0zjBLgsekWG skd4SCtKjWI6PzGqJKvZrVr0bo9g9vD0IlRRBYvp8ECswGCB6WNL+mZtTi/r0nvWd6W5 rYInSmGYBuWMT7HK6h6at1nJtMw+teF9vsdRQBg4irRzxB+Mis1sk6am7N9VdIxkAJXb QWFZX+wD6p2UHly2nPkvAbYp0nMOEbLKqUsaizfoo0StfdAbIbAJk6Cm8MAppTuauyer ZwLQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass (test mode) header.i=@ideasonboard.com header.s=mail header.b=NowtYkLt; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id t5-20020a170902e84500b00177f4ef799fsi5766185plg.9.2022.11.04.09.19.25; Fri, 04 Nov 2022 09:19:38 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass (test mode) header.i=@ideasonboard.com header.s=mail header.b=NowtYkLt; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231995AbiKDP1G (ORCPT + 96 others); Fri, 4 Nov 2022 11:27:06 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36094 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232539AbiKDP0n (ORCPT ); Fri, 4 Nov 2022 11:26:43 -0400 Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [IPv6:2001:4b98:dc2:55:216:3eff:fef7:d647]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id BB02D2EF64; Fri, 4 Nov 2022 08:26:30 -0700 (PDT) Received: from [192.168.1.15] (91-154-32-225.elisa-laajakaista.fi [91.154.32.225]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id B5895415; Fri, 4 Nov 2022 16:26:26 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1667575587; bh=3VzQ30cMBk6wTrjtkgYF9rzwEsB+Jh+az5UA0Ad2rNU=; h=Date:Subject:To:Cc:References:From:In-Reply-To:From; b=NowtYkLtoJJ0QilJeNJ0asKWJP0evDr+fZISuIIqn+BdKixyc3igGHGgGFBAF6PiC NqLaBFzyD6OR7eoZ1Y7nSSptb1SUeeLuirN0yFh4nK4vFBHq9h4+esonh1YBDXWWza yLaR8p527E9bwT1Y0fDrhMmZJenZ/3A7hgi3SEU4= Message-ID: Date: Fri, 4 Nov 2022 17:26:24 +0200 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.2.2 Subject: Re: [PATCH v4 2/8] i2c: add I2C Address Translator (ATR) support Content-Language: en-US To: Andy Shevchenko Cc: devicetree@vger.kernel.org, linux-i2c@vger.kernel.org, linux-kernel@vger.kernel.org, linux-media@vger.kernel.org, Hans Verkuil , Jacopo Mondi , Kieran Bingham , Laurent Pinchart , Luca Ceresoli , Mark Rutland , Matti Vaittinen , Mauro Carvalho Chehab , Peter Rosin , Rob Herring , Sakari Ailus , Vladimir Zapolskiy , Wolfram Sang , satish.nagireddy@getcruise.com References: <20221101132032.1542416-1-tomi.valkeinen@ideasonboard.com> <20221101132032.1542416-3-tomi.valkeinen@ideasonboard.com> From: Tomi Valkeinen In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,NICE_REPLY_A,SPF_HELO_PASS, SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 04/11/2022 14:38, Andy Shevchenko wrote: > On Fri, Nov 04, 2022 at 01:59:06PM +0200, Tomi Valkeinen wrote: >> On 01/11/2022 16:30, Andy Shevchenko wrote: >>> On Tue, Nov 01, 2022 at 03:20:26PM +0200, Tomi Valkeinen wrote: > > ... > >>>> + ret = atr->ops->attach_client(atr, chan->chan_id, info, client, >>>> + &alias_id); >>> >>> On one line looks better. >> >> I agree, but it doesn't fit into 80 characters. I personally think that's a >> too narrow a limit, but some maintainers absolutely require max 80 chars, so >> I try to limit the lines to 80 unless it looks really ugly. > > OK. > > ... > >>>> + WARN(sysfs_create_link(&chan->adap.dev.kobj, &dev->kobj, "atr_device"), >>>> + "can't create symlink to atr device\n"); >>>> + WARN(sysfs_create_link(&dev->kobj, &chan->adap.dev.kobj, symlink_name), >>>> + "can't create symlink for channel %u\n", chan_id); >>> >>> Why WARNs? sysfs has already some in their implementation. >> >> True, and I can drop these if required. But afaics, sysfs_create_link only >> warns if there's a duplicate entry, not for other errors. > > The problem with WARN that it can be easily converted to real Oops. Do you > consider other errors are so fatal that machine would need a reboot? Yes, WARNs are bad, especially as the error here is not critical. I'll change these to dev_warn(). (also, I didn't know WARN could be made to oops). > ... > >>>> + atr_size = struct_size(atr, adapter, max_adapters); >>> >>>> + if (atr_size == SIZE_MAX) >>>> + return ERR_PTR(-EOVERFLOW); >>> >>> Dunno if you really need this to be separated from devm_kzalloc(), either way >>> you will get an error, but in embedded case it will be -ENOMEM. >> >> Yep. Well... I kind of like it to be explicit. Calling alloc(SIZE_MAX) >> doesn't feel nice. > > Yeah, but that is exactly the point of returning SIZE_MAX by the helpers from > overflow.h. And many of them are called inside a few k*alloc*() APIs. > > So, I don't think it's ugly or not nice from that perspective. Ok, sounds fine to me. I'll drop the check. >>>> + atr = devm_kzalloc(dev, atr_size, GFP_KERNEL); >>>> + if (!atr) >>>> + return ERR_PTR(-ENOMEM); > > ... > >>>> +EXPORT_SYMBOL_GPL(i2c_atr_delete); >>> >>> I would put these to their own namespace from day 1. >> >> What would be the namespace? Isn't this something that should be >> subsystem-wide decision? I have to admit I have never used symbol >> namespaces, and don't know much about them. > > Yes, subsystem is I2C, but you introducing a kinda subsubsystem. Wouldn't be > better to provide all symbols in the I2C_ATR namespace from now on? > > It really helps not polluting global namespace and also helps to identify > users in the source tree. Alright, I'll look into this. > ... > >>>> +struct i2c_atr { >>>> + /* private: internal use only */ >>>> + >>>> + struct i2c_adapter *parent; >>>> + struct device *dev; >>>> + const struct i2c_atr_ops *ops; >>>> + >>>> + void *priv; >>>> + >>>> + struct i2c_algorithm algo; >>>> + struct mutex lock; >>>> + int max_adapters; >>>> + >>>> + struct i2c_adapter *adapter[0]; >>> >>> No VLAs. >> >> Ok. >> >> I'm not arguing against any of the comments you've made, I think they are >> all valid, but I want to point out that many of them are in a code copied >> from i2c-mux. >> >> Whether there's any value in keeping i2c-mux and i2c-atr similar in >> design/style... Maybe not. > > You can address my comment by simply dropping 0 in the respective member. Oh, I thought you meant no "extensible" structs. I'll drop the 0. Tomi