From patchwork Sun Jul 7 00:17:58 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Greg KH X-Patchwork-Id: 2824535 Return-Path: X-Original-To: patchwork-linux-arm@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 6388BC0AB2 for ; Sun, 7 Jul 2013 00:17:42 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 472F020123 for ; Sun, 7 Jul 2013 00:17:41 +0000 (UTC) Received: from casper.infradead.org (casper.infradead.org [85.118.1.10]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 29B0020116 for ; Sun, 7 Jul 2013 00:17:40 +0000 (UTC) Received: from merlin.infradead.org ([2001:4978:20e::2]) by casper.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1UvcfV-000871-2F; Sun, 07 Jul 2013 00:17:33 +0000 Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1UvcfS-0001rV-IO; Sun, 07 Jul 2013 00:17:30 +0000 Received: from mail.linuxfoundation.org ([140.211.169.12]) by merlin.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1UvcfN-0001qz-3c for linux-arm-kernel@lists.infradead.org; Sun, 07 Jul 2013 00:17:28 +0000 Received: from localhost (c-76-28-172-123.hsd1.wa.comcast.net [76.28.172.123]) by mail.linuxfoundation.org (Postfix) with ESMTPSA id 3F7D325E; Sun, 7 Jul 2013 00:17:03 +0000 (UTC) Date: Sat, 6 Jul 2013 17:17:58 -0700 From: Greg KH To: Oliver Schinagl Subject: Re: [PATCH 1/2] Initial support for Allwinner's Security ID fuses Message-ID: <20130707001758.GA15335@kroah.com> References: <20130624092942.GG26008@lukather> <20130624160440.GA15201@kroah.com> <51C87DC7.50005@schinagl.nl> <20130624181509.GA8847@kroah.com> <51C8B84C.3020200@schinagl.nl> <20130624214615.GA17604@kroah.com> <51CAA709.4060801@schinagl.nl> <20130626175144.GC2222@kroah.com> <51D674BF.9030207@schinagl.nl> <20130706193646.GB9778@kroah.com> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20130706193646.GB9778@kroah.com> User-Agent: Mutt/1.5.21 (2010-09-15) X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20130706_201725_312628_A7FC9B9A X-CRM114-Status: GOOD ( 21.33 ) X-Spam-Score: -1.9 (-) Cc: linux@arm.linux.org.uk, arnd@arndb.de, Oliver Schinagl , linus.walleij@linaro.org, linux-sunxi@googlegroups.com, linux-kernel@vger.kernel.org, andy.shevchenko@gmail.com, Maxime Ripard , linux-arm-kernel@lists.infradead.org X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Spam-Status: No, score=-4.2 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_MED, 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 On Sat, Jul 06, 2013 at 12:36:46PM -0700, Greg KH wrote: > On Fri, Jul 05, 2013 at 09:24:47AM +0200, Oliver Schinagl wrote: > > The other 'broken' drivers that where linked earlier, also use the > > BINARY attributes. > > > > So Greg, if you could be so kind and give me an example how to > > implement this properly, I am at loss and don't know :( > > Ah crap, devices don't have a binary attribute group, like struct class > does. I'll go add that on Monday and send you the patch to see if that > helps you out. I'll also go through and fix up all of the binary > attribute drivers to keep them from doing that... > > Sorry, I missed that earlier, but thanks for trying and pointing out my > mistake. Can you try this patch out, with your driver, and see if it works for you? thanks, greg k-h ------------------ Subject: driver core: add binary attributes to struct device From: Greg Kroah-Hartman This lets a device provide a set of default binary attributes, like normal attributes, that are initialized and torn down by the driver core at the proper times, so that there are no races with userspace. Reported-by: : Oliver Schinagl Signed-off-by: Greg Kroah-Hartman diff --git a/drivers/base/core.c b/drivers/base/core.c index 2499cef..4040191 100644 --- a/drivers/base/core.c +++ b/drivers/base/core.c @@ -433,7 +433,7 @@ static void device_remove_attributes(struct device *dev, } static int device_add_bin_attributes(struct device *dev, - struct bin_attribute *attrs) + const struct bin_attribute *attrs) { int error = 0; int i; @@ -452,7 +452,7 @@ static int device_add_bin_attributes(struct device *dev, } static void device_remove_bin_attributes(struct device *dev, - struct bin_attribute *attrs) + const struct bin_attribute *attrs) { int i; @@ -516,8 +516,14 @@ static int device_add_attrs(struct device *dev) if (error) goto err_remove_type_groups; + error = device_add_bin_attributes(dev, dev->bin_attrs); + if (error) + goto err_remove_groups; return 0; + err_remove_groups: + device_remove_groups(dev, dev->groups); + err_remove_type_groups: if (type) device_remove_groups(dev, type->groups); @@ -537,6 +543,7 @@ static void device_remove_attrs(struct device *dev) const struct device_type *type = dev->type; device_remove_groups(dev, dev->groups); + device_remove_bin_attributes(dev, dev->bin_attrs); if (type) device_remove_groups(dev, type->groups); diff --git a/include/linux/device.h b/include/linux/device.h index c0a1261..6620ad8 100644 --- a/include/linux/device.h +++ b/include/linux/device.h @@ -645,6 +645,7 @@ struct acpi_dev_node { * @knode_class: The node used to add the device to the class list. * @class: The class of the device. * @groups: Optional attribute groups. + * @bin_attrs: Optional binary attributes for this device. * @release: Callback to free the device after all references have * gone away. This should be set by the allocator of the * device (i.e. the bus driver that discovered the device). @@ -717,6 +718,7 @@ struct device { struct klist_node knode_class; struct class *class; const struct attribute_group **groups; /* optional groups */ + const struct bin_attribute *bin_attrs; void (*release)(struct device *dev); struct iommu_group *iommu_group;