Received: by 2002:ac0:aed5:0:0:0:0:0 with SMTP id t21csp2111784imb; Sun, 3 Mar 2019 18:37:31 -0800 (PST) X-Google-Smtp-Source: AHgI3Ia+ZrcgKluotwpuB4E/7iFlTnooeLI5EPtoxpvFlrXM1Ytp0x9c4jplCQ45ToIjkHlfdNdU X-Received: by 2002:a62:54c5:: with SMTP id i188mr17416613pfb.188.1551667051552; Sun, 03 Mar 2019 18:37:31 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1551667051; cv=none; d=google.com; s=arc-20160816; b=TlTQ//l45RJ7zbS3somL8Qmo2HavsdOxNhhgAHTKAT0eLu2QAZ1E9RwDcOvop3R4cb mBM1PLagcI7taxc8/SVNgoDieTBqU1iEGu/pfT+8m1K5QrS3+8dqCp3f/eXrKBT9eU+d wGuo35TFkVfXS8J1LpY4mzaweibaQRisl8LJa/5M8MBPrwfZBayamTOIzneRFaJb2mOF 3IfSzHj1WPLUddBWxqatyZZd521xm2FfFutkWqsZaYAnJr77gkcOmxEBVWkvv0VxzBiN f0wHWQxGDGE+SBJ8yhFpFTlBzuzzAvKhoWSSF2IuHEzHYVDdAJRdukUAGZNq6JUYTUGm vqYQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding :content-language:in-reply-to:mime-version:user-agent:date :message-id:from:references:to:subject:cc; bh=JvH+ydm+4Jm7Ty7tApDFimyMkblMaml2punLhi9sx94=; b=IFAwki6FsZVizPGH5fVvCmDJeS++8d4YrJXbxeUCPPcfBdLigy88050n5o0wtwNsHR VZZV3kUG1LZhbdWRN4qzGyaZy47602XSyaPRftHm7mlHaTvic/ej7Yol7MRS+IrbabG2 8aING8RWhefCUisYc/mmWfutaAu+kbxYxl03r5tEwk5BpGOQhFZb7XHFnnrHQR7Ois43 nyDJbEGNIwat8UhuNABaXFR8jrMrBHfkTc3lsMcTFdciy5sfBFp4g0AdQoYtZi9u18MO 6mmw9fUipDtfTTtcUAC38IRSzQMeS62Py5jyn01Y/Ef4YYi5mtIUSaTXZPf7DzDGxo0S cAng== ARC-Authentication-Results: i=1; mx.google.com; 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 d16si4248427pll.236.2019.03.03.18.37.16; Sun, 03 Mar 2019 18:37:31 -0800 (PST) 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; 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 S1726197AbfCDCf2 (ORCPT + 99 others); Sun, 3 Mar 2019 21:35:28 -0500 Received: from szxga04-in.huawei.com ([45.249.212.190]:4203 "EHLO huawei.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1725933AbfCDCf1 (ORCPT ); Sun, 3 Mar 2019 21:35:27 -0500 Received: from DGGEMS413-HUB.china.huawei.com (unknown [172.30.72.58]) by Forcepoint Email with ESMTP id 1645B379DC0B44BC9EE5; Mon, 4 Mar 2019 10:35:25 +0800 (CST) Received: from [127.0.0.1] (10.142.63.192) by DGGEMS413-HUB.china.huawei.com (10.3.19.213) with Microsoft SMTP Server id 14.3.408.0; Mon, 4 Mar 2019 10:35:16 +0800 CC: , USB , devicetree , Linux Kernel Mailing List , John Stultz , Suzhuangluan , Kongfei , , , Yao Chen , , , songxiaowei , xu yiping , , , , Chunfeng Yun , "Arnd Bergmann" , Greg Kroah-Hartman , Binghui Wang , Heikki Krogerus Subject: Re: [PATCH v3 10/12] hikey960: Support usb functionality of Hikey960 To: Andy Shevchenko References: <20190302090505.65542-1-chenyu56@huawei.com> <20190302090505.65542-11-chenyu56@huawei.com> From: Chen Yu Message-ID: <386ac0cf-cee7-bc1b-d22c-80dedff391cf@huawei.com> Date: Mon, 4 Mar 2019 10:35:13 +0800 User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:52.0) Gecko/20100101 Thunderbird/52.5.2 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset="utf-8" Content-Language: en-US Content-Transfer-Encoding: 7bit X-Originating-IP: [10.142.63.192] X-CFilter-Loop: Reflected Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Andy, On 2019/3/3 0:01, Andy Shevchenko wrote: > On Sat, Mar 2, 2019 at 11:05 AM Yu Chen wrote: >> >> This driver handles usb hub power on and typeC port event of HiKey960 board: >> 1)DP&DM switching between usb hub and typeC port base on typeC port >> state >> 2)Control power of usb hub on Hikey960 >> 3)Control vbus of typeC port > >> +config HISI_HIKEY_USB >> + tristate "USB functionality of HiSilicon Hikey Platform" >> + depends on OF && GPIOLIB >> + help >> + If you say yes here you get support for usb functionality of HiSilicon Hikey Platform. > >> +#include > > It's hard to see why this have > depends on OF followed by above header inclusion. > This driver depends on devicetree, so I add "depends on OF". But is seems that "#include " can be removed after "of_" API have been removed. Thanks for your reminder! >> + hisi_hikey_usb->typec_vbus = devm_gpiod_get(dev, "typec-vbus", >> + GPIOD_OUT_LOW); > >> + if (!hisi_hikey_usb->typec_vbus) >> + return -ENOENT; > > Hmm... Is it possible to get NULL pointer from gpiod_get() at all? > >> + if (!hisi_hikey_usb->otg_switch) >> + return -ENOENT; > > Ditto. > I check the comments of devm_gpio_get API, it will not return NULL pointer. But is it more safe to keep the NULL checking? What is your advice? >> + /* hub-vdd33-en is optional */ >> + hisi_hikey_usb->hub_vbus = devm_gpiod_get(dev, "hub-vdd33-en", >> + GPIOD_OUT_HIGH); > > devm_gpio_get_optional() if it's indeed optional. > OK.Thanks! >> + hisi_hikey_usb->role_sw = usb_role_switch_get(dev); >> + if (!hisi_hikey_usb->role_sw) >> + return -EPROBE_DEFER; > >> + else if (IS_ERR(hisi_hikey_usb->role_sw)) > > Redundant 'else' > OK. >> + return PTR_ERR(hisi_hikey_usb->role_sw); > >> +static const struct of_device_id id_table_hisi_hikey_usb[] = { >> + {.compatible = "hisilicon,gpio_hubv1"}, >> + {.compatible = "hisilicon,hikey960_usb"}, >> + {} >> +}; > > MODULE_DEVICE_TABLE()? > OK. Thanks Yu Chen