Received: by 2002:a25:8b91:0:0:0:0:0 with SMTP id j17csp376619ybl; Fri, 31 Jan 2020 00:16:31 -0800 (PST) X-Google-Smtp-Source: APXvYqyshcbS4ok+mzqKWPDRM6TxRnBLIRRcpIU+SbAPIc9ifYdwkUMY4SAehWVuuM9ihq6ez8zl X-Received: by 2002:a54:4182:: with SMTP id 2mr5286451oiy.14.1580458591411; Fri, 31 Jan 2020 00:16:31 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1580458591; cv=none; d=google.com; s=arc-20160816; b=WVH+AlInDZET7UF1yn9klqo2wOVTa4ApSRqj5Dpob9GA52NCmxZSu9+rW5UPIwunRO fFwKsZXwzP1W/kthtiS/nc723xH9HiTotbGXYeQ/WOwAOaNcngpb6+N6m/ULGav9jOdh gMNaKWyJBCwJm1S6pdgdN6N6gAljtQPg60coeCNe5Yvc+wmhhzuSE5vDBdXOk/0zBogv jN7Z7bg4vQ+7PHLakU2s72KU03uWvxtUhy9OrF46X4LOjcw1IUFAiI0NwtispDx6yJlW x8ySYlNSNmkUULt9mxRbpAeFzDe6QLb6JpPMX8o6Ce7A5cUe7Ir7VN0LpavSKlnCmVEQ Ogng== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature; bh=0Y/URflAN0egTNKiFFMYLQYMJ9wMyROzssZLeoHgDcA=; b=GsOhhNgLQqhNwmXr27IzQ012FjKn2t0zVkg8cUK1Z6+eViK7Do6ahMzKDcnwMwmHvR PtPi/vJ14VDrZTcPU4/6Q5BFkWLs6U4joVxhFo1U4n7DSILnFcjkSuNMd12bM/qbPgh8 +zBbKf7gJd396PgM8iFOMGNuV9dlO+ikct+biwcZ5KAHDqKyxZP4IipENmQtak7oUQ32 kTfq9D4CnkW2wQjBqsOYsSGwxpy59iwGOeL1agJ5bETLITo7F9eofy1lTIuFJuuynzb3 Tlncw2lAwgrJE4fDSgUMJrc0LAJ2CSQJWBEkAMwYZ58ixKZSMdXGKGhEvfO3zfL+hdR8 3AhQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=bDvPIqs7; 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=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id a194si1273301oib.227.2020.01.31.00.16.19; Fri, 31 Jan 2020 00:16: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; dkim=pass header.i=@gmail.com header.s=20161025 header.b=bDvPIqs7; 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=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728164AbgAaIP1 (ORCPT + 99 others); Fri, 31 Jan 2020 03:15:27 -0500 Received: from mail-pg1-f193.google.com ([209.85.215.193]:36283 "EHLO mail-pg1-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728099AbgAaIP0 (ORCPT ); Fri, 31 Jan 2020 03:15:26 -0500 Received: by mail-pg1-f193.google.com with SMTP id k3so3057064pgc.3; Fri, 31 Jan 2020 00:15:26 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=0Y/URflAN0egTNKiFFMYLQYMJ9wMyROzssZLeoHgDcA=; b=bDvPIqs7zk+6Ua13LmwPSUxJHYoP3sz8dXzrXUCY11vG2q89ymnvF9KOeRMwUirtgO WhyUtcVQPAnzhKrKITFqvSYkxlT9ISAcAWsYUN+KrpW0FCHyu+ZluN9d0tj4O4L669Xl 2lPXBX7A9ppfx8G8cJPmJPdkjkLVNJvFVuhlBD9SJleQXfC/Tqo5TZuncxblMoLotnGK Ib83dfWkfHcjCYYEuWSvqtZNns38l/X/5LdjmvUkkdqJjDw/KKgoqrjFMG2JYHJbJtGo Hwmntfvq8q/lf8F4I/zJ0W6jIKekE15B6f/Dz4JvKJXfdrWECkV2PUL2Ir7vthKG/b/Q h+yQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=0Y/URflAN0egTNKiFFMYLQYMJ9wMyROzssZLeoHgDcA=; b=e6KZ2edjpT7KJDN3hWGg+T5FQmpg6J26Dci8OwgVDEKAIS7qd7NhzNXO0HbLn9Is29 QE2cLK0J1rHRnBq1HKWSQsfMsn/dLprbhaDzJbN/x1O6XDgQK3uibC3ebPti/I1lgc2q +kikTtuxp8IZR/DBzTz9sePd2pYJJz3H05XNlbu+EgkRClLTZd1GdrCy4wE8e3jDyJi6 nEPuFcYR99/c9SGUmqBCCHD3tloev8UX8vwPoPg/40o6+nXmT7emPiKvJJ0o7n3pyTeW eA0WRe81A25hpaGmBK0hhkaQ9rjx/oSdYDbSia10nRXRaww9YS0tEopgYp9JHAKXDKtW u17Q== X-Gm-Message-State: APjAAAVISfE3ran20DdOA430w07mSJi6WAsS/j9Jw5e7OhssAfAtgt6i Yv69ECcVEyqbzrNiKDjjVO/mBQCu7Giiy8SeDyc= X-Received: by 2002:a65:4685:: with SMTP id h5mr9486059pgr.203.1580458525958; Fri, 31 Jan 2020 00:15:25 -0800 (PST) MIME-Version: 1.0 References: <20200131045953.wbj66jkvijnmf5s2@kili.mountain> In-Reply-To: <20200131045953.wbj66jkvijnmf5s2@kili.mountain> From: Andy Shevchenko Date: Fri, 31 Jan 2020 10:15:14 +0200 Message-ID: Subject: Re: [PATCH net] device property: change device_get_phy_mode() to prevent signedess bugs To: Dan Carpenter 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 Content-Type: text/plain; charset="UTF-8" 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 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. -- With Best Regards, Andy Shevchenko