Linux wireless drivers development
 help / color / mirror / Atom feed
* [PATCH] rtl8180: implement get_tsf op for mac80211
@ 2010-01-26 21:22 John W. Linville
  2010-01-26 22:53 ` Gábor Stefanik
  0 siblings, 1 reply; 4+ messages in thread
From: John W. Linville @ 2010-01-26 21:22 UTC (permalink / raw)
  To: linux-wireless; +Cc: John W. Linville

Signed-off-by: John W. Linville <linville@tuxdriver.com>
---
 drivers/net/wireless/rtl818x/rtl8180_dev.c |   15 +++++++++++++++
 1 files changed, 15 insertions(+), 0 deletions(-)

diff --git a/drivers/net/wireless/rtl818x/rtl8180_dev.c b/drivers/net/wireless/rtl818x/rtl8180_dev.c
index 5a2b719..8dbb504 100644
--- a/drivers/net/wireless/rtl818x/rtl8180_dev.c
+++ b/drivers/net/wireless/rtl818x/rtl8180_dev.c
@@ -761,6 +761,20 @@ static void rtl8180_configure_filter(struct ieee80211_hw *dev,
 	rtl818x_iowrite32(priv, &priv->map->RX_CONF, priv->rx_conf);
 }
 
+static u64 rtl8180_get_tsf(struct ieee80211_hw *dev)
+{
+	struct rtl8180_priv *priv = dev->priv;
+	u32 tsftl;
+	u64 tsft;
+
+	tsftl = rtl818x_ioread32(priv, &priv->map->TSFT[0]);
+	tsft = rtl818x_ioread32(priv, &priv->map->TSFT[1]);
+	tsft <<= 32;
+	tsft |= tsftl;
+
+	return tsft;
+}
+
 static const struct ieee80211_ops rtl8180_ops = {
 	.tx			= rtl8180_tx,
 	.start			= rtl8180_start,
@@ -771,6 +785,7 @@ static const struct ieee80211_ops rtl8180_ops = {
 	.bss_info_changed	= rtl8180_bss_info_changed,
 	.prepare_multicast	= rtl8180_prepare_multicast,
 	.configure_filter	= rtl8180_configure_filter,
+	.get_tsf		= rtl8180_get_tsf,
 };
 
 static void rtl8180_eeprom_register_read(struct eeprom_93cx6 *eeprom)
-- 
1.6.2.5


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH] rtl8180: implement get_tsf op for mac80211
  2010-01-26 21:22 [PATCH] rtl8180: implement get_tsf op for mac80211 John W. Linville
@ 2010-01-26 22:53 ` Gábor Stefanik
  2010-01-27  2:10   ` John W. Linville
  0 siblings, 1 reply; 4+ messages in thread
From: Gábor Stefanik @ 2010-01-26 22:53 UTC (permalink / raw)
  To: John W. Linville; +Cc: linux-wireless

On Tue, Jan 26, 2010 at 10:22 PM, John W. Linville
<linville@tuxdriver.com> wrote:
> Signed-off-by: John W. Linville <linville@tuxdriver.com>
> ---
>  drivers/net/wireless/rtl818x/rtl8180_dev.c |   15 +++++++++++++++
>  1 files changed, 15 insertions(+), 0 deletions(-)
>
> diff --git a/drivers/net/wireless/rtl818x/rtl8180_dev.c b/drivers/net/wireless/rtl818x/rtl8180_dev.c
> index 5a2b719..8dbb504 100644
> --- a/drivers/net/wireless/rtl818x/rtl8180_dev.c
> +++ b/drivers/net/wireless/rtl818x/rtl8180_dev.c
> @@ -761,6 +761,20 @@ static void rtl8180_configure_filter(struct ieee80211_hw *dev,
>        rtl818x_iowrite32(priv, &priv->map->RX_CONF, priv->rx_conf);
>  }
>
> +static u64 rtl8180_get_tsf(struct ieee80211_hw *dev)
> +{
> +       struct rtl8180_priv *priv = dev->priv;
> +       u32 tsftl;
> +       u64 tsft;
> +
> +       tsftl = rtl818x_ioread32(priv, &priv->map->TSFT[0]);
> +       tsft = rtl818x_ioread32(priv, &priv->map->TSFT[1]);
> +       tsft <<= 32;
> +       tsft |= tsftl;
> +
> +       return tsft;
> +}

Why not:

struct rtl8180_priv *priv = dev->priv;
u64 tsft;

tsft = rtl818x_ioread32(priv, &priv->map->TSFT[0]);
tfst |= rtl818x_ioread32(priv, &priv->map->TSFT[1]) << 32;

return tsft;

> +
>  static const struct ieee80211_ops rtl8180_ops = {
>        .tx                     = rtl8180_tx,
>        .start                  = rtl8180_start,
> @@ -771,6 +785,7 @@ static const struct ieee80211_ops rtl8180_ops = {
>        .bss_info_changed       = rtl8180_bss_info_changed,
>        .prepare_multicast      = rtl8180_prepare_multicast,
>        .configure_filter       = rtl8180_configure_filter,
> +       .get_tsf                = rtl8180_get_tsf,
>  };
>
>  static void rtl8180_eeprom_register_read(struct eeprom_93cx6 *eeprom)
> --
> 1.6.2.5
>
> --
> To unsubscribe from this list: send the line "unsubscribe linux-wireless" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
>



-- 
Vista: [V]iruses, [I]ntruders, [S]pyware, [T]rojans and [A]dware. :-)

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] rtl8180: implement get_tsf op for mac80211
  2010-01-26 22:53 ` Gábor Stefanik
@ 2010-01-27  2:10   ` John W. Linville
  2010-01-27  4:48     ` Gábor Stefanik
  0 siblings, 1 reply; 4+ messages in thread
