Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1290450

Re: [PATCH] i2c: allow building emev2 without slave mode again

Path csiph.com!eternal-september.org!feeder.eternal-september.org!aioe.org!bofh.it!news.nic.it!robomod
From Arnd Bergmann <arnd@arndb.de>
Newsgroups linux.kernel
Subject Re: [PATCH] i2c: allow building emev2 without slave mode again
Date Sat, 12 Dec 2015 22:10:01 +0100
Message-ID <qEZAt-7ul-7@gated-at.bofh.it> (permalink)
References <qEaRj-7yx-3@gated-at.bofh.it> <qEb10-7RF-13@gated-at.bofh.it> <qEVdv-4sK-7@gated-at.bofh.it>
X-Original-To Wolfram Sang <wsa@the-dreams.de>
User-Agent KMail/4.11.5 (Linux/3.16.0-10-generic; KDE/4.11.5; x86_64; ; )
MIME-Version 1.0
Content-Transfer-Encoding 7Bit
Content-Type text/plain; charset="us-ascii"
X-Provags-ID V03:K0:dgxMzAlSfen1oSkAxQE+2zBDw+x1UflECX51G5LRcF0yVoXo+/+ uEhhdvA5Glw9pdCPbuRaocOtRng0mlFpe5QXPOcT8b8H7PDK15iT29vwG6QwTn6EmIBprU5 7pKCWQcT7+rrsK/cvWpRTgoM9Aq22Dk7um+4taT1FSe0G/yQ1zqZAO0WFq3BuPH9e8EGd1f v2cqmC3sMiw161W5PzHag==
X-Ui-Out-Filterresults notjunk:1;V01:K0:gcVLj8zoCco=:g/LuGl1BCXye9SNDVyRUVC 6xmWtkEsUGiHf488uSP82buisZM3e+gxDFkIsWmpymvN8NQN9S5E3irCGdW0Aq7b8jVFrhIVS gzcmXbPtdZTHRAdouB/e8c16HoA4gwYha18jKctu7QSrb+yH5cBA/e+EA79qGJBdgh0NsV2+U d6+k16ynu2iCIbuEbWwe3tohdoN+mz7Ji3As9sdZxOEYcJsEvblnooxIshsozP/fPPYAZFjfw 2mCyPt/9sWML3yoOCQgnmRV8imRuJi4a4I6U3WPIYXqpPfW2K79PFeRcVa3+vLugQ+o1XI9wt oemNfqezLJi7dXeDdgfIq+M0HSsbhEMwkbHrPOVKpct4eq0Kt/1f0CFaNLmEoDAOmaoGTvOPf oJOljjdOJo9ETzPQ56o5hpD0Cv21zi4ygXgAnWohKl/Zpl1ZvvnOvVL1bS2xLZvKVTjwMom7c QVbztn2D3drL4yyKl3puIfTNpBKMGYRoeY68Ddhjaujta9IIrD1eJxXhsHWtkEbhiJRz4QORz JO1/+x348HGqDjrIeMYvJETorn6wZ9WadOLR6s1UC28Y6UZZ48On/bjmlSkfP2Q0VjPtKYsIS FVswM9yJT8JhrvJdlNyMXnfKCRz7Lax+N8wF8gLYjflbA6K36Kyw5KKsScAf5kPuY/f3jy2ki a2Li8dNQBHjITr4cyMJYQFA/oxfpnsJvxFOqJufoCaO0m5HRoeeKYDdzUty1Jc7YtftrHplWJ E15qNx3gWVeo5dda
Sender robomod@news.nic.it
List-ID <linux-kernel.vger.kernel.org>
X-Mailing-List linux-kernel@vger.kernel.org
Approved robomod@news.nic.it
Lines 70
Organization linux.* mail to news gateway
X-Original-Cc kbuild test robot <lkp@intel.com>, kbuild-all@01.org, linux-i2c@vger.kernel.org, Niklas Söderlund <niklas.soderlund+renesas@ragnatech.se>, linux-sh@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org
X-Original-Date Sat, 12 Dec 2015 22:05:29 +0100
X-Original-Message-ID <2157023.1Ftpc9ZciN@wuerfel>
X-Original-References <201512102224.cVm7Hcp0%fengguang.wu@intel.com> <2592093.cGKEcKVqLU@wuerfel> <20151212162057.GA1530@katana>
X-Original-Sender linux-kernel-owner@vger.kernel.org
Xref csiph.com linux.kernel:1290450

Show key headers only | View raw


