Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp740389imu; Wed, 23 Jan 2019 05:00:20 -0800 (PST) X-Google-Smtp-Source: ALg8bN4qAdqNfgx/qFvoNgE+l1YcwUWcp5G4aYgg67TM9Lwva6Vl7GEwfqHYrD97tQs7J373aObY X-Received: by 2002:a17:902:622:: with SMTP id 31mr2081494plg.171.1548248420793; Wed, 23 Jan 2019 05:00:20 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1548248420; cv=none; d=google.com; s=arc-20160816; b=lRZ2/HPWGWnmBFdF+cJQjLFgzn5m6+4c4ShZ8DV2F7GT0H0788LGIEsN2kQp+84iim 0yfpv1y3ZX7BvnDYmtKKpS4YEaVMMGM83JgNwGNb/Zy1jXx2WWdWUG81SYlVGHIaMtOf llpyb3p9nzx0Vx6QNBb73GCWQv6869vQqp/oj11uAv8NFQGSuqKlmJc5jQUNB29ol0b6 XLiMQlrdUjckdufu8Kz0rvAseYDKkbF8WqBJm36uyXPUCeaLJy/ZkFVETqv/QD26Ab32 CoR5/KG1KDADQEuX5BFFM3+BMsn7CV8UWdZdBIGyHgvFZ9Ia7q+rmOM5xnJSTzbIxvKA 2s+A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:cc:to:subject :message-id:date:from:in-reply-to:references:mime-version :dkim-signature; bh=SKiTehzyUlwJV0b2BKwZAroAqyP7BP93rdA3qUyv8K0=; b=aV2EBgKg3YAWPFP/H1Mh2cenQZkdD/IeMmGAXT4Ye3nDdWrUO7A+Okx2R9cz5AYvqS IrIbBhDsGn64tlDlp2qySqUmrVMe0d5ZqAxtfKEE4q8z7kiYSv+M8RWroi6y33D6k//q CEUo5Bo0p4N8R7QZjaigQNk1sMkfmYOtHRqJMK8l8upOR0Un1/1MLKXMM9KKH00GcxFM MEogD2EcCMs1Wrz8UdBS+xl9f4+NZM0F8L8AgpXiLaWkoL6AvBzaJuh3gsK+2Xs6pfOq fnCK9Y9utfh2k8HK/UdX2eddCj3DaRjdPTc4OGj11DlZMKz2Icwv0tIaTd2xpBUhCzZ5 Fnog== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@benyossef-com.20150623.gappssmtp.com header.s=20150623 header.b=wtE7yITG; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id k26si5955212pgb.72.2019.01.23.05.00.04; Wed, 23 Jan 2019 05:00:20 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@benyossef-com.20150623.gappssmtp.com header.s=20150623 header.b=wtE7yITG; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726252AbfAWM6g (ORCPT + 99 others); Wed, 23 Jan 2019 07:58:36 -0500 Received: from mail-ua1-f67.google.com ([209.85.222.67]:41729 "EHLO mail-ua1-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725991AbfAWM6f (ORCPT ); Wed, 23 Jan 2019 07:58:35 -0500 Received: by mail-ua1-f67.google.com with SMTP id z24so663489ual.8 for ; Wed, 23 Jan 2019 04:58:34 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=benyossef-com.20150623.gappssmtp.com; s=20150623; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc:content-transfer-encoding; bh=SKiTehzyUlwJV0b2BKwZAroAqyP7BP93rdA3qUyv8K0=; b=wtE7yITG9nC0MKUTE1uCkJhlgvNuDODsGQc+7d0xdAjyicQ7J1inMNAW5JNctY5BT2 g1cQuchqogEy/xNENLUgv+qmkeVWW4i9eLSozBElRfRI+sRb7IFvgo/pbc0xrWnXrvDS 7xTN1Kh+spAMsU3/cVtvSIJo2/zJI1LE1mU1nmJfo7Z4LJ7sqsOrFkTufo4I6TVjq1mO ifH620Cic3pmPQhuAoW9/HjmYHUAlY/m21Bd2TtoVXaqt8oTEct8USVnaMK6YJR5ulsJ fzoY5yNfmZxa/P9i9OwCx3eTbOZlfXMP+vmgXB3+ZmUb8PPJ5E3ExdbVoEjWFQuUA8TS K8tA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc:content-transfer-encoding; bh=SKiTehzyUlwJV0b2BKwZAroAqyP7BP93rdA3qUyv8K0=; b=nS38StsEMzi4QnuuA7tVcAWJrQpy8VgGaiF0hUeFX5N14ogEdvOHaPkuuF3qnx/2BA tlfnDgvjJ25JJQD0w3oYmVTkXcdaphrCysah4mOoLym0vUhZFmfkhoKo7s3YnFCm2CBL /HHM+77Ry54ZOuBKqeCjEYikdDiUdKUVKc+FVK7wpuhwDD89pupeLvuRGCuF0BL7yb8g QYNN5+34EHmxV/SKBVbqYYxF/w+FLY+CFmUz/jY7jM4aHjjyoRfYPilUNQQwT9CRbMjp HMjSW7LPpgwEX0/lodlZsktec0CV0qvrll4cd0Qc6CwfaQ6rrhse7ypcX6IinJoviCdA MUrA== X-Gm-Message-State: AJcUuke5lLZ89ELgR5EyYDPK7QKw1Y/1i4XXDYGbGAujTxYU6INeiBX7 ylt/KNF413v0zDSpeJ3zRxt2cClwMNyr7Vx22fbl/8iwBDM= X-Received: by 2002:ab0:7493:: with SMTP id n19mr786352uap.115.1548248314009; Wed, 23 Jan 2019 04:58:34 -0800 (PST) MIME-Version: 1.0 References: <20190122151422.14204-1-gregkh@linuxfoundation.org> <20190122151422.14204-3-gregkh@linuxfoundation.org> In-Reply-To: <20190122151422.14204-3-gregkh@linuxfoundation.org> From: Gilad Ben-Yossef Date: Wed, 23 Jan 2019 14:58:22 +0200 Message-ID: Subject: Re: [PATCH 2/7] crypto: ccrree: no need to check return value of debugfs_create functions To: Greg Kroah-Hartman Cc: Herbert Xu , David Miller , Linux kernel mailing list , Linux Crypto Mailing List , Yael Chemla Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi, On Tue, Jan 22, 2019 at 5:14 PM Greg Kroah-Hartman wrote: > > When calling debugfs functions, there is no need to ever check the > return value. The function can work or not, but the code logic should > never do something different based on this. I get the part about not failing loading the driver just because some debugs entry isn't available, but wont it be weird if debugfs_create_dir() fails but debugfs_create_regset32() succeeds and we suddenly have weird files in the debugfs root dir? Not the end of the world of course but maybe it's better to avoid trying to create the files if the directory is not available? Thanks, Gilad > > Cc: Yael Chemla > Cc: Gilad Ben-Yossef > Cc: Herbert Xu > Cc: "David S. Miller" > Cc: linux-crypto@vger.kernel.org > Signed-off-by: Greg Kroah-Hartman > --- > drivers/crypto/ccree/cc_debugfs.c | 22 +++------------------- > drivers/crypto/ccree/cc_debugfs.h | 8 ++------ > drivers/crypto/ccree/cc_driver.c | 7 +------ > 3 files changed, 6 insertions(+), 31 deletions(-) > > diff --git a/drivers/crypto/ccree/cc_debugfs.c b/drivers/crypto/ccree/cc_= debugfs.c > index 5ca184e42483..5fa05a7bcf36 100644 > --- a/drivers/crypto/ccree/cc_debugfs.c > +++ b/drivers/crypto/ccree/cc_debugfs.c > @@ -39,11 +39,9 @@ static struct debugfs_reg32 debug_regs[] =3D { > CC_DEBUG_REG(AXIM_MON_COMP), > }; > > -int __init cc_debugfs_global_init(void) > +void __init cc_debugfs_global_init(void) > { > cc_debugfs_dir =3D debugfs_create_dir("ccree", NULL); > - > - return !cc_debugfs_dir; > } > > void __exit cc_debugfs_global_fini(void) > @@ -56,7 +54,6 @@ int cc_debugfs_init(struct cc_drvdata *drvdata) > struct device *dev =3D drvdata_to_dev(drvdata); > struct cc_debugfs_ctx *ctx; > struct debugfs_regset32 *regset; > - struct dentry *file; > > debug_regs[0].offset =3D drvdata->sig_offset; > debug_regs[1].offset =3D drvdata->ver_offset; > @@ -74,22 +71,9 @@ int cc_debugfs_init(struct cc_drvdata *drvdata) > regset->base =3D drvdata->cc_base; > > ctx->dir =3D debugfs_create_dir(drvdata->plat_dev->name, cc_debug= fs_dir); > - if (!ctx->dir) > - return -ENFILE; > - > - file =3D debugfs_create_regset32("regs", 0400, ctx->dir, regset); > - if (!file) { > - debugfs_remove(ctx->dir); > - return -ENFILE; > - } > > - file =3D debugfs_create_bool("coherent", 0400, ctx->dir, > - &drvdata->coherent); > - > - if (!file) { > - debugfs_remove_recursive(ctx->dir); > - return -ENFILE; > - } > + debugfs_create_regset32("regs", 0400, ctx->dir, regset); > + debugfs_create_bool("coherent", 0400, ctx->dir, &drvdata->coheren= t); > > drvdata->debugfs =3D ctx; > > diff --git a/drivers/crypto/ccree/cc_debugfs.h b/drivers/crypto/ccree/cc_= debugfs.h > index 5b5320eca7d2..01cbd9a95659 100644 > --- a/drivers/crypto/ccree/cc_debugfs.h > +++ b/drivers/crypto/ccree/cc_debugfs.h > @@ -5,7 +5,7 @@ > #define __CC_DEBUGFS_H__ > > #ifdef CONFIG_DEBUG_FS > -int cc_debugfs_global_init(void); > +void cc_debugfs_global_init(void); > void cc_debugfs_global_fini(void); > > int cc_debugfs_init(struct cc_drvdata *drvdata); > @@ -13,11 +13,7 @@ void cc_debugfs_fini(struct cc_drvdata *drvdata); > > #else > > -static inline int cc_debugfs_global_init(void) > -{ > - return 0; > -} > - > +static inline void cc_debugfs_global_init(void) {} > static inline void cc_debugfs_global_fini(void) {} > > static inline int cc_debugfs_init(struct cc_drvdata *drvdata) > diff --git a/drivers/crypto/ccree/cc_driver.c b/drivers/crypto/ccree/cc_d= river.c > index 8ada308d72ee..662738e53ced 100644 > --- a/drivers/crypto/ccree/cc_driver.c > +++ b/drivers/crypto/ccree/cc_driver.c > @@ -538,13 +538,8 @@ static struct platform_driver ccree_driver =3D { > > static int __init ccree_init(void) > { > - int ret; > - > cc_hash_global_init(); > - > - ret =3D cc_debugfs_global_init(); > - if (ret) > - return ret; > + cc_debugfs_global_init(); > > return platform_driver_register(&ccree_driver); > } > -- > 2.20.1 > --=20 Gilad Ben-Yossef Chief Coffee Drinker values of =CE=B2 will give rise to dom!