Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 16f56e8b authored by LABBE Corentin's avatar LABBE Corentin Committed by Herbert Xu
Browse files

crypto: hifn_795x - fix coding style



The hifn_795x driver is old and have lots of style issue.
This patch try to solve easy ones.

Signed-off-by: default avatarLABBE Corentin <clabbe.montjoie@gmail.com>
Signed-off-by: default avatarHerbert Xu <herbert@gondor.apana.org.au>
parent cfeecab4
Loading
Loading
Loading
Loading
+138 −163
Original line number Diff line number Diff line
@@ -11,10 +11,6 @@
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 */

#include <linux/kernel.h>
@@ -350,10 +346,10 @@ static atomic_t hifn_dev_number;
#define HIFN_NAMESIZE			32
#define HIFN_MAX_RESULT_ORDER		5

#define	HIFN_D_CMD_RSIZE		24*1
#define	HIFN_D_SRC_RSIZE		80*1
#define	HIFN_D_DST_RSIZE		80*1
#define	HIFN_D_RES_RSIZE		24*1
#define	HIFN_D_CMD_RSIZE		(24 * 1)
#define	HIFN_D_SRC_RSIZE		(80 * 1)
#define	HIFN_D_DST_RSIZE		(80 * 1)
#define	HIFN_D_RES_RSIZE		(24 * 1)

#define HIFN_D_DST_DALIGN		4

@@ -378,8 +374,7 @@ static atomic_t hifn_dev_number;
#define	HIFN_MAX_RESULT			(8 + 4 + 4 + 20 + 4)
#define HIFN_USED_RESULT		12

