From patchwork Tue Jul 10 16:18:44 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Johannes Berg X-Patchwork-Id: 170238 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 7AC9B2C01B4 for ; Wed, 11 Jul 2012 02:18:51 +1000 (EST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1756204Ab2GJQSt (ORCPT ); Tue, 10 Jul 2012 12:18:49 -0400 Received: from he.sipsolutions.net ([78.46.109.217]:39063 "EHLO sipsolutions.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754030Ab2GJQSs (ORCPT ); Tue, 10 Jul 2012 12:18:48 -0400 Received: by sipsolutions.net with esmtpsa (TLS1.0:DHE_RSA_CAMELLIA_256_CBC_SHA1:256) (Exim 4.80) (envelope-from ) id 1Sod9A-000568-A9; Tue, 10 Jul 2012 18:18:44 +0200 Message-ID: <1341937124.4475.27.camel@jlt3.sipsolutions.net> Subject: [PATCH] etherdevice: introduce eth_broadcast_addr From: Johannes Berg To: David Miller Cc: netdev@vger.kernel.org, linux-wireless@vger.kernel.org Date: Tue, 10 Jul 2012 18:18:44 +0200 In-Reply-To: <20120708.235808.1602900783296556684.davem@davemloft.net> References: <1341310587.5131.2.camel@jlt3.sipsolutions.net> <20120708.235808.1602900783296556684.davem@davemloft.net> X-Mailer: Evolution 3.4.3-1 Mime-Version: 1.0 Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org From: Johannes Berg A lot of code has either the memset or an inefficient copy from a static array that contains the all-ones broadcast address. Introduce eth_broadcast_addr() to fill an address with all ones, making the code clearer and allowing us to get rid of some constant arrays. Signed-off-by: Johannes Berg Acked-by: Felipe Balbi --- include/linux/etherdevice.h | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/include/linux/etherdevice.h b/include/linux/etherdevice.h index 3d406e0..98a27cc 100644 --- a/include/linux/etherdevice.h +++ b/include/linux/etherdevice.h @@ -138,6 +138,17 @@ static inline void random_ether_addr(u8 *addr) } /** + * eth_broadcast_addr - Assign broadcast address + * @addr: Pointer to a six-byte array containing the Ethernet address + * + * Assign the broadcast address to the given address array. + */ +static inline void eth_broadcast_addr(u8 *addr) +{ + memset(addr, 0xff, ETH_ALEN); +} + +/** * eth_hw_addr_random - Generate software assigned random Ethernet and * set device flag * @dev: pointer to net_device structure