From: Jamie Iles <jamie@jamieiles.com>
To: linux-kernel@vger.kernel.org
Cc: gregkh@suse.de, vapier@gentoo.org, Jamie Iles <jamie@jamieiles.com>
Subject: [RFC PATCHv2 3/4] drivers/otp: allow an ioctl to be specified
Date: Thu, 24 Mar 2011 15:21:10 +0000 [thread overview]
Message-ID: <1300980071-24645-4-git-send-email-jamie@jamieiles.com> (raw)
In-Reply-To: <1300980071-24645-1-git-send-email-jamie@jamieiles.com>
Some drivers may need an ioctl method to provide device specific control
such as blackfin for providing locking. Regions can specify an ioctl to
be used but this field method is optional.
Signed-off-by: Jamie Iles <jamie@jamieiles.com>
---
drivers/otp/otp.c | 30 ++++++++++++++++++++++++------
include/linux/otp.h | 3 +++
2 files changed, 27 insertions(+), 6 deletions(-)
diff --git a/drivers/otp/otp.c b/drivers/otp/otp.c
index dd47cf1..d362d09 100644
--- a/drivers/otp/otp.c
+++ b/drivers/otp/otp.c
@@ -30,14 +30,16 @@ static ssize_t otp_write(struct file *filp, const char __user *buf,
static ssize_t otp_read(struct file *filp, char __user *buf, size_t len,
loff_t *offs);
static loff_t otp_llseek(struct file *filp, loff_t offs, int origin);
+static long otp_ioctl(struct file *filp, unsigned cmd, unsigned long arg);
static const struct file_operations otp_fops = {
- .owner = THIS_MODULE,
- .open = otp_open,
- .release = otp_release,
- .write = otp_write,
- .read = otp_read,
- .llseek = otp_llseek,
+ .owner = THIS_MODULE,
+ .open = otp_open,
+ .release = otp_release,
+ .write = otp_write,
+ .read = otp_read,
+ .llseek = otp_llseek,
+ .unlocked_ioctl = otp_ioctl,
};
static DEFINE_SEMAPHORE(otp_sem);
@@ -691,6 +693,22 @@ out:
return ret ?: written;
}
+static long otp_ioctl(struct file *filp, unsigned cmd, unsigned long arg)
+{
+ struct otp_region *region = filp->private_data;
+ long ret = -ENOTTY;
+
+ if (down_interruptible(&otp_sem))
+ return -ERESTARTSYS;
+
+ if (region->ops->ioctl)
+ ret = region->ops->ioctl(region, cmd, arg);
+
+ up(&otp_sem);
+
+ return ret;
+}
+
/*
* Read an OTP region. This switches the OTP into the appropriate redundancy
* format so we can simply read from the beginning of the region and copy it
diff --git a/include/linux/otp.h b/include/linux/otp.h
index 93ccf8b..ce77f05 100644
--- a/include/linux/otp.h
+++ b/include/linux/otp.h
@@ -100,6 +100,7 @@ struct otp_device {
* @get_size: Get the effective storage size of the region.
* Depending on the number of regions in the device and
* the redundancy format of the region, this may vary.
+ * @ioctl: Optional region ioctl.
*/
struct otp_region_ops {
int (*set_fmt)(struct otp_region *region,
@@ -112,6 +113,8 @@ struct otp_region_ops {
unsigned long word_addr,
u64 *value);
ssize_t (*get_size)(struct otp_region *region);
+ long (*ioctl)(struct otp_region *dev,
+ unsigned cmd, unsigned long arg);
};
/**
--
1.7.4
next prev parent reply other threads:[~2011-03-24 15:21 UTC|newest]
Thread overview: 49+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-03-24 15:21 [RFC PATCHv2 0/4] Support for OTP memory Jamie Iles
2011-03-24 15:21 ` [RFC PATCHv2 1/4] drivers/otp: add initial support " Jamie Iles
2011-03-24 18:32 ` Mike Frysinger
2011-03-24 20:35 ` Jamie Iles
2011-03-24 21:33 ` Mike Frysinger
2011-03-25 10:08 ` Jamie Iles
2011-03-25 21:32 ` Mike Frysinger
2011-03-25 22:27 ` Jamie Iles
2011-03-25 22:36 ` Mike Frysinger
2011-03-24 19:20 ` Greg KH
2011-03-24 20:49 ` Jamie Iles
2011-03-25 20:12 ` Arnd Bergmann
2011-03-25 21:12 ` Greg KH
2011-03-25 22:01 ` Arnd Bergmann
2011-03-25 23:28 ` Greg KH
2011-03-26 11:25 ` Arnd Bergmann
2011-03-26 15:10 ` Greg KH
2011-03-28 13:11 ` Arnd Bergmann
2011-03-25 22:23 ` Jamie Iles
2011-03-25 22:35 ` Arnd Bergmann
2011-03-25 22:38 ` Mike Frysinger
2011-03-25 22:52 ` Jamie Iles
2011-03-25 23:02 ` Arnd Bergmann
2011-03-26 0:21 ` Jamie Iles
2011-03-26 2:16 ` Mike Frysinger
2011-03-26 2:40 ` Jamie Iles
2011-03-26 10:54 ` Arnd Bergmann
2011-03-26 17:55 ` Mike Frysinger
2011-03-26 20:51 ` Arnd Bergmann
2011-03-27 3:52 ` Mike Frysinger
2011-03-27 11:18 ` Arnd Bergmann
2011-03-25 22:53 ` Arnd Bergmann
2011-03-24 15:21 ` [RFC PATCHv2 2/4] drivers/otp: add support for Picoxcell PC3X3 OTP Jamie Iles
2011-03-24 18:50 ` Mike Frysinger
2011-03-24 20:59 ` Jamie Iles
2011-03-24 21:40 ` Mike Frysinger
2011-03-24 15:21 ` Jamie Iles [this message]
2011-03-24 18:35 ` [RFC PATCHv2 3/4] drivers/otp: allow an ioctl to be specified Mike Frysinger
2011-03-24 20:36 ` Jamie Iles
2011-03-24 15:21 ` [RFC PATCHv2 4/4] drivers/otp: convert bfin otp to generic OTP Jamie Iles
2011-03-24 18:52 ` Mike Frysinger
2011-03-24 20:40 ` Jamie Iles
2011-03-24 17:39 ` [RFC PATCHv2 0/4] Support for OTP memory Mike Frysinger
2011-03-24 17:47 ` Jamie Iles
2011-03-24 17:56 ` Mike Frysinger
2011-03-24 18:32 ` Jamie Iles
2011-03-24 18:36 ` Mike Frysinger
2011-03-24 20:38 ` Jamie Iles
2011-03-25 0:12 ` Mark Brown
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=1300980071-24645-4-git-send-email-jamie@jamieiles.com \
--to=jamie@jamieiles.com \
--cc=gregkh@suse.de \
--cc=linux-kernel@vger.kernel.org \
--cc=vapier@gentoo.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
all inboxes | Powered by JetHome®