On Saturday 12 December 2015 17:20:57 Wolfram Sang wrote:
> Hi Arnd,
> 
> thanks for looking into this, but I don't get your point yet.
> 
> > The slave_cb callback function is supposed to set the 'value'
> > here,
> 
> Only if a master wants to READ from us.

Right, and can this never fail?

> > but it might return an error not assign the pointer,
> 
> An error is only returned if a WRITE from a master was not accepted by
> the slave backend.
>
> > It might be best to change the callback to return 'void' and not
> > allow it to fail.
> 
> We need that because in case of an errno, the slave should send NACK to
> the master instead of ACK.
> 
> > At least the eeprom slave cannot fail anyway, and it is the only
> > implementation we have at the moment.
> 
> True. But giving a slave the possibility to NACK a write should be
> present IMO.

Ok, fair enough.
 
> > Alternatively, the  inline could return an error, and both bus
> > drivers check for the error before using 'value'.
> 
> Hum, it does return an error?
> 
> 	return client->slave_cb(client, event, val);
> 
> You probably mean something else?

I mean specifically this code in em_i2c_slave_irq():

                        /* Send data */
                        event = status & I2C_BIT_STD0 ?
                                I2C_SLAVE_READ_REQUESTED :
                                I2C_SLAVE_READ_PROCESSED;
                        i2c_slave_event(priv->slave, event, &value);
                        writeb(value, priv->base + I2C_OFS_IIC0);

With my current code to turn i2c_slave_event() into an empty inline function
in case of !CONFIG_I2C_SLAVE, the compiler knows that "value" is uninitialized
at the point where we write it to the register, and warns about it.

The code will of course never run if slave mode is not allowed, but we should
still shut up the warning, either by making the inline i2c_slave_event
set 'value' to zero or 0xff, or by adding an error check:

			ret = i2c_slave_event(priv->slave, event, &value);
			if (!ret)
				 writeb(value, priv->base + I2C_OFS_IIC0);

and making the empty i2c_slave_event() function return -ENOSYS or -ENOTSUPP.


	Arnd
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Back to linux.kernel | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread


Thread

[PATCH] i2c: allow building emev2 without slave mode again Arnd Bergmann <arnd@arndb.de> - 2015-12-10 14:20 +0100
  Re: [PATCH] i2c: allow building emev2 without slave mode again Wolfram Sang <wsa@the-dreams.de> - 2015-12-10 14:40 +0100
    Re: [PATCH] i2c: allow building emev2 without slave mode again Arnd Bergmann <arnd@arndb.de> - 2015-12-10 15:00 +0100
  Re: [PATCH] i2c: allow building emev2 without slave mode again kbuild test robot <lkp@intel.com> - 2015-12-10 16:00 +0100
    Re: [PATCH] i2c: allow building emev2 without slave mode again Arnd Bergmann <arnd@arndb.de> - 2015-12-10 16:10 +0100
      Re: [PATCH] i2c: allow building emev2 without slave mode again Wolfram Sang <wsa@the-dreams.de> - 2015-12-10 16:20 +0100
      Re: [PATCH] i2c: allow building emev2 without slave mode again Wolfram Sang <wsa@the-dreams.de> - 2015-12-12 17:30 +0100
        Re: [PATCH] i2c: allow building emev2 without slave mode again Arnd Bergmann <arnd@arndb.de> - 2015-12-12 22:10 +0100
          Re: [PATCH] i2c: allow building emev2 without slave mode again Wolfram Sang <wsa@the-dreams.de> - 2015-12-13 10:20 +0100
            Re: [PATCH] i2c: allow building emev2 without slave mode again Arnd Bergmann <arnd@arndb.de> - 2015-12-14 13:10 +0100
              Re: [PATCH] i2c: allow building emev2 without slave mode again Wolfram Sang <wsa@the-dreams.de> - 2015-12-14 15:00 +0100
                Re: [PATCH] i2c: allow building emev2 without slave mode again Arnd Bergmann <arnd@arndb.de> - 2015-12-14 23:30 +0100
                Re: [PATCH] i2c: allow building emev2 without slave mode again Wolfram Sang <wsa@the-dreams.de> - 2015-12-17 13:10 +0100
                Re: [PATCH] i2c: allow building emev2 without slave mode again Arnd Bergmann <arnd@arndb.de> - 2015-12-17 15:50 +0100
                Re: [PATCH] i2c: allow building emev2 without slave mode again Wolfram Sang <wsa@the-dreams.de> - 2015-12-17 20:50 +0100
                Re: [PATCH] i2c: allow building emev2 without slave mode again Arnd Bergmann <arnd@arndb.de> - 2015-12-17 21:00 +0100

csiph-web