All of lore.kernel.org
 help / color / mirror / Atom feed
From: Greg Ungerer <gerg@snapgear.com>
To: Joe Perches <joe@perches.com>
Cc: Geert Uytterhoeven <geert@linux-m68k.org>,
	<netdev@vger.kernel.org>, <linux-m68k@vger.kernel.org>,
	Greg Ungerer <gerg@uclinux.org>
Subject: Re: [PATCH 2/2] net: add support for NS8390 based eth controllers on some ColdFire CPU boards
Date: Wed, 4 Jul 2012 18:06:54 +1000	[thread overview]
Message-ID: <4FF3F99E.30506@snapgear.com> (raw)
In-Reply-To: <CAMuHMdVYiQyurOQOoeLbd6zXnaVK8Y9bUC=wXkHxhQO+cQwecQ@mail.gmail.com>

On 07/04/2012 05:52 PM, Geert Uytterhoeven wrote:
> On Wed, Jul 4, 2012 at 8:39 AM, Joe Perches <joe@perches.com> wrote:
>>>>> +static int mcf8390_init(struct net_device *dev)
>>>>> +{
>>>>> +  static u32 offsets[] = {
>>>>> +          0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
>>>>> +          0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f,
>>>>> +  };
>>>>
>>>> const?  u8?
>>>
>>> That is assigned to the "reg_offset" field of "struct ei_device"
>>> (defined in the existing 8390.h) and that is:
>>>
>>>       u32 *reg_offset;         /* Register mapping table */
>>>
>>> So I can't change this.
>>
>> Sure you can, you can assign a u8 to a u32 just fine.
>
> It's not the value that's assigned, but a pointer to the table, so
> for now it must be non-const u32 *.
>
>> The value fits in a u8.  Might as well make it take
>> less data space.  static const makes it read-only and
>> makes the compiler assign it just once instead of at
>> function invocation.
>
> That needs changes to drivers/net/ethernet/8390/8390.h, and
> also probably to some drivers that assign values to the array.

Yes, that is right, some drivers as well.

Just making that local offsets array const generates compiler
warnings (as you would expect):

   CC      drivers/net/ethernet/8390/mcf8390.o
drivers/net/ethernet/8390/mcf8390.c: In function ‘mcf8390_init’:
drivers/net/ethernet/8390/mcf8390.c:393:23: warning: assignment discards 
qualifiers from pointer target type

Regards
Greg


------------------------------------------------------------------------
Greg Ungerer  --  Principal Engineer        EMAIL:     gerg@snapgear.com
SnapGear Group, McAfee                      PHONE:       +61 7 3435 2888
8 Gardner Close,                            FAX:         +61 7 3891 3630
Milton, QLD, 4064, Australia                WEB: http://www.SnapGear.com

WARNING: multiple messages have this Message-ID (diff)
From: Greg Ungerer <gerg@snapgear.com>
To: Joe Perches <joe@perches.com>
Cc: Geert Uytterhoeven <geert@linux-m68k.org>,
	netdev@vger.kernel.org, linux-m68k@vger.kernel.org,
	Greg Ungerer <gerg@uclinux.org>
Subject: Re: [PATCH 2/2] net: add support for NS8390 based eth controllers on some ColdFire CPU boards
Date: Wed, 4 Jul 2012 18:06:54 +1000	[thread overview]
Message-ID: <4FF3F99E.30506@snapgear.com> (raw)
In-Reply-To: <CAMuHMdVYiQyurOQOoeLbd6zXnaVK8Y9bUC=wXkHxhQO+cQwecQ@mail.gmail.com>

On 07/04/2012 05:52 PM, Geert Uytterhoeven wrote:
> On Wed, Jul 4, 2012 at 8:39 AM, Joe Perches <joe@perches.com> wrote:
>>>>> +static int mcf8390_init(struct net_device *dev)
>>>>> +{
>>>>> +  static u32 offsets[] = {
>>>>> +          0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
>>>>> +          0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f,
>>>>> +  };
>>>>
>>>> const?  u8?
>>>
>>> That is assigned to the "reg_offset" field of "struct ei_device"
>>> (defined in the existing 8390.h) and that is:
>>>
>>>       u32 *reg_offset;         /* Register mapping table */
>>>
>>> So I can't change this.
>>
>> Sure you can, you can assign a u8 to a u32 just fine.
>
> It's not the value that's assigned, but a pointer to the table, so
> for now it must be non-const u32 *.
>
>> The value fits in a u8.  Might as well make it take
>> less data space.  static const makes it read-only and
>> makes the compiler assign it just once instead of at
>> function invocation.
>
> That needs changes to drivers/net/ethernet/8390/8390.h, and
> also probably to some drivers that assign values to the array.

Yes, that is right, some drivers as well.

Just making that local offsets array const generates compiler
warnings (as you would expect):

   CC      drivers/net/ethernet/8390/mcf8390.o
drivers/net/ethernet/8390/mcf8390.c: In function ‘mcf8390_init’:
drivers/net/ethernet/8390/mcf8390.c:393:23: warning: assignment discards 
qualifiers from pointer target type

Regards
Greg


------------------------------------------------------------------------
Greg Ungerer  --  Principal Engineer        EMAIL:     gerg@snapgear.com
SnapGear Group, McAfee                      PHONE:       +61 7 3435 2888
8 Gardner Close,                            FAX:         +61 7 3891 3630
Milton, QLD, 4064, Australia                WEB: http://www.SnapGear.com

  reply	other threads:[~2012-07-04  8:07 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-07-04  4:56 [PATCH 0/2] net: support for NS8390 based ethernet on ColdFire CPU boards gerg
2012-07-04  4:56 ` gerg
2012-07-04  4:56 ` [PATCH 1/2] m68knommu: move the badly named mcfne.h to a better mcf8390.h gerg
2012-07-04  4:56   ` gerg
2012-07-04  4:56 ` [PATCH 2/2] net: add support for NS8390 based eth controllers on some ColdFire CPU boards gerg
2012-07-04  4:56   ` gerg
2012-07-04  5:18   ` Joe Perches
2012-07-04  6:18     ` Greg Ungerer
2012-07-04  6:18       ` Greg Ungerer
2012-07-04  6:39       ` Joe Perches
2012-07-04  7:52         ` Geert Uytterhoeven
2012-07-04  8:06           ` Greg Ungerer [this message]
2012-07-04  8:06             ` Greg Ungerer
2012-07-04 14:52           ` Joe Perches

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=4FF3F99E.30506@snapgear.com \
    --to=gerg@snapgear.com \
    --cc=geert@linux-m68k.org \
    --cc=gerg@uclinux.org \
    --cc=joe@perches.com \
    --cc=linux-m68k@vger.kernel.org \
    --cc=netdev@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.