Received: by 2002:a05:7412:bbc7:b0:fc:a2b0:25d7 with SMTP id kh7csp425150rdb; Thu, 1 Feb 2024 12:28:26 -0800 (PST) X-Google-Smtp-Source: AGHT+IEHNOLPsKbvpTui0zMDpUhAQeNnhuC04/bIzN8SVJIOU8V8Gp+lSyDubapS8QNIgwp0W0vS X-Received: by 2002:a05:6358:6423:b0:178:a3ea:bc9 with SMTP id f35-20020a056358642300b00178a3ea0bc9mr5453313rwh.12.1706819305633; Thu, 01 Feb 2024 12:28:25 -0800 (PST) X-Forwarded-Encrypted: i=1; AJvYcCXGJ6feEZZRpr30tGbgidkFMukSe2AhLKKNyyBu/wjCB3ZUvU4B3wk073xZ/pMGCHSTSJG3eT1xpht0k4w626NcXhsfPeE4c1SEYxqi0A== Return-Path: Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [2604:1380:40f1:3f00::1]) by mx.google.com with ESMTPS id x5-20020a63aa45000000b005d8b991929bsi292151pgo.522.2024.02.01.12.28.25 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 01 Feb 2024 12:28:25 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-48801-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) client-ip=2604:1380:40f1:3f00::1; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@umich.edu header.s=google-2016-06-03 header.b=SdhvkOni; arc=fail (body hash mismatch); spf=pass (google.com: domain of linux-kernel+bounces-48801-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-48801-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=umich.edu Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sy.mirrors.kernel.org (Postfix) with ESMTPS id B8ADEB2498B for ; Thu, 1 Feb 2024 20:02:34 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 6864885642; Thu, 1 Feb 2024 20:02:19 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=fail reason="signature verification failed" (2048-bit key) header.d=umich.edu header.i=@umich.edu header.b="SdhvkOni" Received: from mail-oi1-f171.google.com (mail-oi1-f171.google.com [209.85.167.171]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 7EF6185289 for ; Thu, 1 Feb 2024 20:02:15 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.167.171 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706817738; cv=none; b=keP/X69vsraL1/UoOtUGBnWgWSc9F5H7Fp1+KVtgewR1GHslzknJs9ow28tau3VPBiWHJatYzuUMtZCZJwasQ/GEdZVQr/n9H060L8UC+J3SlKL5l2DeLDQGtdgNqUG0qtPV+y2CWHqN31xwDkeJYmnh4/wuN5R/c3K5BiVj66M= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706817738; c=relaxed/simple; bh=tvy6mSud+tO0FW2Ix++bq0Yqn3nq8l29ZBq1/shnleU=; h=MIME-Version:References:In-Reply-To:From:Date:Message-ID:Subject: To:Cc:Content-Type; b=MFZB0jLkDXguma1WB7QN1tzJcfXaHIgaFtsdAA4fj2DdPnTduECM9mhRx3G6lJd8qFNMR/WAMIm9itk+PfGWKo0g5K8YGLbr0hdtVPIvQHvmVz8M4s5HGNffWKslSOn55qG8NXdfP7YvoocbN3xC6YSQJXN89ClzYNXPwIMR1T4= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=umich.edu; spf=pass smtp.mailfrom=umich.edu; dkim=pass (2048-bit key) header.d=umich.edu header.i=@umich.edu header.b=SdhvkOni; arc=none smtp.client-ip=209.85.167.171 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=umich.edu Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=umich.edu Received: by mail-oi1-f171.google.com with SMTP id 5614622812f47-3bbbc6e51d0so876924b6e.3 for ; Thu, 01 Feb 2024 12:02:15 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=umich.edu; s=google-2016-06-03; t=1706817734; x=1707422534; darn=vger.kernel.org; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=oKtKU9ec/rsz7HBSzIU5uqFOSZbUdu+2rlARf46Czpw=; b=SdhvkOnie1LRW6jS1+B8/uSuT6goBwPJ5Ysv4a0WhSxROFWET7z6lXc6zDSsNw3lfT l4pUCQ13wLkl+D0Rkxcb7xsaI3ncktvMANX2AqlxF6jM/6uRS31Wvn62Pw/u0AXPEU3C lUD20nZY+iDBO5RWhY3sLWc1PkOtFQMIaBHGO6wuzhuZL8XK3WwNEvRzKLJPXv4eVnYN CH+7SkmGsNySP4rt8hM3f8M14PaRW78PVEpA/s+kEawiyY8uD7kznYhDlQ5IwBSpWWI2 Uxkac9x/ZCcnpWh3ZwwJyfMhYqJ/Xsmv8hYUFMqecMSIheVkdkBpPUSt1YT8bM2p1NY/ L6hw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1706817734; x=1707422534; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=oKtKU9ec/rsz7HBSzIU5uqFOSZbUdu+2rlARf46Czpw=; b=p9QzP0ZaR7Wl/7IMyljTYjTE1ij+RuSPZoeI9SOczvMKAiqTkkwbaI3K0l9Bdf/qLt LXDJORvTGCmHIYUuOsaxSVjMJh6vB4t6p8rGvTZDGU6L5mXy1EODM218kUbUB3V3wZMm Z94aQEmEKGk8s+1zfPGtSWLy61k2dngkChePJ9dY7WOUFNApP5Gp9ptpAf4njorI2h6q +EnEHT7YRkct/xdlo4BOTlsWexlmWbl4E4+bKElYUgPjmRoUwQ3o+ICg/3GfJLoLfjNN 15uJ0RFzNAAiWItPF6e/DCGDHLqAN4B7qCaRmxH3K2ml5GVoUL59qbAvKpswO+ugc+Mu +B5Q== X-Gm-Message-State: AOJu0Yz4Cn1DTio+f2BHf2Z4K719fwi0dv5duBM0Jhgz87BUir4L/IEd fr+2sjwO5kvWr/ZKkSJ2scdHphI6cAuSwqiSsKZd0rHKDxSHMcA6J8wQS4jiOmxtcYRGWW4kkFS LGPOrDH6boWlRS/LrksAcLfcH5ufx/9NaRZo1bQ== X-Received: by 2002:a05:6808:640e:b0:3be:aafd:cc6 with SMTP id fg14-20020a056808640e00b003beaafd0cc6mr3387394oib.17.1706817734567; Thu, 01 Feb 2024 12:02:14 -0800 (PST) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 References: <20240201-rockchip-rust-phy_depend-v2-0-c5fa4faab924@christina-quast.de> <20240201-rockchip-rust-phy_depend-v2-2-c5fa4faab924@christina-quast.de> In-Reply-To: <20240201-rockchip-rust-phy_depend-v2-2-c5fa4faab924@christina-quast.de> From: Trevor Gross Date: Thu, 1 Feb 2024 14:02:03 -0600 Message-ID: Subject: Re: [PATCH v2 2/3] rust: phy: add some phy_driver and genphy_ functions To: Christina Quast Cc: Miguel Ojeda , Alex Gaynor , Wedson Almeida Filho , Boqun Feng , Gary Guo , =?UTF-8?Q?Bj=C3=B6rn_Roy_Baron?= , Benno Lossin , Andreas Hindborg , Alice Ryhl , FUJITA Tomonori , Andrew Lunn , Heiner Kallweit , Russell King , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Heiko Stuebner , rust-for-linux@vger.kernel.org, linux-kernel@vger.kernel.org, netdev@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-rockchip@lists.infradead.org Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable On Thu, Feb 1, 2024 at 12:07=E2=80=AFPM Christina Quast wrote: > diff --git a/rust/kernel/net/phy.rs b/rust/kernel/net/phy.rs > index e457b3c7cb2f..373a4d358e9f 100644 > --- a/rust/kernel/net/phy.rs > +++ b/rust/kernel/net/phy.rs > @@ -95,6 +95,22 @@ pub fn phy_id(&self) -> u32 { > unsafe { (*phydev).phy_id } > } > > + /// Gets the current crossover of the PHY. > + pub fn mdix(&self) -> u8 { Are possible values for mdix always ETH_TP_MDI{,_INVALID,_X,_AUTO}? If so, this would be better as an enum. > + let phydev =3D self.0.get(); > + // SAFETY: The struct invariant ensures that we may access > + // this field without additional synchronization. > + unsafe { (*phydev).mdix } > + } > + > /// Gets the state of PHY state machine states. > pub fn state(&self) -> DeviceState { > let phydev =3D self.0.get(); > @@ -300,6 +316,15 @@ pub fn genphy_read_abilities(&mut self) -> Result { > // So it's just an FFI call. > to_result(unsafe { bindings::genphy_read_abilities(phydev) }) > } > + > + /// Writes BMCR > + pub fn genphy_config_aneg(&mut self) -> Result { The docs need an update here > + let phydev =3D self.0.get(); > + // SAFETY: `phydev` is pointing to a valid object by the type in= variant of `Self`. > + // So it's just an FFI call. > + // second param =3D false =3D> autoneg not requested > + to_result(unsafe { bindings::__genphy_config_aneg(phydev, false)= }) I assume you did this since the non-dunder `genphy_config_aneg` is inline. I think that is ok since the implementation is so minimal, but you could also add a binding helper and call that (rust/helpers.c). > + } > } > > /// Defines certain other features this PHY supports (like interrupts). > @@ -583,6 +608,12 @@ fn soft_reset(_dev: &mut Device) -> Result { > Err(code::ENOTSUPP) > } > > + /// Called to initialize the PHY, > + /// including after a reset Docs wrapping > + fn config_init(_dev: &mut Device) -> Result { > + Err(code::ENOTSUPP) > + } These have been changed to raise a build error rather than ENOTSUPP in recent , see [1]. That patch is in net-next so you should see it next time you rebase. Also - these functions are meant for the vtable and don't do anything if they are not wired up. See the create_phy_driver function, you will need to add the field. > /// Probes the hardware to determine what abilities it has. > fn get_features(_dev: &mut Device) -> Result { > Err(code::ENOTSUPP) > > -- > 2.43.0 > [1]: https://lore.kernel.org/rust-for-linux/20240125014502.3527275-2-fujita= tomonori@gmail.com/