From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-3.8 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS autolearn=no autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 681D9C433B4 for ; Mon, 5 Apr 2021 21:34:44 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 1A70461382 for ; Mon, 5 Apr 2021 21:34:44 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239929AbhDEVet (ORCPT ); Mon, 5 Apr 2021 17:34:49 -0400 Received: from vps0.lunn.ch ([185.16.172.187]:34760 "EHLO vps0.lunn.ch" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239935AbhDEVeq (ORCPT ); Mon, 5 Apr 2021 17:34:46 -0400 Received: from andrew by vps0.lunn.ch with local (Exim 4.94) (envelope-from ) id 1lTWrm-00EzfB-E2; Mon, 05 Apr 2021 23:34:38 +0200 Date: Mon, 5 Apr 2021 23:34:38 +0200 From: Andrew Lunn To: Michael Walle Cc: netdev Subject: Re: [PATCH 2/2] of: net: fix of_get_mac_addr_nvmem() for PCI and DSA nodes Message-ID: References: <20210405164643.21130-1-michael@walle.cc> <20210405164643.21130-3-michael@walle.cc> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20210405164643.21130-3-michael@walle.cc> Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org Hi Michael > -static int of_get_mac_addr_nvmem(struct device_node *np, u8 addr) > +static int of_get_mac_addr_nvmem(struct device_node *np, u8 *addr) > { > struct platform_device *pdev = of_find_device_by_node(np); > + struct nvmem_cell *cell; > + const void *mac; > + size_t len; > int ret; > > - if (!pdev) > - return -ENODEV; > + /* Try lookup by device first, there might be a nvmem_cell_lookup > + * associated with a given device. > + */ > + if (pdev) { > + ret = nvmem_get_mac_address(&pdev->dev, addr); > + put_device(&pdev->dev); > + return ret; > + } Can you think of any odd corner case where nvmem_get_mac_address() would fail, but of_nvmem_cell_get(np, "mac-address") would work? Andrew