linux-gpio.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Hans de Goede <hdegoede@redhat.com>
To: "Wu, Wentong" <wentong.wu@intel.com>,
	Oliver Neukum <oneukum@suse.com>,
	"gregkh@linuxfoundation.org" <gregkh@linuxfoundation.org>
Cc: "arnd@arndb.de" <arnd@arndb.de>,
	"mka@chromium.org" <mka@chromium.org>,
	"lee@kernel.org" <lee@kernel.org>,
	"wsa@kernel.org" <wsa@kernel.org>,
	"kfting@nuvoton.com" <kfting@nuvoton.com>,
	"broonie@kernel.org" <broonie@kernel.org>,
	"linus.walleij@linaro.org" <linus.walleij@linaro.org>,
	"maz@kernel.org" <maz@kernel.org>,
	"brgl@bgdev.pl" <brgl@bgdev.pl>,
	"linux-usb@vger.kernel.org" <linux-usb@vger.kernel.org>,
	"linux-i2c@vger.kernel.org" <linux-i2c@vger.kernel.org>,
	"linux-spi@vger.kernel.org" <linux-spi@vger.kernel.org>,
	"linux-gpio@vger.kernel.org" <linux-gpio@vger.kernel.org>,
	"andriy.shevchenko@linux.intel.com" 
	<andriy.shevchenko@linux.intel.com>,
	"heikki.krogerus@linux.intel.com"
	<heikki.krogerus@linux.intel.com>,
	"andi.shyti@linux.intel.com" <andi.shyti@linux.intel.com>,
	"sakari.ailus@linux.intel.com" <sakari.ailus@linux.intel.com>,
	"bartosz.golaszewski@linaro.org" <bartosz.golaszewski@linaro.org>,
	"Pandruvada, Srinivas" <srinivas.pandruvada@intel.com>,
	"Wang, Zhifeng" <zhifeng.wang@intel.com>
Subject: Re: [PATCH v16 1/4] usb: Add support for Intel LJCA device
Date: Thu, 14 Sep 2023 10:21:06 +0200	[thread overview]
Message-ID: <05b9b252-653c-7cf7-9b96-59d9f662b81e@redhat.com> (raw)
In-Reply-To: <DM6PR11MB43162A9B2AC68B2686BBE2598DF7A@DM6PR11MB4316.namprd11.prod.outlook.com>

Hi,

On 9/14/23 03:05, Wu, Wentong wrote:
>> From: Oliver Neukum <oneukum@suse.com>
>>
>> On 13.09.23 03:40, Wentong Wu wrote:
>>
>>> +struct ljca_bank_descriptor {
>>> +	u8 bank_id;
>>> +	u8 pin_num;
>>> +
>>> +	/* 1 bit for each gpio, 1 means valid */
>>> +	u32 valid_pins;
>>
>> No endianness?
> 
> On both sides, the endianness is same.

Right, but normally USB drivers are also written so that they can work on big-endian CPUs.

I realize that this driver will likely never be used with a big-endian CPU but still it is good practice to make the driver work on big-endian CPUs too. Even if it is just to set a good example when other drivers copy the code.

So this should be:

struct ljca_bank_descriptor {
	u8 bank_id;
	u8 pin_num;

	/* 1 bit for each gpio, 1 means valid */
	__le32 valid_pins;
} __packed;

And then when reading valid_pins you should use:

	u32 valid_pins = get_unaligned_le32(&ljca_bank_descriptor.valid_pins);

On x86_64 the compiler should optimize all of this away to
just a regular read.

Regards,

Hans



  reply	other threads:[~2023-09-14  8:22 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-09-13  1:40 [PATCH v16 0/4] Add Intel LJCA device driver Wentong Wu
2023-09-13  1:40 ` [PATCH v16 1/4] usb: Add support for Intel LJCA device Wentong Wu
2023-09-13  6:12   ` kernel test robot
2023-09-13  7:26     ` Hans de Goede
2023-09-13  8:10       ` Wu, Wentong
2023-09-13  9:03   ` Oliver Neukum
2023-09-14  1:05     ` Wu, Wentong
2023-09-14  8:21       ` Hans de Goede [this message]
2023-09-14  8:58         ` Wu, Wentong
2023-09-13  1:40 ` [PATCH v16 2/4] i2c: Add support for Intel LJCA USB I2C driver Wentong Wu
2023-09-13  1:40 ` [PATCH v16 3/4] spi: Add support for Intel LJCA USB SPI driver Wentong Wu
2023-09-13  1:40 ` [PATCH v16 4/4] gpio: update Intel LJCA USB GPIO driver Wentong Wu

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=05b9b252-653c-7cf7-9b96-59d9f662b81e@redhat.com \
    --to=hdegoede@redhat.com \
    --cc=andi.shyti@linux.intel.com \
    --cc=andriy.shevchenko@linux.intel.com \
    --cc=arnd@arndb.de \
    --cc=bartosz.golaszewski@linaro.org \
    --cc=brgl@bgdev.pl \
    --cc=broonie@kernel.org \
    --cc=gregkh@linuxfoundation.org \
    --cc=heikki.krogerus@linux.intel.com \
    --cc=kfting@nuvoton.com \
    --cc=lee@kernel.org \
    --cc=linus.walleij@linaro.org \
    --cc=linux-gpio@vger.kernel.org \
    --cc=linux-i2c@vger.kernel.org \
    --cc=linux-spi@vger.kernel.org \
    --cc=linux-usb@vger.kernel.org \
    --cc=maz@kernel.org \
    --cc=mka@chromium.org \
    --cc=oneukum@suse.com \
    --cc=sakari.ailus@linux.intel.com \
    --cc=srinivas.pandruvada@intel.com \
    --cc=wentong.wu@intel.com \
    --cc=wsa@kernel.org \
    --cc=zhifeng.wang@intel.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;
as well as URLs for NNTP newsgroup(s).