diff mbox series

[v2] i2c: s3c2410: change return type of 'i2c_s3c_irq_nextbyte' from 'int' to 'void'

Message ID 20220506122639.2544-1-hanyihao@vivo.com (mailing list archive)
State New
Headers show
Series [v2] i2c: s3c2410: change return type of 'i2c_s3c_irq_nextbyte' from 'int' to 'void' | expand

Commit Message

Yihao Han May 6, 2022, 12:26 p.m. UTC
Since ret is a redundant variable, and none of the callers check
for return, so remove ret variable and change return type of
'i2c_s3c_irq_nextbyte' from 'int' to 'void'

Suggested-by: Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org>
Signed-off-by: Yihao Han <hanyihao@vivo.com>
---
v2: add return in STATE_IDLE case
---
 drivers/i2c/busses/i2c-s3c2410.c | 7 ++-----
 1 file changed, 2 insertions(+), 5 deletions(-)

Comments

Krzysztof Kozlowski May 6, 2022, 1:31 p.m. UTC | #1
On 06/05/2022 14:26, Yihao Han wrote:
> Since ret is a redundant variable, and none of the callers check
> for return, so remove ret variable and change return type of
> 'i2c_s3c_irq_nextbyte' from 'int' to 'void'
> 
> Suggested-by: Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org>
> Signed-off-by: Yihao Han <hanyihao@vivo.com>
> ---
> v2: add return in STATE_IDLE case
> ---
>  drivers/i2c/busses/i2c-s3c2410.c | 7 ++-----
>  1 file changed, 2 insertions(+), 5 deletions(-)
> 
> diff --git a/drivers/i2c/busses/i2c-s3c2410.c b/drivers/i2c/busses/i2c-s3c2410.c
> index b49a1b170bb2..d2a1fd2aa7a0 100644
> --- a/drivers/i2c/busses/i2c-s3c2410.c
> +++ b/drivers/i2c/busses/i2c-s3c2410.c
> @@ -381,17 +381,16 @@ static inline int is_msgend(struct s3c24xx_i2c *i2c)
>  /*
>   * process an interrupt and work out what to do
>   */
> -static int i2c_s3c_irq_nextbyte(struct s3c24xx_i2c *i2c, unsigned long iicstat)
> +static void i2c_s3c_irq_nextbyte(struct s3c24xx_i2c *i2c, unsigned long iicstat)

This still should not compile... are you sure you run all the checks on it?

Please do not cc non-working addresses (kernel@vivo).

Best regards,
Krzysztof
kernel test robot May 7, 2022, 3:31 a.m. UTC | #2
Hi Yihao,

Thank you for the patch! Yet something to improve:

[auto build test ERROR on krzk/for-next]
[also build test ERROR on v5.18-rc5 next-20220506]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch]

