From patchwork Wed Aug 21 00:11:49 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Greg Kroah-Hartman X-Patchwork-Id: 2847364 Return-Path: X-Original-To: patchwork-linux-acpi@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 7FB149F2F4 for ; Wed, 21 Aug 2013 00:11:54 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id A88C3204D3 for ; Wed, 21 Aug 2013 00:11:53 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id C530F204AB for ; Wed, 21 Aug 2013 00:11:52 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751947Ab3HUALv (ORCPT ); Tue, 20 Aug 2013 20:11:51 -0400 Received: from mail.linuxfoundation.org ([140.211.169.12]:38993 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751524Ab3HUALu (ORCPT ); Tue, 20 Aug 2013 20:11:50 -0400 Received: from localhost (c-76-28-172-123.hsd1.wa.comcast.net [76.28.172.123]) by mail.linuxfoundation.org (Postfix) with ESMTPSA id 3655882D; Wed, 21 Aug 2013 00:11:50 +0000 (UTC) Date: Tue, 20 Aug 2013 17:11:49 -0700 From: Greg KH To: Len Brown , "Rafael J. Wysocki" Cc: linux-acpi@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH] ACPI: bgrt: take advantage of binary sysfs groups Message-ID: <20130821001149.GA16350@kroah.com> MIME-Version: 1.0 Content-Disposition: inline User-Agent: Mutt/1.5.21 (2010-09-15) Sender: linux-acpi-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-acpi@vger.kernel.org X-Spam-Status: No, score=-9.7 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Greg KH Attribute groups now can handle binary sysfs attributes, so clean up the code here by using a binary attribute array. This saves us the extra call to create the binary attribute at saves 6 lines overall. Cc: Len Brown Cc: "Rafael J. Wysocki" Signed-off-by: Greg Kroah-Hartman Acked-by: Rafael J. Wysocki diff --git a/drivers/acpi/bgrt.c b/drivers/acpi/bgrt.c index be603995..7a4128d9 100644 --- a/drivers/acpi/bgrt.c +++ b/drivers/acpi/bgrt.c @@ -51,20 +51,14 @@ static ssize_t show_yoffset(struct device *dev, } static DEVICE_ATTR(yoffset, S_IRUGO, show_yoffset, NULL); -static ssize_t show_image(struct file *file, struct kobject *kobj, +static ssize_t image_read(struct file *file, struct kobject *kobj, struct bin_attribute *attr, char *buf, loff_t off, size_t count) { memcpy(buf, attr->private + off, count); return count; } -static struct bin_attribute image_attr = { - .attr = { - .name = "image", - .mode = S_IRUGO, - }, - .read = show_image, -}; +static BIN_ATTR_RO(image, 0); /* size gets filled in later */ static struct attribute *bgrt_attributes[] = { &dev_attr_version.attr, @@ -75,8 +69,14 @@ static struct attribute *bgrt_attributes[] = { NULL, }; +static struct bin_attribute *bgrt_bin_attributes[] = { + &bin_attr_image, + NULL, +}; + static struct attribute_group bgrt_attribute_group = { .attrs = bgrt_attributes, + .bin_attrs = bgrt_bin_attributes, }; static int __init bgrt_init(void) @@ -87,8 +87,8 @@ static int __init bgrt_init(void) return -ENODEV; sysfs_bin_attr_init(&image_attr); - image_attr.private = bgrt_image; - image_attr.size = bgrt_image_size; + bin_attr_image.private = bgrt_image; + bin_attr_image.size = bgrt_image_size; bgrt_kobj = kobject_create_and_add("bgrt", acpi_kobj); if (!bgrt_kobj) @@ -98,14 +98,8 @@ static int __init bgrt_init(void) if (ret) goto out_kobject; - ret = sysfs_create_bin_file(bgrt_kobj, &image_attr); - if (ret) - goto out_group; - return 0; -out_group: - sysfs_remove_group(bgrt_kobj, &bgrt_attribute_group); out_kobject: kobject_put(bgrt_kobj); return ret;