From: John W. Linville @ 2010-01-27  2:10 UTC (permalink / raw)
  To: Gábor Stefanik; +Cc: linux-wireless

On Tue, Jan 26, 2010 at 11:53:38PM +0100, Gábor Stefanik wrote:
> On Tue, Jan 26, 2010 at 10:22 PM, John W. Linville
> <linville@tuxdriver.com> wrote:
> > Signed-off-by: John W. Linville <linville@tuxdriver.com>
> > ---
> >  drivers/net/wireless/rtl818x/rtl8180_dev.c |   15 +++++++++++++++
> >  1 files changed, 15 insertions(+), 0 deletions(-)
> >
> > diff --git a/drivers/net/wireless/rtl818x/rtl8180_dev.c b/drivers/net/wireless/rtl818x/rtl8180_dev.c
> > index 5a2b719..8dbb504 100644
> > --- a/drivers/net/wireless/rtl818x/rtl8180_dev.c
> > +++ b/drivers/net/wireless/rtl818x/rtl8180_dev.c
> > @@ -761,6 +761,20 @@ static void rtl8180_configure_filter(struct ieee80211_hw *dev,
> >        rtl818x_iowrite32(priv, &priv->map->RX_CONF, priv->rx_conf);
> >  }
> >
> > +static u64 rtl8180_get_tsf(struct ieee80211_hw *dev)
> > +{
> > +       struct rtl8180_priv *priv = dev->priv;
> > +       u32 tsftl;
> > +       u64 tsft;
> > +
> > +       tsftl = rtl818x_ioread32(priv, &priv->map->TSFT[0]);
> > +       tsft = rtl818x_ioread32(priv, &priv->map->TSFT[1]);
> > +       tsft <<= 32;
> > +       tsft |= tsftl;
> > +
> > +       return tsft;
> > +}
> 
> Why not:
> 
> struct rtl8180_priv *priv = dev->priv;
> u64 tsft;
> 
> tsft = rtl818x_ioread32(priv, &priv->map->TSFT[0]);
> tfst |= rtl818x_ioread32(priv, &priv->map->TSFT[1]) << 32;
> 
> return tsft;

What difference does it make?

John
-- 
John W. Linville		Someday the world will need a hero, and you
linville@tuxdriver.com			might be all we have.  Be ready.

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] rtl8180: implement get_tsf op for mac80211
  2010-01-27  2:10   ` John W. Linville
@ 2010-01-27  4:48     ` Gábor Stefanik
  0 siblings, 0 replies; 4+ messages in thread
From: Gábor Stefanik @ 2010-01-27  4:48 UTC (permalink / raw)
  To: John W. Linville; +Cc: linux-wireless

2010/1/27 John W. Linville <linville@tuxdriver.com>:
> On Tue, Jan 26, 2010 at 11:53:38PM +0100, Gábor Stefanik wrote:
>> On Tue, Jan 26, 2010 at 10:22 PM, John W. Linville
>> <linville@tuxdriver.com> wrote:
>> > Signed-off-by: John W. Linville <linville@tuxdriver.com>
>> > ---
>> >  drivers/net/wireless/rtl818x/rtl8180_dev.c |   15 +++++++++++++++
>> >  1 files changed, 15 insertions(+), 0 deletions(-)
>> >
>> > diff --git a/drivers/net/wireless/rtl818x/rtl8180_dev.c b/drivers/net/wireless/rtl818x/rtl8180_dev.c
>> > index 5a2b719..8dbb504 100644
>> > --- a/drivers/net/wireless/rtl818x/rtl8180_dev.c
>> > +++ b/drivers/net/wireless/rtl818x/rtl8180_dev.c
>> > @@ -761,6 +761,20 @@ static void rtl8180_configure_filter(struct ieee80211_hw *dev,
>> >        rtl818x_iowrite32(priv, &priv->map->RX_CONF, priv->rx_conf);
>> >  }
>> >
>> > +static u64 rtl8180_get_tsf(struct ieee80211_hw *dev)
>> > +{
>> > +       struct rtl8180_priv *priv = dev->priv;
>> > +       u32 tsftl;
>> > +       u64 tsft;
>> > +
>> > +       tsftl = rtl818x_ioread32(priv, &priv->map->TSFT[0]);
>> > +       tsft = rtl818x_ioread32(priv, &priv->map->TSFT[1]);
>> > +       tsft <<= 32;
>> > +       tsft |= tsftl;
>> > +
>> > +       return tsft;
>> > +}
>>
>> Why not:
>>
>> struct rtl8180_priv *priv = dev->priv;
>> u64 tsft;
>>
>> tsft = rtl818x_ioread32(priv, &priv->map->TSFT[0]);
>> tfst |= rtl818x_ioread32(priv, &priv->map->TSFT[1]) << 32;
>>
>> return tsft;
>
> What difference does it make?
>
> John

The primary difference is that it is significantly shorter, and gets
away without a temp variable.

(This is like writing

driver_write32(dev, reg, driver_read32(dev, reg) | 0x80);

instead of

tmp = driver_read32(dev, reg);
tmp |= 0x80;
driver_write32(dev, reg, tmp);

Saves some code.)

> --
> John W. Linville                Someday the world will need a hero, and you
> linville@tuxdriver.com                  might be all we have.  Be ready.
>



-- 
Vista: [V]iruses, [I]ntruders, [S]pyware, [T]rojans and [A]dware. :-)

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2010-01-27  4:48 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-01-26 21:22 [PATCH] rtl8180: implement get_tsf op for mac80211 John W. Linville
2010-01-26 22:53 ` Gábor Stefanik
2010-01-27  2:10   ` John W. Linville
2010-01-27  4:48     ` Gábor Stefanik

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox