public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Andrew Lunn <andrew@lunn.ch>
To: Florian Fainelli <f.fainelli@gmail.com>
Cc: netdev@vger.kernel.org, Jason Cooper <jason@lakedaemon.net>,
	Sebastian Hesselbarth <sebastian.hesselbarth@gmail.com>,
	Gregory Clement <gregory.clement@free-electrons.com>,
	Russell King <linux@armlinux.org.uk>,
	Vivien Didelot <vivien.didelot@savoirfairelinux.com>,
	"David S. Miller" <davem@davemloft.net>,
	"moderated list:ARM/Marvell Dove/MV78xx0/Orion SOC support" 
	<linux-arm-kernel@lists.infradead.org>,
	open list <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH net-next v5 3/4] net: phy: Allow pre-declaration of MDIO devices
Date: Mon, 6 Feb 2017 15:04:43 +0100	[thread overview]
Message-ID: <20170206140443.GH32506@lunn.ch> (raw)
In-Reply-To: <20170204210245.14812-4-f.fainelli@gmail.com>

> +/**
> + * 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 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?

      Andrew

  parent reply	other threads:[~2017-02-06 14:04 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-02-04 21:02 [PATCH net-next v5 0/4] net: dsa: Support for pdata in dsa2 Florian Fainelli
2017-02-04 21:02 ` [PATCH net-next v5 1/4] net: dsa: Rename and export dev_to_net_device() Florian Fainelli
2017-02-04 21:02 ` [PATCH net-next v5 2/4] net: dsa: Add support for platform data Florian Fainelli
2017-02-04 21:02 ` [PATCH net-next v5 3/4] net: phy: Allow pre-declaration of MDIO devices Florian Fainelli
2017-02-06 13:48   ` Andrew Lunn
2017-02-06 19:08     ` Florian Fainelli
2017-02-06 14:04   ` Andrew Lunn [this message]
2017-02-06 19:17     ` Florian Fainelli
2017-02-04 21:02 ` [PATCH net-next v5 4/4] ARM: orion: Register DSA switch as a MDIO device Florian Fainelli

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20170206140443.GH32506@lunn.ch \
    --to=andrew@lunn.ch \
    --cc=davem@davemloft.net \
    --cc=f.fainelli@gmail.com \
    --cc=gregory.clement@free-electrons.com \
    --cc=jason@lakedaemon.net \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux@armlinux.org.uk \
    --cc=netdev@vger.kernel.org \
    --cc=sebastian.hesselbarth@gmail.com \
    --cc=vivien.didelot@savoirfairelinux.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox