diff options
author | Francois Romieu <romieu@fr.zoreil.com> | 2011-06-17 11:00:05 -0400 |
---|---|---|
committer | Francois Romieu <romieu@fr.zoreil.com> | 2011-06-17 18:12:38 -0400 |
commit | b6ffd97f5bcfd12df88ece6bc6df7a761ac5a049 (patch) | |
tree | c4424eb4556494cfbeb70832d953e8d237fd5a31 | |
parent | c4dc4d108ace27cc0c594b67bd6bd945deaac8c2 (diff) |
r8169: move the firmware down into the device private data.
No functional difference.
Signed-off-by: Francois Romieu <romieu@fr.zoreil.com>
-rw-r--r-- | drivers/net/r8169.c | 74 |
1 files changed, 48 insertions, 26 deletions
diff --git a/drivers/net/r8169.c b/drivers/net/r8169.c index 73108249462e..3eeefe4b49e0 100644 --- a/drivers/net/r8169.c +++ b/drivers/net/r8169.c | |||
@@ -667,7 +667,9 @@ struct rtl8169_private { | |||
667 | struct rtl8169_counters counters; | 667 | struct rtl8169_counters counters; |
668 | u32 saved_wolopts; | 668 | u32 saved_wolopts; |
669 | 669 | ||
670 | const struct firmware *fw; | 670 | struct rtl_fw { |
671 | const struct firmware *fw; | ||
672 | } *rtl_fw; | ||
671 | #define RTL_FIRMWARE_UNKNOWN ERR_PTR(-EAGAIN); | 673 | #define RTL_FIRMWARE_UNKNOWN ERR_PTR(-EAGAIN); |
672 | }; | 674 | }; |
673 | 675 | ||
@@ -1222,11 +1224,12 @@ static void rtl8169_get_drvinfo(struct net_device *dev, | |||
1222 | struct ethtool_drvinfo *info) | 1224 | struct ethtool_drvinfo *info) |
1223 | { | 1225 | { |
1224 | struct rtl8169_private *tp = netdev_priv(dev); | 1226 | struct rtl8169_private *tp = netdev_priv(dev); |
1227 | struct rtl_fw *rtl_fw = tp->rtl_fw; | ||
1225 | 1228 | ||
1226 | strcpy(info->driver, MODULENAME); | 1229 | strcpy(info->driver, MODULENAME); |
1227 | strcpy(info->version, RTL8169_VERSION); | 1230 | strcpy(info->version, RTL8169_VERSION); |
1228 | strcpy(info->bus_info, pci_name(tp->pci_dev)); | 1231 | strcpy(info->bus_info, pci_name(tp->pci_dev)); |
1229 | strncpy(info->fw_version, IS_ERR_OR_NULL(tp->fw) ? "N/A" : | 1232 | strncpy(info->fw_version, IS_ERR_OR_NULL(rtl_fw) ? "N/A" : |
1230 | rtl_lookup_firmware_name(tp), sizeof(info->fw_version) - 1); | 1233 | rtl_lookup_firmware_name(tp), sizeof(info->fw_version) - 1); |
1231 | } | 1234 | } |
1232 | 1235 | ||
@@ -1741,9 +1744,9 @@ static void rtl_writephy_batch(struct rtl8169_private *tp, | |||
1741 | #define PHY_DELAY_MS 0xe0000000 | 1744 | #define PHY_DELAY_MS 0xe0000000 |
1742 | #define PHY_WRITE_ERI_WORD 0xf0000000 | 1745 | #define PHY_WRITE_ERI_WORD 0xf0000000 |
1743 | 1746 | ||
1744 | static void | 1747 | static void rtl_phy_write_fw(struct rtl8169_private *tp, struct rtl_fw *rtl_fw) |
1745 | rtl_phy_write_fw(struct rtl8169_private *tp, const struct firmware *fw) | ||
1746 | { | 1748 | { |
1749 | const struct firmware *fw = rtl_fw->fw; | ||
1747 | __le32 *phytable = (__le32 *)fw->data; | 1750 | __le32 *phytable = (__le32 *)fw->data; |
1748 | struct net_device *dev = tp->dev; | 1751 | struct net_device *dev = tp->dev; |
1749 | size_t index, fw_size = fw->size / sizeof(*phytable); | 1752 | size_t index, fw_size = fw->size / sizeof(*phytable); |
@@ -1879,18 +1882,20 @@ rtl_phy_write_fw(struct rtl8169_private *tp, const struct firmware *fw) | |||
1879 | 1882 | ||
1880 | static void rtl_release_firmware(struct rtl8169_private *tp) | 1883 | static void rtl_release_firmware(struct rtl8169_private *tp) |
1881 | { | 1884 | { |
1882 | if (!IS_ERR_OR_NULL(tp->fw)) | 1885 | if (!IS_ERR_OR_NULL(tp->rtl_fw)) { |
1883 | release_firmware(tp->fw); | 1886 | release_firmware(tp->rtl_fw->fw); |
1884 | tp->fw = RTL_FIRMWARE_UNKNOWN; | 1887 | kfree(tp->rtl_fw); |
1888 | } | ||
1889 | tp->rtl_fw = RTL_FIRMWARE_UNKNOWN; | ||
1885 | } | 1890 | } |
1886 | 1891 | ||
1887 | static void rtl_apply_firmware(struct rtl8169_private *tp) | 1892 | static void rtl_apply_firmware(struct rtl8169_private *tp) |
1888 | { | 1893 | { |
1889 | const struct firmware *fw = tp->fw; | 1894 | struct rtl_fw *rtl_fw = tp->rtl_fw; |
1890 | 1895 | ||
1891 | /* TODO: release firmware once rtl_phy_write_fw signals failures. */ | 1896 | /* TODO: release firmware once rtl_phy_write_fw signals failures. */ |
1892 | if (!IS_ERR_OR_NULL(fw)) | 1897 | if (!IS_ERR_OR_NULL(rtl_fw)) |
1893 | rtl_phy_write_fw(tp, fw); | 1898 | rtl_phy_write_fw(tp, rtl_fw); |
1894 | } | 1899 | } |
1895 | 1900 | ||
1896 | static void rtl_apply_firmware_cond(struct rtl8169_private *tp, u8 reg, u16 val) | 1901 | static void rtl_apply_firmware_cond(struct rtl8169_private *tp, u8 reg, u16 val) |
@@ -3443,7 +3448,7 @@ rtl8169_init_one(struct pci_dev *pdev, const struct pci_device_id *ent) | |||
3443 | tp->timer.data = (unsigned long) dev; | 3448 | tp->timer.data = (unsigned long) dev; |
3444 | tp->timer.function = rtl8169_phy_timer; | 3449 | tp->timer.function = rtl8169_phy_timer; |
3445 | 3450 | ||
3446 | tp->fw = RTL_FIRMWARE_UNKNOWN; | 3451 | tp->rtl_fw = RTL_FIRMWARE_UNKNOWN; |
3447 | 3452 | ||
3448 | rc = register_netdev(dev); | 3453 | rc = register_netdev(dev); |
3449 | if (rc < 0) | 3454 | if (rc < 0) |
@@ -3512,25 +3517,42 @@ static void __devexit rtl8169_remove_one(struct pci_dev *pdev) | |||
3512 | pci_set_drvdata(pdev, NULL); | 3517 | pci_set_drvdata(pdev, NULL); |
3513 | } | 3518 | } |
3514 | 3519 | ||
3515 | static void rtl_request_firmware(struct rtl8169_private *tp) | 3520 | static void rtl_request_uncached_firmware(struct rtl8169_private *tp) |
3516 | { | 3521 | { |
3517 | /* Return early if the firmware is already loaded / cached. */ | 3522 | struct rtl_fw *rtl_fw; |
3518 | if (IS_ERR(tp->fw)) { | 3523 | const char *name; |
3519 | const char *name; | 3524 | int rc = -ENOMEM; |
3520 | 3525 | ||
3521 | name = rtl_lookup_firmware_name(tp); | 3526 | name = rtl_lookup_firmware_name(tp); |
3522 | if (name) { | 3527 | if (!name) |
3523 | int rc; | 3528 | goto out_no_firmware; |
3524 | 3529 | ||
3525 | rc = request_firmware(&tp->fw, name, &tp->pci_dev->dev); | 3530 | rtl_fw = kzalloc(sizeof(*rtl_fw), GFP_KERNEL); |
3526 | if (rc >= 0) | 3531 | if (!rtl_fw) |
3527 | return; | 3532 | goto err_warn; |
3528 | 3533 | ||
3529 | netif_warn(tp, ifup, tp->dev, "unable to load " | 3534 | rc = request_firmware(&rtl_fw->fw, name, &tp->pci_dev->dev); |
3530 | "firmware patch %s (%d)\n", name, rc); | 3535 | if (rc < 0) |
3531 | } | 3536 | goto err_free; |
3532 | tp->fw = NULL; | 3537 | |
3533 | } | 3538 | tp->rtl_fw = rtl_fw; |
3539 | out: | ||
3540 | return; | ||
3541 | |||
3542 | err_free: | ||
3543 | kfree(rtl_fw); | ||
3544 | err_warn: | ||
3545 | netif_warn(tp, ifup, tp->dev, "unable to load firmware patch %s (%d)\n", | ||
3546 | name, rc); | ||
3547 | out_no_firmware: | ||
3548 | tp->rtl_fw = NULL; | ||
3549 | goto out; | ||
3550 | } | ||
3551 | |||
3552 | static void rtl_request_firmware(struct rtl8169_private *tp) | ||
3553 | { | ||
3554 | if (IS_ERR(tp->rtl_fw)) | ||
3555 | rtl_request_uncached_firmware(tp); | ||
3534 | } | 3556 | } |
3535 | 3557 | ||
3536 | static int rtl8169_open(struct net_device *dev) | 3558 | static int rtl8169_open(struct net_device *dev) |