struct hifn_desc
{
struct hifn_desc {
	volatile __le32		l;
	volatile __le32		p;
};
@@ -410,8 +405,7 @@ struct hifn_dma {

#define HIFN_DEFAULT_ACTIVE_NUM	5

struct hifn_device
{
struct hifn_device {
	char			name[HIFN_NAMESIZE];

	int			irq;
@@ -460,8 +454,7 @@ struct hifn_device
#define	HIFN_D_JUMP			0x40000000
#define	HIFN_D_VALID			0x80000000

struct hifn_base_command
{
struct hifn_base_command {
	volatile __le16		masks;
	volatile __le16		session_num;
	volatile __le16		total_source_count;
@@ -483,8 +476,7 @@ struct hifn_base_command
/*
 * Structure to help build up the command data structure.
 */
struct hifn_crypt_command
{
struct hifn_crypt_command {
	volatile __le16		masks;
	volatile __le16		header_skip;
	volatile __le16		source_count;
@@ -514,8 +506,7 @@ struct hifn_crypt_command
/*
 * Structure to help build up the command data structure.
 */
struct hifn_mac_command
{
struct hifn_mac_command {
	volatile __le16	masks;
	volatile __le16	header_skip;
	volatile __le16	source_count;
@@ -543,8 +534,7 @@ struct hifn_mac_command
#define	HIFN_MAC_CMD_POS_IPSEC		0x0200
#define	HIFN_MAC_CMD_NEW_KEY		0x0800

struct hifn_comp_command
{
struct hifn_comp_command {
	volatile __le16		masks;
	volatile __le16		header_skip;
	volatile __le16		source_count;
@@ -562,8 +552,7 @@ struct hifn_comp_command
#define	HIFN_COMP_CMD_ALG_MPPC		0x0001	/*   MPPC */
#define	HIFN_COMP_CMD_ALG_LZS		0x0000	/*   LZS */

struct hifn_base_result
{
struct hifn_base_result {
	volatile __le16		flags;
	volatile __le16		session;
	volatile __le16		src_cnt;		/* 15:0 of source count */
@@ -576,8 +565,7 @@ struct hifn_base_result
#define	HIFN_BASE_RES_DSTLEN_M		0x3000	/* 17:16 of dest count */
#define	HIFN_BASE_RES_DSTLEN_S		12

struct hifn_comp_result
{
struct hifn_comp_result {
	volatile __le16		flags;
	volatile __le16		crc;
};
@@ -588,8 +576,7 @@ struct hifn_comp_result
#define	HIFN_COMP_RES_ENDMARKER		0x0002	/* LZS: end marker seen */
#define	HIFN_COMP_RES_SRC_NOTZERO	0x0001	/* source expired */

struct hifn_mac_result
{
struct hifn_mac_result {
	volatile __le16		flags;
	volatile __le16		reserved;
	/* followed by 0, 6, 8, or 10 u16's of the MAC, then crypt */
@@ -598,8 +585,7 @@ struct hifn_mac_result
#define	HIFN_MAC_RES_MISCOMPARE		0x0002	/* compare failed */
#define	HIFN_MAC_RES_SRC_NOTZERO	0x0001	/* source expired */

struct hifn_crypt_result
{
struct hifn_crypt_result {
	volatile __le16		flags;
	volatile __le16		reserved;
};
@@ -617,8 +603,7 @@ struct hifn_crypt_result
#define	HIFN_MAX_SEGLEN		0xffff		/* maximum dma segment len */
#define	HIFN_MAX_DMALEN		0x3ffff		/* maximum dma length */

struct hifn_crypto_alg
{
struct hifn_crypto_alg {
	struct list_head	entry;
	struct crypto_alg	alg;
	struct hifn_device	*dev;
@@ -628,22 +613,19 @@ struct hifn_crypto_alg

#define ASYNC_FLAGS_MISALIGNED	(1 << 0)

struct hifn_cipher_walk
{
struct hifn_cipher_walk {
	struct scatterlist	cache[ASYNC_SCATTERLIST_CACHE];
	u32			flags;
	int			num;
};

struct hifn_context
{
struct hifn_context {
	u8			key[HIFN_MAX_CRYPT_KEY_LENGTH];
	struct hifn_device	*dev;
	unsigned int		keysize;
};

struct hifn_request_context
{
struct hifn_request_context {
	u8			*iv;
	unsigned int		ivsize;
	u8			op, type, mode, unused;
@@ -741,13 +723,12 @@ static void hifn_reset_dma(struct hifn_device *dev, int full)
	hifn_reset_puc(dev);
}

static u32 hifn_next_signature(u_int32_t a, u_int cnt)
static u32 hifn_next_signature(u32 a, u_int cnt)
{
	int i;
	u32 v;

	for (i = 0; i < cnt; i++) {

		/* get the parity */
		v = a & 0x80080125;
		v ^= v >> 16;
@@ -845,9 +826,9 @@ static int hifn_init_pubrng(struct hifn_device *dev)
			break;
	}

	if (!i)
	if (!i) {
		dev_err(&dev->pdev->dev, "Failed to initialise public key engine.\n");
	else {
	} else {
		hifn_write_1(dev, HIFN_1_PUB_IEN, HIFN_PUBIEN_DONE);
		dev->dmareg |= HIFN_DMAIER_PUBDONE;
		hifn_write_1(dev, HIFN_1_DMA_IER, dev->dmareg);
@@ -855,9 +836,7 @@ static int hifn_init_pubrng(struct hifn_device *dev)
		dev_dbg(&dev->pdev->dev, "Public key engine has been successfully initialised.\n");
	}

	/*
	 * Enable RNG engine.
	 */
	/* Enable RNG engine. */

	hifn_write_1(dev, HIFN_1_RNG_CONFIG,
			hifn_read_1(dev, HIFN_1_RNG_CONFIG) | HIFN_RNGCFG_ENA);
@@ -885,7 +864,7 @@ static int hifn_enable_crypto(struct hifn_device *dev)
		}
	}

	if (offtbl == NULL) {
	if (!offtbl) {
		dev_err(&dev->pdev->dev, "Unknown card!\n");
		return -ENODEV;
	}
@@ -927,9 +906,7 @@ static void hifn_init_dma(struct hifn_device *dev)
		dma->resr[i].p = __cpu_to_le32(dptr +
				offsetof(struct hifn_dma, result_bufs[i][0]));

	/*
	 * Setup LAST descriptors.
	 */
	/* Setup LAST descriptors. */
	dma->cmdr[HIFN_D_CMD_RSIZE].p = __cpu_to_le32(dptr +
			offsetof(struct hifn_dma, cmdr[0]));
	dma->srcr[HIFN_D_SRC_RSIZE].p = __cpu_to_le32(dptr +
@@ -949,7 +926,7 @@ static void hifn_init_dma(struct hifn_device *dev)
 * to calculate the optimal multiplier. For PCI we assume 66MHz, since that
 * allows us to operate without the risk of overclocking the chip. If it
 * actually uses 33MHz, the chip will operate at half the speed, this can be
 * overriden by specifying the frequency as module parameter (pci33).
 * overridden by specifying the frequency as module parameter (pci33).
 *
 * Unfortunately the PCI clock is not very suitable since the HIFN needs a
 * stable clock and the PCI clock frequency may vary, so the default is the
@@ -1253,8 +1230,9 @@ static int hifn_setup_cmd_desc(struct hifn_device *dev,
			HIFN_D_VALID | HIFN_D_LAST |
			HIFN_D_MASKDONEIRQ | HIFN_D_JUMP);
		dma->cmdi = 0;
	} else
	} else {
		dma->cmdr[dma->cmdi - 1].l |= __cpu_to_le32(HIFN_D_VALID);
	}

	if (!(dev->flags & HIFN_FLAG_CMD_BUSY)) {
		hifn_write_1(dev, HIFN_1_DMA_CSR, HIFN_DMACSR_C_CTRL_ENA);
@@ -2231,9 +2209,7 @@ static inline int hifn_encrypt_3des_ofb(struct ablkcipher_request *req)
			ACRYPTO_TYPE_3DES, ACRYPTO_MODE_OFB);
}

/*
 * 3DES decryption functions.
 */
/* 3DES decryption functions. */
static inline int hifn_decrypt_3des_ecb(struct ablkcipher_request *req)
{
	return hifn_setup_crypto(req, ACRYPTO_OP_DECRYPT,
@@ -2255,8 +2231,7 @@ static inline int hifn_decrypt_3des_ofb(struct ablkcipher_request *req)
			ACRYPTO_TYPE_3DES, ACRYPTO_MODE_OFB);
}

struct hifn_alg_template
{
struct hifn_alg_template {
	char name[CRYPTO_MAX_ALG_NAME];
	char drv_name[CRYPTO_MAX_ALG_NAME];
	unsigned int bsize;
@@ -2416,7 +2391,7 @@ static int hifn_alg_alloc(struct hifn_device *dev, struct hifn_alg_template *t)
	struct hifn_crypto_alg *alg;
	int err;

	alg = kzalloc(sizeof(struct hifn_crypto_alg), GFP_KERNEL);
	alg = kzalloc(sizeof(*alg), GFP_KERNEL);
	if (!alg)
		return -ENOMEM;