2009-10-07 03:40:11

by Hin-Tak Leung

[permalink] [raw]
Subject: [PATCH] compat-2.6: adding ethtool.h to compat-2.6.31.h

Between 2.6.30 and 2.6.31, linux/netdevice.h started
to include linux/ethtool.h (commit b1b67dd45a6b629eb41553856805aaa1614fbb83,
"net: factor out ethtool invocation of vlan/macvlan drivers"),
and commit 7508e486965b0af13984bc6d9da62a8d8f0dc5f9,
"cfg80211: add firmware and hardware version to wiphy", introduces
dependency of ETHTOOL_BUSINFO_LEN from linux/ethtool.h
to net/cfg80211.h .

Signed-off-by: Hin-Tak Leung <[email protected]>
---
compat/compat-2.6.31.h | 1 +
1 files changed, 1 insertions(+), 0 deletions(-)

diff --git a/compat/compat-2.6.31.h b/compat/compat-2.6.31.h
index 154209c..e46334a 100644
--- a/compat/compat-2.6.31.h
+++ b/compat/compat-2.6.31.h
@@ -12,6 +12,7 @@
#include <linux/interrupt.h>
#include <net/dst.h>
#include <net/genetlink.h>
+#include <linux/ethtool.h>

/*
* These macros allow us to backport rfkill without any
--
1.6.5.rc2



2009-10-07 05:41:01

by Luis R. Rodriguez

[permalink] [raw]
Subject: Re: [PATCH] compat-2.6: adding ethtool.h to compat-2.6.31.h

On Tue, Oct 6, 2009 at 11:39 PM, Hin-Tak Leung <[email protected]> wrote:
> Between 2.6.30 and 2.6.31, linux/netdevice.h started
> to include linux/ethtool.h (commit b1b67dd45a6b629eb41553856805aaa1614fbb83,
> "net: factor out ethtool invocation of vlan/macvlan drivers"),
> and commit 7508e486965b0af13984bc6d9da62a8d8f0dc5f9,
> "cfg80211: add firmware and hardware version to wiphy", introduces
> dependency of ETHTOOL_BUSINFO_LEN from linux/ethtool.h
> to net/cfg80211.h .

John's patch titled "cfg80211: fix compile error from missing
ethtool.h" seems to address this upstream. I'll wait until he applies
that to the tree.

Luis

2009-10-07 03:47:06

by Hin-Tak Leung

[permalink] [raw]
Subject: Re: [PATCH] compat-2.6: adding ethtool.h to compat-2.6.31.h

After 'compat-2.6: adjusting 01-netdev.patch for libertas cfg80211
support' (which fixes the patches), and 'compat-2.6: adding ethtool.h
to compat-2.6.31.h' (which fixes the cfg80211.h header), the next
error is ath5k_pm_ops type missing:

----------------
CC [M] /home/Hin-Tak/tmp-git/compat-wireless-2.6/drivers/net/wireless/ath/ath5k/base.o
/home/Hin-Tak/tmp-git/compat-wireless-2.6/drivers/net/wireless/ath/ath5k/base.c:201:
warning: data definition has no type or storage class
/home/Hin-Tak/tmp-git/compat-wireless-2.6/drivers/net/wireless/ath/ath5k/base.c:201:
warning: type defaults to ?int? in declaration of ?SIMPLE_DEV_PM_OPS?
/home/Hin-Tak/tmp-git/compat-wireless-2.6/drivers/net/wireless/ath/ath5k/base.c:201:
warning: parameter names (without types) in function declaration
/home/Hin-Tak/tmp-git/compat-wireless-2.6/drivers/net/wireless/ath/ath5k/base.c:212:
error: ?ath5k_pm_ops? undeclared here (not in a function)
make[5]: *** [/home/Hin-Tak/tmp-git/compat-wireless-2.6/drivers/net/wireless/ath/ath5k/base.o]
Error 1
make[4]: *** [/home/Hin-Tak/tmp-git/compat-wireless-2.6/drivers/net/wireless/ath/ath5k]
Error 2
make[3]: *** [/home/Hin-Tak/tmp-git/compat-wireless-2.6/drivers/net/wireless/ath]
Error 2
make[2]: *** [/home/Hin-Tak/tmp-git/compat-wireless-2.6/drivers/net/wireless]
Error 2
make[1]: *** [_module_/home/Hin-Tak/tmp-git/compat-wireless-2.6] Error 2
make[1]: Leaving directory `/usr/src/kernels/2.6.30.8-67.fc11.x86_64'
make: *** [modules] Error 2
---------------

Since this is slightly outside my interest (I am mostly just tracking
rtl818x and to a lesser extent zd1211rw), I'll let others carry on
fixing compat-wireless against current wireless-testing... apologies.

2009-10-07 15:23:46

by Luis R. Rodriguez

[permalink] [raw]
Subject: Re: [PATCH] compat-2.6: adding ethtool.h to compat-2.6.31.h

On Wed, Oct 7, 2009 at 10:45 AM, John W. Linville
<[email protected]> wrote:
> On Wed, Oct 07, 2009 at 01:40:04AM -0400, Luis R. Rodriguez wrote:
>> On Tue, Oct 6, 2009 at 11:39 PM, Hin-Tak Leung <[email protected]> wrote:
>> > Between 2.6.30 and 2.6.31, linux/netdevice.h started
>> > to include linux/ethtool.h (commit b1b67dd45a6b629eb41553856805aaa1614fbb83,
>> > "net: factor out ethtool invocation of vlan/macvlan drivers"),
>> > and commit 7508e486965b0af13984bc6d9da62a8d8f0dc5f9,
>> > "cfg80211: add firmware and hardware version to wiphy", introduces
>> > dependency of ETHTOOL_BUSINFO_LEN from linux/ethtool.h
>> > to net/cfg80211.h .
>>
>> John's patch titled "cfg80211: fix compile error from missing
>> ethtool.h" seems to address this upstream. I'll wait until he applies
>> that to the tree.
>
> As Hin-Tak points-out, linux/netdevice.h is alreadying "doing the needful". :-)
>
> I'll just drop my patch and let this get sorted in compat-wireless.

Heh ok applied, thanks.

Luis

2009-10-07 05:41:39

by Luis R. Rodriguez

[permalink] [raw]
Subject: Re: [PATCH] compat-2.6: adding ethtool.h to compat-2.6.31.h

On Tue, Oct 6, 2009 at 11:45 PM, Hin-Tak Leung <[email protected]> wrote:

> warning: type defaults to ‘int’ in declaration of ‘SIMPLE_DEV_PM_OPS’

Yeah we need to backport this stuff, it seems all drivers are intended
to be moved to use these simple dev pm ops so we might as well.

Luis

2009-10-07 14:46:46

by John W. Linville

[permalink] [raw]
Subject: Re: [PATCH] compat-2.6: adding ethtool.h to compat-2.6.31.h

On Wed, Oct 07, 2009 at 01:40:04AM -0400, Luis R. Rodriguez wrote:
> On Tue, Oct 6, 2009 at 11:39 PM, Hin-Tak Leung <[email protected]> wrote:
> > Between 2.6.30 and 2.6.31, linux/netdevice.h started
> > to include linux/ethtool.h (commit b1b67dd45a6b629eb41553856805aaa1614fbb83,
> > "net: factor out ethtool invocation of vlan/macvlan drivers"),
> > and commit 7508e486965b0af13984bc6d9da62a8d8f0dc5f9,
> > "cfg80211: add firmware and hardware version to wiphy", introduces
> > dependency of ETHTOOL_BUSINFO_LEN from linux/ethtool.h
> > to net/cfg80211.h .
>
> John's patch titled "cfg80211: fix compile error from missing
> ethtool.h" seems to address this upstream. I'll wait until he applies
> that to the tree.

As Hin-Tak points-out, linux/netdevice.h is alreadying "doing the needful". :-)

I'll just drop my patch and let this get sorted in compat-wireless.

John
--
John W. Linville Someday the world will need a hero, and you
[email protected] might be all we have. Be ready.

2009-10-07 06:31:18

by Luis Chamberlain

[permalink] [raw]
Subject: Re: [PATCH] compat-2.6: adding ethtool.h to compat-2.6.31.h

On Wed, Oct 07, 2009 at 01:41:08AM -0400, Luis R. Rodriguez wrote:
> On Tue, Oct 6, 2009 at 11:45 PM, Hin-Tak Leung <[email protected]> wrote:
>
> > warning: type defaults to ‘int’ in declaration of ‘SIMPLE_DEV_PM_OPS’
>
> Yeah we need to backport this stuff, it seems all drivers are intended
> to be moved to use these simple dev pm ops so we might as well.

OK I just committed this patch as a quick attempt to backport this. Testers
welcomed. You'll need the ethtool patch from Hin-Tak as John hasn't yet applied
his own on wireless-testing.

From: Luis R. Rodriguez <[email protected]>
Subject: [PATCH] compat-2.6: backport dev_pm_ops stuff and SIMPLE_DEV_PM_OPS

The 2.6.29 kernel has new struct dev_pm_ops [1] which are used
on the pci device to distinguish power management hooks for suspend
to RAM and hibernation. Older kernels don't have these so we need
to resort back to the good ol' suspend/resume. Fortunately the calls
are not so different so it should be possible to resuse the same
calls on compat code with only slight modifications.

The SIMPLE_DEV_PM_OPS macro is used as a helper to make the regular
suspend/resume calls be linked to the equivalent hibernation calls
as that is the same behaviour in older kernels. We backport
SIMPLE_DEV_PM_OPS only for kernels 2.6.29..2.6.31 and for older
kernels this is a no-op.

[1] http://lxr.linux.no/#linux+v2.6.29/include/linux/pm.h#L170

Signed-off-by: Luis R. Rodriguez <[email protected]>
---
compat/compat-2.6.32.h | 26 ++++++++++++++++
compat/patches/11-dev-pm-ops.patch | 57 ++++++++++++++++++++++++++++++++++++
2 files changed, 83 insertions(+), 0 deletions(-)
create mode 100644 compat/patches/11-dev-pm-ops.patch

diff --git a/compat/compat-2.6.32.h b/compat/compat-2.6.32.h
index 418b521..9c2dba9 100644
--- a/compat/compat-2.6.32.h
+++ b/compat/compat-2.6.32.h
@@ -8,6 +8,7 @@
#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,32))

#include <linux/netdevice.h>
+#include <linux/pm.h>

#define SDIO_VENDOR_ID_INTEL 0x0089
#define SDIO_DEVICE_ID_INTEL_IWMC3200WIMAX 0x1402
@@ -43,6 +44,31 @@ enum netdev_tx {
typedef enum netdev_tx netdev_tx_t;
#endif /* __KERNEL__ */

