Received: by 10.192.165.148 with SMTP id m20csp289482imm; Fri, 4 May 2018 10:20:01 -0700 (PDT) X-Google-Smtp-Source: AB8JxZplmMU7zUeP3rxycDQe9FMbnu6Nxi8O7fhFlKtk+ZDYHhFq0VuRYUu0Yl81b9RRnb0hi2b+ X-Received: by 2002:a17:902:7b86:: with SMTP id w6-v6mr7010819pll.183.1525454401721; Fri, 04 May 2018 10:20:01 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1525454401; cv=none; d=google.com; s=arc-20160816; b=y1fT8tXoMEGMUTP7UP8eIOwbOovfleTn6Nfdshny2vu88oFmYCc4l7qiCH9qP837Jg mSe/du1KwF8ycW21DEHyV0csqfiIKsRLB+leoY/zrk+/28H86O3SjPKNtsn2lNZOAmvB XpNtmnENSbmot72zUe8yfgZuZwK4ti8KxDd22FWLdl6LB9ZQ1qmKMB6u/opXd6vdgBap VUJpuLoatz6wRsjmjV01l3IwpX0UcbnUK0XBT0VUGbz5Ono4vD3QAwat/iXeWoXATTYL wk+EPXanZPWlO+58ZzsSTf7cuIsGGqsSkdADGCNjGBWIFJnk3FRXbdb0PEPD949vrXKT vlbA== 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-transfer-encoding:content-disposition:mime-version :references:message-id:subject:cc:to:from:date :arc-authentication-results; bh=sJGSfJxU411T0NaYUqZCGJxeY3cHJuJ8DG1/WiPY9jo=; b=MOv6hRtarJNMRaFEV+sGS7GNvd3SK3ZAyj3mCT7nF2g3xhTbne6TMFUi+4fmsluRiq Vl/1Eg6UUpdKr6vXX4M8I4KNg1RAuzSeGTFRkouVbppWFkMDOqz8Svf/p7PseihAXpAw 87iYC14wiq2+Yy43IpzuIvGVUw9WsmiHsxVaIqTFDMf/FK5c8xj+lot+xSCiCYVTmZPb GWBYRdLcdpyFlml6QJ0pZdDdBv7xSFKmAFj4BYcQyZ0U0Zwv2x9v0ubfTUz24q/6Ondv aBlfZvtBqC0m4sDtfstoOFxTmHgvVfgTGAlk885uBqt1O782oZxMDFLqDjJ88N3WBDkd xmzw== 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 g1-v6si7754040plm.268.2018.05.04.10.19.47; Fri, 04 May 2018 10:20:01 -0700 (PDT) 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 S1751883AbeEDRTd (ORCPT + 99 others); Fri, 4 May 2018 13:19:33 -0400 Received: from mail.bootlin.com ([62.4.15.54]:40351 "EHLO mail.bootlin.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751690AbeEDRTa (ORCPT ); Fri, 4 May 2018 13:19:30 -0400 Received: by mail.bootlin.com (Postfix, from userid 110) id 106732072C; Fri, 4 May 2018 19:19:28 +0200 (CEST) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on mail.bootlin.com X-Spam-Level: X-Spam-Status: No, score=-1.0 required=5.0 tests=ALL_TRUSTED,SHORTCIRCUIT shortcircuit=ham autolearn=disabled version=3.4.0 Received: from localhost (LFbn-TOU-1-136-118.w86-201.abo.wanadoo.fr [86.201.22.118]) by mail.bootlin.com (Postfix) with ESMTPSA id D4E3C2038E; Fri, 4 May 2018 19:19:27 +0200 (CEST) Date: Fri, 4 May 2018 19:19:27 +0200 From: Antoine Tenart To: Florian Fainelli Cc: Antoine Tenart , davem@davemloft.net, kishon@ti.com, linux@armlinux.org.uk, gregory.clement@bootlin.com, andrew@lunn.ch, jason@lakedaemon.net, sebastian.hesselbarth@gmail.com, netdev@vger.kernel.org, linux-kernel@vger.kernel.org, thomas.petazzoni@bootlin.com, maxime.chevallier@bootlin.com, miquel.raynal@bootlin.com, nadavh@marvell.com, stefanc@marvell.com, ymarkman@marvell.com, mw@semihalf.com, linux-arm-kernel@lists.infradead.org Subject: Re: [PATCH net-next v2 01/13] net: phy: sfp: make the i2c-bus property really optional Message-ID: <20180504171927.GB13899@kwain> References: <20180504135643.23466-1-antoine.tenart@bootlin.com> <20180504135643.23466-2-antoine.tenart@bootlin.com> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: User-Agent: Mutt/1.9.5 (2018-04-13) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Florian, On Fri, May 04, 2018 at 10:03:16AM -0700, Florian Fainelli wrote: > On 05/04/2018 06:56 AM, Antoine Tenart wrote: > > > > static int sfp_read(struct sfp *sfp, bool a2, u8 addr, void *buf, size_t len) > > { > > + if (!sfp->read) > > + return -EOPNOTSUPP; > > -ENODEV would be closer to the intended meaning IMHO, those this could > be argue that this is yet another color to paint the bikeshed with. I thought about -ENODEV as well, but ended up choosing -EOPNOTSUPP for some reason. But I'm really fine with both solutions, it really depends on if we want to return a callback isn't available from a s/w point of view (-EOPNOTSUPP) or a h/w point of view (-ENODEV). > > ret = sfp_read(sfp, false, 0, &id, sizeof(id)); > > + if (ret == -EOPNOTSUPP) > > + return ret; > > Can you find a way such that only sfp_sm_mod_probe() needs to check > whether the sfp read/write operations returned failure and then we just > make sure the SFP state machine does not make any more progress? Having > to check the sfp_read()/sfp_write() operations all over the place sounds > error prone and won't scale in the future. I tried doing this in this way (only having logic in the probe function), but that wasn't as simple as this solution and it seemed quite invasive as these read/write calls can be called from a few functions but many code paths (as it's a state machine). So I choose the easiest solution to maintain in the long run, as each future state machine update could impact this. Thanks! Antoine -- Antoine T?nart, Bootlin (formerly Free Electrons) Embedded Linux and Kernel engineering https://bootlin.com