Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1297782 > unrolled thread

[PATCH] mac80211: Make addr const in SET_IEEE80211_PERM_ADDR()

Started byBjorn Andersson <bjorn@kryo.se>
First post2015-12-24 09:40 +0100
Last post2015-12-30 21:10 +0100
Articles 5 — 2 participants

Back to article view | Back to linux.kernel


Contents

  [PATCH] mac80211: Make addr const in SET_IEEE80211_PERM_ADDR() Bjorn Andersson <bjorn@kryo.se> - 2015-12-24 09:40 +0100
    Re: [PATCH] mac80211: Make addr const in SET_IEEE80211_PERM_ADDR() Souptick Joarder <jrdr.linux@gmail.com> - 2015-12-30 17:50 +0100
      Re: [PATCH] mac80211: Make addr const in SET_IEEE80211_PERM_ADDR() Bjorn Andersson <bjorn@kryo.se> - 2015-12-30 18:10 +0100
        Re: [PATCH] mac80211: Make addr const in SET_IEEE80211_PERM_ADDR() Souptick Joarder <jrdr.linux@gmail.com> - 2015-12-30 19:40 +0100
          Re: [PATCH] mac80211: Make addr const in SET_IEEE80211_PERM_ADDR() Bjorn Andersson <bjorn@kryo.se> - 2015-12-30 21:10 +0100

#1297782 — [PATCH] mac80211: Make addr const in SET_IEEE80211_PERM_ADDR()

FromBjorn Andersson <bjorn@kryo.se>
Date2015-12-24 09:40 +0100
Subject[PATCH] mac80211: Make addr const in SET_IEEE80211_PERM_ADDR()
Message-ID<qJ9Bg-4ra-5@gated-at.bofh.it>
Make the addr parameter const in SET_IEEE80211_PERM_ADDR() to save
clients from having to cast away a const qualifier.

Signed-off-by: Bjorn Andersson <bjorn.andersson@sonymobile.com>
---
 include/net/mac80211.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/include/net/mac80211.h b/include/net/mac80211.h
