From patchwork Thu Nov 17 16:34:05 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mariusz Tkaczyk X-Patchwork-Id: 13047092 X-Patchwork-Delegate: bhelgaas@google.com Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id B60FDC433FE for ; Thu, 17 Nov 2022 16:35:52 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239529AbiKQQft (ORCPT ); Thu, 17 Nov 2022 11:35:49 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44110 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239737AbiKQQfW (ORCPT ); Thu, 17 Nov 2022 11:35:22 -0500 Received: from mga18.intel.com (mga18.intel.com [134.134.136.126]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 697D845EC3 for ; Thu, 17 Nov 2022 08:34:45 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1668702885; x=1700238885; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=nxFB8NR1SbMSv18c/1yFzRM4z8Qq4CPBOZO4kFUnQrM=; b=VWWLaUPeiZWeCHq9xZSjZy0KgUNEntrIVMU6SiAxapfvci7pd4w5VsM2 PYJ4HsLvjc7e8hQJtolOrfz/Kso5yH63DFz5sl8vK8dVUwrzXqZSyFMVL wzoHOHjEFVVMzvhWWutYk6g2MCFWNIAyZFPUt6yi7nek8DFi5qZ9+4QLm +Js9wm/w+pUXc91iLMttvW9oUw0O89SD+uisbI/9DU+2X5jrRuNUSzdA0 rNY3Pmwvdp+J28va2KR80bSqKHeAiHaqJk5A9grDgPUXpY01PbRNp7NBb spr+Fjo4xuZVenkMRxS3DTvCSxNRYwagoC5jDvQoZU9vTTShcvfGSALJc A==; X-IronPort-AV: E=McAfee;i="6500,9779,10534"; a="296262865" X-IronPort-AV: E=Sophos;i="5.96,171,1665471600"; d="scan'208";a="296262865" Received: from fmsmga007.fm.intel.com ([10.253.24.52]) by orsmga106.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 17 Nov 2022 08:34:45 -0800 X-IronPort-AV: E=McAfee;i="6500,9779,10534"; a="642155452" X-IronPort-AV: E=Sophos;i="5.96,171,1665471600"; d="scan'208";a="642155452" Received: from mtkaczyk-devel.elements.local ([10.102.105.40]) by fmsmga007-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 17 Nov 2022 08:34:43 -0800 From: Mariusz Tkaczyk To: helgaas@kernel.org Cc: linux-pci@vger.kernel.org, stuart.w.hayes@gmail.com, dan.j.williams@intel.com Subject: [PATCH 1/3] misc: enclosure: remove get_active() callback Date: Thu, 17 Nov 2022 17:34:05 +0100 Message-Id: <20221117163407.28472-2-mariusz.tkaczyk@linux.intel.com> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20221117163407.28472-1-mariusz.tkaczyk@linux.intel.com> References: <20221117163407.28472-1-mariusz.tkaczyk@linux.intel.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-pci@vger.kernel.org The callback is not used, remove it. Signed-off-by: Mariusz Tkaczyk --- drivers/misc/enclosure.c | 14 +------------- include/linux/enclosure.h | 2 -- 2 files changed, 1 insertion(+), 15 deletions(-) diff --git a/drivers/misc/enclosure.c b/drivers/misc/enclosure.c index 1b010d9267c9..fd0707a8ed79 100644 --- a/drivers/misc/enclosure.c +++ b/drivers/misc/enclosure.c @@ -531,17 +531,6 @@ static ssize_t set_component_status(struct device *cdev, return -EINVAL; } -static ssize_t get_component_active(struct device *cdev, - struct device_attribute *attr, char *buf) -{ - struct enclosure_device *edev = to_enclosure_device(cdev->parent); - struct enclosure_component *ecomp = to_enclosure_component(cdev); - - if (edev->cb->get_active) - edev->cb->get_active(edev, ecomp); - return sysfs_emit(buf, "%d\n", ecomp->active); -} - static ssize_t set_component_active(struct device *cdev, struct device_attribute *attr, const char *buf, size_t count) @@ -645,8 +634,7 @@ static DEVICE_ATTR(fault, S_IRUGO | S_IWUSR, get_component_fault, set_component_fault); static DEVICE_ATTR(status, S_IRUGO | S_IWUSR, get_component_status, set_component_status); -static DEVICE_ATTR(active, S_IRUGO | S_IWUSR, get_component_active, - set_component_active); +static DEVICE_ATTR(active, S_IWUSR, NULL, set_component_active); static DEVICE_ATTR(locate, S_IRUGO | S_IWUSR, get_component_locate, set_component_locate); static DEVICE_ATTR(power_status, S_IRUGO | S_IWUSR, get_component_power_status, diff --git a/include/linux/enclosure.h b/include/linux/enclosure.h index 1c630e2c2756..8d09c6d07bf1 100644 --- a/include/linux/enclosure.h +++ b/include/linux/enclosure.h @@ -62,8 +62,6 @@ struct enclosure_component_callbacks { int (*set_fault)(struct enclosure_device *, struct enclosure_component *, enum enclosure_component_setting); - void (*get_active)(struct enclosure_device *, - struct enclosure_component *); int (*set_active)(struct enclosure_device *, struct enclosure_component *, enum enclosure_component_setting); From patchwork Thu Nov 17 16:34:06 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mariusz Tkaczyk X-Patchwork-Id: 13047093 X-Patchwork-Delegate: bhelgaas@google.com Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 02438C4332F for ; Thu, 17 Nov 2022 16:35:53 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239737AbiKQQfu (ORCPT ); Thu, 17 Nov 2022 11:35:50 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44116 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239887AbiKQQfX (ORCPT ); Thu, 17 Nov 2022 11:35:23 -0500 Received: from mga18.intel.com (mga18.intel.com [134.134.136.126]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id EB8494C25E for ; Thu, 17 Nov 2022 08:34:47 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1668702887; x=1700238887; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=7ZW/balMI+mVUTIrlzO33ETJ/M3NM4PfnG6G+4/JZ3w=; b=mGWrjxEdgUZXf3SuWqUQQ/1yNGmNeLK8nTWdWH/044ZFYNMk7k+JMBbM 5GMCjsXLNTZQTHFGhBKRPnnkpTS6G7DxvK5Yyv8Ik1APw3YcfSJUJIy9j derdNbJYBhQ44x657yQAVL3d4AiIbezzzX3V5Gtv7VGsKEktXUBYJ2frH pLXEc/5QQ6XJINUIIGaeWPHBdOfuJRilP17bwB7xoNaOfwCJ5JcQtSVK9 izSPKRLiJ2MauIfha+QALXP2+rGJEAN8W3rvCUlBXQa08Q05RkFLwwjoj sRIby0Gus8eMUD8C+Nf1LOemtegynGw5vVUBQv5fnTEks2/zM0ei8ForE g==; X-IronPort-AV: E=McAfee;i="6500,9779,10534"; a="296262878" X-IronPort-AV: E=Sophos;i="5.96,171,1665471600"; d="scan'208";a="296262878" Received: from fmsmga007.fm.intel.com ([10.253.24.52]) by orsmga106.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 17 Nov 2022 08:34:47 -0800 X-IronPort-AV: E=McAfee;i="6500,9779,10534"; a="642155487" X-IronPort-AV: E=Sophos;i="5.96,171,1665471600"; d="scan'208";a="642155487" Received: from mtkaczyk-devel.elements.local ([10.102.105.40]) by fmsmga007-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 17 Nov 2022 08:34:46 -0800 From: Mariusz Tkaczyk To: helgaas@kernel.org Cc: linux-pci@vger.kernel.org, stuart.w.hayes@gmail.com, dan.j.williams@intel.com Subject: [PATCH 2/3] misc: enclosure, ses: simplify some get callbacks Date: Thu, 17 Nov 2022 17:34:06 +0100 Message-Id: <20221117163407.28472-3-mariusz.tkaczyk@linux.intel.com> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20221117163407.28472-1-mariusz.tkaczyk@linux.intel.com> References: <20221117163407.28472-1-mariusz.tkaczyk@linux.intel.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-pci@vger.kernel.org Remove active, status, fault and locate variables from enclosure_component struct. Return then directly. No functional changes intended. Signed-off-by: Mariusz Tkaczyk --- drivers/misc/enclosure.c | 15 +++++++++------ drivers/scsi/ses.c | 33 ++++++++++++++++++--------------- include/linux/enclosure.h | 12 ++++-------- 3 files changed, 31 insertions(+), 29 deletions(-) diff --git a/drivers/misc/enclosure.c b/drivers/misc/enclosure.c index fd0707a8ed79..00f50fd0cc85 100644 --- a/drivers/misc/enclosure.c +++ b/drivers/misc/enclosure.c @@ -478,10 +478,11 @@ static ssize_t get_component_fault(struct device *cdev, { struct enclosure_device *edev = to_enclosure_device(cdev->parent); struct enclosure_component *ecomp = to_enclosure_component(cdev); + int status = 0; if (edev->cb->get_fault) - edev->cb->get_fault(edev, ecomp); - return sysfs_emit(buf, "%d\n", ecomp->fault); + status = edev->cb->get_fault(edev, ecomp); + return sysfs_emit(buf, "%d\n", status); } static ssize_t set_component_fault(struct device *cdev, @@ -502,10 +503,11 @@ static ssize_t get_component_status(struct device *cdev, { struct enclosure_device *edev = to_enclosure_device(cdev->parent); struct enclosure_component *ecomp = to_enclosure_component(cdev); + enum enclosure_status status = 0; if (edev->cb->get_status) - edev->cb->get_status(edev, ecomp); - return sysfs_emit(buf, "%s\n", enclosure_status[ecomp->status]); + status = edev->cb->get_status(edev, ecomp); + return sysfs_emit(buf, "%s\n", enclosure_status[status]); } static ssize_t set_component_status(struct device *cdev, @@ -549,10 +551,11 @@ static ssize_t get_component_locate(struct device *cdev, { struct enclosure_device *edev = to_enclosure_device(cdev->parent); struct enclosure_component *ecomp = to_enclosure_component(cdev); + int status = 0; if (edev->cb->get_locate) - edev->cb->get_locate(edev, ecomp); - return sysfs_emit(buf, "%d\n", ecomp->locate); + status = edev->cb->get_locate(edev, ecomp); + return sysfs_emit(buf, "%d\n", status); } static ssize_t set_component_locate(struct device *cdev, diff --git a/drivers/scsi/ses.c b/drivers/scsi/ses.c index 0a1734f34587..901dc94e5aeb 100644 --- a/drivers/scsi/ses.c +++ b/drivers/scsi/ses.c @@ -209,13 +209,14 @@ static void ses_get_fault(struct enclosure_device *edev, { unsigned char *desc; - if (!ses_page2_supported(edev)) { - ecomp->fault = 0; - return; - } + if (!ses_page2_supported(edev)) + return 0; + desc = ses_get_page2_descriptor(edev, ecomp); if (desc) - ecomp->fault = (desc[3] & 0x60) >> 4; + return (desc[3] & 0x60) >> 4; + + return 0; } static int ses_set_fault(struct enclosure_device *edev, @@ -255,13 +256,14 @@ static void ses_get_status(struct enclosure_device *edev, { unsigned char *desc; - if (!ses_page2_supported(edev)) { - ecomp->status = 0; - return; - } + if (!ses_page2_supported(edev)) + return 0; + desc = ses_get_page2_descriptor(edev, ecomp); if (desc) - ecomp->status = (desc[0] & 0x0f); + return (desc[0] & 0x0f); + + return 0; } static void ses_get_locate(struct enclosure_device *edev, @@ -269,13 +271,14 @@ static void ses_get_locate(struct enclosure_device *edev, { unsigned char *desc; - if (!ses_page2_supported(edev)) { - ecomp->locate = 0; - return; - } + if (!ses_page2_supported(edev)) + return 0; + desc = ses_get_page2_descriptor(edev, ecomp); if (desc) - ecomp->locate = (desc[2] & 0x02) ? 1 : 0; + return (desc[2] & 0x02) ? 1 : 0; + + return 0; } static int ses_set_locate(struct enclosure_device *edev, diff --git a/include/linux/enclosure.h b/include/linux/enclosure.h index 8d09c6d07bf1..b70e9deef3bc 100644 --- a/include/linux/enclosure.h +++ b/include/linux/enclosure.h @@ -52,12 +52,12 @@ enum enclosure_component_setting { struct enclosure_device; struct enclosure_component; struct enclosure_component_callbacks { - void (*get_status)(struct enclosure_device *, + int (*get_status)(struct enclosure_device *, struct enclosure_component *); int (*set_status)(struct enclosure_device *, struct enclosure_component *, enum enclosure_status); - void (*get_fault)(struct enclosure_device *, + int (*get_fault)(struct enclosure_device *, struct enclosure_component *); int (*set_fault)(struct enclosure_device *, struct enclosure_component *, @@ -65,8 +65,8 @@ struct enclosure_component_callbacks { int (*set_active)(struct enclosure_device *, struct enclosure_component *, enum enclosure_component_setting); - void (*get_locate)(struct enclosure_device *, - struct enclosure_component *); + int (*get_locate)(struct enclosure_device *, + struct enclosure_component *); int (*set_locate)(struct enclosure_device *, struct enclosure_component *, enum enclosure_component_setting); @@ -85,11 +85,7 @@ struct enclosure_component { struct device *dev; enum enclosure_component_type type; int number; - int fault; - int active; - int locate; int slot; - enum enclosure_status status; int power_status; }; From patchwork Thu Nov 17 16:34:07 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mariusz Tkaczyk X-Patchwork-Id: 13047094 X-Patchwork-Delegate: bhelgaas@google.com Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id CC94CC433FE for ; Thu, 17 Nov 2022 16:36:38 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S240675AbiKQQgh (ORCPT ); Thu, 17 Nov 2022 11:36:37 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44100 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S240673AbiKQQgQ (ORCPT ); Thu, 17 Nov 2022 11:36:16 -0500 Received: from mga01.intel.com (mga01.intel.com [192.55.52.88]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id DC96870A30 for ; Thu, 17 Nov 2022 08:35:21 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1668702921; x=1700238921; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=HMXxpVugC093Ie4OcNbXaYdZIP1EZQJ+FUItgCxhVIM=; b=QlhU+bhFXZtRaoGsDjnpVMhq5CDpwjcUIhczsZSRtvqyprPWd3OL6uvz 7LfRDj2EJLu4Fucme32D3FHD/V+qgejWDIIo3tvqn+iGHor9HGvwehxrO UTth7Vr7+UuEDx7LCHnM6alxWs4OrHNf6Y4LIfQisD3vF5kky8NUtIPup L1ZXqGIAT4ZbilxnZ57KegwiDxbJm4pEfRQEsGd9SfUdEEP/zReMueVEa c6AIhkN3c8adD0Zr18GNg56wITeA7vNrzMORDIGrTi2WlGTlzktQIVBwA 6bs+EaNZIeZPIyL8TrXlhBdTE1OXUgqOtNi4ksZNwc9dYwz/4QT6doY44 g==; X-IronPort-AV: E=McAfee;i="6500,9779,10534"; a="339731351" X-IronPort-AV: E=Sophos;i="5.96,171,1665471600"; d="scan'208";a="339731351" Received: from fmsmga007.fm.intel.com ([10.253.24.52]) by fmsmga101.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 17 Nov 2022 08:34:49 -0800 X-IronPort-AV: E=McAfee;i="6500,9779,10534"; a="642155517" X-IronPort-AV: E=Sophos;i="5.96,171,1665471600"; d="scan'208";a="642155517" Received: from mtkaczyk-devel.elements.local ([10.102.105.40]) by fmsmga007-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 17 Nov 2022 08:34:48 -0800 From: Mariusz Tkaczyk To: helgaas@kernel.org Cc: linux-pci@vger.kernel.org, stuart.w.hayes@gmail.com, dan.j.williams@intel.com Subject: [PATCH 3/3] misc: enclosure: update sysfs api Date: Thu, 17 Nov 2022 17:34:07 +0100 Message-Id: <20221117163407.28472-4-mariusz.tkaczyk@linux.intel.com> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20221117163407.28472-1-mariusz.tkaczyk@linux.intel.com> References: <20221117163407.28472-1-mariusz.tkaczyk@linux.intel.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-pci@vger.kernel.org Use DEVICE_ATTR RW, RO and WO macros. Update function names accordingly. No functional changes intended. Signed-off-by: Mariusz Tkaczyk --- drivers/misc/enclosure.c | 69 +++++++++++++++++----------------------- 1 file changed, 30 insertions(+), 39 deletions(-) diff --git a/drivers/misc/enclosure.c b/drivers/misc/enclosure.c index 00f50fd0cc85..ab2fd918ecf6 100644 --- a/drivers/misc/enclosure.c +++ b/drivers/misc/enclosure.c @@ -473,8 +473,8 @@ static const char *const enclosure_type[] = { [ENCLOSURE_COMPONENT_ARRAY_DEVICE] = "array device", }; -static ssize_t get_component_fault(struct device *cdev, - struct device_attribute *attr, char *buf) +static ssize_t fault_show(struct device *cdev, struct device_attribute *attr, + char *buf) { struct enclosure_device *edev = to_enclosure_device(cdev->parent); struct enclosure_component *ecomp = to_enclosure_component(cdev); @@ -485,9 +485,8 @@ static ssize_t get_component_fault(struct device *cdev, return sysfs_emit(buf, "%d\n", status); } -static ssize_t set_component_fault(struct device *cdev, - struct device_attribute *attr, - const char *buf, size_t count) +static ssize_t fault_store(struct device *cdev, struct device_attribute *attr, + const char *buf, size_t count) { struct enclosure_device *edev = to_enclosure_device(cdev->parent); struct enclosure_component *ecomp = to_enclosure_component(cdev); @@ -498,8 +497,8 @@ static ssize_t set_component_fault(struct device *cdev, return count; } -static ssize_t get_component_status(struct device *cdev, - struct device_attribute *attr,char *buf) +static ssize_t status_show(struct device *cdev, struct device_attribute *attr, + char *buf) { struct enclosure_device *edev = to_enclosure_device(cdev->parent); struct enclosure_component *ecomp = to_enclosure_component(cdev); @@ -510,9 +509,8 @@ static ssize_t get_component_status(struct device *cdev, return sysfs_emit(buf, "%s\n", enclosure_status[status]); } -static ssize_t set_component_status(struct device *cdev, - struct device_attribute *attr, - const char *buf, size_t count) +static ssize_t status_store(struct device *cdev, struct device_attribute *attr, + const char *buf, size_t count) { struct enclosure_device *edev = to_enclosure_device(cdev->parent); struct enclosure_component *ecomp = to_enclosure_component(cdev); @@ -533,9 +531,8 @@ static ssize_t set_component_status(struct device *cdev, return -EINVAL; } -static ssize_t set_component_active(struct device *cdev, - struct device_attribute *attr, - const char *buf, size_t count) +static ssize_t active_store(struct device *cdev, struct device_attribute *attr, + const char *buf, size_t count) { struct enclosure_device *edev = to_enclosure_device(cdev->parent); struct enclosure_component *ecomp = to_enclosure_component(cdev); @@ -546,8 +543,8 @@ static ssize_t set_component_active(struct device *cdev, return count; } -static ssize_t get_component_locate(struct device *cdev, - struct device_attribute *attr, char *buf) +static ssize_t locate_show(struct device *cdev, struct device_attribute *attr, + char *buf) { struct enclosure_device *edev = to_enclosure_device(cdev->parent); struct enclosure_component *ecomp = to_enclosure_component(cdev); @@ -558,9 +555,8 @@ static ssize_t get_component_locate(struct device *cdev, return sysfs_emit(buf, "%d\n", status); } -static ssize_t set_component_locate(struct device *cdev, - struct device_attribute *attr, - const char *buf, size_t count) +static ssize_t locate_store(struct device *cdev, struct device_attribute *attr, + const char *buf, size_t count) { struct enclosure_device *edev = to_enclosure_device(cdev->parent); struct enclosure_component *ecomp = to_enclosure_component(cdev); @@ -571,9 +567,8 @@ static ssize_t set_component_locate(struct device *cdev, return count; } -static ssize_t get_component_power_status(struct device *cdev, - struct device_attribute *attr, - char *buf) +static ssize_t power_status_show(struct device *cdev, + struct device_attribute *attr, char *buf) { struct enclosure_device *edev = to_enclosure_device(cdev->parent); struct enclosure_component *ecomp = to_enclosure_component(cdev); @@ -588,9 +583,9 @@ static ssize_t get_component_power_status(struct device *cdev, return sysfs_emit(buf, "%s\n", ecomp->power_status ? "on" : "off"); } -static ssize_t set_component_power_status(struct device *cdev, - struct device_attribute *attr, - const char *buf, size_t count) +static ssize_t power_status_store(struct device *cdev, + struct device_attribute *attr, + const char *buf, size_t count) { struct enclosure_device *edev = to_enclosure_device(cdev->parent); struct enclosure_component *ecomp = to_enclosure_component(cdev); @@ -610,16 +605,16 @@ static ssize_t set_component_power_status(struct device *cdev, return count; } -static ssize_t get_component_type(struct device *cdev, - struct device_attribute *attr, char *buf) +static ssize_t type_show(struct device *cdev, + struct device_attribute *attr, char *buf) { struct enclosure_component *ecomp = to_enclosure_component(cdev); return sysfs_emit(buf, "%s\n", enclosure_type[ecomp->type]); } -static ssize_t get_component_slot(struct device *cdev, - struct device_attribute *attr, char *buf) +static ssize_t slot_show(struct device *cdev, + struct device_attribute *attr, char *buf) { struct enclosure_component *ecomp = to_enclosure_component(cdev); int slot; @@ -633,17 +628,13 @@ static ssize_t get_component_slot(struct device *cdev, return sysfs_emit(buf, "%d\n", slot); } -static DEVICE_ATTR(fault, S_IRUGO | S_IWUSR, get_component_fault, - set_component_fault); -static DEVICE_ATTR(status, S_IRUGO | S_IWUSR, get_component_status, - set_component_status); -static DEVICE_ATTR(active, S_IWUSR, NULL, set_component_active); -static DEVICE_ATTR(locate, S_IRUGO | S_IWUSR, get_component_locate, - set_component_locate); -static DEVICE_ATTR(power_status, S_IRUGO | S_IWUSR, get_component_power_status, - set_component_power_status); -static DEVICE_ATTR(type, S_IRUGO, get_component_type, NULL); -static DEVICE_ATTR(slot, S_IRUGO, get_component_slot, NULL); +static DEVICE_ATTR_RW(fault); +static DEVICE_ATTR_RW(status); +static DEVICE_ATTR_WO(active); +static DEVICE_ATTR_RW(locate); +static DEVICE_ATTR_RW(power_status); +static DEVICE_ATTR_RO(type); +static DEVICE_ATTR_RO(slot); static struct attribute *enclosure_component_attrs[] = { &dev_attr_fault.attr,