mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Greg Kroah-Hartman <gregkh@suse.de>
To: linux-kernel@vger.kernel.org
Cc: Brandon Philips <brandon@ifup.org>,
	Brandon Philips <bphilips@suse.de>,
	"Hans J. Koch" <hjk@linutronix.de>,
	Greg Kroah-Hartman <gregkh@suse.de>
Subject: [PATCH 08/11] UIO: fix Greg's stupid changes
Date: Thu, 21 Feb 2008 15:48:04 -0800	[thread overview]
Message-ID: <1203637687-7273-8-git-send-email-gregkh@suse.de> (raw)
In-Reply-To: <20080221234649.GB7128@kroah.com>

From: Brandon Philips <brandon@ifup.org>

This fixes two bugs with UIO that cropped up recently in -rc1

1) WARNING: at fs/sysfs/file.c:334 sysfs_open_file when trying to open
   a map addr/size file - complaining about missing sysfs_ops for ktype

2) Permission denied when reading uio/uio0/maps/map0/{addr,size} when
   files are mode S_IRUGO

Also fix a typo: attr_attribute -> addr_attribute

Signed-off-by: Brandon Philips <bphilips@suse.de>
Signed-off-by: Hans J. Koch <hjk@linutronix.de>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
---
 drivers/uio/uio.c |   54 ++++++++++++++++++++++++++++++++++++----------------
 1 files changed, 37 insertions(+), 17 deletions(-)

diff --git a/drivers/uio/uio.c b/drivers/uio/uio.c
index 2a77e9d..e8a01f2 100644
--- a/drivers/uio/uio.c
+++ b/drivers/uio/uio.c
@@ -57,29 +57,29 @@ struct uio_map {
 };
 #define to_map(map) container_of(map, struct uio_map, kobj)
 
-
-static ssize_t map_attr_show(struct kobject *kobj, struct kobj_attribute *attr,
-			     char *buf)
+static ssize_t map_addr_show(struct uio_mem *mem, char *buf)
 {
-	struct uio_map *map = to_map(kobj);
-	struct uio_mem *mem = map->mem;
-
-	if (strncmp(attr->attr.name, "addr", 4) == 0)
-		return sprintf(buf, "0x%lx\n", mem->addr);
-
-	if (strncmp(attr->attr.name, "size", 4) == 0)
-		return sprintf(buf, "0x%lx\n", mem->size);
+	return sprintf(buf, "0x%lx\n", mem->addr);
+}
 
-	return -ENODEV;
+static ssize_t map_size_show(struct uio_mem *mem, char *buf)
+{
+	return sprintf(buf, "0x%lx\n", mem->size);
 }
 
-static struct kobj_attribute attr_attribute =
-	__ATTR(addr, S_IRUGO, map_attr_show, NULL);
-static struct kobj_attribute size_attribute =
-	__ATTR(size, S_IRUGO, map_attr_show, NULL);
+struct uio_sysfs_entry {
+	struct attribute attr;
+	ssize_t (*show)(struct uio_mem *, char *);
+	ssize_t (*store)(struct uio_mem *, const char *, size_t);
+};
+
+static struct uio_sysfs_entry addr_attribute =
+	__ATTR(addr, S_IRUGO, map_addr_show, NULL);
+static struct uio_sysfs_entry size_attribute =
+	__ATTR(size, S_IRUGO, map_size_show, NULL);
 
 static struct attribute *attrs[] = {
-	&attr_attribute.attr,
+	&addr_attribute.attr,
 	&size_attribute.attr,
 	NULL,	/* need to NULL terminate the list of attributes */
 };
@@ -90,8 +90,28 @@ static void map_release(struct kobject *kobj)
 	kfree(map);
 }
 
+static ssize_t map_type_show(struct kobject *kobj, struct attribute *attr,
+			     char *buf)
+{
+	struct uio_map *map = to_map(kobj);
+	struct uio_mem *mem = map->mem;
+	struct uio_sysfs_entry *entry;
+
+	entry = container_of(attr, struct uio_sysfs_entry, attr);
+
+	if (!entry->show)
+		return -EIO;
+
+	return entry->show(mem, buf);
+}
+
+static struct sysfs_ops uio_sysfs_ops = {
+	.show = map_type_show,
+};
+
 static struct kobj_type map_attr_type = {
 	.release	= map_release,
+	.sysfs_ops	= &uio_sysfs_ops,
 	.default_attrs	= attrs,
 };
 
-- 
1.5.4


  parent reply	other threads:[~2008-02-21 23:52 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-02-21 23:46 [GIT PATCH] driver core fixes against 2.6.25-rc2 git Greg KH
2008-02-21 23:47 ` [PATCH 01/11] Fix broken utf-8 encodings in ja_JP translation of stable_kernel_rules.txt Greg Kroah-Hartman
2008-02-21 23:47 ` [PATCH 02/11] slabinfo: fall back from /sys/kernel/slab to /sys/slab Greg Kroah-Hartman
2008-02-21 23:47 ` [PATCH 03/11] cpufreq: fix kobject reference count handling Greg Kroah-Hartman
2008-02-21 23:53   ` Dave Jones
2008-02-21 23:48 ` [PATCH 04/11] driver-core: fix kernel-doc function parameters Greg Kroah-Hartman
2008-02-21 23:48 ` [PATCH 05/11] Driver core: Fix error handling in bus_add_driver() Greg Kroah-Hartman
2008-02-21 23:48 ` [PATCH 06/11] ide: mark "ide=reverse" option as obsolete Greg Kroah-Hartman
2008-02-21 23:48 ` [PATCH 07/11] stable_kernel_rules: fix must already be in mainline Greg Kroah-Hartman
2008-02-21 23:48 ` Greg Kroah-Hartman [this message]
2008-02-21 23:48 ` [PATCH 09/11] PM: Remove unbalanced mutex_unlock() from dpm_resume() Greg Kroah-Hartman
2008-02-21 23:48 ` [PATCH 10/11] POWERPC: fix typo in pseries/power.c Greg Kroah-Hartman
2008-02-21 23:48 ` [PATCH 11/11] modules: do not try to add sysfs attributes if !CONFIG_SYSFS Greg Kroah-Hartman
2008-02-22  7:56 ` [GIT PATCH] driver core fixes against 2.6.25-rc2 git Sam Ravnborg
2008-02-22 19:56   ` Greg KH
2008-02-22 20:07     ` Sam Ravnborg

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1203637687-7273-8-git-send-email-gregkh@suse.de \
    --to=gregkh@suse.de \
    --cc=bphilips@suse.de \
    --cc=brandon@ifup.org \
    --cc=hjk@linutronix.de \
    --cc=linux-kernel@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

Powered by JetHome