Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755472AbbHLOnn (ORCPT ); Wed, 12 Aug 2015 10:43:43 -0400 Received: from mail-bl2on0109.outbound.protection.outlook.com ([65.55.169.109]:56251 "EHLO na01-bl2-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1753416AbbHLOnl (ORCPT ); Wed, 12 Aug 2015 10:43:41 -0400 From: Madalin-Cristian Bucur To: Stas Sergeev , Florian Fainelli , "netdev@vger.kernel.org" , "grant.likely@linaro.org" , "robh+dt@kernel.org" CC: "devicetree@vger.kernel.org" , "linux-kernel@vger.kernel.org" , Liberman Igal , Stas Sergeev , "joakim.tjernlund@transmode.se" , Shaohui Xie Subject: RE: [PATCH 0/2] of: fsl/fman: reuse the fixed node parsing code Thread-Topic: [PATCH 0/2] of: fsl/fman: reuse the fixed node parsing code Thread-Index: AQHQz40u7/EeGP0M3EaSWT7KT29M554CYVyAgASdLgCAAAcBIIAACVUAgAFL3eCAABP/gIAABbOQ Date: Wed, 12 Aug 2015 14:43:38 +0000 Message-ID: References: <1438785745-15517-1-git-send-email-madalin.bucur@freescale.com> <55C63D3B.5020005@gmail.com> <55CA1C14.3000202@list.ru> <55CA29C8.5000707@list.ru> <55CB50F1.7050308@list.ru> In-Reply-To: <55CB50F1.7050308@list.ru> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: authentication-results: spf=none (sender IP is ) smtp.mailfrom=madalin.bucur@freescale.com; x-originating-ip: [192.88.166.1] x-microsoft-exchange-diagnostics: 1;BL2PR03MB500;5:Rgr4hKKaSMOWGO4vpJRKa+D78hJbLtZJhCS/sdZCMfI4KIaGmwUYXniHfbbvmaQJGO8210H5etyu/bHS4k4uA7nD9YU947G4UA6au7EZ03OcRxNQ9DLNFfRiX6Xkpn7dt+h1BkCIGC5n5JYxVNM4Mw==;24:PoAajzc9v709nTpunjC/UvPVVRFh/y3erU+Nhy/ixG3nCV/v/cezZBKUAew1zh2szlUAInLKLzeNyehLdbh1q0c7B8OyvrzQvXWULDlpT2o=;20:bnrUweDDJ8EuJxNf0sJBlA0yChtLcBHOAPnYBDCD4eyOigvQIMtfLj9lu3+HUZtnkEDgvDP7LHnkMT30IqUnFQ== x-microsoft-antispam: UriScan:;BCL:0;PCL:0;RULEID:;SRVR:BL2PR03MB500; 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:BL2PR03MB500;BCL:0;PCL:0;RULEID:;SRVR:BL2PR03MB500; x-forefront-prvs: 0666E15D35 x-forefront-antispam-report: SFV:NSPM;SFS:(10019020)(6009001)(199003)(189002)(13464003)(64706001)(93886004)(50986999)(54356999)(76176999)(19580405001)(2201001)(19580395003)(86362001)(5003600100002)(74316001)(33656002)(87936001)(5002640100001)(2656002)(189998001)(99286002)(66066001)(92566002)(122556002)(68736005)(40100003)(77096005)(62966003)(76576001)(77156002)(46102003)(5001830100001)(105586002)(10400500002)(107886002)(5001960100002)(106356001)(2900100001)(106116001)(2950100001)(4001540100001)(2501003)(5001920100001)(81156007)(102836002)(5001860100001)(5001770100001)(97736004)(101416001)(4001430100001)(179675005);DIR:OUT;SFP:1102;SCL:1;SRVR:BL2PR03MB500;H:BL2PR03MB545.namprd03.prod.outlook.com;FPR:;SPF:None;PTR:InfoNoRecords;A:1;MX:1;LANG:en; Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 X-OriginatorOrg: freescale.com X-MS-Exchange-CrossTenant-originalarrivaltime: 12 Aug 2015 14:43:38.3199 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 710a03f5-10f6-4d38-9ff4-a80b81da590d X-MS-Exchange-Transport-CrossTenantHeadersStamped: BL2PR03MB500 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Transfer-Encoding: 8bit X-MIME-Autoconverted: from base64 to 8bit by mail.home.local id t7CEhmup019267 Content-Length: 5594 Lines: 148 > -----Original Message----- > From: Stas Sergeev [mailto:stsp@list.ru] > > 12.08.2015 16:26, Madalin-Cristian Bucur пишет: > >>> I've tried to make the smallest changes that allow me to retrieve those > >>> without modifying existing API. > >>> Why is it important to hide the default values from the MAC driver? > >> My worry is that the fixed values are not really fixed, and > >> therefore are not always useful to access directly. It is likely > >> not a problem for your use-case, as, as you say, the AN is > >> disabled, but this is probably not the best to do in general. > > Yes, not a problem in my case. > > > >> And also you do: > >> --- > >> > >> - err = of_phy_register_fixed_link(mac_node); > >> - if (err) > >> + struct phy_device *phy; > >> + > >> + mac_dev->fixed_link = kzalloc(sizeof(*mac_dev- > >>> fixed_link), > >> + GFP_KERNEL); > >> + if (of_phy_parse_fixed_link(mac_node, mac_dev- > >>> fixed_link)) > >> + goto _return_dev_set_drvdata; > >> + > >> + phy = fixed_phy_register(PHY_POLL, mac_dev->fixed_link, > >> + mac_node); > >> > >> --- > >> > >> which means you really want to circumvent the current OF > >> api quite a lot, without saying why in the patch description. > > I circumvent the API because I din not want to change existing API. > > If I could get a reference to the status struct without changing any code > > or without being required to call by myself fixed_phy_register(), I > > would of done that. Given the existing code in > of_phy_register_fixed_link(), > > this was my only option. I could have broken of_phy_register_fixed_link() > > in two functions: > > > > of_phy_parse_fixed_link() and of_phy_register_fixed_link(), the latter > doing only > > the call to fixed_phy_register() > > > > that would allow to keep of_phy_register_fixed_link() as it is, broken in > two stages: > > > > - parsing > > - registering > > > > than can be used by other drivers in order to get the status but I think it's > overkill. > What I referred to as "circumventing an API" is that you do > phy = fixed_phy_register(PHY_POLL, mac_dev->fixed_link, + mac_node); > by hands, instead of letting the of_phy_register_fixed_link() doing so. > > How about a smaller circumvention, like this for instance: > --- > err = of_phy_register_fixed_link(mac_node); > phy = of_phy_find_device(dn); > status = fixed_phy_get_link_status(phy); // no such func, to be coded up > --- > > Or even like this: > --- > err = of_phy_register_fixed_link(mac_node); > phy = of_phy_find_device(dn); > set_speed_and_duplex(phy->speed, phy->duplex); // not sure if these > values are available that early > --- After my patch, all that of_phy_register_fixed_link() does is to call the new parsing function I introduced then register the fixed PHY. I could have done this (pseudocode): - add of_phy_parse_fixed_link() as seen in the patch - add of_phy_register_fixed_phy() that just calls fixed_phy_register(): int of_phy_register_fixed_phy(node) { phy = fixed_phy_register(PHY_POLL, mac_dev->fixed_link, mac_node); return (!phy); } - change of_phy_register_fixed_link() to contain only this: int of_phy_register_fixed_link(node) { of_phy_parse_fixed_link(node, &status); return of_phy_register_fixed_phy(node); } Then I could call only of_* functions but the end result would be the same and of_phy_register_fixed_phy() would not justify its existence that much... The getter for status you suggest would be fine, but not sure how one would retrieve it from the mac_node unless we change of_phy_register_fixed_link() to return the pointer to phy (and all the drivers that use it...). > > Also I meant the description should have been in the patch, > not in the e-mail. :) You only wrote _what_ the patch does > (which is of course obvious from the code itself), but not > _why_ and _what was fixed_ (what didn't work). > If you refer to the first, separation patch, I thought the description was enough: of: separate fixed link parsing from registration Some drivers may need to parse the fixed link values before registering the fixed link phy. Separate the parsing from the actual registration and provide an export for the added parsing function. Signed-off-by: Madalin Bucur For this one it was a bit brief, I admit - the longer version would be that before it we were not using from fixed link anything else but the fact the link was fixed (ignored actual speed, duplex values there) and this patch tries to fix that. In the end this patch will be squashed in a new FMan patch set, let me use that as an excuse for the brief commit log :) > > You are concerned about people > > abusing this API to read fixed link status when the link is not really fixed, I'm > concerned > > about declaring the link as fixed-link when it's not. Maybe the > naming/binding needs to be > > revised to cover the case when all is fixed but the link. > Yes, naming is the problem. fixed-link is just a bad name. > See how it is defined: > --- > Some Ethernet MACs have a "fixed link", and are not connected to a > normal MDIO-managed PHY device. > --- > To me this means any non-MDIO PHY connection, but > unfortunately the name "fixed-link" suggests a bit more > than advertised. :( Yes, maybe the new binding could be updated to load semantically the presence or absence of certain parameters such as link. ????{.n?+???????+%?????ݶ??w??{.n?+????{??G?????{ay?ʇڙ?,j??f???h?????????z_??(?階?ݢj"???m??????G????????????&???~???iO???z??v?^?m???? ????????I?