Skip to content

Commit

Permalink
staging: dst: fix coding style
Browse files Browse the repository at this point in the history
Signed-off-by: Mariusz Ziulek <mz.mzet@gmail.com>
Cc: Evgeniy Polyakov <zbr@ioremap.net>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
  • Loading branch information
Mariusz Ziulek authored and Greg Kroah-Hartman committed Dec 11, 2009
1 parent f5e08ca commit d52ac3f
Show file tree
Hide file tree
Showing 6 changed files with 135 additions and 116 deletions.
64 changes: 33 additions & 31 deletions drivers/staging/dst/crypto.c
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,8 @@ static struct crypto_hash *dst_init_hash(struct dst_crypto_ctl *ctl, u8 *key)
return ERR_PTR(err);
}

static struct crypto_ablkcipher *dst_init_cipher(struct dst_crypto_ctl *ctl, u8 *key)
static struct crypto_ablkcipher *dst_init_cipher(struct dst_crypto_ctl *ctl,
u8 *key)
{
int err = -EINVAL;
struct crypto_ablkcipher *cipher;
Expand Down Expand Up @@ -105,7 +106,7 @@ static void dst_crypto_pages_free(struct dst_crypto_engine *e)
{
unsigned int i;

for (i=0; i<e->page_num; ++i)
for (i = 0; i < e->page_num; ++i)
__free_page(e->pages[i]);
kfree(e->pages);
}
Expand All @@ -118,7 +119,7 @@ static int dst_crypto_pages_alloc(struct dst_crypto_engine *e, int num)
if (!e->pages)
return -ENOMEM;

for (i=0; i<num; ++i) {
for (i = 0; i < num; ++i) {
e->pages[i] = alloc_page(GFP_KERNEL);
if (!e->pages[i])
goto err_out_free_pages;
Expand All @@ -139,7 +140,8 @@ static int dst_crypto_pages_alloc(struct dst_crypto_engine *e, int num)
* Initialize crypto engine for given node.
* Setup cipher/hash, keys, pool of threads and private data.
*/
static int dst_crypto_engine_init(struct dst_crypto_engine *e, struct dst_node *n)
static int dst_crypto_engine_init(struct dst_crypto_engine *e,
struct dst_node *n)
{
int err;
struct dst_crypto_ctl *ctl = &n->crypto;
Expand Down Expand Up @@ -198,8 +200,7 @@ static void dst_crypto_engine_exit(struct dst_crypto_engine *e)
/*
* Waiting for cipher processing to be completed.
*/
struct dst_crypto_completion
{
struct dst_crypto_completion {
struct completion complete;
int error;
};
Expand Down Expand Up @@ -237,17 +238,17 @@ static int dst_crypto_process(struct ablkcipher_request *req,
err = crypto_ablkcipher_decrypt(req);

switch (err) {
case -EINPROGRESS:
case -EBUSY:
err = wait_for_completion_interruptible_timeout(&c.complete,
timeout);
if (!err)
err = -ETIMEDOUT;
else
err = c.error;
break;
default:
break;
case -EINPROGRESS:
case -EBUSY:
err = wait_for_completion_interruptible_timeout(&c.complete,
timeout);
if (!err)
err = -ETIMEDOUT;
else
err = c.error;
break;
default:
break;
}

return err;
Expand All @@ -263,7 +264,7 @@ static int dst_crypto_process(struct ablkcipher_request *req,
* temporary storage, which is then being sent to the remote peer.
*/
static int dst_trans_iter_out(struct bio *bio, struct dst_crypto_engine *e,
int (* iterator) (struct dst_crypto_engine *e,
int (*iterator) (struct dst_crypto_engine *e,
struct scatterlist *dst,
struct scatterlist *src))
{
Expand All @@ -286,7 +287,7 @@ static int dst_trans_iter_out(struct bio *bio, struct dst_crypto_engine *e,
}

static int dst_trans_iter_in(struct bio *bio, struct dst_crypto_engine *e,
int (* iterator) (struct dst_crypto_engine *e,
int (*iterator) (struct dst_crypto_engine *e,
struct scatterlist *dst,
struct scatterlist *src))
{
Expand Down Expand Up @@ -411,9 +412,9 @@ static void dst_crypto_thread_cleanup(void *private)
* Initialize crypto engine for given node: store keys, create pool
* of threads, initialize each one.
*
* Each thread has unique ID, but 0 and 1 are reserved for receiving and accepting
* threads (if export node), so IDs could start from 2, but starting them
* from 10 allows easily understand what this thread is for.
* Each thread has unique ID, but 0 and 1 are reserved for receiving and
* accepting threads (if export node), so IDs could start from 2, but starting
* them from 10 allows easily understand what this thread is for.
*/
int dst_node_crypto_init(struct dst_node *n, struct dst_crypto_ctl *ctl)
{
Expand All @@ -436,10 +437,10 @@ int dst_node_crypto_init(struct dst_node *n, struct dst_crypto_ctl *ctl)
}
memcpy(&n->crypto, ctl, sizeof(struct dst_crypto_ctl));

for (i=0; i<ctl->thread_num; ++i) {
for (i = 0; i < ctl->thread_num; ++i) {
snprintf(name, sizeof(name), "%s-crypto-%d", n->name, i);
/* Unique ids... */
err = thread_pool_add_worker(n->pool, name, i+10,
err = thread_pool_add_worker(n->pool, name, i + 10,
dst_crypto_thread_init, dst_crypto_thread_cleanup, n);
if (err)
goto err_out_free_threads;
Expand Down Expand Up @@ -496,8 +497,8 @@ static void dst_dump_bio(struct bio *bio)
bv->bv_len, bv->bv_offset);

p = kmap(bv->bv_page) + bv->bv_offset;
for (i=0; i<bv->bv_len; ++i)
printk("%02x ", p[i]);
for (i = 0; i < bv->bv_len; ++i)
printk(KERN_DEBUG "%02x ", p[i]);
kunmap(bv->bv_page);
printk("\n");
}
Expand Down Expand Up @@ -532,7 +533,7 @@ static int dst_crypto_process_sending(struct dst_crypto_engine *e,
printk(KERN_DEBUG "%s: bio: %llu/%u, rw: %lu, hash: ",
__func__, (u64)bio->bi_sector,
bio->bi_size, bio_data_dir(bio));
for (i=0; i<crypto_hash_digestsize(e->hash); ++i)
for (i = 0; i < crypto_hash_digestsize(e->hash); ++i)
printk("%02x ", hash[i]);
printk("\n");
}
Expand Down Expand Up @@ -572,9 +573,9 @@ static int dst_crypto_process_receiving(struct dst_crypto_engine *e,
unsigned int i;

printk(", recv/calc: ");
for (i=0; i<crypto_hash_digestsize(e->hash); ++i) {
for (i = 0; i < crypto_hash_digestsize(e->hash); ++i)
printk("%02x/%02x ", recv_hash[i], hash[i]);
}

}
printk("\n");
#endif
Expand Down Expand Up @@ -680,8 +681,9 @@ static int dst_export_crypto_action(void *crypto_engine, void *schedule_data)
struct dst_export_priv *p = bio->bi_private;
int err;

dprintk("%s: e: %p, data: %p, bio: %llu/%u, dir: %lu.\n", __func__,
e, e->data, (u64)bio->bi_sector, bio->bi_size, bio_data_dir(bio));
dprintk("%s: e: %p, data: %p, bio: %llu/%u, dir: %lu.\n",
__func__, e, e->data, (u64)bio->bi_sector,
bio->bi_size, bio_data_dir(bio));

e->enc = (bio_data_dir(bio) == READ);
e->iv = p->cmd.id;
Expand Down
26 changes: 15 additions & 11 deletions drivers/staging/dst/dcore.c
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ static int dst_request(struct request_queue *q, struct bio *bio)
* bio_rw_flagged(bio, BIO_RW_DISCARD) only, which does not
* work in this case.
*/
//err = -EOPNOTSUPP;
/* err = -EOPNOTSUPP; */
err = 0;
goto end_io;
}
Expand Down Expand Up @@ -197,7 +197,8 @@ static int dst_node_create_disk(struct dst_node *n)
n->disk->fops = &dst_blk_ops;
n->disk->queue = n->queue;
n->disk->private_data = n;
snprintf(n->disk->disk_name, sizeof(n->disk->disk_name), "dst-%s", n->name);
snprintf(n->disk->disk_name, sizeof(n->disk->disk_name),
"dst-%s", n->name);

return 0;

Expand Down Expand Up @@ -246,7 +247,8 @@ static ssize_t dst_show_type(struct device *dev,
return sprintf(buf, "%u.%u.%u.%u:%d\n",
NIPQUAD(sin->sin_addr.s_addr), ntohs(sin->sin_port));
} else if (family == AF_INET6) {
struct sockaddr_in6 *sin = (struct sockaddr_in6 *)&info->net.addr;
struct sockaddr_in6 *sin = (struct sockaddr_in6 *)
&info->net.addr;
return sprintf(buf,
"%pi6:%d\n",
&sin->sin6_addr, ntohs(sin->sin6_port));
Expand All @@ -261,7 +263,7 @@ static ssize_t dst_show_type(struct device *dev,
sz -= size;
buf += size;

for (i=0; i<addrlen; ++i) {
for (i = 0; i < addrlen; ++i) {
if (sz < 3)
break;

Expand All @@ -286,7 +288,7 @@ static int dst_create_node_attributes(struct dst_node *n)
{
int err, i;

for (i=0; i<ARRAY_SIZE(dst_node_attrs); ++i) {
for (i = 0; i < ARRAY_SIZE(dst_node_attrs); ++i) {
err = device_create_file(&n->info->device,
&dst_node_attrs[i]);
if (err)
Expand All @@ -306,7 +308,7 @@ static void dst_remove_node_attributes(struct dst_node *n)
{
int i;

for (i=0; i<ARRAY_SIZE(dst_node_attrs); ++i)
for (i = 0; i < ARRAY_SIZE(dst_node_attrs); ++i)
device_remove_file(&n->info->device,
&dst_node_attrs[i]);
}
Expand Down Expand Up @@ -358,7 +360,7 @@ static int dst_node_sysfs_init(struct dst_node *n)
*/
static inline unsigned int dst_hash(char *str, unsigned int size)
{
return (jhash(str, size, 0) % dst_hashtable_size);
return jhash(str, size, 0) % dst_hashtable_size;
}

static void dst_node_remove(struct dst_node *n)
Expand Down Expand Up @@ -641,7 +643,8 @@ static int dst_start_remote(struct dst_node *n)
dst_node_set_size(n);
add_disk(n->disk);

dprintk("DST: started remote node '%s', minor: %d.\n", n->name, n->disk->first_minor);
dprintk("DST: started remote node '%s', minor: %d.\n",
n->name, n->disk->first_minor);

return 0;
}
Expand Down Expand Up @@ -740,7 +743,8 @@ static int dst_node_remove_unload(struct dst_node *n)
* counter will be equal to 1),
* and subsequent dst_node_put() calls will free the node.
*/
dprintk("%s: going to sleep with %d refcnt.\n", __func__, atomic_read(&n->refcnt));
dprintk("%s: going to sleep with %d refcnt.\n",
__func__, atomic_read(&n->refcnt));
wait_event(n->wait, atomic_read(&n->refcnt) <= 2);

dst_node_put(n);
Expand Down Expand Up @@ -921,7 +925,7 @@ static int __init dst_hashtable_init(void)
if (!dst_hashtable)
return -ENOMEM;

for (i=0; i<dst_hashtable_size; ++i)
for (i = 0; i < dst_hashtable_size; ++i)
INIT_LIST_HEAD(&dst_hashtable[i]);

return 0;
Expand All @@ -932,7 +936,7 @@ static void dst_hashtable_exit(void)
unsigned int i;
struct dst_node *n, *tmp;

for (i=0; i<dst_hashtable_size; ++i) {
for (i = 0; i < dst_hashtable_size; ++i) {
list_for_each_entry_safe(n, tmp, &dst_hashtable[i], node_entry) {
dst_node_remove_unload(n);
}
Expand Down
31 changes: 17 additions & 14 deletions drivers/staging/dst/export.c
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,8 @@ void dst_export_exit(void)
* its permissions are checked in a security attributes and sent
* back.
*/
static unsigned int dst_check_permissions(struct dst_state *main, struct dst_state *st)
static unsigned int dst_check_permissions(struct dst_state *main,
struct dst_state *st)
{
struct dst_node *n = main->node;
struct dst_secure *sentry;
Expand All @@ -73,9 +74,9 @@ static unsigned int dst_check_permissions(struct dst_state *main, struct dst_sta

/*
* This '2' below is a port field. This may be very wrong to do
* in atalk for example though. If there will be any need to extent
* protocol to something else, I can create per-family helpers and
* use them instead of this memcmp.
* in atalk for example though. If there will be any need
* to extent protocol to something else, I can create
* per-family helpers and use them instead of this memcmp.
*/
if (memcmp(s->addr.sa_data + 2, sa->sa_data + 2,
sa->sa_data_len - 2))
Expand Down Expand Up @@ -125,8 +126,8 @@ static struct dst_state *dst_accept_client(struct dst_state *st)
* Magic HZ? Polling check above is not safe in
* all cases (like socket reset in BH context),
* so it is simpler just to postpone it to the
* process context instead of implementing special
* locking there.
* process context instead of implementing
* special locking there.
*/
schedule_timeout(HZ);
}
Expand Down Expand Up @@ -272,8 +273,8 @@ static void dst_state_cleanup_export(struct dst_state *st)
if (p)
bio_put(p->bio);

dprintk("%s: st: %p, refcnt: %d, list_empty: %d, p: %p.\n",
__func__, st, atomic_read(&st->refcnt),
dprintk("%s: st: %p, refcnt: %d, list_empty: %d, p: "
"%p.\n", __func__, st, atomic_read(&st->refcnt),
list_empty(&st->request_list), p);
}
}
Expand Down Expand Up @@ -303,9 +304,9 @@ static int dst_accept(void *init_data, void *schedule_data)
if (!err) {
while (n->trans_scan_timeout) {
err = wait_event_interruptible_timeout(st->thread_wait,
!list_empty(&st->request_list) ||
!n->trans_scan_timeout ||
st->need_exit,
!list_empty(&st->request_list) ||
!n->trans_scan_timeout ||
st->need_exit,
HZ);

if (!n->trans_scan_timeout || st->need_exit)
Expand Down Expand Up @@ -341,8 +342,9 @@ static int dst_accept(void *init_data, void *schedule_data)
int dst_start_export(struct dst_node *n)
{
if (list_empty(&n->security_list)) {
printk(KERN_ERR "You are trying to export node '%s' without security attributes.\n"
"No clients will be allowed to connect. Exiting.\n", n->name);
printk(KERN_ERR "You are trying to export node '%s' "
"without security attributes.\nNo clients will "
"be allowed to connect. Exiting.\n", n->name);
return -EINVAL;
}
return dst_node_trans_init(n, sizeof(struct dst_export_priv));
Expand Down Expand Up @@ -552,7 +554,8 @@ int dst_process_io(struct dst_state *st)
if (!bio)
goto err_out_exit;

priv = (struct dst_export_priv *)(((void *)bio) - sizeof (struct dst_export_priv));
priv = (struct dst_export_priv *)(((void *)bio) -
sizeof (struct dst_export_priv));

priv->state = dst_state_get(st);
priv->bio = bio;
Expand Down
Loading

0 comments on commit d52ac3f

Please sign in to comment.