+
+/*
+ * dev_pm_ops is only available on kernels >= 2.6.29, for
+ * older kernels we rely on reverting the work to old
+ * power management style stuff.
+ */
+#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,29))
+/*
+ * Use this if you want to use the same suspend and resume callbacks for suspend
+ * to RAM and hibernation.
+ */
+#define SIMPLE_DEV_PM_OPS(name, suspend_fn, resume_fn) \
+struct dev_pm_ops name = { \
+ .suspend = suspend_fn, \
+ .resume = resume_fn, \
+ .freeze = suspend_fn, \
+ .thaw = resume_fn, \
+ .poweroff = suspend_fn, \
+ .restore = resume_fn, \
+}
+#else
+#define SIMPLE_DEV_PM_OPS(name, suspend_fn, resume_fn)
+#endif /* >= 2.6.29 */
+
+
#endif /* (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,32)) */

#endif /* LINUX_26_32_COMPAT_H */
diff --git a/compat/patches/11-dev-pm-ops.patch b/compat/patches/11-dev-pm-ops.patch
new file mode 100644
index 0000000..e01eafc
--- /dev/null
+++ b/compat/patches/11-dev-pm-ops.patch
@@ -0,0 +1,57 @@
+The 2.6.29 kernel has new struct dev_pm_ops [1] which are used
+on the pci device to distinguish power management hooks for suspend
+to RAM and hibernation. Older kernels don't have these so we need
+to resort back to the good ol' suspend/resume. Fortunately the calls
+are not so different so it should be possible to resuse the same
+calls on compat code with only slight modifications.
+
+[1] http://lxr.linux.no/#linux+v2.6.29/include/linux/pm.h#L170
+
+--- a/drivers/net/wireless/ath/ath5k/base.c 2009-10-07 01:58:19.000000000 -0400
++++ b/drivers/net/wireless/ath/ath5k/base.c 2009-10-07 02:19:58.000000000 -0400
+@@ -197,6 +197,32 @@
+ #ifdef CONFIG_PM
+ static int ath5k_pci_suspend(struct device *dev);
+ static int ath5k_pci_resume(struct device *dev);
++#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,29))
++#endif
++static int ath5k_pci_suspend_compat(struct pci_dev *pdev, pm_message_t state)
++{
++ int r;
++
++ r = ath5k_pci_suspend(pdev->dev);
++ if (r)
++ return r;
++
++ pci_save_state(pdev);
++ pci_disable_device(pdev);
++ pci_set_power_state(pdev, PCI_D3hot);
++}
++
++static int ath5k_pci_resume_compat(struct pci_dev *pdev)
++{
++ int r;
++
++ pci_restore_state(pdev);
++ r = pci_enable_device(pdev);
++ if (r)
++ return r;
++
++ return ath5k_pci_resume(pdev->dev);
++}
+
+ SIMPLE_DEV_PM_OPS(ath5k_pm_ops, ath5k_pci_suspend, ath5k_pci_resume);
+ #define ATH5K_PM_OPS (&ath5k_pm_ops)
+@@ -209,7 +235,12 @@
+ .id_table = ath5k_pci_id_table,
+ .probe = ath5k_pci_probe,
+ .remove = __devexit_p(ath5k_pci_remove),
++#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,29))
+ .driver.pm = ATH5K_PM_OPS,
++#else
++ .suspend = ath5k_pci_suspend_compat,
++ .resume = ath5k_pci_resume_compat,
++#endif
+ };
+
+
--
1.6.0.4