From patchwork Wed May 24 11:12:30 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mariusz Tkaczyk X-Patchwork-Id: 98448 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b0ea:0:b0:3b6:4342:cba0 with SMTP id b10csp2769002vqo; Wed, 24 May 2023 04:24:18 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ6SPDhgstnleQf/ZJG3bXDthagrywvFMmhjs0uXvD8s7PZBSfCkZmav84QnssVd+xPzCtns X-Received: by 2002:a17:902:d511:b0:1ab:7c4:eb24 with SMTP id b17-20020a170902d51100b001ab07c4eb24mr21926820plg.22.1684927457910; Wed, 24 May 2023 04:24:17 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1684927457; cv=none; d=google.com; s=arc-20160816; b=vga8pskR6Z2XKig44YBCfxndj/iU6E/3nKZC6Sppq4CSRJtCiduWGuhixfKPQHv0I7 YjlYz04IcSmMJJXSYdiSBASh7nwQE+kEoSxhutzgIQsd80Qxihp7WmUTtZrnxJP42V9B blOYsUeOFlVi2Feql3DMqhmIWMBwR4BaIm8PQBkPdCs9PZ16UI3o5IJifLj5FCRF6r2a P7iSdcu+uk/TqvMSdvY+VZd2V1dtPI/iGMZprCEpBDm0IOz7xDUnL+wLna8s92rJaoV0 gircy7bK/Ojl1h3N4nZb9Dslp2CNR2dpXnazg59VwK8k0UbOwrxhfXiLnoNTqphcM/6k T8Kg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=JtP9DzQHjz2ki6P4y7/gyS6YpVjjdcQi57zdq/mfU5g=; b=0D2qEm2rJboXT/Cit4Pio3AwRP3538GWv61nnEq7UCXdDa5MY5eSLArs0+RHMjHhpt PbQmQV9/MOlp1vWbTOpbM0HJpA9/QzPeKFpE/TMjhCHhAbeE4Tgh1cKAEVeZoEHPTP5W 8JngxaUvKUHaCQzJzwyLINpQWfokyxIartTMnj5uI5ydmm+LKSu4Mh4E5UTjX9C2/CWH 0yRD6u6A9VSOuXmCob0lvHFtSEwVMH7ydWJPxXgHhqvrd1/0XnUS9+y7C+9+wY3Jv8ki TupFPEbC8vD9/ktUL5gylm2ThKHbSiZf+tzVN+oaFvQaGQSbH5YVk/ttMFZBDNQzmVzM h2FQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=GT15OCMF; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id f19-20020a170902e99300b001a9b2c782ddsi1929734plb.176.2023.05.24.04.24.02; Wed, 24 May 2023 04:24:17 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=GT15OCMF; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234687AbjEXLNX (ORCPT + 99 others); Wed, 24 May 2023 07:13:23 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43026 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234703AbjEXLNW (ORCPT ); Wed, 24 May 2023 07:13:22 -0400 Received: from mga12.intel.com (mga12.intel.com [192.55.52.136]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C7D1D184 for ; Wed, 24 May 2023 04:13:20 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1684926800; x=1716462800; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=KPu+Z5pRjn3fh7neqH+is0rz0f3wQ9W+ZJzp1UiPaJs=; b=GT15OCMFxe3r6Wso4RRbRxIkPpVSq3fwkrZsioGTTNjxOIFxLy2HLGeg kTpEApZsxEi/Uk19ANymI8UOvLFn594b8KN9CjNCw2gn9MFQiwPFgqQhx byB8IBmHr+VbGE1/RtHcQl0kHoY9k+yft5ABvq9gbSxqel/k2GbhHUbqY DTPUGciEeROKhDJe8x5+npMizRQugmEBM9ufqP1bnYvlp4XqQ5LAuE2GS S/e/jEfjnN6cyiRv32wZ+J0c/t34u6cY6LGbHNdp8PJo9Sw7aiGQjzFgd AVCdmi9Qm9FgoMV6CEZiDhF54f0ph+122gavplU12nup61b4HkenUnOLb g==; X-IronPort-AV: E=McAfee;i="6600,9927,10719"; a="333156291" X-IronPort-AV: E=Sophos;i="6.00,189,1681196400"; d="scan'208";a="333156291" Received: from orsmga005.jf.intel.com ([10.7.209.41]) by fmsmga106.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 24 May 2023 04:13:00 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10719"; a="878621192" X-IronPort-AV: E=Sophos;i="6.00,189,1681196400"; d="scan'208";a="878621192" Received: from mtkaczyk-devel.igk.intel.com ([10.102.105.40]) by orsmga005-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 24 May 2023 04:12:59 -0700 From: Mariusz Tkaczyk To: arnd@arndb.de Cc: andriy.shevchenko@intel.com, linux-kernel@vger.kernel.org, dan.j.williams@intel.com Subject: [PATCH v2 1/2] misc: enclosure: remove get_active callback Date: Wed, 24 May 2023 13:12:30 +0200 Message-Id: <20230524111231.14506-2-mariusz.tkaczyk@linux.intel.com> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20230524111231.14506-1-mariusz.tkaczyk@linux.intel.com> References: <20230524111231.14506-1-mariusz.tkaczyk@linux.intel.com> MIME-Version: 1.0 X-Spam-Status: No, score=-4.3 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_EF,RCVD_IN_DNSWL_MED,SPF_HELO_PASS, SPF_NONE,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1766774494304938938?= X-GMAIL-MSGID: =?utf-8?q?1766774494304938938?= The callback is not used, remove it. Leave possibility to read cached ecomp->active value. Reviewed-by: Dan Williams Signed-off-by: Mariusz Tkaczyk --- drivers/misc/enclosure.c | 4 +--- include/linux/enclosure.h | 2 -- 2 files changed, 1 insertion(+), 5 deletions(-) diff --git a/drivers/misc/enclosure.c b/drivers/misc/enclosure.c index 1b010d9267c9..59704fdb962a 100644 --- a/drivers/misc/enclosure.c +++ b/drivers/misc/enclosure.c @@ -534,11 +534,9 @@ static ssize_t set_component_status(struct device *cdev, 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); + /* The value of ecomp->active may have been updated by edev->cb->set_active(). */ return sysfs_emit(buf, "%d\n", ecomp->active); } 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 Wed May 24 11:12:31 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mariusz Tkaczyk X-Patchwork-Id: 98452 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b0ea:0:b0:3b6:4342:cba0 with SMTP id b10csp2781024vqo; Wed, 24 May 2023 04:46:08 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ5ODtk9R5O168ZV7m2+Ph3HTTOZwwk73MqEiyjwHox6SQ7HHLL6Cm5U90cqI5LHAdZu/69I X-Received: by 2002:a05:6a21:339b:b0:10c:67c9:e5ea with SMTP id yy27-20020a056a21339b00b0010c67c9e5eamr6282057pzb.31.1684928768278; Wed, 24 May 2023 04:46:08 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1684928768; cv=none; d=google.com; s=arc-20160816; b=aoG5TwvMQt5z0xyHGE1OMEjVedPQNPfqXJolQkl1R0J24jNmw1/24VUfMeR+nvfkoG zvh3hy9KBrGCFQnN0BZTVm0qhHDVK5mQZ34Xky9FfLVGl8AET1bq6+aae5Q1gAHHfJ22 gpkJd+p/74dAAULiWJ+BDqrybROHJyinv//oLbfoyZYfDXFHk8gGt2sPSYYAH+DvnEOA VqMQBBGuUW8jpbCDdP6VJ/2gNvZR9TuP43PazJGw8+Ukylc0tSKKlinYjDE9vhXkJEpv AG16rbEu+mXMZ1dLbNH4wrQlh4qV9KB/kaLbbtmRhw7A/Vt/GCnELmd1bZB+cUydTQ8h aglQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=4jwSUjIllPvbhH142QglRSxsDzk0XT2tlceMKlCenX0=; b=x46mUEJpI1NgvfRtkDGJ6ZoyuhHTC9nHY4jyehX92w+OMQquq68QNq35cmPXZrKWYH BhGkgu81lPPClOEbTSvt6+ww59mfJ0z6t46KP87fdMKGOcBT3PEkl1cJ2en97ZZchmXf KyNGiokSmQXrssaTSGehz3/BUPmII3QJI1p/+pZ5H7al5CIvhBbZ/hi/Ruazz7NjMY0n ej70xMM0uhydxS5klCrBi+w+iy3HlVWPRt6d8EwLU9lYNj2UxxMMVZVo9Ns7z1I4LZZA P6F52XgEnDNsEr0ZBQsowoAZmG6prqQ6MiEdlC1YwEw2tpoBMG78j2wDaVVWMhERCSee vlmg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=UMZNN7jD; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id v5-20020a626105000000b0063d61f05a8fsi8176859pfb.198.2023.05.24.04.45.53; Wed, 24 May 2023 04:46:08 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=UMZNN7jD; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234703AbjEXLNa (ORCPT + 99 others); Wed, 24 May 2023 07:13:30 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43104 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234720AbjEXLN3 (ORCPT ); Wed, 24 May 2023 07:13:29 -0400 Received: from mga12.intel.com (mga12.intel.com [192.55.52.136]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B9133139 for ; Wed, 24 May 2023 04:13:26 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1684926806; x=1716462806; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=3AV3Yx4AGK3x6utTSXAG8DPnytjUXdcCkaS3PI2AvfY=; b=UMZNN7jDLxEtJlN5PEXXaHO4+Z7rYbIBgDs+a5dN0RQsIIgBMMksXtl2 nEbo4YOTSErsdWFrl8AKG+lhavLWbUXgpL8nY3xIfFmW2ABaoDT56c9sm Brq4FZJ0HcxTjLS/q4y8yPNQLdWvw8+TQp8zl57vV5IPlhVJoV6cY2OQG aMY3Zgx+mwlC/R8HwiNXDRQnkaq0JBoEVRCg13+lzVnVT6TxaUTIF3OFM aAe+Bj04gRLHSmpKHwehILblvDUlt84AVyjOUCd9Jd1tGQeflW+ussK3t E6/MlVhLxP8F1sCBVhjtk9ViOH8177iQqvopXStuHnnjZyIHC4BlxNaho g==; X-IronPort-AV: E=McAfee;i="6600,9927,10719"; a="333156326" X-IronPort-AV: E=Sophos;i="6.00,189,1681196400"; d="scan'208";a="333156326" Received: from orsmga005.jf.intel.com ([10.7.209.41]) by fmsmga106.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 24 May 2023 04:13:06 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10719"; a="878621310" X-IronPort-AV: E=Sophos;i="6.00,189,1681196400"; d="scan'208";a="878621310" Received: from mtkaczyk-devel.igk.intel.com ([10.102.105.40]) by orsmga005-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 24 May 2023 04:13:02 -0700 From: Mariusz Tkaczyk To: arnd@arndb.de Cc: andriy.shevchenko@intel.com, linux-kernel@vger.kernel.org, dan.j.williams@intel.com Subject: [PATCH v2 2/2] misc: enclosure: update sysfs api Date: Wed, 24 May 2023 13:12:31 +0200 Message-Id: <20230524111231.14506-3-mariusz.tkaczyk@linux.intel.com> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20230524111231.14506-1-mariusz.tkaczyk@linux.intel.com> References: <20230524111231.14506-1-mariusz.tkaczyk@linux.intel.com> MIME-Version: 1.0 X-Spam-Status: No, score=-4.3 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_EF,RCVD_IN_DNSWL_MED,SPF_HELO_PASS, SPF_NONE,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1766775868080353877?= X-GMAIL-MSGID: =?utf-8?q?1766775868080353877?= Use DEVICE_ATTR RW and RO macros. Update function names accordingly. No functional changes intended. Reviewed-by: Dan Williams Signed-off-by: Mariusz Tkaczyk Reviewed-by: Christoph Hellwig --- drivers/misc/enclosure.c | 80 +++++++++++++++++++--------------------- 1 file changed, 38 insertions(+), 42 deletions(-) diff --git a/drivers/misc/enclosure.c b/drivers/misc/enclosure.c index 59704fdb962a..95d70840a88a 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); @@ -484,9 +484,8 @@ static ssize_t get_component_fault(struct device *cdev, return sysfs_emit(buf, "%d\n", ecomp->fault); } -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); @@ -497,8 +496,10 @@ 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 DEVICE_ATTR_RW(fault); + +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); @@ -508,9 +509,8 @@ static ssize_t get_component_status(struct device *cdev, return sysfs_emit(buf, "%s\n", enclosure_status[ecomp->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); @@ -531,8 +531,10 @@ 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) +static DEVICE_ATTR_RW(status); + +static ssize_t active_show(struct device *cdev, struct device_attribute *attr, + char *buf) { struct enclosure_component *ecomp = to_enclosure_component(cdev); @@ -540,9 +542,8 @@ static ssize_t get_component_active(struct device *cdev, 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) +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); @@ -553,8 +554,10 @@ 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 DEVICE_ATTR_RW(active); + +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); @@ -564,9 +567,8 @@ static ssize_t get_component_locate(struct device *cdev, return sysfs_emit(buf, "%d\n", ecomp->locate); } -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); @@ -577,9 +579,10 @@ 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 DEVICE_ATTR_RW(locate); + +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); @@ -594,9 +597,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); @@ -616,16 +619,20 @@ 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 DEVICE_ATTR_RW(power_status); + +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 DEVICE_ATTR_RO(type); + +static ssize_t slot_show(struct device *cdev, struct device_attribute *attr, + char *buf) { struct enclosure_component *ecomp = to_enclosure_component(cdev); int slot; @@ -639,18 +646,7 @@ 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_IRUGO | S_IWUSR, get_component_active, - 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_RO(slot); static struct attribute *enclosure_component_attrs[] = { &dev_attr_fault.attr,