linux-spi.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Gerhard Sittig <gsi-ynQEQJNshbs@public.gmane.org>
To: Jonas Gorski <jogo-p3rKhJxN3npAfugRpC6u6w@public.gmane.org>
Cc: Alexander Shiyan <shc_work-JGs/UdohzUI@public.gmane.org>,
	linux-spi-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
	Mark Brown <broonie-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org>
Subject: Re: [PATCH RFC] Remove "spi-cs-high" property for GPIO-based chipselects
Date: Mon, 2 Dec 2013 23:36:32 +0100	[thread overview]
Message-ID: <20131202223632.GA2982@book.gsilab.sittig.org> (raw)
In-Reply-To: <CAOiHx=krrM+NZ7detAv9_UsB+bUXtKL0m4=pDHO30uduJsDdFg-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>

On Mon, Dec 02, 2013 at 23:09 +0100, Jonas Gorski wrote:
> 
> On Mon, Dec 2, 2013 at 9:17 PM, Gerhard Sittig <gsi-ynQEQJNshbs@public.gmane.org> wrote:
> > On Mon, Dec 02, 2013 at 19:03 +0100, Jonas Gorski wrote:
> >>
> >> I see the allocation, but I don't see the assignment of
> >> master->cs_gpios_flags. Only master->cs_gpios gets assigned.
> >
> > It's a side effect of the of_get_named_gpio_flags() call (passing
> > the variable by reference).
> >
> > Don't worry, I felt the same when I read the patch.  Took me a
> > while to spot that everything was still in place. :)
> 
> I still don't see it. The patch adds an additional pointer member:
> 
> > struct spi_master {
> >        (...)
> >        /* gpio chip select */
> >        int                     *cs_gpios;
> > +       /* GPIO flags */
> > +       enum of_gpio_flags      *cs_gpios_flags;
>  };
> 
> Then it changes the memory allocation to allocate additional memory for it:
> 
> > -       cs = devm_kzalloc(&master->dev,
> > -                         sizeof(int) * master->num_chipselect,
> > -                         GFP_KERNEL);
> > -       master->cs_gpios = cs;
> > +       master->cs_gpios = devm_kzalloc(&master->dev, master->num_chipselect *
> > +               (sizeof(int) + sizeof(enum of_gpio_flags)), GFP_KERNEL);
> 
> But it only assigns the memory pointer to master->cs_gpios, but
> master->cs_gpios_flags will still point to whatever it was initialized
> to (likely 0), and is never actually set.

You are right, I misread the code.

The assignment of "&cs_gpios[master->num_chipselect]" to the
cs_gpio_flags "start address" is missing.  Which involves dirty
casts that may be considered ugly.

Alternatively the two arrays could get allocated separately
(don't know what the overhead would be, and if that is considered
bad practise or wasteful although it's cleaner).


> Unless there is some serious black magic in of_get_named_gpio_flags(),
> but I doubt that would be allowed in the kernel ;)
> 
> So as far as I can tell there's missing something along
> 
> master->cs_gpios_flags = (enum of_gpio_flags *)&master->cs_gpios[master->num_chipselect];

Right!  This kind of assignment is "the standin" for the black
magic that is not expected here. :)


virtually yours
Gerhard Sittig
-- 
DENX Software Engineering GmbH,     MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich, Office: Kirchenstr. 5, D-82194 Groebenzell, Germany
Phone: +49-8142-66989-0 Fax: +49-8142-66989-80  Email: office-ynQEQJNshbs@public.gmane.org
--
To unsubscribe from this list: send the line "unsubscribe linux-spi" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

  parent reply	other threads:[~2013-12-02 22:36 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-12-01  7:59 [PATCH RFC] Remove "spi-cs-high" property for GPIO-based chipselects Alexander Shiyan
     [not found] ` <1385884756-31373-1-git-send-email-shc_work-JGs/UdohzUI@public.gmane.org>
2013-12-02 11:43   ` Mark Brown
     [not found]     ` <20131202114310.GP27568-GFdadSzt00ze9xe1eoZjHA@public.gmane.org>
2013-12-02 11:58       ` Alexander Shiyan
     [not found]         ` <1385985513.987194654-zxFGIbyeZotsdVUOrk1QfQ@public.gmane.org>
2013-12-02 12:33           ` Mark Brown
     [not found]             ` <20131202123339.GZ27568-GFdadSzt00ze9xe1eoZjHA@public.gmane.org>
2013-12-02 12:42               ` Alexander Shiyan
     [not found]                 ` <1385988152.848953040-u8tvknxLvilsdVUOrk1QfQ@public.gmane.org>
2013-12-02 12:46                   ` Mark Brown
2013-12-02 13:49   ` Jonas Gorski
     [not found]     ` <CAOiHx=nAcGdk7QgKPrbmkbQYzWL6qNb2cnJj3c_A+9++RrLoeA-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2013-12-02 14:54       ` Alexander Shiyan
     [not found]         ` <1385996099.869286515-/wTItXjRvv7WO3iv0lnsqw@public.gmane.org>
2013-12-02 18:03           ` Jonas Gorski
     [not found]             ` <CAOiHx=kLkiWjnuUV_1-rVrO-EDQw=Ut0eZE5egYrmiVK9wmxfw-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2013-12-02 20:17               ` Gerhard Sittig
     [not found]                 ` <20131202201722.GZ2982-kDjWylLy9wD0K7fsECOQyeGNnDKD8DIp@public.gmane.org>
2013-12-02 22:09                   ` Jonas Gorski
     [not found]                     ` <CAOiHx=krrM+NZ7detAv9_UsB+bUXtKL0m4=pDHO30uduJsDdFg-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2013-12-02 22:36                       ` Gerhard Sittig [this message]
     [not found]                         ` <20131202223632.GA2982-kDjWylLy9wD0K7fsECOQyeGNnDKD8DIp@public.gmane.org>
2013-12-03  4:23                           ` Alexander Shiyan
2013-12-02 14:59   ` Gerhard Sittig
     [not found]     ` <20131202145911.GT2982-kDjWylLy9wD0K7fsECOQyeGNnDKD8DIp@public.gmane.org>
2013-12-02 15:24       ` Alexander Shiyan
     [not found]         ` <1385997862.727371043-/wTItXjRvv7WO3iv0lnsqw@public.gmane.org>
2013-12-02 16:31           ` Gerhard Sittig
     [not found]             ` <20131202163124.GW2982-kDjWylLy9wD0K7fsECOQyeGNnDKD8DIp@public.gmane.org>
2013-12-02 17:14               ` Alexander Shiyan

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=20131202223632.GA2982@book.gsilab.sittig.org \
    --to=gsi-ynqeqjnshbs@public.gmane.org \
    --cc=broonie-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org \
    --cc=jogo-p3rKhJxN3npAfugRpC6u6w@public.gmane.org \
    --cc=linux-spi-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
    --cc=shc_work-JGs/UdohzUI@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).