linux-i2c.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Jean Delvare <khali-PUYAD+kWke1g9hUCZPvPmw@public.gmane.org>
To: Jonathan Cameron <jic23-KWPb1pKIrIJaa/9Udqfwiw@public.gmane.org>
Cc: ben-linux-elnMNo+KYs3YtjvyW6yDsg@public.gmane.org,
	linux-i2c-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
	Michael.Hennerich-OyLXuOCK7orQT0dZR+AlfA@public.gmane.org
Subject: Re: [PATCH] i2c: boilerplate function for byte swapped smbus_write/read_word_data
Date: Sun, 9 Oct 2011 09:41:18 +0200	[thread overview]
Message-ID: <20111009094118.44b616bf@endymion.delvare> (raw)
In-Reply-To: <20111008231005.41161836-R0o5gVi9kd7kN2dkZ6Wm7A@public.gmane.org>

On Sat, 8 Oct 2011 23:10:05 +0200, Jean Delvare wrote:
> On Thu, 22 Sep 2011 14:48:14 +0100, Jonathan Cameron wrote:
> > @@ -88,6 +89,23 @@ extern s32 i2c_smbus_read_word_data(const struct i2c_client *client,
> >  				    u8 command);
> >  extern s32 i2c_smbus_write_word_data(const struct i2c_client *client,
> >  				     u8 command, u16 value);
> > +
> > +static inline s32
> > +i2c_smbus_read_word_data_swapped(const struct i2c_client *client,
> > +				 u8 command)
> > +{
> > +	s32 value = i2c_smbus_read_word_data(client, command);
> > +
> > +	return (value < 0) ? value : swab16(value);
> > +}
> > +
> > +static inline s32
> > +i2c_smbus_write_word_data_swapped(const struct i2c_client *client,
> > +				  u8 command, u16 value)
> > +{
> > +	return i2c_smbus_write_word_data(client, command, swab16(value));
> > +}
> > +
> >  /* Returns the number of read bytes */
> >  extern s32 i2c_smbus_read_block_data(const struct i2c_client *client,
> >  				     u8 command, u8 *values);
> 
> It might make sense to change the _data_swapped suffix to just
> _swapped, for the sake of avoiding overly long function names (_data
> was never meaningful for the original functions anyway as there is no
> ambiguity.)
> 
> Other than these minor details, I like the patch very much, I tested if
> with 9 hwmon drivers and it indeed makes the drivers cleaner/smaller.
> I'll be happy to commit it when I am able to do this again.

Oh, and I think the new functions should be listed in
Documentation/i2c/smbus-protocol. Maybe not as separate entries, as
they are not new fundamental types, nor part of the SMBus protocol, but
at least as as notes in the SMBus Read Word and SMBus Write Word
sections.

-- 
Jean Delvare

  parent reply	other threads:[~2011-10-09  7:41 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-09-22 13:48 [PATCH] i2c: boilerplate function for byte swapped smbus_write/read_word_data Jonathan Cameron
     [not found] ` <1316699294-6936-1-git-send-email-jic23-KWPb1pKIrIJaa/9Udqfwiw@public.gmane.org>
2011-10-04 16:37   ` Jonathan Cameron
     [not found]     ` <4E8B3637.1030704-KWPb1pKIrIJaa/9Udqfwiw@public.gmane.org>
2011-10-04 17:05       ` Jean Delvare
2011-10-08 21:10   ` Jean Delvare
     [not found]     ` <20111008231005.41161836-R0o5gVi9kd7kN2dkZ6Wm7A@public.gmane.org>
2011-10-09  7:41       ` Jean Delvare [this message]
     [not found]         ` <20111009094118.44b616bf-R0o5gVi9kd7kN2dkZ6Wm7A@public.gmane.org>
2011-10-10  9:07           ` [PATCH V2] " Jonathan Cameron
2011-10-10  9:07           ` [PATCH] " Jonathan Cameron
     [not found]             ` <1318237663-13937-2-git-send-email-jic23-KWPb1pKIrIJaa/9Udqfwiw@public.gmane.org>
2011-10-10 11:50               ` Jean Delvare
     [not found]                 ` <20111010135014.72598737-R0o5gVi9kd7kN2dkZ6Wm7A@public.gmane.org>
2011-10-11 11:49                   ` Jean Delvare
     [not found]                     ` <20111011134906.60a8c284-R0o5gVi9kd7kN2dkZ6Wm7A@public.gmane.org>
2011-10-11 15:21                       ` Jonathan Cameron
     [not found]                         ` <4E945F06.6050308-KWPb1pKIrIJaa/9Udqfwiw@public.gmane.org>
2011-10-21 10:16                           ` Jonathan Cameron

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=20111009094118.44b616bf@endymion.delvare \
    --to=khali-puyad+kwke1g9huczpvpmw@public.gmane.org \
    --cc=Michael.Hennerich-OyLXuOCK7orQT0dZR+AlfA@public.gmane.org \
    --cc=ben-linux-elnMNo+KYs3YtjvyW6yDsg@public.gmane.org \
    --cc=jic23-KWPb1pKIrIJaa/9Udqfwiw@public.gmane.org \
    --cc=linux-i2c-u79uwXL29TY76Z2rM5mHXA@public.gmane.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;
as well as URLs for NNTP newsgroup(s).