From: Marc Kleine-Budde <mkl@pengutronix.de>
To: Sascha Hauer <s.hauer@pengutronix.de>
Cc: barebox@lists.infradead.org
Subject: Re: [PATCH 1/4] ARM i.MX IIM: Add a iim read function
Date: Thu, 28 Jul 2011 16:10:23 +0200 [thread overview]
Message-ID: <4E316DCF.80700@pengutronix.de> (raw)
In-Reply-To: <1311847560-22946-2-git-send-email-s.hauer@pengutronix.de>
[-- Attachment #1.1: Type: text/plain, Size: 3288 bytes --]
On 07/28/2011 12:05 PM, Sascha Hauer wrote:
> To allow reading the iim from code.
>
> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
> ---
> arch/arm/mach-imx/iim.c | 28 ++++++++++++++++++++++++----
> arch/arm/mach-imx/include/mach/iim.h | 7 +++++++
> 2 files changed, 31 insertions(+), 4 deletions(-)
>
> diff --git a/arch/arm/mach-imx/iim.c b/arch/arm/mach-imx/iim.c
> index 0774ebb..7a8712b 100644
> --- a/arch/arm/mach-imx/iim.c
> +++ b/arch/arm/mach-imx/iim.c
> @@ -22,6 +22,8 @@
> #include <xfuncs.h>
> #include <errno.h>
> #include <param.h>
> +#include <fcntl.h>
> +#include <malloc.h>
>
> #include <asm/io.h>
>
> @@ -73,7 +75,7 @@ static int do_fuse_sense(unsigned long reg_base, unsigned int bank,
> return readb(reg_base + IIM_SDAT);
> }
>
> -static ssize_t imx_iim_read(struct cdev *cdev, void *buf, size_t count,
> +static ssize_t imx_iim_cdev_read(struct cdev *cdev, void *buf, size_t count,
> ulong offset, ulong flags)
> {
> ulong size, i;
> @@ -168,7 +170,7 @@ out:
> }
> #endif /* CONFIG_IMX_IIM_FUSE_BLOW */
>
> -static ssize_t imx_iim_write(struct cdev *cdev, const void *buf, size_t count,
> +static ssize_t imx_iim_cdev_write(struct cdev *cdev, const void *buf, size_t count,
> ulong offset, ulong flags)
> {
> ulong size, i;
> @@ -204,8 +206,8 @@ static ssize_t imx_iim_write(struct cdev *cdev, const void *buf, size_t count,
> }
>
> static struct file_operations imx_iim_ops = {
> - .read = imx_iim_read,
> - .write = imx_iim_write,
> + .read = imx_iim_cdev_read,
> + .write = imx_iim_cdev_write,
> .lseek = dev_lseek_default,
> };
>
> @@ -297,6 +299,24 @@ static int imx_iim_init(void)
> }
> coredevice_initcall(imx_iim_init);
>
> +int imx_iim_read(unsigned int bank, int offset, int count, void *buf)
The order of count and buf is IMHO unintuitive:
ssize_t read(int fildes, void *buf, size_t nbyte);
Marc
> +{
> + struct cdev *cdev;
> + char *name = asprintf(DRIVERNAME "_bank%d", bank);
> + int ret;
> +
> + cdev = cdev_open(name, O_RDONLY);
> + if (!cdev)
> + return -ENODEV;
> +
> + ret = cdev_read(cdev, buf, count, offset, 0);
> +
> + cdev_close(cdev);
> + free(name);
> +
> + return ret;
> +}
> +
> int imx_iim_get_mac(unsigned char *mac)
> {
> int i;
> diff --git a/arch/arm/mach-imx/include/mach/iim.h b/arch/arm/mach-imx/include/mach/iim.h
> index 03ff485..9ff44be 100644
> --- a/arch/arm/mach-imx/include/mach/iim.h
> +++ b/arch/arm/mach-imx/include/mach/iim.h
> @@ -46,8 +46,15 @@ struct imx_iim_platform_data {
> };
>
> #ifdef CONFIG_IMX_IIM
> +int imx_iim_read(unsigned int bank, int offset, int count, void *buf);
> int imx_iim_get_mac(unsigned char *mac);
> #else
> +static inline int imx_iim_read(unsigned int bank, int offset, int count,
> + void *buf)
> +{
> + return -EINVAL;
> +}
> +
> static inline int imx_iim_get_mac(unsigned char *mac)
> {
> return -EINVAL;
--
Pengutronix e.K. | Marc Kleine-Budde |
Industrial Linux Solutions | Phone: +49-231-2826-924 |
Vertretung West/Dortmund | Fax: +49-5121-206917-5555 |
Amtsgericht Hildesheim, HRA 2686 | http://www.pengutronix.de |
[-- Attachment #1.2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 262 bytes --]
[-- Attachment #2: Type: text/plain, Size: 149 bytes --]
_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox
next prev parent reply other threads:[~2011-07-28 14:10 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-07-28 10:05 MAC address setting Sascha Hauer
2011-07-28 10:05 ` [PATCH 1/4] ARM i.MX IIM: Add a iim read function Sascha Hauer
2011-07-28 14:10 ` Marc Kleine-Budde [this message]
2011-07-28 10:05 ` [PATCH 2/4] net: Add a possibility for boards to give network devices a MAC address Sascha Hauer
2011-07-28 10:05 ` [PATCH 3/4] ARM i.MX: rework IIM MAC address setting Sascha Hauer
2011-07-28 10:06 ` [PATCH 4/4] ARM i.MX51 babbage: set fec ethernet address from IIM Sascha Hauer
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=4E316DCF.80700@pengutronix.de \
--to=mkl@pengutronix.de \
--cc=barebox@lists.infradead.org \
--cc=s.hauer@pengutronix.de \
/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