From patchwork Sun Sep 9 02:32:28 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: duanjiong X-Patchwork-Id: 182611 X-Patchwork-Delegate: davem@davemloft.net Return-Path: X-Original-To: patchwork-incoming@ozlabs.org Delivered-To: patchwork-incoming@ozlabs.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 205C02C0098 for ; Sun, 9 Sep 2012 12:32:44 +1000 (EST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752006Ab2IICch (ORCPT ); Sat, 8 Sep 2012 22:32:37 -0400 Received: from mail-ie0-f174.google.com ([209.85.223.174]:61683 "EHLO mail-ie0-f174.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751670Ab2IICcf (ORCPT ); Sat, 8 Sep 2012 22:32:35 -0400 Received: by ieje11 with SMTP id e11so1135297iej.19 for ; Sat, 08 Sep 2012 19:32:35 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=message-id:date:from:user-agent:mime-version:to:cc:subject :content-type:content-transfer-encoding; bh=ikB26n6a1U88j73ItNebdZBWdf6gnpidy1oC5umKmkU=; b=tABT45uykZfIPcQpBEUnWRtnXpcEPqMpCpLx5+uxkQ5xm/Qt/xjOCvfVAt8vp9TSAd 8pbAIibUAkAj7VQ7QV0NfbXOosC+AA3p4Q4Y5C1DAXeJydSnYmQjtp8XvKdJixd2RLAj emuDd16rqxjpmDg8Tce7Vc+wsxS5sRsnxLoqtVhQI1MeuuJkJK9+LDezSvJXaVdq8pvs 7PG/Wi1EGUWKCsCqkmi23A2ikXxc5VLFmzZ8u4CLfdB0UhgkVtqb/mL6OvUQRJa2UFMZ zC++5YJxkRfWXDb3LAVBRZHlFTDIjeLupI8e6j7L/TsMK917gxSLsW6VKaG9yPLo0usV 5Xnw== Received: by 10.50.155.129 with SMTP id vw1mr4687825igb.11.1347157955141; Sat, 08 Sep 2012 19:32:35 -0700 (PDT) Received: from [192.168.1.103] ([222.94.144.200]) by mx.google.com with ESMTPS id wn5sm4896214igc.7.2012.09.08.19.32.31 (version=SSLv3 cipher=OTHER); Sat, 08 Sep 2012 19:32:33 -0700 (PDT) Message-ID: <504BFFBC.9070209@gmail.com> Date: Sun, 09 Sep 2012 10:32:28 +0800 From: Duan Jiong User-Agent: Mozilla/5.0 (X11; Linux i686; rv:15.0) Gecko/20120828 Thunderbird/15.0 MIME-Version: 1.0 To: davem@davemloft.net CC: netdev@vger.kernel.org Subject: [PATCH net-next] etherdevice: introduce help function eth_zero_addr() Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org a lot of code has either the memset or an inefficient copy from a static array that contains the all-zeros Ethernet address. Introduce help function eth_zero_addr() to fill an address with all zeros, making the code clearer and allowing us to get rid of some constant arrays. Signed-off-by: Duan Jiong --- include/linux/etherdevice.h | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/include/linux/etherdevice.h b/include/linux/etherdevice.h index d426336..b006ba0 100644 --- a/include/linux/etherdevice.h +++ b/include/linux/etherdevice.h @@ -151,6 +151,17 @@ static inline void eth_broadcast_addr(u8 *addr) } /** + * eth_zero_addr - Assign zero address + * @addr: Pointer to a six-byte array containing the Ethernet address + * + * Assign the zero address to the given address array. + */ +static inline void eth_zero_addr(u8 *addr) +{ + memset(addr, 0x00, ETH_ALEN); +} + +/** * eth_hw_addr_random - Generate software assigned random Ethernet and * set device flag * @dev: pointer to net_device structure