url:    https://github.com/intel-lab-lkp/linux/commits/Yihao-Han/i2c-s3c2410-change-return-type-of-i2c_s3c_irq_nextbyte-from-int-to-void/20220506-202923
base:   https://git.kernel.org/pub/scm/linux/kernel/git/krzk/linux.git for-next
config: arm-randconfig-c002-20220506 (https://download.01.org/0day-ci/archive/20220507/202205071109.36SjNuHG-lkp@intel.com/config)
compiler: clang version 15.0.0 (https://github.com/llvm/llvm-project 5e004fb787698440a387750db7f8028e7cb14cfc)
reproduce (this is a W=1 build):
        wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
        chmod +x ~/bin/make.cross
        # install arm cross compiling tool for clang build
        # apt-get install binutils-arm-linux-gnueabi
        # https://github.com/intel-lab-lkp/linux/commit/fdefdf435e27cd445a10a77f475e6d316245ed2b
        git remote add linux-review https://github.com/intel-lab-lkp/linux
        git fetch --no-tags linux-review Yihao-Han/i2c-s3c2410-change-return-type-of-i2c_s3c_irq_nextbyte-from-int-to-void/20220506-202923
        git checkout fdefdf435e27cd445a10a77f475e6d316245ed2b
        # save the config file
        mkdir build_dir && cp config build_dir/.config
        COMPILER_INSTALL_PATH=$HOME/0day COMPILER=clang make.cross W=1 O=build_dir ARCH=arm SHELL=/bin/bash drivers/i2c/busses/

If you fix the issue, kindly add following tag as appropriate
Reported-by: kernel test robot <lkp@intel.com>

All errors (new ones prefixed by >>):

>> drivers/i2c/busses/i2c-s3c2410.c:384:13: error: conflicting types for 'i2c_s3c_irq_nextbyte'
   static void i2c_s3c_irq_nextbyte(struct s3c24xx_i2c *i2c, unsigned long iicstat)
               ^
   drivers/i2c/busses/i2c-s3c2410.c:140:12: note: previous declaration is here
   static int i2c_s3c_irq_nextbyte(struct s3c24xx_i2c *i2c, unsigned long iicstat);
              ^
   1 error generated.


vim +/i2c_s3c_irq_nextbyte +384 drivers/i2c/busses/i2c-s3c2410.c

   380	
   381	/*
   382	 * process an interrupt and work out what to do
   383	 */
 > 384	static void i2c_s3c_irq_nextbyte(struct s3c24xx_i2c *i2c, unsigned long iicstat)
   385	{
   386		unsigned long tmp;
   387		unsigned char byte;
   388	
   389		switch (i2c->state) {
   390	
   391		case STATE_IDLE:
   392			dev_err(i2c->dev, "%s: called in STATE_IDLE\n", __func__);
   393			return;
   394	
   395		case STATE_STOP:
   396			dev_err(i2c->dev, "%s: called in STATE_STOP\n", __func__);
   397			s3c24xx_i2c_disable_irq(i2c);
   398			goto out_ack;
   399	
   400		case STATE_START:
   401			/*
   402			 * last thing we did was send a start condition on the
   403			 * bus, or started a new i2c message
   404			 */
   405			if (iicstat & S3C2410_IICSTAT_LASTBIT &&
   406			    !(i2c->msg->flags & I2C_M_IGNORE_NAK)) {
   407				/* ack was not received... */
   408				dev_dbg(i2c->dev, "ack was not received\n");
   409				s3c24xx_i2c_stop(i2c, -ENXIO);
   410				goto out_ack;
   411			}
   412	
   413			if (i2c->msg->flags & I2C_M_RD)
   414				i2c->state = STATE_READ;
   415			else
   416				i2c->state = STATE_WRITE;
   417	
   418			/*
   419			 * Terminate the transfer if there is nothing to do
   420			 * as this is used by the i2c probe to find devices.
   421			 */
   422			if (is_lastmsg(i2c) && i2c->msg->len == 0) {
   423				s3c24xx_i2c_stop(i2c, 0);
   424				goto out_ack;
   425			}
   426	
   427			if (i2c->state == STATE_READ)
   428				goto prepare_read;
   429	
   430			/*
   431			 * fall through to the write state, as we will need to
   432			 * send a byte as well
   433			 */
   434			fallthrough;
   435		case STATE_WRITE:
   436			/*
   437			 * we are writing data to the device... check for the
   438			 * end of the message, and if so, work out what to do
   439			 */
   440			if (!(i2c->msg->flags & I2C_M_IGNORE_NAK)) {
   441				if (iicstat & S3C2410_IICSTAT_LASTBIT) {
   442					dev_dbg(i2c->dev, "WRITE: No Ack\n");
   443	
   444					s3c24xx_i2c_stop(i2c, -ECONNREFUSED);
   445					goto out_ack;
   446				}
   447			}
   448	
   449	 retry_write:
   450	
   451			if (!is_msgend(i2c)) {
   452				byte = i2c->msg->buf[i2c->msg_ptr++];
   453				writeb(byte, i2c->regs + S3C2410_IICDS);
   454	
   455				/*
   456				 * delay after writing the byte to allow the
   457				 * data setup time on the bus, as writing the
   458				 * data to the register causes the first bit
   459				 * to appear on SDA, and SCL will change as
   460				 * soon as the interrupt is acknowledged
   461				 */
   462				ndelay(i2c->tx_setup);
   463	
   464			} else if (!is_lastmsg(i2c)) {
   465				/* we need to go to the next i2c message */
   466	
   467				dev_dbg(i2c->dev, "WRITE: Next Message\n");
   468	
   469				i2c->msg_ptr = 0;
   470				i2c->msg_idx++;
   471				i2c->msg++;
   472	
   473				/* check to see if we need to do another message */
   474				if (i2c->msg->flags & I2C_M_NOSTART) {
   475	
   476					if (i2c->msg->flags & I2C_M_RD) {
   477						/*
   478						 * cannot do this, the controller
   479						 * forces us to send a new START
   480						 * when we change direction
   481						 */
   482						dev_dbg(i2c->dev,
   483							"missing START before write->read\n");
   484						s3c24xx_i2c_stop(i2c, -EINVAL);
   485						break;
   486					}
   487	
   488					goto retry_write;
   489				} else {
   490					/* send the new start */
   491					s3c24xx_i2c_message_start(i2c, i2c->msg);
   492					i2c->state = STATE_START;
   493				}
   494	
   495			} else {
   496				/* send stop */
   497				s3c24xx_i2c_stop(i2c, 0);
   498			}
   499			break;
   500	
   501		case STATE_READ:
   502			/*
   503			 * we have a byte of data in the data register, do
   504			 * something with it, and then work out whether we are
   505			 * going to do any more read/write
   506			 */
   507			byte = readb(i2c->regs + S3C2410_IICDS);
   508			i2c->msg->buf[i2c->msg_ptr++] = byte;
   509	
   510			/* Add actual length to read for smbus block read */
   511			if (i2c->msg->flags & I2C_M_RECV_LEN && i2c->msg->len == 1)
   512				i2c->msg->len += byte;
   513	 prepare_read:
   514			if (is_msglast(i2c)) {
   515				/* last byte of buffer */
   516	
   517				if (is_lastmsg(i2c))
   518					s3c24xx_i2c_disable_ack(i2c);
   519	
   520			} else if (is_msgend(i2c)) {
   521				/*
   522				 * ok, we've read the entire buffer, see if there
   523				 * is anything else we need to do
   524				 */
   525				if (is_lastmsg(i2c)) {
   526					/* last message, send stop and complete */
   527					dev_dbg(i2c->dev, "READ: Send Stop\n");
   528	
   529					s3c24xx_i2c_stop(i2c, 0);
   530				} else {
   531					/* go to the next transfer */
   532					dev_dbg(i2c->dev, "READ: Next Transfer\n");
   533	
   534					i2c->msg_ptr = 0;
   535					i2c->msg_idx++;
   536					i2c->msg++;
   537				}
   538			}
   539	
   540			break;
   541		}
   542	
   543		/* acknowlegde the IRQ and get back on with the work */
   544	
   545	 out_ack:
   546		tmp = readl(i2c->regs + S3C2410_IICCON);
   547		tmp &= ~S3C2410_IICCON_IRQPEND;
   548		writel(tmp, i2c->regs + S3C2410_IICCON);
   549	}
   550
diff mbox series

Patch

diff --git a/drivers/i2c/busses/i2c-s3c2410.c b/drivers/i2c/busses/i2c-s3c2410.c
index b49a1b170bb2..d2a1fd2aa7a0 100644
--- a/drivers/i2c/busses/i2c-s3c2410.c
+++ b/drivers/i2c/busses/i2c-s3c2410.c
@@ -381,17 +381,16 @@  static inline int is_msgend(struct s3c24xx_i2c *i2c)
 /*
  * process an interrupt and work out what to do
  */
-static int i2c_s3c_irq_nextbyte(struct s3c24xx_i2c *i2c, unsigned long iicstat)
+static void i2c_s3c_irq_nextbyte(struct s3c24xx_i2c *i2c, unsigned long iicstat)
 {
 	unsigned long tmp;
 	unsigned char byte;
-	int ret = 0;
 
 	switch (i2c->state) {
 
 	case STATE_IDLE:
 		dev_err(i2c->dev, "%s: called in STATE_IDLE\n", __func__);
-		goto out;
+		return;
 
 	case STATE_STOP:
 		dev_err(i2c->dev, "%s: called in STATE_STOP\n", __func__);
@@ -547,8 +546,6 @@  static int i2c_s3c_irq_nextbyte(struct s3c24xx_i2c *i2c, unsigned long iicstat)
 	tmp = readl(i2c->regs + S3C2410_IICCON);
 	tmp &= ~S3C2410_IICCON_IRQPEND;
 	writel(tmp, i2c->regs + S3C2410_IICCON);
- out:
-	return ret;
 }
 
 /*