Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp172521pxj; Thu, 20 May 2021 07:00:40 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzkOQPDBV87rU6//bC1PzJe3wOGJVhPQhN/Alg8bXNVn1jNkJBiNKUmTJHC4Gv5+P8UzGLL X-Received: by 2002:a05:6e02:1348:: with SMTP id k8mr5354432ilr.104.1621519239979; Thu, 20 May 2021 07:00:39 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1621519239; cv=none; d=google.com; s=arc-20160816; b=J5VbE7LkXPMkbRTtWwnoUUXJA5DwWnmYbK398kAuco1CXf7py7fhlaKz/afJIcm7R6 22b5aAqD5GiiGHpnUVZFVLdyfvZ68lx6MlOTg6qpuvkCuUsXPJ5Cu9ZMbG6JFcyV2Kdh DQq3zmS5ApB9PmNV1J1INtafk3A1Y2l3Sl+CrHDCDzVRKIR5RoYd/z3OnkdVc5sMeibs sZmroaPPepG+5Ll1k/raGrHDrxhR3Zr2QdBsEiwdOU+HkMZeyn4wHXwKzEGZ3KLTipR8 NLpHk5geWmy3lATzpJfC2PJ8pj4Fm6SWE/xTddX2lWrQNNK9rYbW9ZfKgZjzr/RmS03C AgPA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:message-id:date:subject:cc:to:from; bh=JffPfiV35EPyIYybKQ2QQb1H659oKNXGn4MKhn4B1Tw=; b=rqIGf/+/dfS8IaV3r+/+qfKy2yQ5xZCbPizg/QUxaeuewLh3wmof8ZOwfCrGAvNPEi fJFXbwFE/7+FO2LvWTSd1VXbjwAYETgiwm7JY5KzZf6jyJjdYUwxKmcPg+GUh9suQPow 1SWEoiUzayrYWsioKNdqo2aqWX4K16OR9Tf2gLJOSSuvhMdELuNgqaH2v6VKhVUbudAB vOVaFJnWp7BlysVWPlLXB7eyw58anMJM54xvsbEyMMqx8iUEsNMybOwOjebF03YuH+My 2mCgaNuTRdcytlBtXQ/EvDV41QZTWjmFESBFxDGgGl5bRskjE/hK5w/OvL5BsBu25Drt 5Dog== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-crypto-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-crypto-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=huawei.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id n9si2122346jaj.15.2021.05.20.07.00.05; Thu, 20 May 2021 07:00:39 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-crypto-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-crypto-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-crypto-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=huawei.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238641AbhETOBO (ORCPT + 99 others); Thu, 20 May 2021 10:01:14 -0400 Received: from szxga06-in.huawei.com ([45.249.212.32]:3633 "EHLO szxga06-in.huawei.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S243483AbhETN7w (ORCPT ); Thu, 20 May 2021 09:59:52 -0400 Received: from dggems705-chm.china.huawei.com (unknown [172.30.72.60]) by szxga06-in.huawei.com (SkyGuard) with ESMTP id 4FmB911qMZzmWsr; Thu, 20 May 2021 21:56:05 +0800 (CST) Received: from dggema769-chm.china.huawei.com (10.1.198.211) by dggems705-chm.china.huawei.com (10.3.19.182) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256) id 15.1.2176.2; Thu, 20 May 2021 21:58:22 +0800 Received: from localhost (10.174.179.215) by dggema769-chm.china.huawei.com (10.1.198.211) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.2176.2; Thu, 20 May 2021 21:58:21 +0800 From: YueHaibing To: , , CC: , Subject: [PATCH -next] hwrng: core - Use DEVICE_ATTR_ macro Date: Thu, 20 May 2021 21:57:13 +0800 Message-ID: <20210520135713.32464-1-yuehaibing@huawei.com> X-Mailer: git-send-email 2.10.2.windows.1 MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [10.174.179.215] X-ClientProxiedBy: dggems701-chm.china.huawei.com (10.3.19.178) To dggema769-chm.china.huawei.com (10.1.198.211) X-CFilter-Loop: Reflected Precedence: bulk List-ID: X-Mailing-List: linux-crypto@vger.kernel.org Use DEVICE_ATTR_RW()/DEVICE_ATTR_RO() helper instead of plain DEVICE_ATTR, which makes the code a bit shorter and easier to read. Signed-off-by: YueHaibing --- drivers/char/hw_random/core.c | 36 +++++++++++++++-------------------- 1 file changed, 15 insertions(+), 21 deletions(-) diff --git a/drivers/char/hw_random/core.c b/drivers/char/hw_random/core.c index adb3c2bd7783..59beaf4d29bd 100644 --- a/drivers/char/hw_random/core.c +++ b/drivers/char/hw_random/core.c @@ -319,9 +319,9 @@ static int enable_best_rng(void) return ret; } -static ssize_t hwrng_attr_current_store(struct device *dev, - struct device_attribute *attr, - const char *buf, size_t len) +static ssize_t rng_current_store(struct device *dev, + struct device_attribute *attr, + const char *buf, size_t len) { int err = -ENODEV; struct hwrng *rng, *old_rng, *new_rng; @@ -354,9 +354,9 @@ static ssize_t hwrng_attr_current_store(struct device *dev, return err ? : len; } -static ssize_t hwrng_attr_current_show(struct device *dev, - struct device_attribute *attr, - char *buf) +static ssize_t rng_current_show(struct device *dev, + struct device_attribute *attr, + char *buf) { ssize_t ret; struct hwrng *rng; @@ -371,9 +371,9 @@ static ssize_t hwrng_attr_current_show(struct device *dev, return ret; } -static ssize_t hwrng_attr_available_show(struct device *dev, - struct device_attribute *attr, - char *buf) +static ssize_t rng_available_show(struct device *dev, + struct device_attribute *attr, + char *buf) { int err; struct hwrng *rng; @@ -392,22 +392,16 @@ static ssize_t hwrng_attr_available_show(struct device *dev, return strlen(buf); } -static ssize_t hwrng_attr_selected_show(struct device *dev, - struct device_attribute *attr, - char *buf) +static ssize_t rng_selected_show(struct device *dev, + struct device_attribute *attr, + char *buf) { return sysfs_emit(buf, "%d\n", cur_rng_set_by_user); } -static DEVICE_ATTR(rng_current, S_IRUGO | S_IWUSR, - hwrng_attr_current_show, - hwrng_attr_current_store); -static DEVICE_ATTR(rng_available, S_IRUGO, - hwrng_attr_available_show, - NULL); -static DEVICE_ATTR(rng_selected, S_IRUGO, - hwrng_attr_selected_show, - NULL); +static DEVICE_ATTR_RW(rng_current); +static DEVICE_ATTR_RO(rng_available); +static DEVICE_ATTR_RO(rng_selected); static struct attribute *rng_dev_attrs[] = { &dev_attr_rng_current.attr, -- 2.17.1