From patchwork Thu Mar 12 16:27:31 2009 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jiri Pirko X-Patchwork-Id: 24350 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.176.167]) by ozlabs.org (Postfix) with ESMTP id 003B6DE115 for ; Fri, 13 Mar 2009 03:28:56 +1100 (EST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1758039AbZCLQ1k (ORCPT ); Thu, 12 Mar 2009 12:27:40 -0400 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S1757578AbZCLQ1j (ORCPT ); Thu, 12 Mar 2009 12:27:39 -0400 Received: from mx2.redhat.com ([66.187.237.31]:60170 "EHLO mx2.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1757989AbZCLQ1i (ORCPT ); Thu, 12 Mar 2009 12:27:38 -0400 Received: from int-mx2.corp.redhat.com (int-mx2.corp.redhat.com [172.16.27.26]) by mx2.redhat.com (8.13.8/8.13.8) with ESMTP id n2CGRXoM000674; Thu, 12 Mar 2009 12:27:33 -0400 Received: from ns3.rdu.redhat.com (ns3.rdu.redhat.com [10.11.255.199]) by int-mx2.corp.redhat.com (8.13.1/8.13.1) with ESMTP id n2CGRXha011457; Thu, 12 Mar 2009 12:27:33 -0400 Received: from localhost (vpn-10-68.str.redhat.com [10.32.10.68]) by ns3.rdu.redhat.com (8.13.8/8.13.8) with ESMTP id n2CGRWwU019489; Thu, 12 Mar 2009 12:27:32 -0400 Date: Thu, 12 Mar 2009 17:27:31 +0100 From: Jiri Pirko To: linux-kernel@vger.kernel.org Cc: ivecera@redhat.com, jgarzik@pobox.com, davem@davemloft.net, netdev@vger.kernel.org Subject: [PATCH] 8139cp: allow to set mac address on running device Message-ID: <20090312162730.GA20153@psychotron.englab.brq.redhat.com> MIME-Version: 1.0 Content-Disposition: inline User-Agent: Mutt/1.5.18 (2008-05-17) X-Scanned-By: MIMEDefang 2.58 on 172.16.27.26 Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org So far there was not a chance to set a mac address on running 8139cp device. This is for example needed when you want to use this NIC as a bonding slave in bonding device in mode balance-alb. This simple patch allows it. Jirka Signed-off-by: Jiri Pirko drivers/net/8139cp.c | 24 +++++++++++++++++++++++- 1 files changed, 23 insertions(+), 1 deletions(-) --- To unsubscribe from this list: send the line "unsubscribe netdev" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html diff --git a/drivers/net/8139cp.c b/drivers/net/8139cp.c index 4e19ae3..13b708a 100644 --- a/drivers/net/8139cp.c +++ b/drivers/net/8139cp.c @@ -1602,6 +1602,28 @@ static int cp_ioctl (struct net_device *dev, struct ifreq *rq, int cmd) return rc; } +static int cp_set_mac_address(struct net_device *dev, void *p) +{ + struct cp_private *cp = netdev_priv(dev); + struct sockaddr *addr = p; + + if (!is_valid_ether_addr(addr->sa_data)) + return -EADDRNOTAVAIL; + + memcpy(dev->dev_addr, addr->sa_data, dev->addr_len); + + spin_lock_irq(&cp->lock); + + cpw8_f(Cfg9346, Cfg9346_Unlock); + cpw32_f(MAC0 + 0, le32_to_cpu (*(__le32 *) (dev->dev_addr + 0))); + cpw32_f(MAC0 + 4, le32_to_cpu (*(__le32 *) (dev->dev_addr + 4))); + cpw8_f(Cfg9346, Cfg9346_Lock); + + spin_unlock_irq(&cp->lock); + + return 0; +} + /* Serial EEPROM section. */ /* EEPROM_Ctrl bits. */ @@ -1821,7 +1843,7 @@ static const struct net_device_ops cp_netdev_ops = { .ndo_open = cp_open, .ndo_stop = cp_close, .ndo_validate_addr = eth_validate_addr, - .ndo_set_mac_address = eth_mac_addr, + .ndo_set_mac_address = cp_set_mac_address, .ndo_set_multicast_list = cp_set_rx_mode, .ndo_get_stats = cp_get_stats, .ndo_do_ioctl = cp_ioctl,