From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752489AbdBFTRh (ORCPT ); Mon, 6 Feb 2017 14:17:37 -0500 Received: from mail-pf0-f196.google.com ([209.85.192.196]:32825 "EHLO mail-pf0-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750997AbdBFTRf (ORCPT ); Mon, 6 Feb 2017 14:17:35 -0500 Subject: Re: [PATCH net-next v5 3/4] net: phy: Allow pre-declaration of MDIO devices To: Andrew Lunn References: <20170204210245.14812-1-f.fainelli@gmail.com> <20170204210245.14812-4-f.fainelli@gmail.com> <20170206140443.GH32506@lunn.ch> Cc: netdev@vger.kernel.org, Jason Cooper , Sebastian Hesselbarth , Gregory Clement , Russell King , Vivien Didelot , "David S. Miller" , "moderated list:ARM/Marvell Dove/MV78xx0/Orion SOC support" , open list From: Florian Fainelli Message-ID: Date: Mon, 6 Feb 2017 11:17:32 -0800 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.7.0 MIME-Version: 1.0 In-Reply-To: <20170206140443.GH32506@lunn.ch> Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 02/06/2017 06:04 AM, Andrew Lunn wrote: >> +/** >> + * mdio_register_board_info - register MDIO devices for a given board >> + * @info: array of devices descriptors >> + * @n: number of descriptors provided >> + * Context: can sleep >> + * >> + * The board info passed can be marked with __initdata but be pointers >> + * such as platform_data etc. are copied as-is >> + */ >> +int mdiobus_register_board_info(const struct mdio_board_info *info, >> + unsigned int n) >> +{ >> + struct mdio_board_entry *be; >> + unsigned int i; >> + >> + be = kcalloc(n, sizeof(*be), GFP_KERNEL); >> + if (!be) >> + return -ENOMEM; >> + >> + for (i = 0; i < n; i++, be++, info++) { >> + memcpy(&be->board_info, info, sizeof(*info)); >> + mutex_lock(&mdio_board_lock); >> + list_add_tail(&be->list, &mdio_board_list); >> + mutex_unlock(&mdio_board_lock); >> + } >> + >> + return 0; > > Hi Florian > > I've recently been playing with a hot-pluggable SPI bus controller. It > is a USB device, hence can come and go. On the SPI bus i have an > SRAM. On order to instantiate the MTD device, i need SPI board info. I > cannot add the board info until after the SPI bus master appears, > since i need to know its ID to fill in the board info. At the moment, > i have udev script which when the SPI bus master appears loads a > little kernel module which registers the board info. > > Such a scheme will not work here. You need to iterate the list of MDIO > devices at the end of mdiobus_register_board_info() to see if the just > registered board info applies to any existing MDIO bus. I was thinking when mdio_device_register() is called, see if there is a matching board info for it, and if so, assign its platform_data accordingly. In the case where mdiobus_register_with_board > > I don't think we yet have any hardware which would do this. But there > have been patches to one of the USB-Ethernet dongles to allow it run > without a PHY. My guess is, to allow an SFP module. But it is not too > big a step for somebody to make a USB attached Ethernet switch. > > Maybe consider adding this functionality? Also an unregister call? Sure, makes sense. -- Florian