Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp2448204pxj; Sun, 23 May 2021 00:15:26 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyr7zsaHiPnovn5ErOAbPJrC+V4Y4sxozqfGhbM76+/KTrakHiCygd/heh8xSrwIJyjX50n X-Received: by 2002:a05:6402:27c6:: with SMTP id c6mr19658756ede.200.1621754126192; Sun, 23 May 2021 00:15:26 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1621754126; cv=none; d=google.com; s=arc-20160816; b=qyxXNq42NROmhVKGCvvCPZDlPjUVQHqKqmhXL8GHESO5SPzdHJDXUJl5eSP/yc+zJH QsauOO0owWan7RwZLcHpmIQIk/qg5NnGCk6M2/DMFAaiU6KJRtoTj9gRxHQwnht2PvDX wTnbGOr24qpGwtlowrgUIVmBlUKv23Eis6YNuCmkydBdt5p4yWVrztsDmVscLIf4uOkq uDL+NO+W4kyExupy1k0vWsHueYdafNkyQXZPrs5aqNEqEfOL35zfs06jtauO1wx4hTmB 0wpetR7LE7oLV0PaTpht7rlA9RhN8csDi9vXHBPCZUY4Pgx4eBHDDDhFz/zcUwbNsT7y pejQ== 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=i+/uoQUK4YAC4zl0dg0tOFs7tTYEEUcWZ0SvKXfKUPE=; b=c8ClpOFYuPZ00Sr3nxnj5T/vZAEh7d1aEMiQOIyf+7pQnHxSrXyVD8AhtiPcY8T24w 6jeUuTVBRdYIvuQN6JuVZxeYU35ym1uosdZ6nLxXAYybmmP19XLV4lvFJ13LnICaVDWm 5MhwLQn3CgM5ygnxEw3DHS+VnxQjw0VzgcOOmdWuI9u01feamB4bXpWQlyZAVIV54/46 Ia5ANgs25bMQrNP1/pe0ez7aiQwKuUAeM6Ffn2MCCsBFS3jncdcHxi+AnlnK8Clmtf+R nj3xcrvM8kfs9EjquqyBhUN+PACgHZL6D9diExwx1NWB1S47NO7DQLY9ZQPBD4ui94uw vxjg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-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 p24si7989660edr.329.2021.05.23.00.15.02; Sun, 23 May 2021 00:15:26 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-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-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-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 S231620AbhEWHMw (ORCPT + 99 others); Sun, 23 May 2021 03:12:52 -0400 Received: from szxga06-in.huawei.com ([45.249.212.32]:3659 "EHLO szxga06-in.huawei.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231559AbhEWHMv (ORCPT ); Sun, 23 May 2021 03:12:51 -0400 Received: from dggems701-chm.china.huawei.com (unknown [172.30.72.59]) by szxga06-in.huawei.com (SkyGuard) with ESMTP id 4Fns014hV2zmXf4; Sun, 23 May 2021 15:09:05 +0800 (CST) Received: from dggema769-chm.china.huawei.com (10.1.198.211) by dggems701-chm.china.huawei.com (10.3.19.178) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256) id 15.1.2176.2; Sun, 23 May 2021 15:11:24 +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; Sun, 23 May 2021 15:11:23 +0800 From: YueHaibing To: , CC: , , YueHaibing Subject: [PATCH -next] ALSA: control_led - use DEVICE_ATTR_*() macro Date: Sun, 23 May 2021 15:11:09 +0800 Message-ID: <20210523071109.28940-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: dggems703-chm.china.huawei.com (10.3.19.180) To dggema769-chm.china.huawei.com (10.1.198.211) X-CFilter-Loop: Reflected Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Use DEVICE_ATTR_*() helper instead of plain DEVICE_ATTR, which makes the code a bit shorter and easier to read. Signed-off-by: YueHaibing --- sound/core/control_led.c | 34 +++++++++++++++++++--------------- 1 file changed, 19 insertions(+), 15 deletions(-) diff --git a/sound/core/control_led.c b/sound/core/control_led.c index 25f57c14f294..a5e751f26d46 100644 --- a/sound/core/control_led.c +++ b/sound/core/control_led.c @@ -375,7 +375,7 @@ static void snd_ctl_led_disconnect(struct snd_card *card) * sysfs */ -static ssize_t show_mode(struct device *dev, +static ssize_t mode_show(struct device *dev, struct device_attribute *attr, char *buf) { struct snd_ctl_led *led = container_of(dev, struct snd_ctl_led, dev); @@ -390,7 +390,8 @@ static ssize_t show_mode(struct device *dev, return sprintf(buf, "%s\n", str); } -static ssize_t store_mode(struct device *dev, struct device_attribute *attr, +static ssize_t mode_store(struct device *dev, + struct device_attribute *attr, const char *buf, size_t count) { struct snd_ctl_led *led = container_of(dev, struct snd_ctl_led, dev); @@ -419,7 +420,7 @@ static ssize_t store_mode(struct device *dev, struct device_attribute *attr, return count; } -static ssize_t show_brightness(struct device *dev, +static ssize_t brightness_show(struct device *dev, struct device_attribute *attr, char *buf) { struct snd_ctl_led *led = container_of(dev, struct snd_ctl_led, dev); @@ -427,8 +428,8 @@ static ssize_t show_brightness(struct device *dev, return sprintf(buf, "%u\n", ledtrig_audio_get(led->trigger_type)); } -static DEVICE_ATTR(mode, 0644, show_mode, store_mode); -static DEVICE_ATTR(brightness, 0444, show_brightness, NULL); +static DEVICE_ATTR_RW(mode); +static DEVICE_ATTR_RO(brightness); static struct attribute *snd_ctl_led_dev_attrs[] = { &dev_attr_mode.attr, @@ -562,22 +563,25 @@ static ssize_t set_led_id(struct snd_ctl_led_card *led_card, const char *buf, si return count; } -static ssize_t parse_attach(struct device *dev, struct device_attribute *attr, +static ssize_t attach_store(struct device *dev, + struct device_attribute *attr, const char *buf, size_t count) { struct snd_ctl_led_card *led_card = container_of(dev, struct snd_ctl_led_card, dev); return set_led_id(led_card, buf, count, true); } -static ssize_t parse_detach(struct device *dev, struct device_attribute *attr, +static ssize_t detach_store(struct device *dev, + struct device_attribute *attr, const char *buf, size_t count) { struct snd_ctl_led_card *led_card = container_of(dev, struct snd_ctl_led_card, dev); return set_led_id(led_card, buf, count, false); } -static ssize_t ctl_reset(struct device *dev, struct device_attribute *attr, - const char *buf, size_t count) +static ssize_t reset_store(struct device *dev, + struct device_attribute *attr, + const char *buf, size_t count) { struct snd_ctl_led_card *led_card = container_of(dev, struct snd_ctl_led_card, dev); int err; @@ -590,8 +594,8 @@ static ssize_t ctl_reset(struct device *dev, struct device_attribute *attr, return count; } -static ssize_t ctl_list(struct device *dev, - struct device_attribute *attr, char *buf) +static ssize_t list_show(struct device *dev, + struct device_attribute *attr, char *buf) { struct snd_ctl_led_card *led_card = container_of(dev, struct snd_ctl_led_card, dev); struct snd_card *card; @@ -624,10 +628,10 @@ static ssize_t ctl_list(struct device *dev, return buf2 - buf; } -static DEVICE_ATTR(attach, 0200, NULL, parse_attach); -static DEVICE_ATTR(detach, 0200, NULL, parse_detach); -static DEVICE_ATTR(reset, 0200, NULL, ctl_reset); -static DEVICE_ATTR(list, 0444, ctl_list, NULL); +static DEVICE_ATTR_WO(attach); +static DEVICE_ATTR_WO(detach); +static DEVICE_ATTR_WO(reset); +static DEVICE_ATTR_RO(list); static struct attribute *snd_ctl_led_card_attrs[] = { &dev_attr_attach.attr, -- 2.17.1