Received: by 2002:a05:6358:16cd:b0:dc:6189:e246 with SMTP id r13csp748354rwl; Fri, 4 Nov 2022 06:04:13 -0700 (PDT) X-Google-Smtp-Source: AMsMyM6tju000+w0C6H0qXAWuIcZuHdAxTHrEuxLxUEK0f/9v/ektJVu3BvHMtBgT49oUtJlWkBF X-Received: by 2002:a17:907:8a17:b0:7ad:b5f1:8ff7 with SMTP id sc23-20020a1709078a1700b007adb5f18ff7mr32694150ejc.529.1667567053184; Fri, 04 Nov 2022 06:04:13 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1667567053; cv=none; d=google.com; s=arc-20160816; b=Hd3Dv9NORA0SHBYHDaH0uI9OMI7dZ6H/Z2yVTIQqvQGj+h2gN5BELLOWf5awBPWf7Z qAZuKqZ2YcOT2yMG1xAlhl0aMny+CvU+zWB3KPhx1vI20o7dO6TOvB5neel38Pi8NDRh rOZpMIA+/OZnd6MJcrK5KC5aspvgO7WnzDpCE/iH05lylIdoXxek5Y253l6Q3YGAHCDj VEjwHs9X9dIWh6V0zlExOZdJT3ivV34qOOxoGXk3/Bl7dSN4gQaCZ3MyuO/EzC41Ewui L4xCeEjLuNQojwsDDrCH0jVgOgY+PlqM0ywSP+TDNjX8k4pObNgK5WVcC/pssPwbGBX2 nIoA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:organization:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date :dkim-signature; bh=zU+DPHv2QzgmPCsWMd/DQTqYmI7uksBkrIpAINb3BDg=; b=cz9A1+IeaHxyWMmXmc0eZRH3KszbocJbTk8eelkauSHY2CtFQ+26nyESHx5vAVBvz7 ycCUAo1DrTu+SAChNajLIguktfR4G7329nQmp1p5EcUZHdsA1NCtT7wWeEVJ5x28xFpS cOq75J8Oy4bXDO4+Ke72F3sSIkTquE1It30G0OeA+TiiYuJvws2HJGwqUXdkmVWtCvCW BnQNQJU5MZlO/3KAfcAiwGlblMr4E0D20/A0Ue3Vf+MByo1s0r1/Qy4/8nXrBvcmyO/P 04HC8ekKPCE8YmuoXsW0F2OKebi61yDErEV9a8d6dWu8VvckD04b5I6wNhftTTMwoHtx 8UYw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b="Glv/0ncm"; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id dm19-20020a170907949300b0078c6abf19bfsi5973881ejc.948.2022.11.04.06.03.47; Fri, 04 Nov 2022 06:04:13 -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 header.i=@intel.com header.s=Intel header.b="Glv/0ncm"; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231921AbiKDMjD (ORCPT + 97 others); Fri, 4 Nov 2022 08:39:03 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55536 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231932AbiKDMiw (ORCPT ); Fri, 4 Nov 2022 08:38:52 -0400 Received: from mga09.intel.com (mga09.intel.com [134.134.136.24]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2080C25E1; Fri, 4 Nov 2022 05:38:50 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1667565530; x=1699101530; h=date:from:to:cc:subject:message-id:references: mime-version:in-reply-to; bh=NHtoi7Gggy94oj28EJ6rXJUUNVzupmtF6MVG47LlqR4=; b=Glv/0ncmt93ywfXRh2b6iPFxnjGr6RswHpFZj37MHhiKHIvimz+bv690 jRjdUT8bQ/1a/Okqm4xbkU1tcsTYRB+K3sG2BqBWlWQSeduJ1HOIWr6Hc vhUD7vDd0B0GGbfkWWcGnZTW655YlRewiPMmO1MHkNB98cBINZIVeIlZU BbH9LXrzCItAAFFL2FbFzJpaMGADywlk8mXpK26r01LDbObvYqdUdjk/e CemPLwW2ihChHTd9NI6sq7dLYh3/9NJ3E41lrTRhXGG1IX0O4KKRqseLn Dccs1tMNLMygeznQZE9I2BIlRHpDDuwVxxPqIIJGATisG/1R7o9sa/bJ1 A==; X-IronPort-AV: E=McAfee;i="6500,9779,10520"; a="311076771" X-IronPort-AV: E=Sophos;i="5.96,137,1665471600"; d="scan'208";a="311076771" Received: from fmsmga004.fm.intel.com ([10.253.24.48]) by orsmga102.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 04 Nov 2022 05:38:49 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6500,9779,10520"; a="704068044" X-IronPort-AV: E=Sophos;i="5.96,137,1665471600"; d="scan'208";a="704068044" Received: from smile.fi.intel.com ([10.237.72.54]) by fmsmga004.fm.intel.com with ESMTP; 04 Nov 2022 05:38:44 -0700 Received: from andy by smile.fi.intel.com with local (Exim 4.96) (envelope-from ) id 1oqvy6-007N6B-0W; Fri, 04 Nov 2022 14:38:42 +0200 Date: Fri, 4 Nov 2022 14:38:41 +0200 From: Andy Shevchenko To: Tomi Valkeinen 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 Subject: Re: [PATCH v4 2/8] i2c: add I2C Address Translator (ATR) support Message-ID: References: <20221101132032.1542416-1-tomi.valkeinen@ideasonboard.com> <20221101132032.1542416-3-tomi.valkeinen@ideasonboard.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: Organization: Intel Finland Oy - BIC 0357606-4 - Westendinkatu 7, 02160 Espoo X-Spam-Status: No, score=-5.4 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED, RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL,SPF_HELO_NONE,SPF_NONE 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 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? ... > > > + 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. > > > + 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. ... > > > +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. > > > +}; -- With Best Regards, Andy Shevchenko