From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752654AbcD0XHe (ORCPT ); Wed, 27 Apr 2016 19:07:34 -0400 Received: from vps0.lunn.ch ([178.209.37.122]:51078 "EHLO vps0.lunn.ch" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751038AbcD0XHd (ORCPT ); Wed, 27 Apr 2016 19:07:33 -0400 Date: Thu, 28 Apr 2016 01:07:29 +0200 From: Andrew Lunn To: Vivien Didelot Cc: netdev@vger.kernel.org, linux-kernel@vger.kernel.org, kernel@savoirfairelinux.com, "David S. Miller" , Florian Fainelli , Jiri Pirko Subject: Re: [RFC 01/20] net: dsa: introduce a dsa_port structure Message-ID: <20160427230729.GH29024@lunn.ch> References: <1461796217-18893-1-git-send-email-vivien.didelot@savoirfairelinux.com> <1461796217-18893-2-git-send-email-vivien.didelot@savoirfairelinux.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1461796217-18893-2-git-send-email-vivien.didelot@savoirfairelinux.com> User-Agent: Mutt/1.5.21 (2010-09-15) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org > @@ -230,6 +231,13 @@ static int dsa_switch_setup_one(struct dsa_switch *ds, struct device *parent) > for (i = 0; i < DSA_MAX_PORTS; i++) { > char *name; > > + dp[i] = devm_kzalloc(parent, sizeof(*dp), GFP_KERNEL); > + if (dp[i] == NULL) > + return -ENOMEM; You are not saving anything here by dynamically allocating the memory, since you do it for all ports. So just make it a member of ds with size DSA_MAX_PORTS. I would then call this array structure ports. Humm, i also think keeping it in dsa_slave_priv is wrong, if you have defined the structure in the global include/net/dsa.h. dsa_switch is a better place for it. Andrew