Skip to content

Commit

Permalink
s390/zcrypt: code beautify
Browse files Browse the repository at this point in the history
Code beautify by following most of the checkpatch suggestions:
 - SPDX license identifier line complains by checkpatch
 - missing space or newline complains by checkpatch
 - octal numbers for permssions complains by checkpatch
 - renaming of static sysfs functions complains by checkpatch
 - fix of block comment complains by checkpatch
 - fix printf like calls where function name instead of %s __func__
   was used
 - __packed instead of __attribute__((packed))
 - init to zero for static variables removed
 - use of DEVICE_ATTR_RO and DEVICE_ATTR_RW macros

No functional code changes or API changes!

Signed-off-by: Harald Freudenberger <freude@linux.ibm.com>
Signed-off-by: Martin Schwidefsky <schwidefsky@de.ibm.com>
  • Loading branch information
Harald Freudenberger authored and Martin Schwidefsky committed Aug 20, 2018
1 parent 9b97e9f commit ac2b96f
Show file tree
Hide file tree
Showing 19 changed files with 270 additions and 241 deletions.
72 changes: 36 additions & 36 deletions arch/s390/include/uapi/asm/zcrypt.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,12 +32,12 @@
* - length(n_modulus) = inputdatalength
*/
struct ica_rsa_modexpo {
char __user * inputdata;
unsigned int inputdatalength;
char __user * outputdata;
unsigned int outputdatalength;
char __user * b_key;
char __user * n_modulus;
char __user *inputdata;
unsigned int inputdatalength;
char __user *outputdata;
unsigned int outputdatalength;
char __user *b_key;
char __user *n_modulus;
};

/**
Expand All @@ -55,15 +55,15 @@ struct ica_rsa_modexpo {
* - length(u_mult_inv) = inputdatalength/2 + 8
*/
struct ica_rsa_modexpo_crt {
char __user * inputdata;
unsigned int inputdatalength;
char __user * outputdata;
unsigned int outputdatalength;
char __user * bp_key;
char __user * bq_key;
char __user * np_prime;
char __user * nq_prime;
char __user * u_mult_inv;
char __user *inputdata;
unsigned int inputdatalength;
char __user *outputdata;
unsigned int outputdatalength;
char __user *bp_key;
char __user *bq_key;
char __user *np_prime;
char __user *nq_prime;
char __user *u_mult_inv;
};

/**
Expand Down Expand Up @@ -93,18 +93,18 @@ struct CPRBX {
unsigned int req_extbl; /* request extension block len */
unsigned char pad_001[4]; /* reserved */
unsigned int rpld_extbl; /* replied extension block len */
unsigned char padx000[16 - sizeof (char *)];
unsigned char * req_parmb; /* request parm block 'address' */
unsigned char padx001[16 - sizeof (char *)];
unsigned char * req_datab; /* request data block 'address' */
unsigned char padx002[16 - sizeof (char *)];
unsigned char * rpl_parmb; /* reply parm block 'address' */
unsigned char padx003[16 - sizeof (char *)];
unsigned char * rpl_datab; /* reply data block 'address' */
unsigned char padx004[16 - sizeof (char *)];
unsigned char * req_extb; /* request extension block 'addr'*/
unsigned char padx005[16 - sizeof (char *)];
unsigned char * rpl_extb; /* reply extension block 'address'*/
unsigned char padx000[16 - sizeof(char *)];
unsigned char *req_parmb; /* request parm block 'address' */
unsigned char padx001[16 - sizeof(char *)];
unsigned char *req_datab; /* request data block 'address' */
unsigned char padx002[16 - sizeof(char *)];
unsigned char *rpl_parmb; /* reply parm block 'address' */
unsigned char padx003[16 - sizeof(char *)];
unsigned char *rpl_datab; /* reply data block 'address' */
unsigned char padx004[16 - sizeof(char *)];
unsigned char *req_extb; /* request extension block 'addr'*/
unsigned char padx005[16 - sizeof(char *)];
unsigned char *rpl_extb; /* reply extension block 'address'*/
unsigned short ccp_rtcode; /* server return code */
unsigned short ccp_rscode; /* server reason code */
unsigned int mac_data_len; /* Mac Data Length */
Expand All @@ -127,17 +127,17 @@ struct ica_xcRB {
unsigned int user_defined;
unsigned short request_ID;
unsigned int request_control_blk_length;
unsigned char padding1[16 - sizeof (char *)];
char __user * request_control_blk_addr;
unsigned char padding1[16 - sizeof(char *)];
char __user *request_control_blk_addr;
unsigned int request_data_length;
char padding2[16 - sizeof (char *)];
char __user * request_data_address;
char padding2[16 - sizeof(char *)];
char __user *request_data_address;
unsigned int reply_control_blk_length;
char padding3[16 - sizeof (char *)];
char __user * reply_control_blk_addr;
char padding3[16 - sizeof(char *)];
char __user *reply_control_blk_addr;
unsigned int reply_data_length;
char padding4[16 - sizeof (char *)];
char __user * reply_data_addr;
char padding4[16 - sizeof(char *)];
char __user *reply_data_addr;
unsigned short priority_window;
unsigned int status;
} __attribute__((packed));
Expand Down Expand Up @@ -233,7 +233,7 @@ struct zcrypt_device_matrix_ext {
struct zcrypt_device_status_ext device[MAX_ZDEV_ENTRIES_EXT];
};

