mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Randy Dunlap <rdunlap@xenotime.net>
To: Vernon Mauery <vernux@us.ibm.com>
Cc: Arnd Bergmann <arnd@arndb.de>,
	Linux Kernel Mailing List <linux-kernel@vger.kernel.org>,
	Keith Mannthey <kmannth@us.ibm.com>
Subject: Re: [RFC][Patch] IBM Real-Time "SMI Free" mode driver -v4
Date: Fri, 24 Sep 2010 09:56:25 -0700	[thread overview]
Message-ID: <20100924095625.5beedf5a.rdunlap@xenotime.net> (raw)
In-Reply-To: <AANLkTimMWAk22gSn2cXA25VNJ1o3OX-mazJfFFd_+MH2@mail.gmail.com>

On Fri, 24 Sep 2010 07:14:27 -0700 Vernon Mauery wrote:

> On Fri, Sep 24, 2010 at 6:12 AM, Arnd Bergmann <arnd@arndb.de> wrote:
> > On Friday 24 September 2010, Vernon Mauery wrote:
> >> +enum rtl_addr_type {
> >> +     RTL_ADDR_TYPE_IO = 1,
> >> +     RTL_ADDR_TYPE_MMIO,
> >> +} __attribute__((packed));
> >> +
> >> +enum rtl_cmd_type {
> >> +     RTL_CMD_NOP = 0,
> >> +     RTL_CMD_ENTER_PRTM,
> >> +     RTL_CMD_EXIT_PRTM,
> >> +} __attribute__((packed));
> >
> > You didn't reply to Randy's comment about the packed attribute.
> > I think it's rather confusing here.

thanks.

> Sorry.  I missed that comment.  The packed attribute on an enum forces
> it into the smallest int type it can be.  enums are normally the size
> of an int, but this enum in the RTL table must fit in an 8-bit int.

I think you would be better off making 'command' below be a u8 then.
Otherwise someone else might add an enum value that is > 255 and the
struct size will change.  I.e., the current way is error-prone.
Just using u8 for command's type is safer.


> >> +/* The RTL table as presented by the EBDA: */
> >> +struct ibm_rtl_table {
> >> +     char signature[5];
> >> +     u8 version;
> >> +     u8 rt_status;
> >> +     enum rtl_cmd_type command;
> >> +     u8 command_status;
> >> +     enum rtl_addr_type cmd_address_type;
> >> +     u8 cmd_granularity;
> >> +     u8 cmd_offset;
> >> +     u16 reserve1;
> >> +     u8 cmd_port_address[4]; /* platform dependent address */
> >> +     u8 cmd_port_value[4];   /* platform dependent value */
> >> +};
> >
> > I would recommend marking the member in this structure as packed instead,
> > not the enum.
> 
> It does not have the same effect.  Without the packed attribute on the
> enums, they end up to be the wrong size and then we would be reading
> from the wrong location in memory.

Thanks for the explanation.

---
~Randy
*** Remember to use Documentation/SubmitChecklist when testing your code ***

  parent reply	other threads:[~2010-09-24 16:56 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-09-21 22:46 [RFC][Patch] IBM Real-Time "SMI Free" mode driver -v3 Vernon Mauery
2010-09-23 21:38 ` Randy Dunlap
2010-09-23 22:12   ` Vernon Mauery
2010-09-23 22:53     ` [RFC][Patch] IBM Real-Time "SMI Free" mode driver -v4 Vernon Mauery
2010-09-24 13:12       ` Arnd Bergmann
2010-09-24 14:14         ` Vernon Mauery
2010-09-24 14:24           ` Arnd Bergmann
2010-09-24 16:56           ` Randy Dunlap [this message]
2010-09-24 21:06             ` [RFC][Patch] IBM Real-Time "SMI Free" mode driver -v5 Vernon Mauery
2010-09-24 21:20               ` Randy Dunlap
2010-09-24 21:30                 ` Vernon Mauery
2010-09-24 21:35                   ` Randy Dunlap
2010-09-24 21:58                     ` [RFC][Patch] IBM Real-Time "SMI Free" mode driver -v6 Vernon Mauery
2010-09-25  2:07                   ` [RFC][Patch] IBM Real-Time "SMI Free" mode driver -v5 Henrique de Moraes Holschuh
2010-09-25 14:42                     ` [RFC][Patch] IBM Real-Time "SMI Free" mode driver -v6 Vernon Mauery
2010-09-24 17:09           ` [RFC][Patch] IBM Real-Time "SMI Free" mode driver -v4 Vernon Mauery
2010-09-24 17:40             ` Arnd Bergmann
2010-09-24 18:23               ` Vernon Mauery
2010-09-24 20:40                 ` Arnd Bergmann
2010-09-24 20:45                 ` Vernon Mauery

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=20100924095625.5beedf5a.rdunlap@xenotime.net \
    --to=rdunlap@xenotime.net \
    --cc=arnd@arndb.de \
    --cc=kmannth@us.ibm.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=vernux@us.ibm.com \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®