Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755324AbbGGIjE (ORCPT ); Tue, 7 Jul 2015 04:39:04 -0400 Received: from relmlor4.renesas.com ([210.160.252.174]:53982 "EHLO relmlie3.idc.renesas.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1752583AbbGGIi4 convert rfc822-to-8bit (ORCPT ); Tue, 7 Jul 2015 04:38:56 -0400 X-IronPort-AV: E=Sophos;i="5.15,421,1432566000"; d="scan'208";a="191039068" From: Phil Edworthy To: Yoshihiro Shimoda CC: Rob Herring , Pawel Moll , "Mark Rutland" , Ian Campbell , Kumar Gala , Sergei Shtylyov , "devicetree@vger.kernel.org" , "linux-kernel@vger.kernel.org" , "linux-usb@vger.kernel.org" , "linux-sh@vger.kernel.org" , Kishon Vijay Abraham I Subject: RE: [PATCH v2] phy: rcar-gen2 usb: Add Host/Function switching for USB0 Thread-Topic: [PATCH v2] phy: rcar-gen2 usb: Add Host/Function switching for USB0 Thread-Index: AQHQtJ5IucRMEUSZmEaHf/IBIf1IAZ3ODqcAgAGmopA= Date: Tue, 7 Jul 2015 08:38:49 +0000 Message-ID: References: <1435824347-22732-1-git-send-email-phil.edworthy@renesas.com> In-Reply-To: Accept-Language: en-GB, en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: authentication-results: renesas.com; dkim=none (message not signed) header.d=none; x-originating-ip: [193.141.220.21] x-microsoft-exchange-diagnostics: 1;SIXPR06MB0921;5:uDxhWZ2P5nNJqvwto8+8+l/02UGsHJ7tEc0u/57tOiBDqCalR0kYpEEfQuiTOQrg01PoSPcuhNIsjjWP+DmP8eCcPJVNrSgzzcMc50Y2I82yJtBZCzyRii7TWEsM1l+VMcv+y6km2/jFhXqScMvchA==;24:OG7z/PrKO5tuzoIrmaiGLFcg2IkaZtYblrCfzVthGbTOKOEEtgFW0GHjLhG1mZzV+tv4Z5SoZad/nIEqq/NxKKdrlqIf5Q1Vki1Zo6NKNT0=;20:hLa1lW4i7qImpGOREHcwc0aLJN5xfUVSPyDxsZPEC7T+7Z4AKGJ5PJnpn6ZzhbFbvAFADRRWvcB1QBBLin1jOhOpnyLmWZtKH3VBcP8DGK8LvB6OUKAsV2NMDX8VbNSA4Dst/3/BFq6sxwr1mq88McpB1Oeh1C9W0IhfLf0Lgk8= x-microsoft-antispam: UriScan:;BCL:0;PCL:0;RULEID:;SRVR:SIXPR06MB0921; x-microsoft-antispam-prvs: x-exchange-antispam-report-test: UriScan:; x-exchange-antispam-report-cfa-test: BCL:0;PCL:0;RULEID:(601004)(5005006)(3002001);SRVR:SIXPR06MB0921;BCL:0;PCL:0;RULEID:;SRVR:SIXPR06MB0921; x-forefront-prvs: 0630013541 x-forefront-antispam-report: SFV:NSPM;SFS:(10019020)(6009001)(45984002)(377454003)(51704005)(24454002)(66066001)(19580395003)(46102003)(62966003)(122556002)(106116001)(5001960100002)(54356999)(40100003)(110136002)(76576001)(2950100001)(77156002)(76176999)(2656002)(50986999)(92566002)(5002640100001)(86362001)(87936001)(77096005)(33656002)(189998001)(2900100001)(102836002)(5001920100001)(74316001)(5003600100002)(4001450100001);DIR:OUT;SFP:1102;SCL:1;SRVR:SIXPR06MB0921;H:SIXPR06MB0639.apcprd06.prod.outlook.com;FPR:;SPF:None;MLV:sfv;LANG:en; spamdiagnosticoutput: 1:23 spamdiagnosticmetadata: NSPM Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 8BIT MIME-Version: 1.0 X-OriginatorOrg: renesas.com X-MS-Exchange-CrossTenant-originalarrivaltime: 07 Jul 2015 08:38:49.7261 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 53d82571-da19-47e4-9cb4-625a166a4a2a X-MS-Exchange-Transport-CrossTenantHeadersStamped: SIXPR06MB0921 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 4095 Lines: 145 Hi Shimoda-san, On 06 July 2015 08:18, Shimoda-san wrote: > Hi Phil-san, > > Thank you very much for the patch! > > > Sent: Thursday, July 02, 2015 5:06 PM > < snip > > > +/* VBUS change IRQ handler */ > > +static irqreturn_t gpio_vbus_irq(int irq, void *data) > > +{ > > + struct rcar_gen2_channel *channel = data; > > + > > + /* Wait 20ms before doing anything as VBUS needs to settle */ > > + schedule_delayed_work(&channel->work, msecs_to_jiffies(20)); > > + > > + return IRQ_HANDLED; > > +} > > + > > +static int probe_otg(struct platform_device *pdev, > > + struct rcar_gen2_phy_driver *drv) > > +{ > > + struct device *dev = &pdev->dev; > > + struct rcar_gen2_channel *ch = drv->channels; > > + int irq; > > + int ret; > > + > > + /* GPIOs for Host/Fn switching */ > > + ch->gpio_id = of_get_named_gpio_flags(dev->of_node, > > + "renesas,id-gpio", 0, NULL); > > + ch->gpio_vbus = of_get_named_gpio_flags(dev->of_node, > > + "renesas,vbus-gpio", 0, NULL); > > + > > + /* Need valid ID and VBUS gpios for Host/Fn switching */ > > + if (gpio_is_valid(ch->gpio_id) && gpio_is_valid(ch->gpio_vbus)) { > > + ch->use_otg = 1; > > + > > + /* GPIO for ID input */ > > + ret = devm_gpio_request_one(dev, ch->gpio_id, GPIOF_IN, > "id"); > > + if (ret) > > + return ret; > > + > > + /* GPIO for VBUS input */ > > + ret = devm_gpio_request_one(dev, ch->gpio_vbus, GPIOF_IN, > "vbus"); > > According to the checkpatch.pl, "line over 80 characters". As I understand it, the 80 chars is not a hard rule. One reason for the 80 char guideline is to avoid overly complex code, but I don't think that can be said of the above line! > > + if (ret) > > + return ret; > > + > > + irq = gpio_to_irq(ch->gpio_vbus); > > + ret = devm_request_irq(dev, irq, gpio_vbus_irq, > VBUS_IRQ_FLAGS, > > + "vbus_detect", ch); > > + if (ret) > > + return ret; > > + > > + /* Optional GPIO for VBUS power */ > > + ch->gpio_vbus_pwr = of_get_named_gpio_flags(dev->of_node, > > + "renesas,vbus-pwr-gpio", 0, > NULL); > > Same above. Since this code was already split over two lines, I agree with you here. > > > + if (gpio_is_valid(ch->gpio_id)) { > > + ret = devm_gpio_request_one(dev, ch->gpio_vbus_pwr, > > + GPIOF_OUT_INIT_LOW, "vbus-pwr"); > > + if (ret) > > + return ret; > > + } > > + > > + } else if (gpio_is_valid(ch->gpio_id)) { > > + dev_err(dev, "Failed to get VBUS gpio\n"); > > + return ch->gpio_vbus; > > + } else if (gpio_is_valid(ch->gpio_vbus)) { > > + dev_err(dev, "Failed to get ID gpio\n"); > > + return ch->gpio_id; > > + } > > + > > + return 0; > > +} > > + > > +/* bind/unbind the peripheral controller */ > > +static int rcar_gen2_usb_set_peripheral(struct usb_otg *otg, > > + struct usb_gadget *gadget) > > +{ > > + otg->gadget = gadget; > > + if (!gadget) { > > + usb_gadget_vbus_disconnect(otg->gadget); > > Since the otg->gadget is NULL, this driver should not call this function here. Ah, yes you are correct! > > + otg->state = OTG_STATE_UNDEFINED; > > + } > > + > > + return 0; > > +} > > + > > static int rcar_gen2_phy_probe(struct platform_device *pdev) > > { > > struct device *dev = &pdev->dev; > < snip > > > @@ -323,6 +540,14 @@ static int rcar_gen2_phy_probe(struct platform_device > *pdev) > > > > dev_set_drvdata(dev, drv); > > > > + /* > > + * If we already have something plugged into USB0, we won't get an edge > > + * on VBUS, so we have to manually schedule work to look at the VBUS > > + * and ID signals. > > + */ > > + if (drv->channels->use_otg) > > + schedule_delayed_work(&drv->channels->work, > msecs_to_jiffies(100)); > > This line is also "line over 80 characters". I don't think it is necessary to force this into the 80 char recommendation. > Best regards, > Yoshihiro Shimoda > > > + > > return 0; > > } > > > > -- > > 1.9.1 Best regards Phil -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/