From patchwork Mon Jul 6 22:47:55 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 491864 X-Patchwork-Delegate: sjg@chromium.org Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from theia.denx.de (theia.denx.de [85.214.87.163]) by ozlabs.org (Postfix) with ESMTP id 70465140187 for ; Tue, 7 Jul 2015 08:51:27 +1000 (AEST) Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=google.com header.i=@google.com header.b=JHYXE+BC; dkim-atps=neutral Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 07CCC4B8CD; Tue, 7 Jul 2015 00:50:09 +0200 (CEST) Received: from theia.denx.de ([127.0.0.1]) by localhost (theia.denx.de [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id FhorzfA_BQNI; Tue, 7 Jul 2015 00:50:08 +0200 (CEST) Received: from theia.denx.de (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 813424B8C4; Tue, 7 Jul 2015 00:49:27 +0200 (CEST) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 7FD314B7F5 for ; Tue, 7 Jul 2015 00:48:47 +0200 (CEST) Received: from theia.denx.de ([127.0.0.1]) by localhost (theia.denx.de [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id X2M96BCGGYTU for ; Tue, 7 Jul 2015 00:48:47 +0200 (CEST) X-policyd-weight: NOT_IN_SBL_XBL_SPAMHAUS=-1.5 NOT_IN_SPAMCOP=-1.5 NOT_IN_BL_NJABL=-1.5 (only DNSBL check requested) Received: from mail-ie0-f173.google.com (mail-ie0-f173.google.com [209.85.223.173]) by theia.denx.de (Postfix) with ESMTPS id 21E674B80D for ; Tue, 7 Jul 2015 00:48:41 +0200 (CEST) Received: by iebmu5 with SMTP id mu5so122982390ieb.1 for ; Mon, 06 Jul 2015 15:48:40 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references; bh=0Nml+SReBWPq1Ot1r3QsS18pDnLW77Z3ZA3GfvGdTko=; b=JHYXE+BC6klHU6I5CHUeG+/rqfkIqEKEuHsaXOVRLNz9suWsspbjY/DbdM7+rLoFrD 82y86KrteqKas5xu49MH6sZGCzNEjct04iCx1HAf2wF7TN6YdBMJB9n5/KvawkoSRPqu LqUHc/9fkSyVGy+jO23DaNwrYDIgZjzRZdO37CeGRRZ8ZbnYgqVXz1+V+YtVuCKH6Bqj GtbnOMIOJvVayhob43ITcd94ehkr3IYucOReuzEGzjSFfQGDs7FMNpAJR5NU034GgBRa u9KDbp+uucv1tcbdqVY6elNtabuojDlim11opWdm8/eFOiyMNQFTSe7XA/AeVGfZHsl2 KFMw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references; bh=0Nml+SReBWPq1Ot1r3QsS18pDnLW77Z3ZA3GfvGdTko=; b=Sc8oCGPvlKRUog0ARIzEYvIxH3R6V/KTtbQ6cUiVeU1/dLom4pzuZgRXlxAStgpofd zt49LxFsMB+OniVsdck5qI6AyKoau65CnNgjfVetQEFaC2OdgrsLHo6MOBKXJvyQZ7mb VfJTC6Z7/+z1kIYhuRd1LFJfcdxtpfKs2Z56u74OAnCThiCek13LfDXSy0B8GXDlKP/R mzmj0WD2MACwhhktVXJJVI5lbguYZg9Dcj5zovS1uyyRBQDr0tIltxJSXuiQgLIhEJKA 5RUOeuQzskkU/PL43obffpOAC3T7gTzMK3uR4+89WAsBE6zOGZ/d9RYV6wmUbj//OwkU sfwA== X-Gm-Message-State: ALoCoQkN/PGjGt26Tr10E04DEqA762CGoz6vLop4Gr7loONO2uAtoLZvwrS5gDEYHPOlLIT18SgI X-Received: by 10.50.112.73 with SMTP id io9mr75433742igb.18.1436222920244; Mon, 06 Jul 2015 15:48:40 -0700 (PDT) Received: from kaki.bld.corp.google.com ([172.29.216.32]) by mx.google.com with ESMTPSA id 191sm13370487iof.18.2015.07.06.15.48.34 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 06 Jul 2015 15:48:37 -0700 (PDT) Received: by kaki.bld.corp.google.com (Postfix, from userid 121222) id F3700221091; Mon, 6 Jul 2015 16:48:29 -0600 (MDT) From: Simon Glass To: U-Boot Mailing List Date: Mon, 6 Jul 2015 16:47:55 -0600 Message-Id: <1436222877-17548-17-git-send-email-sjg@chromium.org> X-Mailer: git-send-email 2.4.3.573.g4eafbef In-Reply-To: <1436222877-17548-1-git-send-email-sjg@chromium.org> References: <1436222877-17548-1-git-send-email-sjg@chromium.org> Cc: Tom Rini , Joe Hershberger , Radha Mohan Chintakuntla Subject: [U-Boot] [PATCH 16/18] net: Allow drivers to return -ENOSYS with the write_hwaddr() method X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.15 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" Some drivers may want to implement this method for some of their devices but not for others. So it is not possible to just leave the operation out of the table. Drivers could get around this by masquerading as two separate drivers but that seems unpleasant. Allow the driver to return an error when it does not want to process the write_hwaddr() method. Signed-off-by: Simon Glass --- include/net.h | 4 +++- net/eth.c | 6 ++++++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/include/net.h b/include/net.h index b9c13f2..d09bec9 100644 --- a/include/net.h +++ b/include/net.h @@ -119,7 +119,9 @@ enum eth_recv_flags { * mcast: Join or leave a multicast group (for TFTP) - optional * write_hwaddr: Write a MAC address to the hardware (used to pass it to Linux * on some platforms like ARM). This function expects the - * eth_pdata::enetaddr field to be populated - optional + * eth_pdata::enetaddr field to be populated. The method can + * return -ENOSYS to indicate that this is not implemented for + this hardware - optional. * read_rom_hwaddr: Some devices have a backup of the MAC address stored in a * ROM on the board. This is how the driver should expose it * to the network stack. This function should fill in the diff --git a/net/eth.c b/net/eth.c index 72ce91c..d3ec8d6 100644 --- a/net/eth.c +++ b/net/eth.c @@ -287,7 +287,13 @@ static int eth_write_hwaddr(struct udevice *dev) return -EINVAL; } + /* + * Drivers are allowed to decide not to implement this at + * run-time. E.g. Some devices may use it and some may not. + */ ret = eth_get_ops(dev)->write_hwaddr(dev); + if (ret == -ENOSYS) + ret = 0; if (ret) printf("\nWarning: %s failed to set MAC address\n", dev->name);