From: Neelesh Gupta <neelegup@linux.vnet.ibm.com>
To: Cyril Bur <cyrilbur@gmail.com>, linuxppc-dev@ozlabs.org
Cc: Joel Stanley <joel@jms.id.au>, Jeremy Kerr <jk@ozlabs.org>
Subject: Re: [PATCH V3] drivers/mtd: add powernv flash MTD abstraction driver
Date: Fri, 29 May 2015 14:52:36 +0530 [thread overview]
Message-ID: <55682FDC.8030505@linux.vnet.ibm.com> (raw)
In-Reply-To: <1432884797-3056-1-git-send-email-cyrilbur@gmail.com>
[-- Attachment #1: Type: text/plain, Size: 2597 bytes --]
[...]
> +/**
> + * @mtd: the device
> + * @erase: the erase info
> + * Returns 0 if erase successful or -ERRNO if an error occurred
> + */
> +static int powernv_flash_erase(struct mtd_info *mtd, struct erase_info *erase)
> +{
> + int rc;
> +
> + erase->state = MTD_ERASING;
> +
> + /* todo: register our own notifier to do a true async implementation */
> + rc = powernv_flash_async_op(mtd, FLASH_OP_ERASE, erase->addr,
> + erase->len, NULL, NULL);
> +
> + if (rc) {
> + erase->fail_addr = erase->addr;
> + erase->state = MTD_ERASE_FAILED;
> + } else {
> + erase->state = MTD_ERASE_DONE;
> + }
> + mtd_erase_callback(erase);
return rc ? You also document the same '.... or -ERRNO if an error
occurred'
> + return 0;
> +}
> +
> +/**
> + * powernv_flash_set_driver_info - Fill the mtd_info structure and docg3
> + * structure @pdev: The platform device
> + * @mtd: The structure to fill
> + */
> +static int powernv_flash_set_driver_info(struct device *dev,
> + struct mtd_info *mtd)
> +{
> + u64 size;
> + u32 erase_size;
> + int rc;
> +
> + rc = of_property_read_u32(dev->of_node, "ibm,flash-block-size",
> + &erase_size);
> + if (rc) {
> + dev_err(dev, "couldn't get resource block size information\n");
> + return rc;
> + }
> +
> + rc = of_property_read_u64(dev->of_node, "reg", &size);
> + if (rc) {
> + dev_err(dev, "couldn't get resource size information\n");
> + return rc;
> + }
> +
> + /*
> + * Going to have to check what details I need to set and how to
> + * get them
> + */
> + mtd->name = of_get_property(dev->of_node, "name", NULL);
> + mtd->type = MTD_NORFLASH;
> + mtd->flags = MTD_WRITEABLE;
> + mtd->size = size;
> + mtd->erasesize = erase_size;
> + mtd->writebufsize = mtd->writesize = 1;
> + mtd->owner = THIS_MODULE;
> + mtd->_erase = powernv_flash_erase;
> + mtd->_read = powernv_flash_read;
> + mtd->_write = powernv_flash_write;
> + mtd->dev.parent = dev;
> + return 0;
> +}
> +
> +/**
> + * powernv_flash_probe
> + * @pdev: platform device
> + *
> + * Returns 0 on success, -ENOMEM, -ENXIO on error
> + */
> +static int powernv_flash_probe(struct platform_device *pdev)
> +{
> + struct device *dev = &pdev->dev;
> + struct powernv_flash *data;
> + int ret;
> +
> + data = devm_kzalloc(dev, sizeof(*data), GFP_KERNEL);
> + if (!data) {
> + ret = -ENOMEM;
> + goto out;
> + }
> + data->mtd.priv = data;
'mtd' is contained within the 'data' so you can cast 'mtd' to get the 'data'
anywhere you want using container_of() macro.. 'priv' can be used to pass
an unrelated structure .... just a thought, you may ignore it.. :)
Rest looks ok.
Neelesh.
[-- Attachment #2: Type: text/html, Size: 3205 bytes --]
next prev parent reply other threads:[~2015-05-29 9:22 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-05-29 7:33 [PATCH V3] drivers/mtd: add powernv flash MTD abstraction driver Cyril Bur
2015-05-29 9:22 ` Neelesh Gupta [this message]
2015-06-01 3:18 ` Cyril Bur
2015-06-01 3:26 ` Cyril Bur
2015-06-02 3:58 ` [V3] " Michael Ellerman
-- strict thread matches above, loose matches on Subject: below --
2015-06-02 4:26 [PATCH V3] " Cyril Bur
2015-06-02 5:14 ` Neelesh Gupta
2015-06-05 4:40 ` Cyril Bur
2015-06-05 4:40 ` Cyril Bur
2015-06-05 8:16 ` Richard Weinberger
2015-06-05 8:16 ` Richard Weinberger
2015-06-11 5:43 ` Michael Ellerman
2015-06-11 5:43 ` Michael Ellerman
2015-06-11 6:28 ` Richard Weinberger
2015-06-11 6:28 ` Richard Weinberger
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=55682FDC.8030505@linux.vnet.ibm.com \
--to=neelegup@linux.vnet.ibm.com \
--cc=cyrilbur@gmail.com \
--cc=jk@ozlabs.org \
--cc=joel@jms.id.au \
--cc=linuxppc-dev@ozlabs.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.