From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1756087AbdKCXQM (ORCPT ); Fri, 3 Nov 2017 19:16:12 -0400 Received: from mail-qk0-f193.google.com ([209.85.220.193]:51014 "EHLO mail-qk0-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755031AbdKCXQJ (ORCPT ); Fri, 3 Nov 2017 19:16:09 -0400 X-Google-Smtp-Source: ABhQp+R+nvIuiO59ndwV9QmcOMXjRuF8NcoD+cKYjO3b5DQwEaA7yWl9UU9tXIVBiT06jDziPtATMw== Subject: Re: [PATCH net-next 03/11] net: dsa: simplify tree reference counting To: Vivien Didelot , netdev@vger.kernel.org Cc: linux-kernel@vger.kernel.org, kernel@savoirfairelinux.com, "David S. Miller" , Andrew Lunn References: <20171103230530.996-1-vivien.didelot@savoirfairelinux.com> <20171103230530.996-4-vivien.didelot@savoirfairelinux.com> From: Florian Fainelli Message-ID: Date: Fri, 3 Nov 2017 16:16:05 -0700 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.2.1 MIME-Version: 1.0 In-Reply-To: <20171103230530.996-4-vivien.didelot@savoirfairelinux.com> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 11/03/2017 04:05 PM, Vivien Didelot wrote: > DSA trees have a refcount used to automatically free the dsa_switch_tree > structure once there is no switch devices inside of it. > > The refcount is incremented when a switch is added to the tree, and > decremented when it is removed from it. > > But because of kref_init, the refcount is also incremented at > initialization, and when looking up the tree from the list for symmetry. > > Thus the current code stores the number of switches plus one, and makes > the switch registration more complex. > > To simplify the switch registration function, we reset the refcount to > zero after initialization and don't increment it when looking up a tree. > > Signed-off-by: Vivien Didelot Reviewed-by: Florian Fainelli -- Florian