#define AUTOSELECT ((unsigned int)0xFFFFFFFF)
#define AUTOSELECT 0xFFFFFFFF

#define ZCRYPT_IOCTL_MAGIC 'z'

Expand Down
73 changes: 38 additions & 35 deletions drivers/s390/crypto/ap_bus.c
Original file line number Diff line number Diff line change
Expand Up @@ -43,12 +43,12 @@
*/
int ap_domain_index = -1; /* Adjunct Processor Domain Index */
static DEFINE_SPINLOCK(ap_domain_lock);
module_param_named(domain, ap_domain_index, int, S_IRUSR|S_IRGRP);
module_param_named(domain, ap_domain_index, int, 0440);
MODULE_PARM_DESC(domain, "domain index for ap devices");
EXPORT_SYMBOL(ap_domain_index);

static int ap_thread_flag = 0;
module_param_named(poll_thread, ap_thread_flag, int, S_IRUSR|S_IRGRP);
static int ap_thread_flag;
module_param_named(poll_thread, ap_thread_flag, int, 0440);
MODULE_PARM_DESC(poll_thread, "Turn on/off poll thread, default is 0 (off).");

static struct device *ap_root_device;
Expand Down Expand Up @@ -78,22 +78,26 @@ static DECLARE_WORK(ap_scan_work, ap_scan_bus);
static void ap_tasklet_fn(unsigned long);
static DECLARE_TASKLET(ap_tasklet, ap_tasklet_fn, 0);
static DECLARE_WAIT_QUEUE_HEAD(ap_poll_wait);
static struct task_struct *ap_poll_kthread = NULL;
static struct task_struct *ap_poll_kthread;
static DEFINE_MUTEX(ap_poll_thread_mutex);
static DEFINE_SPINLOCK(ap_poll_timer_lock);
static struct hrtimer ap_poll_timer;
/* In LPAR poll with 4kHz frequency. Poll every 250000 nanoseconds.
* If z/VM change to 1500000 nanoseconds to adjust to z/VM polling.*/
/*
* In LPAR poll with 4kHz frequency. Poll every 250000 nanoseconds.
* If z/VM change to 1500000 nanoseconds to adjust to z/VM polling.
*/
static unsigned long long poll_timeout = 250000;