index 7c30faff245f..a6f3c9c4b7c2 100644
--- a/include/net/mac80211.h
+++ b/include/net/mac80211.h
@@ -2167,7 +2167,7 @@ static inline void SET_IEEE80211_DEV(struct ieee80211_hw *hw, struct device *dev
  * @hw: the &struct ieee80211_hw to set the MAC address for
  * @addr: the address to set
  */
-static inline void SET_IEEE80211_PERM_ADDR(struct ieee80211_hw *hw, u8 *addr)
+static inline void SET_IEEE80211_PERM_ADDR(struct ieee80211_hw *hw, const u8 *addr)
 {
 	memcpy(hw->wiphy->perm_addr, addr, ETH_ALEN);
 }
-- 
2.5.0

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

[toc] | [next] | [standalone]


#1299419

FromSouptick Joarder <jrdr.linux@gmail.com>
Date2015-12-30 17:50 +0100
Message-ID<qLs6J-Cv-3@gated-at.bofh.it>
In reply to#1297782
HI Bjorn,

On Thu, Dec 24, 2015 at 2:03 PM, Bjorn Andersson <bjorn@kryo.se> wrote:
> Make the addr parameter const in SET_IEEE80211_PERM_ADDR() to save
> clients from having to cast away a const qualifier.
>
> Signed-off-by: Bjorn Andersson <bjorn.andersson@sonymobile.com>
> ---
>  include/net/mac80211.h | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/include/net/mac80211.h b/include/net/mac80211.h
> index 7c30faff245f..a6f3c9c4b7c2 100644
> --- a/include/net/mac80211.h
> +++ b/include/net/mac80211.h
> @@ -2167,7 +2167,7 @@ static inline void SET_IEEE80211_DEV(struct ieee80211_hw *hw, struct device *dev
>   * @hw: the &struct ieee80211_hw to set the MAC address for
>   * @addr: the address to set
>   */
> -static inline void SET_IEEE80211_PERM_ADDR(struct ieee80211_hw *hw, u8 *addr)
> +static inline void SET_IEEE80211_PERM_ADDR(struct ieee80211_hw *hw, const u8 *addr)

I guess without const or with const doesn't make much difference here.
Correct me if I am wrong.
>  {
>         memcpy(hw->wiphy->perm_addr, addr, ETH_ALEN);
>  }
> --
> 2.5.0
>
> --
> 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

-Souptick
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

[toc] | [prev] | [next] | [standalone]


#1299424

FromBjorn Andersson <bjorn@kryo.se>
Date2015-12-30 18:10 +0100
Message-ID<qLsq6-YR-5@gated-at.bofh.it>
In reply to#1299419
On Wed, Dec 30, 2015 at 8:47 AM, Souptick Joarder <jrdr.linux@gmail.com> wrote:
>
> HI Bjorn,
>
> On Thu, Dec 24, 2015 at 2:03 PM, Bjorn Andersson <bjorn@kryo.se> wrote:
> > Make the addr parameter const in SET_IEEE80211_PERM_ADDR() to save
> > clients from having to cast away a const qualifier.
> >
> > Signed-off-by: Bjorn Andersson <bjorn.andersson@sonymobile.com>
> > ---
> >  include/net/mac80211.h | 2 +-
> >  1 file changed, 1 insertion(+), 1 deletion(-)
> >
> > diff --git a/include/net/mac80211.h b/include/net/mac80211.h
> > index 7c30faff245f..a6f3c9c4b7c2 100644
> > --- a/include/net/mac80211.h
> > +++ b/include/net/mac80211.h
> > @@ -2167,7 +2167,7 @@ static inline void SET_IEEE80211_DEV(struct ieee80211_hw *hw, struct device *dev
> >   * @hw: the &struct ieee80211_hw to set the MAC address for
> >   * @addr: the address to set
> >   */
> > -static inline void SET_IEEE80211_PERM_ADDR(struct ieee80211_hw *hw, u8 *addr)
> > +static inline void SET_IEEE80211_PERM_ADDR(struct ieee80211_hw *hw, const u8 *addr)
>
> I guess without const or with const doesn't make much difference here.
> Correct me if I am wrong.

For most cases it doesn't make any difference, but in my driver I
acquire the mac address as a const u8 *. Therefor I need to cast away
the const part when calling this API.

There's an existing example of this in
drivers/net/wireless/st/cw1200/main.c line 601.


I think it's safe to assume that this API won't ever modify the passed
addr buffer, so there would be no future issues of marking the
parameter const either.

>
> >  {
> >         memcpy(hw->wiphy->perm_addr, addr, ETH_ALEN);
> >  }
>

Regards,
Bjorn
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

[toc] | [prev] | [next] | [standalone]


#1299451

FromSouptick Joarder <jrdr.linux@gmail.com>
Date2015-12-30 19:40 +0100
Message-ID<qLtPb-1Kb-1@gated-at.bofh.it>
In reply to#1299424
On Wed, Dec 30, 2015 at 10:35 PM, Bjorn Andersson <bjorn@kryo.se> wrote:
> On Wed, Dec 30, 2015 at 8:47 AM, Souptick Joarder <jrdr.linux@gmail.com> wrote:
>>
>> HI Bjorn,
>>
>> On Thu, Dec 24, 2015 at 2:03 PM, Bjorn Andersson <bjorn@kryo.se> wrote:
>> > Make the addr parameter const in SET_IEEE80211_PERM_ADDR() to save
>> > clients from having to cast away a const qualifier.
>> >
>> > Signed-off-by: Bjorn Andersson <bjorn.andersson@sonymobile.com>
>> > ---
>> >  include/net/mac80211.h | 2 +-
>> >  1 file changed, 1 insertion(+), 1 deletion(-)
>> >
>> > diff --git a/include/net/mac80211.h b/include/net/mac80211.h
>> > index 7c30faff245f..a6f3c9c4b7c2 100644
>> > --- a/include/net/mac80211.h
>> > +++ b/include/net/mac80211.h
>> > @@ -2167,7 +2167,7 @@ static inline void SET_IEEE80211_DEV(struct ieee80211_hw *hw, struct device *dev
>> >   * @hw: the &struct ieee80211_hw to set the MAC address for
>> >   * @addr: the address to set
>> >   */
>> > -static inline void SET_IEEE80211_PERM_ADDR(struct ieee80211_hw *hw, u8 *addr)
>> > +static inline void SET_IEEE80211_PERM_ADDR(struct ieee80211_hw *hw, const u8 *addr)
>>
>> I guess without const or with const doesn't make much difference here.
>> Correct me if I am wrong.
>
> For most cases it doesn't make any difference, but in my driver I
> acquire the mac address as a const u8 *. Therefor I need to cast away
> the const part when calling this API.
>
> There's an existing example of this in
> drivers/net/wireless/st/cw1200/main.c line 601.

Is the path correct ? I think path is
drivers/net/wireless/cw1200/main.c line 334

> I think it's safe to assume that this API won't ever modify the passed
> addr buffer, so there would be no future issues of marking the
> parameter const either.

I agree with you.

>
>>
>> >  {
>> >         memcpy(hw->wiphy->perm_addr, addr, ETH_ALEN);
>> >  }
>>
>
> Regards,
> Bjorn

-Souptick
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

[toc] | [prev] | [next] | [standalone]


#1299480

FromBjorn Andersson <bjorn@kryo.se>
Date2015-12-30 21:10 +0100
Message-ID<qLvei-2Ma-15@gated-at.bofh.it>
In reply to#1299451
On Wed, Dec 30, 2015 at 10:30 AM, Souptick Joarder <jrdr.linux@gmail.com> wrote:
> On Wed, Dec 30, 2015 at 10:35 PM, Bjorn Andersson <bjorn@kryo.se> wrote:
>> On Wed, Dec 30, 2015 at 8:47 AM, Souptick Joarder <jrdr.linux@gmail.com> wrote:
>>>
>>> HI Bjorn,
>>>
>>> On Thu, Dec 24, 2015 at 2:03 PM, Bjorn Andersson <bjorn@kryo.se> wrote:
>>> > Make the addr parameter const in SET_IEEE80211_PERM_ADDR() to save
>>> > clients from having to cast away a const qualifier.
>>> >
>>> > Signed-off-by: Bjorn Andersson <bjorn.andersson@sonymobile.com>
>>> > ---
>>> >  include/net/mac80211.h | 2 +-
>>> >  1 file changed, 1 insertion(+), 1 deletion(-)
>>> >
>>> > diff --git a/include/net/mac80211.h b/include/net/mac80211.h
>>> > index 7c30faff245f..a6f3c9c4b7c2 100644
>>> > --- a/include/net/mac80211.h
>>> > +++ b/include/net/mac80211.h
>>> > @@ -2167,7 +2167,7 @@ static inline void SET_IEEE80211_DEV(struct ieee80211_hw *hw, struct device *dev
>>> >   * @hw: the &struct ieee80211_hw to set the MAC address for
>>> >   * @addr: the address to set
>>> >   */
>>> > -static inline void SET_IEEE80211_PERM_ADDR(struct ieee80211_hw *hw, u8 *addr)
>>> > +static inline void SET_IEEE80211_PERM_ADDR(struct ieee80211_hw *hw, const u8 *addr)
>>>
>>> I guess without const or with const doesn't make much difference here.
>>> Correct me if I am wrong.
>>
>> For most cases it doesn't make any difference, but in my driver I
>> acquire the mac address as a const u8 *. Therefor I need to cast away
>> the const part when calling this API.
>>
>> There's an existing example of this in
>> drivers/net/wireless/st/cw1200/main.c line 601.
>
> Is the path correct ? I think path is
> drivers/net/wireless/cw1200/main.c line 334
>

It's apparently being relocated in linux-next, and I'm not sure where
I got that line number from. But that's the example I tried to refer
to ;)

Sorry about that.

Regards,
Bjorn

>> I think it's safe to assume that this API won't ever modify the passed
>> addr buffer, so there would be no future issues of marking the
>> parameter const either.
>
> I agree with you.
>
>>
>>>
>>> >  {
>>> >         memcpy(hw->wiphy->perm_addr, addr, ETH_ALEN);
>>> >  }
>>>
>>
>> Regards,
>> Bjorn
>
> -Souptick
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

[toc] | [prev] | [standalone]


Back to top | Article view | linux.kernel


csiph-web