Hi Herbert,

[auto build test WARNING on cryptodev/master]
[also build test WARNING on v4.10-rc7 next-20170206]
[if your patch is applied to the wrong git tree, please drop us a note to help 
improve the system]

url:    
https://github.com/0day-ci/linux/commits/Herbert-Xu/crypto-atmel-Fix-authenc-compile-test-warnings/20170206-171201
base:   
https://git.kernel.org/pub/scm/linux/kernel/git/herbert/cryptodev-2.6.git master
config: ia64-allmodconfig (attached as .config)
compiler: ia64-linux-gcc (GCC) 6.2.0
reproduce:
        wget 
https://git.kernel.org/cgit/linux/kernel/git/wfg/lkp-tests.git/plain/sbin/make.cross
 -O ~/bin/make.cross
        chmod +x ~/bin/make.cross
        # save the attached .config to linux build tree
        make.cross ARCH=ia64 

All warnings (new ones prefixed by >>):

   In file included from drivers/crypto/atmel-tdes.c:17:0:
   drivers/crypto/atmel-tdes.c: In function 'atmel_tdes_sg_copy':
   include/linux/kernel.h:753:16: warning: comparison of distinct pointer types 
lacks a cast
     (void) (&min1 == &min2);   \
                   ^
   include/linux/kernel.h:756:2: note: in expansion of macro '__min'
     __min(typeof(x), typeof(y),   \
     ^~~~~
>> drivers/crypto/atmel-tdes.c:157:11: note: in expansion of macro 'min'
      count = min(count, buflen);
              ^~~
   In file included from include/linux/printk.h:6:0,
                    from include/linux/kernel.h:13,
                    from drivers/crypto/atmel-tdes.c:17:
   drivers/crypto/atmel-tdes.c: In function 'atmel_tdes_crypt_pdc_stop':
>> include/linux/kern_levels.h:4:18: warning: format '%u' expects argument of 
>> type 'unsigned int', but argument 2 has type 'size_t {aka long unsigned 
>> int}' [-Wformat=]
    #define KERN_SOH "\001"  /* ASCII Start Of Header */
                     ^
   include/linux/kern_levels.h:10:18: note: in expansion of macro 'KERN_SOH'
    #define KERN_ERR KERN_SOH "3" /* error conditions */
                     ^~~~~~~~
   include/linux/printk.h:292:9: note: in expansion of macro 'KERN_ERR'
     printk(KERN_ERR pr_fmt(fmt), ##__VA_ARGS__)
            ^~~~~~~~
>> drivers/crypto/atmel-tdes.c:339:4: note: in expansion of macro 'pr_err'
       pr_err("not all data converted: %u\n", count);
       ^~~~~~
   drivers/crypto/atmel-tdes.c: In function 'atmel_tdes_buff_init':
>> drivers/crypto/atmel-tdes.c:364:26: warning: format '%d' expects argument of 
>> type 'int', but argument 3 has type 'size_t {aka long unsigned int}' 
>> [-Wformat=]
      dev_err(dd->dev, "dma %d bytes error\n", dd->buflen);
                             ^
   drivers/crypto/atmel-tdes.c:372:26: warning: format '%d' expects argument of 
type 'int', but argument 3 has type 'size_t {aka long unsigned int}' [-Wformat=]
      dev_err(dd->dev, "dma %d bytes error\n", dd->buflen);
                             ^
   In file included from drivers/crypto/atmel-tdes.c:17:0:
   drivers/crypto/atmel-tdes.c: In function 'atmel_tdes_crypt_start':
   include/linux/kernel.h:753:16: warning: comparison of distinct pointer types 
lacks a cast
     (void) (&min1 == &min2);   \
                   ^
   include/linux/kernel.h:756:2: note: in expansion of macro '__min'
     __min(typeof(x), typeof(y),   \
     ^~~~~
   drivers/crypto/atmel-tdes.c:528:11: note: in expansion of macro 'min'
      count = min(dd->total, sg_dma_len(dd->in_sg));
              ^~~
   include/linux/kernel.h:753:16: warning: comparison of distinct pointer types 
lacks a cast
     (void) (&min1 == &min2);   \
                   ^
   include/linux/kernel.h:756:2: note: in expansion of macro '__min'
     __min(typeof(x), typeof(y),   \
     ^~~~~
   drivers/crypto/atmel-tdes.c:529:11: note: in expansion of macro 'min'
      count = min(count, sg_dma_len(dd->out_sg));
              ^~~
   In file included from include/linux/printk.h:6:0,
                    from include/linux/kernel.h:13,
                    from drivers/crypto/atmel-tdes.c:17:
   drivers/crypto/atmel-tdes.c: In function 'atmel_tdes_crypt_dma_stop':
>> include/linux/kern_levels.h:4:18: warning: format '%u' expects argument of 
>> type 'unsigned int', but argument 2 has type 'size_t {aka long unsigned 
>> int}' [-Wformat=]
    #define KERN_SOH "\001"  /* ASCII Start Of Header */
                     ^
   include/linux/kern_levels.h:10:18: note: in expansion of macro 'KERN_SOH'
    #define KERN_ERR KERN_SOH "3" /* error conditions */
                     ^~~~~~~~
   include/linux/printk.h:292:9: note: in expansion of macro 'KERN_ERR'
     printk(KERN_ERR pr_fmt(fmt), ##__VA_ARGS__)
            ^~~~~~~~
   drivers/crypto/atmel-tdes.c:664:5: note: in expansion of macro 'pr_err'
        pr_err("not all data converted: %u\n", count);
        ^~~~~~

vim +/min +157 drivers/crypto/atmel-tdes.c

13802005 Nicolas Royer  2012-07-01   11   * by the Free Software Foundation.
13802005 Nicolas Royer  2012-07-01   12   *
13802005 Nicolas Royer  2012-07-01   13   * Some ideas are from omap-aes.c 
drivers.
13802005 Nicolas Royer  2012-07-01   14   */
13802005 Nicolas Royer  2012-07-01   15  
13802005 Nicolas Royer  2012-07-01   16  
13802005 Nicolas Royer  2012-07-01  @17  #include <linux/kernel.h>
13802005 Nicolas Royer  2012-07-01   18  #include <linux/module.h>
13802005 Nicolas Royer  2012-07-01   19  #include <linux/slab.h>
13802005 Nicolas Royer  2012-07-01   20  #include <linux/err.h>
13802005 Nicolas Royer  2012-07-01   21  #include <linux/clk.h>
13802005 Nicolas Royer  2012-07-01   22  #include <linux/io.h>
13802005 Nicolas Royer  2012-07-01   23  #include <linux/hw_random.h>
13802005 Nicolas Royer  2012-07-01   24  #include <linux/platform_device.h>
13802005 Nicolas Royer  2012-07-01   25  
13802005 Nicolas Royer  2012-07-01   26  #include <linux/device.h>
13802005 Nicolas Royer  2012-07-01   27  #include <linux/init.h>
13802005 Nicolas Royer  2012-07-01   28  #include <linux/errno.h>
13802005 Nicolas Royer  2012-07-01   29  #include <linux/interrupt.h>
13802005 Nicolas Royer  2012-07-01   30  #include <linux/irq.h>
13802005 Nicolas Royer  2012-07-01   31  #include <linux/scatterlist.h>
13802005 Nicolas Royer  2012-07-01   32  #include <linux/dma-mapping.h>
84c8976b Nicolas Ferre  2013-10-15   33  #include <linux/of_device.h>
13802005 Nicolas Royer  2012-07-01   34  #include <linux/delay.h>
13802005 Nicolas Royer  2012-07-01   35  #include <linux/crypto.h>
13802005 Nicolas Royer  2012-07-01   36  #include <linux/cryptohash.h>
13802005 Nicolas Royer  2012-07-01   37  #include <crypto/scatterwalk.h>
13802005 Nicolas Royer  2012-07-01   38  #include <crypto/algapi.h>
13802005 Nicolas Royer  2012-07-01   39  #include <crypto/des.h>
13802005 Nicolas Royer  2012-07-01   40  #include <crypto/hash.h>
13802005 Nicolas Royer  2012-07-01   41  #include <crypto/internal/hash.h>
1f858040 Nicolas Royer  2013-02-20   42  #include 
<linux/platform_data/crypto-atmel.h>
13802005 Nicolas Royer  2012-07-01   43  #include "atmel-tdes-regs.h"
13802005 Nicolas Royer  2012-07-01   44  
13802005 Nicolas Royer  2012-07-01   45  /* TDES flags  */
1f858040 Nicolas Royer  2013-02-20   46  #define TDES_FLAGS_MODE_MASK           
0x00ff
13802005 Nicolas Royer  2012-07-01   47  #define TDES_FLAGS_ENCRYPT     BIT(0)
13802005 Nicolas Royer  2012-07-01   48  #define TDES_FLAGS_CBC         BIT(1)
13802005 Nicolas Royer  2012-07-01   49  #define TDES_FLAGS_CFB         BIT(2)
13802005 Nicolas Royer  2012-07-01   50  #define TDES_FLAGS_CFB8                
BIT(3)
13802005 Nicolas Royer  2012-07-01   51  #define TDES_FLAGS_CFB16       BIT(4)
13802005 Nicolas Royer  2012-07-01   52  #define TDES_FLAGS_CFB32       BIT(5)
1f858040 Nicolas Royer  2013-02-20   53  #define TDES_FLAGS_CFB64       BIT(6)
1f858040 Nicolas Royer  2013-02-20   54  #define TDES_FLAGS_OFB         BIT(7)
13802005 Nicolas Royer  2012-07-01   55  
13802005 Nicolas Royer  2012-07-01   56  #define TDES_FLAGS_INIT                
BIT(16)
13802005 Nicolas Royer  2012-07-01   57  #define TDES_FLAGS_FAST                
BIT(17)
13802005 Nicolas Royer  2012-07-01   58  #define TDES_FLAGS_BUSY                
BIT(18)
1f858040 Nicolas Royer  2013-02-20   59  #define TDES_FLAGS_DMA         BIT(19)
13802005 Nicolas Royer  2012-07-01   60  
1f858040 Nicolas Royer  2013-02-20   61  #define ATMEL_TDES_QUEUE_LENGTH        
50
13802005 Nicolas Royer  2012-07-01   62  
13802005 Nicolas Royer  2012-07-01   63  #define CFB8_BLOCK_SIZE                
1
13802005 Nicolas Royer  2012-07-01   64  #define CFB16_BLOCK_SIZE       2
13802005 Nicolas Royer  2012-07-01   65  #define CFB32_BLOCK_SIZE       4
13802005 Nicolas Royer  2012-07-01   66  
1f858040 Nicolas Royer  2013-02-20   67  struct atmel_tdes_caps {
1f858040 Nicolas Royer  2013-02-20   68         bool    has_dma;
1f858040 Nicolas Royer  2013-02-20   69         u32             has_cfb_3keys;
1f858040 Nicolas Royer  2013-02-20   70  };
13802005 Nicolas Royer  2012-07-01   71  
13802005 Nicolas Royer  2012-07-01   72  struct atmel_tdes_dev;
13802005 Nicolas Royer  2012-07-01   73  
13802005 Nicolas Royer  2012-07-01   74  struct atmel_tdes_ctx {
13802005 Nicolas Royer  2012-07-01   75         struct atmel_tdes_dev *dd;
13802005 Nicolas Royer  2012-07-01   76  
13802005 Nicolas Royer  2012-07-01   77         int             keylen;
13802005 Nicolas Royer  2012-07-01   78         u32             
key[3*DES_KEY_SIZE / sizeof(u32)];
13802005 Nicolas Royer  2012-07-01   79         unsigned long   flags;
1f858040 Nicolas Royer  2013-02-20   80  
1f858040 Nicolas Royer  2013-02-20   81         u16             block_size;
13802005 Nicolas Royer  2012-07-01   82  };
13802005 Nicolas Royer  2012-07-01   83  
13802005 Nicolas Royer  2012-07-01   84  struct atmel_tdes_reqctx {
13802005 Nicolas Royer  2012-07-01   85         unsigned long mode;
13802005 Nicolas Royer  2012-07-01   86  };
13802005 Nicolas Royer  2012-07-01   87  
1f858040 Nicolas Royer  2013-02-20   88  struct atmel_tdes_dma {
1f858040 Nicolas Royer  2013-02-20   89         struct dma_chan                 
*chan;
1f858040 Nicolas Royer  2013-02-20   90         struct dma_slave_config 
dma_conf;
1f858040 Nicolas Royer  2013-02-20   91  };
1f858040 Nicolas Royer  2013-02-20   92  
13802005 Nicolas Royer  2012-07-01   93  struct atmel_tdes_dev {
13802005 Nicolas Royer  2012-07-01   94         struct list_head        list;
13802005 Nicolas Royer  2012-07-01   95         unsigned long           
phys_base;
13802005 Nicolas Royer  2012-07-01   96         void __iomem            
*io_base;
13802005 Nicolas Royer  2012-07-01   97  
13802005 Nicolas Royer  2012-07-01   98         struct atmel_tdes_ctx   *ctx;
13802005 Nicolas Royer  2012-07-01   99         struct device           *dev;
13802005 Nicolas Royer  2012-07-01  100         struct clk                      
*iclk;
13802005 Nicolas Royer  2012-07-01  101         int                             
        irq;
13802005 Nicolas Royer  2012-07-01  102  
13802005 Nicolas Royer  2012-07-01  103         unsigned long           flags;
13802005 Nicolas Royer  2012-07-01  104         int                     err;
13802005 Nicolas Royer  2012-07-01  105  
13802005 Nicolas Royer  2012-07-01  106         spinlock_t              lock;
13802005 Nicolas Royer  2012-07-01  107         struct crypto_queue     queue;
13802005 Nicolas Royer  2012-07-01  108  
13802005 Nicolas Royer  2012-07-01  109         struct tasklet_struct   
done_task;
13802005 Nicolas Royer  2012-07-01  110         struct tasklet_struct   
queue_task;
13802005 Nicolas Royer  2012-07-01  111  
13802005 Nicolas Royer  2012-07-01  112         struct ablkcipher_request       
*req;
13802005 Nicolas Royer  2012-07-01  113         size_t                          
total;
13802005 Nicolas Royer  2012-07-01  114  
13802005 Nicolas Royer  2012-07-01  115         struct scatterlist      *in_sg;
1f858040 Nicolas Royer  2013-02-20  116         unsigned int            
nb_in_sg;
13802005 Nicolas Royer  2012-07-01  117         size_t                          
in_offset;
13802005 Nicolas Royer  2012-07-01  118         struct scatterlist      *out_sg;
1f858040 Nicolas Royer  2013-02-20  119         unsigned int            
nb_out_sg;
13802005 Nicolas Royer  2012-07-01  120         size_t                          
out_offset;
13802005 Nicolas Royer  2012-07-01  121  
13802005 Nicolas Royer  2012-07-01  122         size_t  buflen;
13802005 Nicolas Royer  2012-07-01  123         size_t  dma_size;
13802005 Nicolas Royer  2012-07-01  124  
13802005 Nicolas Royer  2012-07-01  125         void    *buf_in;
13802005 Nicolas Royer  2012-07-01  126         int             dma_in;
13802005 Nicolas Royer  2012-07-01  127         dma_addr_t      dma_addr_in;
1f858040 Nicolas Royer  2013-02-20  128         struct atmel_tdes_dma   
dma_lch_in;
13802005 Nicolas Royer  2012-07-01  129  
13802005 Nicolas Royer  2012-07-01  130         void    *buf_out;
13802005 Nicolas Royer  2012-07-01  131         int             dma_out;
13802005 Nicolas Royer  2012-07-01  132         dma_addr_t      dma_addr_out;
1f858040 Nicolas Royer  2013-02-20  133         struct atmel_tdes_dma   
dma_lch_out;
1f858040 Nicolas Royer  2013-02-20  134  
1f858040 Nicolas Royer  2013-02-20  135         struct atmel_tdes_caps  caps;
1f858040 Nicolas Royer  2013-02-20  136  
1f858040 Nicolas Royer  2013-02-20  137         u32     hw_version;
13802005 Nicolas Royer  2012-07-01  138  };
13802005 Nicolas Royer  2012-07-01  139  
13802005 Nicolas Royer  2012-07-01  140  struct atmel_tdes_drv {
13802005 Nicolas Royer  2012-07-01  141         struct list_head        
dev_list;
13802005 Nicolas Royer  2012-07-01  142         spinlock_t              lock;
13802005 Nicolas Royer  2012-07-01  143  };
13802005 Nicolas Royer  2012-07-01  144  
13802005 Nicolas Royer  2012-07-01  145  static struct atmel_tdes_drv 
atmel_tdes = {
13802005 Nicolas Royer  2012-07-01  146         .dev_list = 
LIST_HEAD_INIT(atmel_tdes.dev_list),
13802005 Nicolas Royer  2012-07-01  147         .lock = 
__SPIN_LOCK_UNLOCKED(atmel_tdes.lock),
13802005 Nicolas Royer  2012-07-01  148  };
13802005 Nicolas Royer  2012-07-01  149  
13802005 Nicolas Royer  2012-07-01  150  static int atmel_tdes_sg_copy(struct 
scatterlist **sg, size_t *offset,
13802005 Nicolas Royer  2012-07-01  151                         void *buf, 
size_t buflen, size_t total, int out)
13802005 Nicolas Royer  2012-07-01  152  {
13802005 Nicolas Royer  2012-07-01  153         unsigned int count, off = 0;
13802005 Nicolas Royer  2012-07-01  154  
13802005 Nicolas Royer  2012-07-01  155         while (buflen && total) {
13802005 Nicolas Royer  2012-07-01  156                 count = 
min((*sg)->length - *offset, total);
13802005 Nicolas Royer  2012-07-01 @157                 count = min(count, 
buflen);
13802005 Nicolas Royer  2012-07-01  158  
13802005 Nicolas Royer  2012-07-01  159                 if (!count)
13802005 Nicolas Royer  2012-07-01  160                         return off;
13802005 Nicolas Royer  2012-07-01  161  
13802005 Nicolas Royer  2012-07-01  162                 
scatterwalk_map_and_copy(buf + off, *sg, *offset, count, out);
13802005 Nicolas Royer  2012-07-01  163  
13802005 Nicolas Royer  2012-07-01  164                 off += count;
13802005 Nicolas Royer  2012-07-01  165                 buflen -= count;
13802005 Nicolas Royer  2012-07-01  166                 *offset += count;
13802005 Nicolas Royer  2012-07-01  167                 total -= count;
13802005 Nicolas Royer  2012-07-01  168  
13802005 Nicolas Royer  2012-07-01  169                 if (*offset == 
(*sg)->length) {
13802005 Nicolas Royer  2012-07-01  170                         *sg = 
sg_next(*sg);
13802005 Nicolas Royer  2012-07-01  171                         if (*sg)
13802005 Nicolas Royer  2012-07-01  172                                 *offset 
= 0;
13802005 Nicolas Royer  2012-07-01  173                         else
13802005 Nicolas Royer  2012-07-01  174                                 total = 
0;
13802005 Nicolas Royer  2012-07-01  175                 }
13802005 Nicolas Royer  2012-07-01  176         }
13802005 Nicolas Royer  2012-07-01  177  
13802005 Nicolas Royer  2012-07-01  178         return off;
13802005 Nicolas Royer  2012-07-01  179  }
13802005 Nicolas Royer  2012-07-01  180  
13802005 Nicolas Royer  2012-07-01  181  static inline u32 
atmel_tdes_read(struct atmel_tdes_dev *dd, u32 offset)
13802005 Nicolas Royer  2012-07-01  182  {
13802005 Nicolas Royer  2012-07-01  183         return 
readl_relaxed(dd->io_base + offset);
13802005 Nicolas Royer  2012-07-01  184  }
13802005 Nicolas Royer  2012-07-01  185  
13802005 Nicolas Royer  2012-07-01  186  static inline void 
atmel_tdes_write(struct atmel_tdes_dev *dd,
13802005 Nicolas Royer  2012-07-01  187                                         
u32 offset, u32 value)
13802005 Nicolas Royer  2012-07-01  188  {
13802005 Nicolas Royer  2012-07-01  189         writel_relaxed(value, 
dd->io_base + offset);
13802005 Nicolas Royer  2012-07-01  190  }
13802005 Nicolas Royer  2012-07-01  191  
13802005 Nicolas Royer  2012-07-01  192  static void atmel_tdes_write_n(struct 
atmel_tdes_dev *dd, u32 offset,
13802005 Nicolas Royer  2012-07-01  193                                         
u32 *value, int count)
13802005 Nicolas Royer  2012-07-01  194  {
13802005 Nicolas Royer  2012-07-01  195         for (; count--; value++, offset 
+= 4)
13802005 Nicolas Royer  2012-07-01  196                 atmel_tdes_write(dd, 
offset, *value);
13802005 Nicolas Royer  2012-07-01  197  }
13802005 Nicolas Royer  2012-07-01  198  
13802005 Nicolas Royer  2012-07-01  199  static struct atmel_tdes_dev 
*atmel_tdes_find_dev(struct atmel_tdes_ctx *ctx)
13802005 Nicolas Royer  2012-07-01  200  {
13802005 Nicolas Royer  2012-07-01  201         struct atmel_tdes_dev *tdes_dd 
= NULL;
13802005 Nicolas Royer  2012-07-01  202         struct atmel_tdes_dev *tmp;
13802005 Nicolas Royer  2012-07-01  203  
13802005 Nicolas Royer  2012-07-01  204         spin_lock_bh(&atmel_tdes.lock);
13802005 Nicolas Royer  2012-07-01  205         if (!ctx->dd) {
13802005 Nicolas Royer  2012-07-01  206                 
list_for_each_entry(tmp, &atmel_tdes.dev_list, list) {
13802005 Nicolas Royer  2012-07-01  207                         tdes_dd = tmp;
13802005 Nicolas Royer  2012-07-01  208                         break;
13802005 Nicolas Royer  2012-07-01  209                 }
13802005 Nicolas Royer  2012-07-01  210                 ctx->dd = tdes_dd;
13802005 Nicolas Royer  2012-07-01  211         } else {
13802005 Nicolas Royer  2012-07-01  212                 tdes_dd = ctx->dd;
13802005 Nicolas Royer  2012-07-01  213         }
13802005 Nicolas Royer  2012-07-01  214         
spin_unlock_bh(&atmel_tdes.lock);
13802005 Nicolas Royer  2012-07-01  215  
13802005 Nicolas Royer  2012-07-01  216         return tdes_dd;
13802005 Nicolas Royer  2012-07-01  217  }
13802005 Nicolas Royer  2012-07-01  218  
13802005 Nicolas Royer  2012-07-01  219  static int atmel_tdes_hw_init(struct 
atmel_tdes_dev *dd)
13802005 Nicolas Royer  2012-07-01  220  {
9d83d299 LABBE Corentin 2015-10-02  221         int err;
9d83d299 LABBE Corentin 2015-10-02  222  
9d83d299 LABBE Corentin 2015-10-02  223         err = 
clk_prepare_enable(dd->iclk);
9d83d299 LABBE Corentin 2015-10-02  224         if (err)
9d83d299 LABBE Corentin 2015-10-02  225                 return err;
13802005 Nicolas Royer  2012-07-01  226  
13802005 Nicolas Royer  2012-07-01  227         if (!(dd->flags & 
TDES_FLAGS_INIT)) {
13802005 Nicolas Royer  2012-07-01  228                 atmel_tdes_write(dd, 
TDES_CR, TDES_CR_SWRST);
13802005 Nicolas Royer  2012-07-01  229                 dd->flags |= 
TDES_FLAGS_INIT;
13802005 Nicolas Royer  2012-07-01  230                 dd->err = 0;
13802005 Nicolas Royer  2012-07-01  231         }
13802005 Nicolas Royer  2012-07-01  232  
13802005 Nicolas Royer  2012-07-01  233         return 0;
13802005 Nicolas Royer  2012-07-01  234  }
13802005 Nicolas Royer  2012-07-01  235  
1f858040 Nicolas Royer  2013-02-20  236  static inline unsigned int 
atmel_tdes_get_version(struct atmel_tdes_dev *dd)
1f858040 Nicolas Royer  2013-02-20  237  {
1f858040 Nicolas Royer  2013-02-20  238         return atmel_tdes_read(dd, 
TDES_HW_VERSION) & 0x00000fff;
1f858040 Nicolas Royer  2013-02-20  239  }
1f858040 Nicolas Royer  2013-02-20  240  
1f858040 Nicolas Royer  2013-02-20  241  static void 
atmel_tdes_hw_version_init(struct atmel_tdes_dev *dd)
1f858040 Nicolas Royer  2013-02-20  242  {
1f858040 Nicolas Royer  2013-02-20  243         atmel_tdes_hw_init(dd);
1f858040 Nicolas Royer  2013-02-20  244  
1f858040 Nicolas Royer  2013-02-20  245         dd->hw_version = 
atmel_tdes_get_version(dd);
1f858040 Nicolas Royer  2013-02-20  246  
1f858040 Nicolas Royer  2013-02-20  247         dev_info(dd->dev,
1f858040 Nicolas Royer  2013-02-20  248                         "version: 
0x%x\n", dd->hw_version);
1f858040 Nicolas Royer  2013-02-20  249  
1f858040 Nicolas Royer  2013-02-20  250         clk_disable_unprepare(dd->iclk);
1f858040 Nicolas Royer  2013-02-20  251  }
1f858040 Nicolas Royer  2013-02-20  252  
1f858040 Nicolas Royer  2013-02-20  253  static void 
atmel_tdes_dma_callback(void *data)
1f858040 Nicolas Royer  2013-02-20  254  {
1f858040 Nicolas Royer  2013-02-20  255         struct atmel_tdes_dev *dd = 
data;
1f858040 Nicolas Royer  2013-02-20  256  
1f858040 Nicolas Royer  2013-02-20  257         /* dma_lch_out - completed */
1f858040 Nicolas Royer  2013-02-20  258         
tasklet_schedule(&dd->done_task);
1f858040 Nicolas Royer  2013-02-20  259  }
1f858040 Nicolas Royer  2013-02-20  260  
13802005 Nicolas Royer  2012-07-01  261  static int 
atmel_tdes_write_ctrl(struct atmel_tdes_dev *dd)
13802005 Nicolas Royer  2012-07-01  262  {
13802005 Nicolas Royer  2012-07-01  263         int err;
13802005 Nicolas Royer  2012-07-01  264         u32 valcr = 0, valmr = 
TDES_MR_SMOD_PDC;
13802005 Nicolas Royer  2012-07-01  265  
13802005 Nicolas Royer  2012-07-01  266         err = atmel_tdes_hw_init(dd);
13802005 Nicolas Royer  2012-07-01  267  
13802005 Nicolas Royer  2012-07-01  268         if (err)
13802005 Nicolas Royer  2012-07-01  269                 return err;
13802005 Nicolas Royer  2012-07-01  270  
1f858040 Nicolas Royer  2013-02-20  271         if (!dd->caps.has_dma)
1f858040 Nicolas Royer  2013-02-20  272                 atmel_tdes_write(dd, 
TDES_PTCR,
1f858040 Nicolas Royer  2013-02-20  273                         
TDES_PTCR_TXTDIS | TDES_PTCR_RXTDIS);
13802005 Nicolas Royer  2012-07-01  274  
13802005 Nicolas Royer  2012-07-01  275         /* MR register must be set 
before IV registers */
13802005 Nicolas Royer  2012-07-01  276         if (dd->ctx->keylen > 
(DES_KEY_SIZE << 1)) {
13802005 Nicolas Royer  2012-07-01  277                 valmr |= 
TDES_MR_KEYMOD_3KEY;
13802005 Nicolas Royer  2012-07-01  278                 valmr |= 
TDES_MR_TDESMOD_TDES;
13802005 Nicolas Royer  2012-07-01  279         } else if (dd->ctx->keylen > 
DES_KEY_SIZE) {
13802005 Nicolas Royer  2012-07-01  280                 valmr |= 
TDES_MR_KEYMOD_2KEY;
13802005 Nicolas Royer  2012-07-01  281                 valmr |= 
TDES_MR_TDESMOD_TDES;
13802005 Nicolas Royer  2012-07-01  282         } else {
13802005 Nicolas Royer  2012-07-01  283                 valmr |= 
TDES_MR_TDESMOD_DES;
13802005 Nicolas Royer  2012-07-01  284         }
13802005 Nicolas Royer  2012-07-01  285  
13802005 Nicolas Royer  2012-07-01  286         if (dd->flags & TDES_FLAGS_CBC) 
{
13802005 Nicolas Royer  2012-07-01  287                 valmr |= 
TDES_MR_OPMOD_CBC;
13802005 Nicolas Royer  2012-07-01  288         } else if (dd->flags & 
TDES_FLAGS_CFB) {
13802005 Nicolas Royer  2012-07-01  289                 valmr |= 
TDES_MR_OPMOD_CFB;
13802005 Nicolas Royer  2012-07-01  290  
13802005 Nicolas Royer  2012-07-01  291                 if (dd->flags & 
TDES_FLAGS_CFB8)
13802005 Nicolas Royer  2012-07-01  292                         valmr |= 
TDES_MR_CFBS_8b;
13802005 Nicolas Royer  2012-07-01  293                 else if (dd->flags & 
TDES_FLAGS_CFB16)
13802005 Nicolas Royer  2012-07-01  294                         valmr |= 
TDES_MR_CFBS_16b;
13802005 Nicolas Royer  2012-07-01  295                 else if (dd->flags & 
TDES_FLAGS_CFB32)
13802005 Nicolas Royer  2012-07-01  296                         valmr |= 
TDES_MR_CFBS_32b;
1f858040 Nicolas Royer  2013-02-20  297                 else if (dd->flags & 
TDES_FLAGS_CFB64)
1f858040 Nicolas Royer  2013-02-20  298                         valmr |= 
TDES_MR_CFBS_64b;
13802005 Nicolas Royer  2012-07-01  299         } else if (dd->flags & 
TDES_FLAGS_OFB) {
13802005 Nicolas Royer  2012-07-01  300                 valmr |= 
TDES_MR_OPMOD_OFB;
13802005 Nicolas Royer  2012-07-01  301         }
13802005 Nicolas Royer  2012-07-01  302  
13802005 Nicolas Royer  2012-07-01  303         if ((dd->flags & 
TDES_FLAGS_ENCRYPT) || (dd->flags & TDES_FLAGS_OFB))
13802005 Nicolas Royer  2012-07-01  304                 valmr |= 
TDES_MR_CYPHER_ENC;
13802005 Nicolas Royer  2012-07-01  305  
13802005 Nicolas Royer  2012-07-01  306         atmel_tdes_write(dd, TDES_CR, 
valcr);
13802005 Nicolas Royer  2012-07-01  307         atmel_tdes_write(dd, TDES_MR, 
valmr);
13802005 Nicolas Royer  2012-07-01  308  
13802005 Nicolas Royer  2012-07-01  309         atmel_tdes_write_n(dd, 
TDES_KEY1W1R, dd->ctx->key,
13802005 Nicolas Royer  2012-07-01  310                                         
        dd->ctx->keylen >> 2);
13802005 Nicolas Royer  2012-07-01  311  
13802005 Nicolas Royer  2012-07-01  312         if (((dd->flags & 
TDES_FLAGS_CBC) || (dd->flags & TDES_FLAGS_CFB) ||
13802005 Nicolas Royer  2012-07-01  313                 (dd->flags & 
TDES_FLAGS_OFB)) && dd->req->info) {
13802005 Nicolas Royer  2012-07-01  314                 atmel_tdes_write_n(dd, 
TDES_IV1R, dd->req->info, 2);
13802005 Nicolas Royer  2012-07-01  315         }
13802005 Nicolas Royer  2012-07-01  316  
13802005 Nicolas Royer  2012-07-01  317         return 0;
13802005 Nicolas Royer  2012-07-01  318  }
13802005 Nicolas Royer  2012-07-01  319  
1f858040 Nicolas Royer  2013-02-20  320  static int 
atmel_tdes_crypt_pdc_stop(struct atmel_tdes_dev *dd)
13802005 Nicolas Royer  2012-07-01  321  {
13802005 Nicolas Royer  2012-07-01  322         int err = 0;
13802005 Nicolas Royer  2012-07-01  323         size_t count;
13802005 Nicolas Royer  2012-07-01  324  
13802005 Nicolas Royer  2012-07-01  325         atmel_tdes_write(dd, TDES_PTCR, 
TDES_PTCR_TXTDIS|TDES_PTCR_RXTDIS);
13802005 Nicolas Royer  2012-07-01  326  
13802005 Nicolas Royer  2012-07-01  327         if (dd->flags & 
TDES_FLAGS_FAST) {
13802005 Nicolas Royer  2012-07-01  328                 dma_unmap_sg(dd->dev, 
dd->out_sg, 1, DMA_FROM_DEVICE);
13802005 Nicolas Royer  2012-07-01  329                 dma_unmap_sg(dd->dev, 
dd->in_sg, 1, DMA_TO_DEVICE);
13802005 Nicolas Royer  2012-07-01  330         } else {
13802005 Nicolas Royer  2012-07-01  331                 
dma_sync_single_for_device(dd->dev, dd->dma_addr_out,
13802005 Nicolas Royer  2012-07-01  332                                         
   dd->dma_size, DMA_FROM_DEVICE);
13802005 Nicolas Royer  2012-07-01  333  
13802005 Nicolas Royer  2012-07-01  334                 /* copy data */
13802005 Nicolas Royer  2012-07-01  335                 count = 
atmel_tdes_sg_copy(&dd->out_sg, &dd->out_offset,
13802005 Nicolas Royer  2012-07-01  336                                 
dd->buf_out, dd->buflen, dd->dma_size, 1);
13802005 Nicolas Royer  2012-07-01  337                 if (count != 
dd->dma_size) {
13802005 Nicolas Royer  2012-07-01  338                         err = -EINVAL;
13802005 Nicolas Royer  2012-07-01 @339                         pr_err("not all 
data converted: %u\n", count);
13802005 Nicolas Royer  2012-07-01  340                 }
13802005 Nicolas Royer  2012-07-01  341         }
13802005 Nicolas Royer  2012-07-01  342  

:::::: The code at line 157 was first introduced by commit
:::::: 13802005d8f2db244ec1f5d7f6923de8f7a463db crypto: atmel - add Atmel 
DES/TDES driver

:::::: TO: Nicolas Royer <nico...@eukrea.com>
:::::: CC: Herbert Xu <herb...@gondor.apana.org.au>

---
0-DAY kernel test infrastructure                Open Source Technology Center
https://lists.01.org/pipermail/kbuild-all                   Intel Corporation

Attachment: .config.gz
Description: application/gzip

Reply via email to