diff options
| author | Thomas Graf <tgraf@suug.ch> | 2012-06-12 22:55:00 -0400 |
|---|---|---|
| committer | David S. Miller <davem@davemloft.net> | 2012-06-13 18:46:35 -0400 |
| commit | 4e4f2f69704be0ae218d91fb827e5a6987fe262f (patch) | |
| tree | c09331aa6359ab7aa56a122b266b6614998f159b | |
| parent | 716b31abbd39baab307c0a7b38dce9a20c16c62d (diff) | |
dcbnl: Move dcb app allocation into dcb_app_add()
Signed-off-by: Thomas Graf <tgraf@suug.ch>
Signed-off-by: David S. Miller <davem@davemloft.net>
| -rw-r--r-- | net/dcb/dcbnl.c | 47 |
1 files changed, 22 insertions, 25 deletions
diff --git a/net/dcb/dcbnl.c b/net/dcb/dcbnl.c index 6817f1439951..6e1c32468236 100644 --- a/net/dcb/dcbnl.c +++ b/net/dcb/dcbnl.c | |||
| @@ -1732,6 +1732,21 @@ static struct dcb_app_type *dcb_app_lookup(const struct dcb_app *app, | |||
| 1732 | return NULL; | 1732 | return NULL; |
| 1733 | } | 1733 | } |
| 1734 | 1734 | ||
| 1735 | static int dcb_app_add(const struct dcb_app *app, int ifindex) | ||
| 1736 | { | ||
| 1737 | struct dcb_app_type *entry; | ||
| 1738 | |||
| 1739 | entry = kmalloc(sizeof(*entry), GFP_ATOMIC); | ||
| 1740 | if (!entry) | ||
| 1741 | return -ENOMEM; | ||
| 1742 | |||
| 1743 | memcpy(&entry->app, app, sizeof(*app)); | ||
| 1744 | entry->ifindex = ifindex; | ||
| 1745 | list_add(&entry->list, &dcb_app_list); | ||
| 1746 | |||
| 1747 | return 0; | ||
| 1748 | } | ||
| 1749 | |||
| 1735 | /** | 1750 | /** |
| 1736 | * dcb_getapp - retrieve the DCBX application user priority | 1751 | * dcb_getapp - retrieve the DCBX application user priority |
| 1737 | * | 1752 | * |
| @@ -1764,6 +1779,7 @@ int dcb_setapp(struct net_device *dev, struct dcb_app *new) | |||
| 1764 | { | 1779 | { |
| 1765 | struct dcb_app_type *itr; | 1780 | struct dcb_app_type *itr; |
| 1766 | struct dcb_app_type event; | 1781 | struct dcb_app_type event; |
| 1782 | int err = 0; | ||
| 1767 | 1783 | ||
| 1768 | event.ifindex = dev->ifindex; | 1784 | event.ifindex = dev->ifindex; |
| 1769 | memcpy(&event.app, new, sizeof(event.app)); | 1785 | memcpy(&event.app, new, sizeof(event.app)); |
| @@ -1782,22 +1798,13 @@ int dcb_setapp(struct net_device *dev, struct dcb_app *new) | |||
| 1782 | goto out; | 1798 | goto out; |
| 1783 | } | 1799 | } |
| 1784 | /* App type does not exist add new application type */ | 1800 | /* App type does not exist add new application type */ |
| 1785 | if (new->priority) { | 1801 | if (new->priority) |
| 1786 | struct dcb_app_type *entry; | 1802 | err = dcb_app_add(new, dev->ifindex); |
| 1787 | entry = kmalloc(sizeof(struct dcb_app_type), GFP_ATOMIC); | ||
| 1788 | if (!entry) { | ||
| 1789 | spin_unlock(&dcb_lock); | ||
| 1790 | return -ENOMEM; | ||
| 1791 | } | ||
| 1792 | |||
| 1793 | memcpy(&entry->app, new, sizeof(*new)); | ||
| 1794 | entry->ifindex = dev->ifindex; | ||
| 1795 | list_add(&entry->list, &dcb_app_list); | ||
| 1796 | } | ||
| 1797 | out: | 1803 | out: |
| 1798 | spin_unlock(&dcb_lock); | 1804 | spin_unlock(&dcb_lock); |
| 1799 | call_dcbevent_notifiers(DCB_APP_EVENT, &event); | 1805 | if (!err) |
| 1800 | return 0; | 1806 | call_dcbevent_notifiers(DCB_APP_EVENT, &event); |
| 1807 | return err; | ||
| 1801 | } | 1808 | } |
| 1802 | EXPORT_SYMBOL(dcb_setapp); | 1809 | EXPORT_SYMBOL(dcb_setapp); |
| 1803 | 1810 | ||
| @@ -1831,7 +1838,6 @@ EXPORT_SYMBOL(dcb_ieee_getapp_mask); | |||
| 1831 | */ | 1838 | */ |
| 1832 | int dcb_ieee_setapp(struct net_device *dev, struct dcb_app *new) | 1839 | int dcb_ieee_setapp(struct net_device *dev, struct dcb_app *new) |
| 1833 | { | 1840 | { |
| 1834 | struct dcb_app_type *entry; | ||
| 1835 | struct dcb_app_type event; | 1841 | struct dcb_app_type event; |
| 1836 | int err = 0; | 1842 | int err = 0; |
| 1837 | 1843 | ||
| @@ -1847,16 +1853,7 @@ int dcb_ieee_setapp(struct net_device *dev, struct dcb_app *new) | |||
| 1847 | goto out; | 1853 | goto out; |
| 1848 | } | 1854 | } |
| 1849 | 1855 | ||
| 1850 | /* App entry does not exist add new entry */ | 1856 | err = dcb_app_add(new, dev->ifindex); |
| 1851 | entry = kmalloc(sizeof(struct dcb_app_type), GFP_ATOMIC); | ||
| 1852 | if (!entry) { | ||
| 1853 | err = -ENOMEM; | ||
| 1854 | goto out; | ||
| 1855 | } | ||
| 1856 | |||
| 1857 | memcpy(&entry->app, new, sizeof(*new)); | ||
| 1858 | entry->ifindex = dev->ifindex; | ||
| 1859 | list_add(&entry->list, &dcb_app_list); | ||
| 1860 | out: | 1857 | out: |
| 1861 | spin_unlock(&dcb_lock); | 1858 | spin_unlock(&dcb_lock); |
| 1862 | if (!err) | 1859 | if (!err) |
