From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751474AbdJDHhb (ORCPT ); Wed, 4 Oct 2017 03:37:31 -0400 Received: from mail1.skidata.com ([91.230.2.99]:43186 "EHLO mail1.skidata.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751047AbdJDHha (ORCPT ); Wed, 4 Oct 2017 03:37:30 -0400 X-Greylist: delayed 598 seconds by postgrey-1.27 at vger.kernel.org; Wed, 04 Oct 2017 03:37:29 EDT X-IronPort-AV: E=Sophos;i="5.42,476,1500933600"; d="scan'208";a="6403056" Subject: Re: [PATCH 2/9 v2] usb: usb251xb: Add USB251x specific port count setting To: Serge Semin , , , CC: , , , , Richard Leitner References: <20170915233113.17855-1-fancer.lancer@gmail.com> <20170916104220.3742-1-fancer.lancer@gmail.com> <20170916104220.3742-3-fancer.lancer@gmail.com> From: Richard Leitner Message-ID: <1e473b53-f031-fa86-9c2d-5b4c8bba8a28@skidata.com> Date: Wed, 4 Oct 2017 09:27:14 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.3.0 MIME-Version: 1.0 In-Reply-To: <20170916104220.3742-3-fancer.lancer@gmail.com> Content-Type: text/plain; charset="utf-8" Content-Language: en-US Content-Transfer-Encoding: 8bit X-Originating-IP: [172.16.60.30] X-ClientProxiedBy: sdex1srv.skidata.net (172.16.10.92) To sdex1srv.skidata.net (172.16.10.92) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 09/16/2017 12:42 PM, Serge Semin wrote: > USB251xb as well as USB2517 datasheet states, that all these > hubs differ by number of ports declared as the last digit in the > model name. So USB2512 got two ports, USB2513 - three, and so on. > Such setting must be reflected in the device specific data > structure and corresponding dts property should be checked whether > it doesn't get out of available ports. > > Signed-off-by: Serge Semin > --- > drivers/usb/misc/usb251xb.c | 21 ++++++++++++++++++--- > 1 file changed, 18 insertions(+), 3 deletions(-) > > diff --git a/drivers/usb/misc/usb251xb.c b/drivers/usb/misc/usb251xb.c > index 96a8c20ac..5cb0e5570 100644 > --- a/drivers/usb/misc/usb251xb.c > +++ b/drivers/usb/misc/usb251xb.c ... > > @@ -422,8 +431,10 @@ static int usb251xb_get_ofdata(struct usb251xb *hub, > for (i = 0; i < len / sizeof(u32); i++) { > u32 port = be32_to_cpu(cproperty_u32[i]); > > - if ((port >= 1) && (port <= 4)) > + if ((port >= 1) && (port <= data->port_cnt)) > hub->non_rem_dev |= BIT(port); > + else > + dev_warn(dev, "port %u doesn't exist\n", port); I'd prefer to add the (invalid) property trying to be set in this warning messages. So someone is able to find the invalid dt setting faster. Something like; dev_warn(dev, "requested NRD port %u doesn't exist\n", port); > } > } > > @@ -433,8 +444,10 @@ static int usb251xb_get_ofdata(struct usb251xb *hub, > for (i = 0; i < len / sizeof(u32); i++) { > u32 port = be32_to_cpu(cproperty_u32[i]); > > - if ((port >= 1) && (port <= 4)) > + if ((port >= 1) && (port <= data->port_cnt)) > hub->port_disable_sp |= BIT(port); > + else > + dev_warn(dev, "port %u doesn't exist\n", port); ... same as above. For example: dev_warn(dev, "requested PDS port %u doesn't exist\n", port); > } > } > > @@ -444,8 +457,10 @@ static int usb251xb_get_ofdata(struct usb251xb *hub, > for (i = 0; i < len / sizeof(u32); i++) { > u32 port = be32_to_cpu(cproperty_u32[i]); > > - if ((port >= 1) && (port <= 4)) > + if ((port >= 1) && (port <= data->port_cnt)) > hub->port_disable_bp |= BIT(port); > + else > + dev_warn(dev, "port %u doesn't exist\n", port); ... same as above. For example: dev_warn(dev, "requested PDB port %u doesn't exist\n", port); Apart from that this patch looks fine for me. Thanks for the spot of the hardcoded max ports check. regards, Richard.L