Received: by 2002:a25:8b91:0:0:0:0:0 with SMTP id j17csp385208ybl; Fri, 31 Jan 2020 00:28:03 -0800 (PST) X-Google-Smtp-Source: APXvYqwgCnBKTvMOOXLsO2//+sW0JOqoqQ5GdhC/rPJ60HdfqxVOpR3DrhDI2kzDggFB+7zsWYc7 X-Received: by 2002:a9d:5c1:: with SMTP id 59mr6754456otd.192.1580459283818; Fri, 31 Jan 2020 00:28:03 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1580459283; cv=none; d=google.com; s=arc-20160816; b=ikzQo4LAwPKOImeR6pemdG0u8pEMXaKO06cDax2lT1Vfg5GuHBWa7DTy5//3PjcrOD 45/NM1SGS0tHwuFw/wR2F9FLApGB1eqoDRHnsrm/s2NFrwBX1x0ywQBP/0akvro60tu1 9OUaph13h6kYaRGJXklemSe8N91k+MEh7L8bhNt6UhiH/PkmsaQ4KRRKXlq9s/h/IRf8 3BFgggnLVbG4TMhYIws9dEt4QqiMsyw0lMr5MejKJ1J3E7GBl6/owAdsMVMm0Na5GfxU DBnZaYuUa8uB1sDEJfQlszsTk/jehPGoYabeZkfkEYpsiCaTdt02MKIOaaKOggsfl3DU BWLg== 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; bh=9HJDg4ebV+36JCqgzBLlPd7SgnrdxJDhGJ/uJ+JFH5w=; b=VPYZ/5T8grUaKbg9ZK8vXuDCNzJWxHohmUEN3WpihNLKecwW0GwO4WdL57gIH+0AmV c2hLwIDqKjMsVuS3nrLsYTZ6Sigbz0FH0JJBGDFzAy/0rJyOBRPpd50HiW/tTIoPLc25 wIknkGhBAwSLkJOOxpENHEyiteZbnbdcAynyexNAzWwbSQPeUM0dL7Sn7l0hdwh0s4ZH CtVCzH4JWWUjsLOPHB4AZybc/u8dCUyHpAPyWORNGP7q2B9C9jprkOsNr+VPEhhbEF1j EH1g4V9uf1sYVAptyOVxhpbYFeLZUDq64FXyWTAnT9WWX82IT0HOFDMyP6FIxgnoC05Y N+fw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@oracle.com header.s=corp-2019-08-05 header.b=g4IJM3qs; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=oracle.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id t137si4204010oif.61.2020.01.31.00.27.38; Fri, 31 Jan 2020 00:28:03 -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; dkim=pass header.i=@oracle.com header.s=corp-2019-08-05 header.b=g4IJM3qs; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=oracle.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728184AbgAaIZ4 (ORCPT + 99 others); Fri, 31 Jan 2020 03:25:56 -0500 Received: from userp2120.oracle.com ([156.151.31.85]:59190 "EHLO userp2120.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728124AbgAaIZ4 (ORCPT ); Fri, 31 Jan 2020 03:25:56 -0500 Received: from pps.filterd (userp2120.oracle.com [127.0.0.1]) by userp2120.oracle.com (8.16.0.27/8.16.0.27) with SMTP id 00V8NIiR125627; Fri, 31 Jan 2020 08:25:25 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=date : from : to : cc : subject : message-id : references : mime-version : content-type : in-reply-to; s=corp-2019-08-05; bh=9HJDg4ebV+36JCqgzBLlPd7SgnrdxJDhGJ/uJ+JFH5w=; b=g4IJM3qs4GwjlL9VCYQgNkQp2YhlDOd+SEZceV9za8UGvo9EhsNs5FvkHCaCFT+gea+l WA82aQYc5m5DZk/p7J9LBevmYm6HI+mF0sW4WMlnYCk7um1wisMTJpAPmlCNXi5Ve3F4 EH3V3yG6Po9VVIyLg0NRjN+1Ih8zYFhD7EGqXlszWrLf3saKZ9cFpeMDHqn6OFoGWaaU 2ma2AvsVhNaQJCS1FK5UGjZFzzCrjPH65HGS3pml7oucbHx+9YVVdhxr1gREHrHKo/Co lPDLF+YvKZdL+64fX9RNt9+dNhWbU9lqVjJEAalWqnEQL6p/oVcMwxw9P+wqxh8pnabm aw== Received: from userp3020.oracle.com (userp3020.oracle.com [156.151.31.79]) by userp2120.oracle.com with ESMTP id 2xrearrppq-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 31 Jan 2020 08:25:25 +0000 Received: from pps.filterd (userp3020.oracle.com [127.0.0.1]) by userp3020.oracle.com (8.16.0.27/8.16.0.27) with SMTP id 00V8NFU0123097; Fri, 31 Jan 2020 08:25:24 GMT Received: from userv0122.oracle.com (userv0122.oracle.com [156.151.31.75]) by userp3020.oracle.com with ESMTP id 2xva6q2yh0-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 31 Jan 2020 08:25:24 +0000 Received: from abhmp0014.oracle.com (abhmp0014.oracle.com [141.146.116.20]) by userv0122.oracle.com (8.14.4/8.14.4) with ESMTP id 00V8PLea003983; Fri, 31 Jan 2020 08:25:21 GMT Received: from kadam (/129.205.23.165) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Fri, 31 Jan 2020 00:25:20 -0800 Date: Fri, 31 Jan 2020 11:24:51 +0300 From: Dan Carpenter To: Andy Shevchenko Cc: Greg Kroah-Hartman , Ajay Gupta , "David S. Miller" , "Rafael J. Wysocki" , Iyappan Subramanian , Keyur Chudgar , Quan Nguyen , Steve Glendinning , Jassi Brar , Ilias Apalodimas , Giuseppe Cavallaro , Alexandre Torgue , Jose Abreu , Maxime Coquelin , Dmitry Torokhov , Andy Shevchenko , Sakari Ailus , Heikki Krogerus , Linux Kernel Mailing List , netdev , linux-stm32@st-md-mailman.stormreply.com, kernel-janitors@vger.kernel.org Subject: Re: [PATCH net] device property: change device_get_phy_mode() to prevent signedess bugs Message-ID: <20200131082451.GD11068@kadam> References: <20200131045953.wbj66jkvijnmf5s2@kili.mountain> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.9.4 (2018-02-28) X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9516 signatures=668685 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 suspectscore=0 malwarescore=0 phishscore=0 bulkscore=0 spamscore=0 mlxscore=0 mlxlogscore=999 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1911140001 definitions=main-2001310074 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9516 signatures=668685 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 priorityscore=1501 malwarescore=0 suspectscore=0 phishscore=0 bulkscore=0 spamscore=0 clxscore=1015 lowpriorityscore=0 mlxscore=0 impostorscore=0 mlxlogscore=999 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1911140001 definitions=main-2001310074 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, Jan 31, 2020 at 10:15:14AM +0200, Andy Shevchenko wrote: > On Fri, Jan 31, 2020 at 7:03 AM Dan Carpenter wrote: > > > > The device_get_phy_mode() was returning negative error codes on > > failure and positive phy_interface_t values on success. The problem is > > that the phy_interface_t type is an enum which GCC treats as unsigned. > > This lead to recurring signedness bugs where we check "if (phy_mode < 0)" > > and "phy_mode" is unsigned. > > > > In the commit 0c65b2b90d13 ("net: of_get_phy_mode: Change API to solve > > int/unit warnings") we updated of_get_phy_mode() take a pointer to > > phy_mode and only return zero on success and negatives on failure. This > > patch does the same thing for device_get_phy_mode(). Plus it's just > > nice for the API to be the same in both places. > > > > + err = device_get_phy_mode(dev, &config->phy_interface); > > > + if (err) > > + config->phy_interface = PHY_INTERFACE_MODE_NA; > > Do you need these? It seems the default settings when error appears. > We don't need it, but I thought it made things more readable. regards, dan carpenter