Re: [PATCH] i2c: New driver for Nuvoton SMBus adapters

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi Adam,

Thank you for the patch! Perhaps something to improve:

[auto build test WARNING on wsa/i2c/for-next]
[also build test WARNING on v5.17-rc8 next-20220310]
[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/0day-ci/linux/commits/Adam-Honse/i2c-New-driver-for-Nuvoton-SMBus-adapters/20220314-064247
base:   https://git.kernel.org/pub/scm/linux/kernel/git/wsa/linux.git i2c/for-next
config: arm64-allmodconfig (https://download.01.org/0day-ci/archive/20220315/202203150442.qhRCXPnf-lkp@xxxxxxxxx/config)
compiler: clang version 15.0.0 (https://github.com/llvm/llvm-project 3e4950d7fa78ac83f33bbf1658e2f49a73719236)
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 arm64 cross compiling tool for clang build
        # apt-get install binutils-aarch64-linux-gnu
        # https://github.com/0day-ci/linux/commit/040a1be0d30ce2c611e30eb923d6f1b0afc44e7d
        git remote add linux-review https://github.com/0day-ci/linux
        git fetch --no-tags linux-review Adam-Honse/i2c-New-driver-for-Nuvoton-SMBus-adapters/20220314-064247
        git checkout 040a1be0d30ce2c611e30eb923d6f1b0afc44e7d
        # save the config file to linux build tree
        mkdir build_dir
        COMPILER_INSTALL_PATH=$HOME/0day COMPILER=clang make.cross W=1 O=build_dir ARCH=arm64 SHELL=/bin/bash drivers/i2c/busses/ drivers/mfd/

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

All warnings (new ones prefixed by >>):

>> drivers/i2c/busses/i2c-nct6775.c:219:2: warning: unannotated fall-through between switch labels [-Wimplicit-fallthrough]
           case I2C_SMBUS_BYTE:
           ^
   drivers/i2c/busses/i2c-nct6775.c:219:2: note: insert '__attribute__((fallthrough));' to silence this warning
           case I2C_SMBUS_BYTE:
           ^
           __attribute__((fallthrough)); 
   drivers/i2c/busses/i2c-nct6775.c:219:2: note: insert 'break;' to avoid fall-through
           case I2C_SMBUS_BYTE:
           ^
           break; 
>> drivers/i2c/busses/i2c-nct6775.c:90:27: warning: unused variable 'nct6775_device_names' [-Wunused-const-variable]
   static const char * const nct6775_device_names[] = {
                             ^
   drivers/i2c/busses/i2c-nct6775.c:133:1: warning: unused function 'superio_outb' [-Wunused-function]
   superio_outb(int ioreg, int reg, int val)
   ^
   3 warnings generated.


vim +219 drivers/i2c/busses/i2c-nct6775.c

    88	
    89	/* used to set data->name = nct6775_device_names[data->sio_kind] */
  > 90	static const char * const nct6775_device_names[] = {
    91		"nct6106",
    92		"nct6775",
    93		"nct6776",
    94		"nct6779",
    95		"nct6791",
    96		"nct6792",
    97		"nct6793",
    98		"nct6795",
    99		"nct6796",
   100		"nct6798",
   101	};
   102	
   103	static const char * const nct6775_sio_names[] __initconst = {
   104		"NCT6106D",
   105		"NCT6775F",
   106		"NCT6776D/F",
   107		"NCT6779D",
   108		"NCT6791D",
   109		"NCT6792D",
   110		"NCT6793D",
   111		"NCT6795D",
   112		"NCT6796D",
   113		"NCT6798D",
   114	};
   115	
   116	#define SIO_REG_LDSEL		0x07	/* Logical device select */
   117	#define SIO_REG_DEVID		0x20	/* Device ID (2 bytes) */
   118	#define SIO_REG_SMBA		0x62	/* SMBus base address register */
   119	
   120	#define SIO_NCT6106_ID		0xc450
   121	#define SIO_NCT6775_ID		0xb470
   122	#define SIO_NCT6776_ID		0xc330
   123	#define SIO_NCT6779_ID		0xc560
   124	#define SIO_NCT6791_ID		0xc800
   125	#define SIO_NCT6792_ID		0xc910
   126	#define SIO_NCT6793_ID		0xd120
   127	#define SIO_NCT6795_ID		0xd350
   128	#define SIO_NCT6796_ID		0xd420
   129	#define SIO_NCT6798_ID		0xd428
   130	#define SIO_ID_MASK			0xFFF0
   131	
   132	static inline void
   133	superio_outb(int ioreg, int reg, int val)
   134	{
   135		outb(reg, ioreg);
   136		outb(val, ioreg + 1);
   137	}
   138	
   139	static inline int
   140	superio_inb(int ioreg, int reg)
   141	{
   142		outb(reg, ioreg);
   143		return inb(ioreg + 1);
   144	}
   145	
   146	static inline void
   147	superio_select(int ioreg, int ld)
   148	{
   149		outb(SIO_REG_LDSEL, ioreg);
   150		outb(ld, ioreg + 1);
   151	}
   152	
   153	static inline int
   154	superio_enter(int ioreg)
   155	{
   156		/*
   157		 * Try to reserve <ioreg> and <ioreg + 1> for exclusive access.
   158		 */
   159		if (!request_muxed_region(ioreg, 2, DRVNAME))
   160			return -EBUSY;
   161	
   162		outb(0x87, ioreg);
   163		outb(0x87, ioreg);
   164	
   165		return 0;
   166	}
   167	
   168	static inline void
   169	superio_exit(int ioreg)
   170	{
   171		outb(0xaa, ioreg);
   172		outb(0x02, ioreg);
   173		outb(0x02, ioreg + 1);
   174		release_region(ioreg, 2);
   175	}
   176	
   177	/*
   178	 * ISA constants
   179	 */
   180	
   181	#define IOREGION_ALIGNMENT	(~7)
   182	#define IOREGION_LENGTH		2
   183	#define ADDR_REG_OFFSET		0
   184	#define DATA_REG_OFFSET		1
   185	
   186	#define NCT6775_REG_BANK	0x4E
   187	#define NCT6775_REG_CONFIG	0x40
   188	
   189	static struct i2c_adapter *nct6775_adapter;
   190	
   191	struct i2c_nct6775_adapdata {
   192		unsigned short smba;
   193	};
   194	
   195	/* Return negative errno on error. */
   196	static s32 nct6775_access(struct i2c_adapter *adap, u16 addr,
   197			 unsigned short flags, char read_write,
   198			 u8 command, int size, union i2c_smbus_data *data)
   199	{
   200		struct i2c_nct6775_adapdata *adapdata = i2c_get_adapdata(adap);
   201		unsigned short nuvoton_nct6793d_smba = adapdata->smba;
   202		int i, len, cnt;
   203		union i2c_smbus_data tmp_data;
   204		int timeout = 0;
   205	
   206		tmp_data.word = 0;
   207		cnt = 0;
   208		len = 0;
   209	
   210		outb_p(NCT6793D_SOFT_RESET, SMBHSTCTL);
   211	
   212		switch (size) {
   213		case I2C_SMBUS_QUICK:
   214			outb_p((addr << 1) | read_write,
   215					SMBHSTADD);
   216			break;
   217		case I2C_SMBUS_BYTE_DATA:
   218			tmp_data.byte = data->byte;
 > 219		case I2C_SMBUS_BYTE:
   220			outb_p((addr << 1) | read_write,
   221					SMBHSTADD);
   222			outb_p(command, SMBHSTIDX);
   223			if (read_write == I2C_SMBUS_WRITE) {
   224				outb_p(tmp_data.byte, SMBHSTDAT);
   225				outb_p(NCT6793D_WRITE_BYTE, SMBHSTCMD);
   226			} else {
   227				outb_p(NCT6793D_READ_BYTE, SMBHSTCMD);
   228			}
   229			break;
   230		case I2C_SMBUS_WORD_DATA:
   231			outb_p((addr << 1) | read_write,
   232					SMBHSTADD);
   233			outb_p(command, SMBHSTIDX);
   234			if (read_write == I2C_SMBUS_WRITE) {
   235				outb_p(data->word & 0xff, SMBHSTDAT);
   236				outb_p((data->word & 0xff00) >> 8, SMBHSTDAT);
   237				outb_p(NCT6793D_WRITE_WORD, SMBHSTCMD);
   238			} else {
   239				outb_p(NCT6793D_READ_WORD, SMBHSTCMD);
   240			}
   241			break;
   242		case I2C_SMBUS_BLOCK_DATA:
   243			outb_p((addr << 1) | read_write,
   244					SMBHSTADD);
   245			outb_p(command, SMBHSTIDX);
   246			if (read_write == I2C_SMBUS_WRITE) {
   247				len = data->block[0];
   248				if (len == 0 || len > I2C_SMBUS_BLOCK_MAX)
   249					return -EINVAL;
   250				outb_p(len, SMBBLKSZ);
   251	
   252				cnt = 1;
   253				if (len >= 4) {
   254					for (i = cnt; i <= 4; i++)
   255						outb_p(data->block[i], SMBHSTDAT);
   256	
   257					len -= 4;
   258					cnt += 4;
   259				} else {
   260					for (i = cnt; i <= len; i++)
   261						outb_p(data->block[i], SMBHSTDAT);
   262	
   263					len = 0;
   264				}
   265	
   266				outb_p(NCT6793D_WRITE_BLOCK, SMBHSTCMD);
   267			} else {
   268				return -EOPNOTSUPP;
   269			}
   270			break;
   271		default:
   272			dev_warn(&adap->dev, "Unsupported transaction %d\n", size);
   273			return -EOPNOTSUPP;
   274		}
   275	
   276		outb_p(NCT6793D_MANUAL_START, SMBHSTCTL);
   277	
   278		while ((size == I2C_SMBUS_BLOCK_DATA) && (len > 0)) {
   279			if (read_write == I2C_SMBUS_WRITE) {
   280				timeout = 0;
   281				while ((inb_p(SMBHSTSTS) & NCT6793D_FIFO_EMPTY) == 0) {
   282					if (timeout > MAX_RETRIES)
   283						return -ETIMEDOUT;
   284	
   285					usleep_range(250, 500);
   286					timeout++;
   287				}
   288	
   289				//Load more bytes into FIFO
   290				if (len >= 4) {
   291					for (i = cnt; i <= (cnt + 4); i++)
   292						outb_p(data->block[i], SMBHSTDAT);
   293	
   294					len -= 4;
   295					cnt += 4;
   296				} else {
   297					for (i = cnt; i <= (cnt + len); i++)
   298						outb_p(data->block[i], SMBHSTDAT);
   299	
   300					len = 0;
   301				}
   302			} else {
   303				return -EOPNOTSUPP;
   304			}
   305	
   306		}
   307	
   308		//wait for manual mode to complete
   309		timeout = 0;
   310		while ((inb_p(SMBHSTSTS) & NCT6793D_MANUAL_ACTIVE) != 0) {
   311			if (timeout > MAX_RETRIES)
   312				return -ETIMEDOUT;
   313	
   314			usleep_range(250, 500);
   315			timeout++;
   316		}
   317	
   318		if ((inb_p(SMBHSTERR) & NCT6793D_NO_ACK) != 0)
   319			return -ENXIO;
   320	
   321		else if ((read_write == I2C_SMBUS_WRITE) || (size == I2C_SMBUS_QUICK))
   322			return 0;
   323	
   324		switch (size) {
   325		case I2C_SMBUS_QUICK:
   326		case I2C_SMBUS_BYTE_DATA:
   327			data->byte = inb_p(SMBHSTDAT);
   328			break;
   329		case I2C_SMBUS_WORD_DATA:
   330			data->word = inb_p(SMBHSTDAT) + (inb_p(SMBHSTDAT) << 8);
   331			break;
   332		}
   333		return 0;
   334	}
   335	

---
0-DAY CI Kernel Test Service
https://lists.01.org/hyperkitty/list/kbuild-all@xxxxxxxxxxxx



[Index of Archives]     [Linux GPIO]     [Linux SPI]     [Linux Hardward Monitoring]     [LM Sensors]     [Linux USB Devel]     [Linux Media]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux