From: Michael Straube <straube.linux@gmail.com>
To: Dan Carpenter <dan.carpenter@oracle.com>
Cc: Joe Perches <joe@perches.com>,
Andy Shevchenko <andy.shevchenko@gmail.com>,
Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
devel@driverdev.osuosl.org,
Linux Kernel Mailing List <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH v3 3/4] staging: rtl8723bs: use ether_addr_copy() in rtw_macaddr_cfg()
Date: Wed, 27 Jun 2018 14:56:00 +0200 [thread overview]
Message-ID: <6221958a-f817-e01b-7e0f-adbbba9acde4@gmail.com> (raw)
In-Reply-To: <20180627083306.rk3niwazi332rqs5@mwanda>
Am 27.06.2018 um 10:33 schrieb Dan Carpenter:
> On Tue, Jun 26, 2018 at 10:32:09PM +0200, Michael Straube wrote:
>>
>> On 06/26/18 22:17, Joe Perches wrote:
>>> On Tue, 2018-06-26 at 21:44 +0200, Michael Straube wrote:
>>>> On 06/26/18 19:32, Andy Shevchenko wrote:
>>>>> On Tue, Jun 26, 2018 at 11:14 AM, Michael Straube
>>>>> <straube.linux@gmail.com> wrote:
>>>>>> Use ether_addr_copy() instead of memcpy() to copy the mac address.
>>>>>>
>>>>>
>>>>> Suggested-by ?
>>>>>
>>>>
>>>> I'll add it. Sorry, I was not aware of the Suggested-by tag.
>>>>
>>>>> Btw, ensure that the source and destination buffers are aligned to u16
>>>>> as required by API.
>>>>
>>>> To be honest I'm not sure how to do that excactly.
>>>>
>>>> Use __align(2) in the array declarations? e.g.:
>>>>
>>>> u8 mac[ETH_ALEN] __align(2);
>>>
>>> All initial function automatics are naturally aligned.
>>>>
>> So there is nothing to change? Now I'm confused.
>
> Do not add the __align(2), as Joe says, it's not required. You just
> need to C alignment rules (it's expected/required for this sort of
> patch).
>
> Like if you have a struct:
>
> struct foo {
> char a;
> int b;
> };
>
> There is going to be a 3 byte gap between a and b because ints are
> normally __align(4). The exception is when the struct is __packed. So
> sizeof(struct foo) in this case is going to be 8. kmalloc() returns
> pointers which are 8 at least byte aligned normally. See
> ARCH_KMALLOC_MINALIGN. There is one arch where it's 4 byte aligned?
>
> So when you would get things which aren't __align(2) is when you have:
>
> struct bar {
> char a[3];
> u8 mac[ETH_ALEN];
> };
>
> Here the struct member before the mac[] is an odd number of char. Or
> when the struct is packed.
>
> regards,
> dan carpenter
>
Thank you for your explanation. I will not add __aligned(2).
The other buffer is u32 aligned:
struct eeprom_priv
{
u8 bautoload_fail_flag;
u8 bloadfile_fail_flag;
u8 bloadmac_fail_flag;
u8 EepromOrEfuse;
u8 mac_addr[6]; /* PermanentAddress */
...
u32 ocr;
...
};
Should I add a thanks line to the commit message:
Thanks to Dan Carpenter, Joe Perches and Andy Shevchenko.
Or would that be considered as too much?
Regards
Michael
next prev parent reply other threads:[~2018-06-27 12:56 UTC|newest]
Thread overview: 19+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-06-26 8:14 [PATCH v3 1/4] staging: rtl8723bs: fix comparsion to NULL - coding style Michael Straube
2018-06-26 8:14 ` [PATCH v3 2/4] staging: rtl8723bs: refactor rtw_macaddr_cfg() Michael Straube
2018-06-26 17:29 ` Andy Shevchenko
2018-06-26 19:19 ` Michael Straube
2018-06-26 8:14 ` [PATCH v3 3/4] staging: rtl8723bs: use ether_addr_copy() in rtw_macaddr_cfg() Michael Straube
2018-06-26 17:32 ` Andy Shevchenko
2018-06-26 19:44 ` Michael Straube
2018-06-26 20:17 ` Joe Perches
2018-06-26 20:32 ` Michael Straube
2018-06-26 21:36 ` Joe Perches
2018-06-27 8:33 ` Dan Carpenter
2018-06-27 12:56 ` Michael Straube [this message]
2018-06-27 13:11 ` Dan Carpenter
2018-06-27 16:14 ` Andy Shevchenko
2018-06-27 16:42 ` Joe Perches
2018-06-27 18:35 ` Dan Carpenter
2018-06-26 8:14 ` [PATCH v3 4/4] staging: rtl8723bs: use mac_pton() " Michael Straube
2018-06-26 17:34 ` Andy Shevchenko
2018-06-26 20:48 ` Michael Straube
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=6221958a-f817-e01b-7e0f-adbbba9acde4@gmail.com \
--to=straube.linux@gmail.com \
--cc=andy.shevchenko@gmail.com \
--cc=dan.carpenter@oracle.com \
--cc=devel@driverdev.osuosl.org \
--cc=gregkh@linuxfoundation.org \
--cc=joe@perches.com \
--cc=linux-kernel@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 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®