Received: by 10.213.65.68 with SMTP id h4csp699034imn; Fri, 23 Mar 2018 13:52:03 -0700 (PDT) X-Google-Smtp-Source: AG47ELvyNBW+OmQQ/ylVGUzSuTQKOq4iNPNLTShO3sU7u24Eo/gDfnArraFncfSMcXF+ipEWGlLM X-Received: by 10.101.75.81 with SMTP id k17mr12685935pgt.335.1521838323775; Fri, 23 Mar 2018 13:52:03 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1521838323; cv=none; d=google.com; s=arc-20160816; b=WHA3T+CYisD4oCsB1GDdiSyK0REB2jRgNJ+UywBq58kDx/BoQ78ff85cheNZHM925d Xm1pTqxqkB6NlJBXMINUHrJtiGHifw4lxVQRaTctIAY3i6k+OF1gA4PjrfkWc3eU7kKl prLx4MAoPeRzo4+VB6mF5C3HGDzyrHJ8qkS3AW0W4tGno6Amv3xCh2QU/N6ccLyzt6WV Rjyw8554RnLgYQ+kU+fTuL31G695gyve/qW3/Gp9S4LPefTD8LhjbU1PwzLuIzdAPl8h hnyXSd8VrhpRnhyO2aLEJ+Aca1XInafhmviD/90WLweEPML8Ab/avUXKf63Vs3EGZIdK ANEQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature:arc-authentication-results; bh=RPsIrAEotpf9xjF3aS2UuAY3gdkwYBdfQkCDHKyCPQY=; b=VrnW5VYnMlXyziVG4jD6TtpM6oDfbAA6KcnMMS3/VeF8OvTYIRxZyJXHrz9irsJqAJ blKvNJlKCSRqfDurnhStDpkq0to6XFwW85Bv1CeW0P27STuPJ1eGLHlA/aXCIZsj6J4k g5eOT2/6f4phw+2owA3rlkCNEcBuqEzg3+d9SOUxp5vjA+lg+NGf0kPyaxbjT2BEU98a B2ks44OzK5k/u7a0lnXg4swt2UkrBENtP/hRTF3M2wevsO8tkwn/fRC7lOPpqsecZYbk xc/18ipJknIo/SDTn5q/YF/CUn87+Zmg6MQbk1NaCUQ7JuZ/sLCuxc4TF0M+hhbc4wG+ Oxrw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@lunn.ch header.s=20171124 header.b=Du9Vj9ed; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id s5-v6si9394506plp.28.2018.03.23.13.51.49; Fri, 23 Mar 2018 13:52:03 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@lunn.ch header.s=20171124 header.b=Du9Vj9ed; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752106AbeCWUtr (ORCPT + 99 others); Fri, 23 Mar 2018 16:49:47 -0400 Received: from vps0.lunn.ch ([185.16.172.187]:40618 "EHLO vps0.lunn.ch" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751747AbeCWUtp (ORCPT ); Fri, 23 Mar 2018 16:49:45 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lunn.ch; s=20171124; h=In-Reply-To:Content-Type:MIME-Version:References:Message-ID:Subject:Cc:To:From:Date; bh=RPsIrAEotpf9xjF3aS2UuAY3gdkwYBdfQkCDHKyCPQY=; b=Du9Vj9edP9et1KjKUKMvKQ/XN8yeZaXueRY27l0kyYJb36bzVgkc21aELbAmAyI04ghNsoFoMpMa7dMlyvZ0uiYmgLN6IJqgDsbGSRQHn5fhM5FLGgLw6rWf2ypmAYL4A0FJdaCFY45qvK7ATSOon5gNP3AfGGHy/+obDcfU2e0=; Received: from andrew by vps0.lunn.ch with local (Exim 4.84_2) (envelope-from ) id 1ezTd5-0005V2-K8; Fri, 23 Mar 2018 21:49:39 +0100 Date: Fri, 23 Mar 2018 21:49:39 +0100 From: Andrew Lunn To: Alexandre Belloni Cc: "David S . Miller" , Allan Nielsen , razvan.stefanescu@nxp.com, po.liu@nxp.com, Thomas Petazzoni , Florian Fainelli , netdev@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-mips@linux-mips.org Subject: Re: [PATCH net-next 3/8] net: mscc: Add MDIO driver Message-ID: <20180323204939.GS24361@lunn.ch> References: <20180323201117.8416-1-alexandre.belloni@bootlin.com> <20180323201117.8416-4-alexandre.belloni@bootlin.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20180323201117.8416-4-alexandre.belloni@bootlin.com> User-Agent: Mutt/1.5.23 (2014-03-12) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, Mar 23, 2018 at 09:11:12PM +0100, Alexandre Belloni wrote: > Add a driver for the Microsemi MII Management controller (MIIM) found on > Microsemi SoCs. > On Ocelot, there are two controllers, one is connected to the internal > PHYs, the other one can communicate with external PHYs. Hi Alexandre This looks to be standalone. Such drivers we try to put in drivers/net/phy. > +static int mscc_miim_read(struct mii_bus *bus, int mii_id, int regnum) > +{ > + struct mscc_miim_dev *miim = bus->priv; > + u32 val; > + int ret; > + > + mutex_lock(&miim->lock); What are you locking against here? And you don't appear to initialize the mutex anywhere. > +static int mscc_miim_reset(struct mii_bus *bus) > +{ > + struct mscc_miim_dev *miim = bus->priv; > + int i; > + > + if (miim->phy_regs) { > + writel(0, miim->phy_regs + MSCC_PHY_REG_PHY_CFG); > + writel(0x1ff, miim->phy_regs + MSCC_PHY_REG_PHY_CFG); > + mdelay(500); > + } > + > + for (i = 0; i < PHY_MAX_ADDR; i++) { > + if (mscc_miim_read(bus, i, MII_PHYSID1) < 0) > + bus->phy_mask |= BIT(i); > + } Why do this? Especially so for the external bus, where the PHYs might have a GPIO reset line, and won't respond until the gpio is released. The core code does that just before it scans the bus, or just before it scans the particular address on the bus, depending on the scope of the GPIO. Otherwise, pretty good :-) Andrew