public inbox for linux-mtd@lists.infradead.org
 help / color / mirror / Atom feed
From: Matthieu CASTET <matthieu.castet@parrot.com>
To: yuhang wang <wangyuhang2014@gmail.com>
Cc: "broonie@kernel.org" <broonie@kernel.org>,
	"linux-mtd@lists.infradead.org" <linux-mtd@lists.infradead.org>,
	"pekon@ti.com" <pekon@ti.com>,
	"spi-devel-general@lists.sourceforge.net"
	<spi-devel-general@lists.sourceforge.net>,
	"sourav.poddar@ti.com" <sourav.poddar@ti.com>,
	"tpiepho@gmail.com" <tpiepho@gmail.com>
Subject: Re: [PATCH] SPI: DUAL and QUAD support
Date: Mon, 29 Jul 2013 17:35:11 +0200	[thread overview]
Message-ID: <20130729173511.65caa07d@parrot.com> (raw)
In-Reply-To: <CAHSAbzOPfpbPHohG7-EzftiPr5T2m19qgrKg7KS2jSKD-B=goA@mail.gmail.com>

Le Mon, 29 Jul 2013 15:25:51 +0100,
yuhang wang <wangyuhang2014@gmail.com> a écrit :

> Hi,
> 
> 2013/7/29 Matthieu CASTET <matthieu.castet@parrot.com>:
> > Le Mon, 29 Jul 2013 11:53:14 +0100,
> > wangyuhang <wangyuhang2014@gmail.com> a écrit :
> >
> >> Hi,
> >>
> >> modify two things.
> >> 1:
> >> >> @@ -1316,6 +1324,12 @@ int spi_setup(struct spi_device *spi)
> >> >>         /* help drivers fail *cleanly* when they need options
> >> >>          * that aren't supported with their current master
> >> >>          */
> >> >> +       if (((spi->mode >> 8) & 0x03) == 0x03 ||
> >> >> +               ((spi->mode >> 10) & 0x03) == 0x03) {
> >> >> +               dev_err(&spi->dev,
> >> >> +               "setup: can not select dual and quad at the same
> >> >> time\n")
> >> >> +               return -EINVAL;
> >> >> +       }
> >> >> +               return -EINVAL;
> >> >> +       }
> >>
> >> >This code won't work if the constants you added for mode flags
> >> >change value.  More importantly, anyone searching the code for
> >> >SPI_TX_DUAL, etc. won't find this code.
> >>
> >> so use the certain macro to replace.
> >>
> >> 2:
> >> >You need to make sure that existing userspace binaries can run
> >> >unmodified, changing the types will change the layout of the ioctl
> >> >arguments.  This may mean that you need to add new ioctls if you
> >> >need to change types.
> >>
> >> I recovered the SPI_IOC_RD_LSB_FIRST ioctl.
> >> Add new ioctl to fit u16 mode.
> >> In addition,may SPI_IOC_RD_LSB_FIRST should be del in a better way.
> >>
> >> Signed-off-by: wangyuhang <wangyuhang2014@gmail.com>
> >> ---
> >
> >>  /* IOCTL commands */
> >> @@ -54,6 +61,8 @@
> >>   * @tx_buf: Holds pointer to userspace buffer with transmit data,
> >> or null.
> >>   *     If no data is provided, zeroes are shifted out.
> >>   * @rx_buf: Holds pointer to userspace buffer for receive data, or
> >> null.
> >> + * @tx_nbits: number of bits used for writting.
> >> + * @rx_nbits: number of bits used for reading.
> >>   * @len: Length of tx and rx buffers, in bytes.
> >>   * @speed_hz: Temporary override of the device's bitrate.
> >>   * @bits_per_word: Temporary override of the device's wordsize.
> >> @@ -85,6 +94,8 @@
> >>  struct spi_ioc_transfer {
> >>         __u64           tx_buf;
> >>         __u64           rx_buf;
> >> +       __u8            tx_nbits;
> >> +       __u8            rx_nbits;
> >>
> >>         __u32           len;
> >>         __u32           speed_hz;
> > You still break old userspace ABI.
> >
> > You need to create a new structure, if you need to add fields.
> >
> I dont think adding the members will cause the program in userspace
> any errors. User do not have to set these members.
Did you try to run on your patch kernel a program build without the
patch ?


if I build my program with :

> >>  struct spi_ioc_transfer {
> >>         __u64           tx_buf;
> >>         __u64           rx_buf;
> >>
> >>         __u32           len;
> >>         __u32           speed_hz;

Now I run it on a new kernel.
The kernel won't parse correctly my structure : len will go in
tx_nbits, rx_nbits and len.

Keep in mind that it is binary interface, not source interface. You
should not have to rebuild your binary.

Matthieu

  reply	other threads:[~2013-07-29 15:35 UTC|newest]

Thread overview: 22+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-07-27  9:39 [PATCH V2] SPI: DUAL and QUAD support wangyuhang
2013-07-29  0:32 ` Trent Piepho
2013-07-29  2:44   ` yuhang wang
2013-07-29  6:42     ` Mark Brown
2013-07-29 10:53       ` [PATCH] " wangyuhang
2013-07-29 12:43         ` Gupta, Pekon
2013-07-29 13:58           ` yuhang wang
2013-07-29 14:21             ` Gupta, Pekon
2013-07-29 14:52               ` yuhang wang
2013-07-29 23:26               ` Trent Piepho
2013-07-30  7:30                 ` yuhang wang
2013-08-08  8:57                   ` Gupta, Pekon
2013-08-09  3:22                     ` yuhang wang
2013-08-09  4:25                       ` Gupta, Pekon
2013-08-09  9:14                         ` yuhang wang
2013-08-07 11:57           ` Gupta, Pekon
2013-08-09  2:09             ` yuhang wang
2013-08-09  2:50               ` Gupta, Pekon
2013-07-29 12:56         ` Matthieu CASTET
2013-07-29 14:25           ` yuhang wang
2013-07-29 15:35             ` Matthieu CASTET [this message]
2013-07-30  1:13               ` yuhang wang

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=20130729173511.65caa07d@parrot.com \
    --to=matthieu.castet@parrot.com \
    --cc=broonie@kernel.org \
    --cc=linux-mtd@lists.infradead.org \
    --cc=pekon@ti.com \
    --cc=sourav.poddar@ti.com \
    --cc=spi-devel-general@lists.sourceforge.net \
    --cc=tpiepho@gmail.com \
    --cc=wangyuhang2014@gmail.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