/* Suspend flag */
static int ap_suspend_flag;
/* Maximum domain id */
static int ap_max_domain_id;
/* Flag to check if domain was set through module parameter domain=. This is
/*
* Flag to check if domain was set through module parameter domain=. This is
* important when supsend and resume is done in a z/VM environment where the
* domain might change. */
static int user_set_domain = 0;
* domain might change.
*/
static int user_set_domain;
static struct bus_type ap_bus_type;

/* Adapter interrupt definitions */
Expand Down Expand Up @@ -531,7 +535,7 @@ static int ap_bus_match(struct device *dev, struct device_driver *drv)
* It sets up a single environment variable DEV_TYPE which contains the
* hardware device type.
*/
static int ap_uevent (struct device *dev, struct kobj_uevent_env *env)
static int ap_uevent(struct device *dev, struct kobj_uevent_env *env)
{
struct ap_device *ap_dev = to_ap_dev(dev);
int retval = 0;
Expand Down Expand Up @@ -570,7 +574,7 @@ static int ap_dev_resume(struct device *dev)

static void ap_bus_suspend(void)
{
AP_DBF(DBF_DEBUG, "ap_bus_suspend running\n");
AP_DBF(DBF_DEBUG, "%s running\n", __func__);

ap_suspend_flag = 1;
/*
Expand Down Expand Up @@ -607,7 +611,7 @@ static void ap_bus_resume(void)
{
int rc;

AP_DBF(DBF_DEBUG, "ap_bus_resume running\n");
AP_DBF(DBF_DEBUG, "%s running\n", __func__);

/* remove all queue devices */
bus_for_each_dev(&ap_bus_type, NULL, NULL,
Expand Down Expand Up @@ -775,7 +779,7 @@ static ssize_t ap_domain_store(struct bus_type *bus,
return count;
}

static BUS_ATTR(ap_domain, 0644, ap_domain_show, ap_domain_store);
static BUS_ATTR_RW(ap_domain);

static ssize_t ap_control_domain_mask_show(struct bus_type *bus, char *buf)
{
Expand All @@ -790,8 +794,7 @@ static ssize_t ap_control_domain_mask_show(struct bus_type *bus, char *buf)
ap_configuration->adm[6], ap_configuration->adm[7]);
}

static BUS_ATTR(ap_control_domain_mask, 0444,
ap_control_domain_mask_show, NULL);
static BUS_ATTR_RO(ap_control_domain_mask);

static ssize_t ap_usage_domain_mask_show(struct bus_type *bus, char *buf)
{
Expand All @@ -806,24 +809,23 @@ static ssize_t ap_usage_domain_mask_show(struct bus_type *bus, char *buf)
ap_configuration->aqm[6], ap_configuration->aqm[7]);
}

static BUS_ATTR(ap_usage_domain_mask, 0444,
ap_usage_domain_mask_show, NULL);

static ssize_t ap_config_time_show(struct bus_type *bus, char *buf)
{
return snprintf(buf, PAGE_SIZE, "%d\n", ap_config_time);
}
static BUS_ATTR_RO(ap_usage_domain_mask);

static ssize_t ap_interrupts_show(struct bus_type *bus, char *buf)
{
return snprintf(buf, PAGE_SIZE, "%d\n",
ap_using_interrupts() ? 1 : 0);
}

static BUS_ATTR(ap_interrupts, 0444, ap_interrupts_show, NULL);
static BUS_ATTR_RO(ap_interrupts);

static ssize_t config_time_show(struct bus_type *bus, char *buf)
{
return snprintf(buf, PAGE_SIZE, "%d\n", ap_config_time);
}

static ssize_t ap_config_time_store(struct bus_type *bus,
const char *buf, size_t count)
static ssize_t config_time_store(struct bus_type *bus,
const char *buf, size_t count)
{
int time;

Expand All @@ -834,15 +836,15 @@ static ssize_t ap_config_time_store(struct bus_type *bus,
return count;
}

static BUS_ATTR(config_time, 0644, ap_config_time_show, ap_config_time_store);
static BUS_ATTR_RW(config_time);

static ssize_t ap_poll_thread_show(struct bus_type *bus, char *buf)
static ssize_t poll_thread_show(struct bus_type *bus, char *buf)
{
return snprintf(buf, PAGE_SIZE, "%d\n", ap_poll_kthread ? 1 : 0);
}

static ssize_t ap_poll_thread_store(struct bus_type *bus,
const char *buf, size_t count)
static ssize_t poll_thread_store(struct bus_type *bus,
const char *buf, size_t count)
{
int flag, rc;

Expand All @@ -857,7 +859,7 @@ static ssize_t ap_poll_thread_store(struct bus_type *bus,
return count;
}

static BUS_ATTR(poll_thread, 0644, ap_poll_thread_show, ap_poll_thread_store);
static BUS_ATTR_RW(poll_thread);

static ssize_t poll_timeout_show(struct bus_type *bus, char *buf)
{
Expand Down Expand Up @@ -886,7 +888,7 @@ static ssize_t poll_timeout_store(struct bus_type *bus, const char *buf,
return count;
}

static BUS_ATTR(poll_timeout, 0644, poll_timeout_show, poll_timeout_store);
static BUS_ATTR_RW(poll_timeout);

static ssize_t ap_max_domain_id_show(struct bus_type *bus, char *buf)
{
Expand All @@ -899,7 +901,7 @@ static ssize_t ap_max_domain_id_show(struct bus_type *bus, char *buf)
return snprintf(buf, PAGE_SIZE, "%d\n", max_domain_id);
}

static BUS_ATTR(ap_max_domain_id, 0444, ap_max_domain_id_show, NULL);
static BUS_ATTR_RO(ap_max_domain_id);

static struct bus_attribute *const ap_bus_attrs[] = {
&bus_attr_ap_domain,
Expand Down Expand Up @@ -956,7 +958,7 @@ static int ap_select_domain(void)
best_domain = i;
}
}
if (best_domain >= 0){
if (best_domain >= 0) {
ap_domain_index = best_domain;
AP_DBF(DBF_DEBUG, "new ap_domain_index=%d\n", ap_domain_index);
spin_unlock_bh(&ap_domain_lock);
Expand Down Expand Up @@ -1038,7 +1040,7 @@ static void ap_scan_bus(struct work_struct *unused)
unsigned int func = 0;
int rc, id, dom, borked, domains, defdomdevs = 0;

AP_DBF(DBF_DEBUG, "ap_scan_bus running\n");
AP_DBF(DBF_DEBUG, "%s running\n", __func__);

ap_query_configuration(ap_configuration);
if (ap_select_domain() != 0)
Expand Down Expand Up @@ -1163,7 +1165,8 @@ static void ap_scan_bus(struct work_struct *unused)
} /* end device loop */

if (defdomdevs < 1)
AP_DBF(DBF_INFO, "no queue device with default domain %d available\n",
AP_DBF(DBF_INFO,
"no queue device with default domain %d available\n",
ap_domain_index);

out:
Expand Down
4 changes: 2 additions & 2 deletions drivers/s390/crypto/ap_bus.h
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// SPDX-License-Identifier: GPL-2.0+
/* SPDX-License-Identifier: GPL-2.0+ */
/*
* Copyright IBM Corp. 2006, 2012
* Author(s): Cornelia Huck <cornelia.huck@de.ibm.com>
Expand Down Expand Up @@ -167,7 +167,7 @@ struct ap_queue {
int pendingq_count; /* # requests on pendingq list. */
int requestq_count; /* # requests on requestq list. */
int total_request_count; /* # requests ever for this AP device.*/
int request_timeout; /* Request timout in jiffies. */
int request_timeout; /* Request timeout in jiffies. */
struct timer_list timeout; /* Timer for request timeouts. */
struct list_head pendingq; /* List of message sent to AP queue. */
struct list_head requestq; /* List of message yet to be sent. */
Expand Down
Loading

0 comments on commit ac2b96f

Please sign in to comment.