From patchwork Wed Jun 15 01:14:44 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Frank Wang X-Patchwork-Id: 9177193 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 18F86604DB for ; Wed, 15 Jun 2016 01:15:31 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 07E0A28303 for ; Wed, 15 Jun 2016 01:15:31 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id EF0C128340; Wed, 15 Jun 2016 01:15:30 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-4.2 required=2.0 tests=BAYES_00, RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.9]) (using TLSv1.2 with cipher AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 9655C28303 for ; Wed, 15 Jun 2016 01:15:30 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1bCzQP-0002So-IE; Wed, 15 Jun 2016 01:15:21 +0000 Received: from regular1.263xmail.com ([211.150.99.134]) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1bCzQN-0001FA-0F for linux-rockchip@lists.infradead.org; Wed, 15 Jun 2016 01:15:20 +0000 Received: from frank.wang?rock-chips.com (unknown [192.168.167.84]) by regular1.263xmail.com (Postfix) with SMTP id 8AC359140; Wed, 15 Jun 2016 09:14:51 +0800 (CST) X-263anti-spam: KSV:0; X-MAIL-GRAY: 0 X-MAIL-DELIVERY: 1 X-KSVirus-check: 0 X-ABS-CHECKED: 4 X-ADDR-CHECKED: 0 Received: from [172.16.12.210] (localhost.localdomain [127.0.0.1]) by smtp.263.net (Postfix) with ESMTP id 1BDAE23920; Wed, 15 Jun 2016 09:14:47 +0800 (CST) X-RL-SENDER: frank.wang@rock-chips.com X-FST-TO: frank.wang@rock-chips.com X-SENDER-IP: 58.22.7.114 X-LOGIN-NAME: frank.wang@rock-chips.com X-UNIQUE-TAG: <5fba0ad625191eb0d1462902da99e8b1> X-ATTACHMENT-NUM: 0 X-SENDER: wmc@rock-chips.com X-DNS-TYPE: 0 Received: from [172.16.12.210] (unknown [58.22.7.114]) by smtp.263.net (Postfix) whith ESMTP id 262903OR77T; Wed, 15 Jun 2016 09:14:49 +0800 (CST) Subject: Re: [PATCH v5 2/2] phy: rockchip-inno-usb2: add a new driver for Rockchip usb2phy To: =?UTF-8?Q?Heiko_St=c3=bcbner?= , Guenter Roeck References: <1465783810-18756-1-git-send-email-frank.wang@rock-chips.com> <7225720.0AClDW7eQ6@diego> <4065185.1IWsBDlcMJ@diego> From: Frank Wang Message-ID: <24acf224-e792-6648-fcdb-8729ded6df84@rock-chips.com> Date: Wed, 15 Jun 2016 09:14:44 +0800 User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:45.0) Gecko/20100101 Thunderbird/45.1.1 MIME-Version: 1.0 In-Reply-To: <4065185.1IWsBDlcMJ@diego> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20160614_181519_528132_409151B3 X-CRM114-Status: GOOD ( 10.42 ) X-BeenThere: linux-rockchip@lists.infradead.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: Upstream kernel work for Rockchip platforms List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: mark.rutland@arm.com, devicetree@vger.kernel.org, Ziyuan Xu , Tao Huang , pawel.moll@arm.com, ijc+devicetree@hellion.org.uk, frank.wang@rock-chips.com, linux-kernel@vger.kernel.org, linux-usb@vger.kernel.org, Douglas Anderson , kishon@ti.com, Kever Yang , linux-rockchip@lists.infradead.org, robh+dt@kernel.org, Kumar Gala , Guenter Roeck , jwerner@chromium.org, william.wu@rock-chips.com, Guenter Roeck Sender: "Linux-rockchip" Errors-To: linux-rockchip-bounces+patchwork-linux-rockchip=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP Hi Heiko & Guenter, On 2016/6/14 22:00, Heiko Stübner wrote: > Am Dienstag, 14. Juni 2016, 06:50:31 schrieb Guenter Roeck: >> On Tue, Jun 14, 2016 at 6:27 AM, Heiko Stübner wrote: >>> Am Montag, 13. Juni 2016, 10:10:10 schrieb Frank Wang: >>>> The newer SoCs (rk3366, rk3399) take a different usb-phy IP block >>>> than rk3288 and before, and most of phy-related registers are also >>>> different from the past, so a new phy driver is required necessarily. >>>> >>>> Signed-off-by: Frank Wang >>>> --- > [...] > >>>> +static int rockchip_usb2phy_init(struct phy *phy) >>>> +{ >>>> + struct rockchip_usb2phy_port *rport = phy_get_drvdata(phy); >>>> + struct rockchip_usb2phy *rphy = dev_get_drvdata(phy->dev.parent); >>>> + int ret; >>>> + >>>> >>> if (!rport->port_cfg) >>> >>> return 0; >>> >>> Otherwise the currently empty otg-port will cause null-pointer >>> dereferences >>> when it gets assigned in the devicetree already. >> Not really, at least not here - that port should not have port_id set >> to USB2PHY_PORT_HOST. >> >> Does it even make sense to instantiate the otg port ? Is it going to >> do anything without port configuration ? > Ok, that would be the other option - not creating the phy in the driver. Well, I will put this conditional inside *_host_port_init(), if it is an empty, the phy-device should not be created. Something like the following: > initially as well most likely, supplying the additional otg-parts later on. @Guenter, just as Heiko said, the otg-parts is not ready now, it will be supplied later. BR. Frank --- a/drivers/phy/phy-rockchip-inno-usb2.c +++ b/drivers/phy/phy-rockchip-inno-usb2.c @@ -483,9 +483,13 @@ static int rockchip_usb2phy_host_port_init(struct rockchip_usb2phy *rphy, { int ret; - rport->port_id = USB2PHY_PORT_HOST; rport->port_cfg = &rphy->phy_cfg->port_cfgs[USB2PHY_PORT_HOST]; + if (!rport->port_cfg) { + dev_err(rphy->dev, "no host port-config provided.\n"); + return -EINVAL; + } + rport->port_id = USB2PHY_PORT_HOST; > Or from what I've seen, handling it as similar to the host-port should work