From: Borislav Petkov <bp@amd64.org>
To: Francois Romieu <romieu@fr.zoreil.com>
Cc: "netdev@vger.kernel.org" <netdev@vger.kernel.org>,
"Ciprian Docan" <docan@eden.rutgers.edu>,
"Fejes József" <fejes@joco.name>,
"Realtek linux nic maintainers" <nic_swsd@realtek.com>,
"Ben Hutchings" <ben@decadent.org.uk>
Subject: Re: [PATCH rfc 5/5] r8169: provide some firmware information via ethtool.
Date: Thu, 28 Apr 2011 15:34:02 +0200 [thread overview]
Message-ID: <20110428133402.GE10378@aftab> (raw)
In-Reply-To: <20110427203730.GH19708@electric-eye.fr.zoreil.com>
On Wed, Apr 27, 2011 at 04:37:30PM -0400, Francois Romieu wrote:
> There is no real firmware version yet but the manpage of ethtool
> is rather terse about the driver information.
>
> Signed-off-by: Francois Romieu <romieu@fr.zoreil.com>
> Cc: Ciprian Docan <docan@eden.rutgers.edu>
> Cc: Fejes József <fejes@joco.name>
> Cc: Borislav Petkov <borislav.petkov@amd.com>
> Cc: Realtek linux nic maintainers <nic_swsd@realtek.com>
> ---
> drivers/net/r8169.c | 45 +++++++++++++++++++++++++--------------------
> 1 files changed, 25 insertions(+), 20 deletions(-)
>
> diff --git a/drivers/net/r8169.c b/drivers/net/r8169.c
> index 2606a20..76e81ac 100644
> --- a/drivers/net/r8169.c
> +++ b/drivers/net/r8169.c
> @@ -1190,6 +1190,19 @@ static int rtl8169_set_wol(struct net_device *dev, struct ethtool_wolinfo *wol)
> return 0;
> }
>
> +static const char *rtl_lookup_firmware_name(struct rtl8169_private *tp)
> +{
> + int i;
> +
> + for (i = 0; i < ARRAY_SIZE(rtl_firmware_infos); i++) {
> + const struct rtl_firmware_info *info = rtl_firmware_infos + i;
> +
> + if (info->mac_version == tp->mac_version)
> + return info->fw_name;
> + }
> + return NULL;
> +}
> +
> static void rtl8169_get_drvinfo(struct net_device *dev,
> struct ethtool_drvinfo *info)
> {
> @@ -1198,6 +1211,8 @@ static void rtl8169_get_drvinfo(struct net_device *dev,
> strcpy(info->driver, MODULENAME);
> strcpy(info->version, RTL8169_VERSION);
> strcpy(info->bus_info, pci_name(tp->pci_dev));
> + strncpy(info->fw_version, IS_ERR_OR_NULL(tp->fw) ? "N/A" :
> + rtl_lookup_firmware_name(tp), sizeof(info->fw_version));
> }
>
> static int rtl8169_get_regs_len(struct net_device *dev)
> @@ -3502,33 +3517,23 @@ static void __devexit rtl8169_remove_one(struct pci_dev *pdev)
>
> static void rtl_request_firmware(struct rtl8169_private *tp)
> {
> - int i;
> -
> /* Return early if the firmware is already loaded / cached. */
> - if (!IS_ERR(tp->fw))
> - goto out;
> -
> - for (i = 0; i < ARRAY_SIZE(rtl_firmware_infos); i++) {
> - const struct rtl_firmware_info *info = rtl_firmware_infos + i;
> + if (IS_ERR(tp->fw)) {
> + const char *name;
>
> - if (info->mac_version == tp->mac_version) {
> - const char *name = info->fw_name;
> + name = rtl_lookup_firmware_name(tp);
> + if (name) {
Yep, looks good. Just a minor nitpick:
you could save yourself an indentation level by doing
if (!name)
continue;
so that the netif_warn() string below could stay unbroken for easier
grepping.
> int rc;
>
> rc = request_firmware(&tp->fw, name, &tp->pci_dev->dev);
> - if (rc < 0) {
> - netif_warn(tp, ifup, tp->dev, "unable to load "
> - "firmware patch %s (%d)\n", name, rc);
> - goto out_disable_request_firmware;
> - }
> - goto out;
> + if (rc >= 0)
> + return;
> +
> + netif_warn(tp, ifup, tp->dev, "unable to load "
> + "firmware patch %s (%d)\n", name, rc);
> }
> + tp->fw = NULL;
> }
> -
> -out_disable_request_firmware:
> - tp->fw = NULL;
> -out:
> - return;
> }
>
> static int rtl8169_open(struct net_device *dev)
> --
> 1.7.4.4
>
Thanks.
--
Regards/Gruss,
Boris.
Advanced Micro Devices GmbH
Einsteinring 24, 85609 Dornach
General Managers: Alberto Bozzo, Andrew Bowd
Registration: Dornach, Gemeinde Aschheim, Landkreis Muenchen
Registergericht Muenchen, HRB Nr. 43632
prev parent reply other threads:[~2011-04-28 13:34 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-04-27 20:37 [PATCH rfc 5/5] r8169: provide some firmware information via ethtool Francois Romieu
2011-04-28 13:34 ` Borislav Petkov [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20110428133402.GE10378@aftab \
--to=bp@amd64.org \
--cc=ben@decadent.org.uk \
--cc=docan@eden.rutgers.edu \
--cc=fejes@joco.name \
--cc=netdev@vger.kernel.org \
--cc=nic_swsd@realtek.com \
--cc=romieu@fr.zoreil.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox