From: Lee Jones <lee.jones-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org>
To: Arnd Bergmann <arnd-r2nGTMty4D4@public.gmane.org>
Cc: linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r@public.gmane.org,
linus.walleij-0IS4wlFg1OjSUeElwK9/Pw@public.gmane.org,
broonie-yzvPICuk2AATkU/dhu1WVueM+bqZidxxQQ4Iyu8u01E@public.gmane.org,
grant.likely-s3s/WqlpOiPyB63q8FvJNQ@public.gmane.org,
linux-i2c-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
ben-linux-elnMNo+KYs3YtjvyW6yDsg@public.gmane.org,
cjb-2X9k7bc8m7Mdnm+yROfE0A@public.gmane.org,
sameo-VuQAYsv1563Yd54FQh9/CA@public.gmane.org
Subject: Re: [PATCH 06/15] mfd/ab8500: Remove confusing ab8500-i2c file and merge into ab8500-core
Date: Fri, 04 May 2012 22:24:10 +0100 [thread overview]
Message-ID: <4FA448FA.8000404@linaro.org> (raw)
In-Reply-To: <201205042025.15421.arnd-r2nGTMty4D4@public.gmane.org>
On 04/05/12 21:25, Arnd Bergmann wrote:
> On Friday 04 May 2012, Lee Jones wrote:
>>
>> ab8500-i2c is used as core code to register the ab8500 device.
>> After allocating ab8500 memory, it immediately calls into
>> ab8500-core where the real initialisation takes place. This
>> patch moves all core registration and memory allocation into
>> the true ab8500-core file and removes ab8500-i2c completely.
>>
>> Signed-off-by: Lee Jones<lee.jones-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org>
>
> These changes all look good, but I think I would go further here.
> I believe we discussed this and I agreed that we could leave that
> for later, but upon reading this code, I think now that it's getting
> rather silly.
>
>> @@ -125,6 +126,41 @@ static const char ab8500_version_str[][7] = {
>> [AB8500_VERSION_AB8540] = "AB8540",
>> };
>>
>> +static int ab8500_i2c_write(struct ab8500 *ab8500, u16 addr, u8 data)
>> +{
>> + int ret;
>> +
>> + ret = prcmu_abb_write((u8)(addr>> 8), (u8)(addr& 0xFF),&data, 1);
>> + if (ret< 0)
>> + dev_err(ab8500->dev, "prcmu i2c error %d\n", ret);
>> + return ret;
>> +}
>> +
>> +static int ab8500_i2c_write_masked(struct ab8500 *ab8500, u16 addr, u8 mask,
>> + u8 data)
>> +{
>> + int ret;
>> +
>> + ret = prcmu_abb_write_masked((u8)(addr>> 8), (u8)(addr& 0xFF),&data,
>> +&mask, 1);
>> + if (ret< 0)
>> + dev_err(ab8500->dev, "prcmu i2c error %d\n", ret);
>> + return ret;
>> +}
>> +
>> +static int ab8500_i2c_read(struct ab8500 *ab8500, u16 addr)
>> +{
>> + int ret;
>> + u8 data;
>> +
>> + ret = prcmu_abb_read((u8)(addr>> 8), (u8)(addr& 0xFF),&data, 1);
>> + if (ret< 0) {
>> + dev_err(ab8500->dev, "prcmu i2c error %d\n", ret);
>> + return ret;
>> + }
>> + return (int)data;
>> +}
>> +
>> static int ab8500_get_chip_id(struct device *dev)
>> {
>> struct ab8500 *ab8500;
>
> Each of these functions is called only from a single location, and through an indirect
> function pointer.
>
>> + ab8500->read = ab8500_i2c_read;
>> + ab8500->write = ab8500_i2c_write;
>> + ab8500->write_masked = ab8500_i2c_write_masked;
>
> Which you unconditionally assign here.
>
> If you apply this patch below, then there is no reason to add any of those.
> There is room for additional simplification even, but this is the most
> important one. Note that the ab8500 mutex was only needed to support the
> case where write_masked is not present, and that the debug output
> on error is pointless because the prcmu driver already writes the same
> output. The next step would be to remove all the {get,set}_register functions
> from ab8500 and just call the prcmu directly.
It's something I'm happy to do, but wasn't the point of the patch. I
don't know much about this code, as I didn't write it.
> Signed-off-by: Arnd Bergmann<arnd-r2nGTMty4D4@public.gmane.org>
> ---
>
> drivers/mfd/ab8500-core.c | 72 +++---------------------------------------------------------------------
> include/linux/mfd/abx500/ab8500.h | 1 -
> 2 files changed, 3 insertions(+), 70 deletions(-)
>
> diff --git a/drivers/mfd/ab8500-core.c b/drivers/mfd/ab8500-core.c
> index 1f08704..b10bd2f 100644
> --- a/drivers/mfd/ab8500-core.c
> +++ b/drivers/mfd/ab8500-core.c
> @@ -138,24 +138,8 @@ static int ab8500_get_chip_id(struct device *dev)
> static int set_register_interruptible(struct ab8500 *ab8500, u8 bank,
> u8 reg, u8 data)
> {
> - int ret;
> - /*
> - * Put the u8 bank and u8 register together into a an u16.
> - * The bank on higher 8 bits and register in lower 8 bits.
> - * */
> - u16 addr = ((u16)bank)<< 8 | reg;
> -
> dev_vdbg(ab8500->dev, "wr: addr %#x<= %#x\n", addr, data);
> -
> - mutex_lock(&ab8500->lock);
> -
> - ret = ab8500->write(ab8500, addr, data);
> - if (ret< 0)
> - dev_err(ab8500->dev, "failed to write reg %#x: %d\n",
> - addr, ret);
> - mutex_unlock(&ab8500->lock);
> -
> - return ret;
> + return prcmu_abb_write(bank, reg,&data, 1);
> }
>
> static int ab8500_set_register(struct device *dev, u8 bank,
> @@ -169,21 +153,7 @@ static int ab8500_set_register(struct device *dev, u8 bank,
> static int get_register_interruptible(struct ab8500 *ab8500, u8 bank,
> u8 reg, u8 *value)
> {
> - int ret;
> - /* put the u8 bank and u8 reg together into a an u16.
> - * bank on higher 8 bits and reg in lower */
> - u16 addr = ((u16)bank)<< 8 | reg;
> -
> - mutex_lock(&ab8500->lock);
> -
> - ret = ab8500->read(ab8500, addr);
> - if (ret< 0)
> - dev_err(ab8500->dev, "failed to read reg %#x: %d\n",
> - addr, ret);
> - else
> - *value = ret;
> -
> - mutex_unlock(&ab8500->lock);
> + ret = prcmu_abb_read(bank, addr, value, 1);
> dev_vdbg(ab8500->dev, "rd: addr %#x => data %#x\n", addr, ret);
>
> return ret;
> @@ -200,42 +170,7 @@ static int ab8500_get_register(struct device *dev, u8 bank,
> static int mask_and_set_register_interruptible(struct ab8500 *ab8500, u8 bank,
> u8 reg, u8 bitmask, u8 bitvalues)
> {
> - int ret;
> - /* put the u8 bank and u8 reg together into a an u16.
> - * bank on higher 8 bits and reg in lower */
> - u16 addr = ((u16)bank)<< 8 | reg;
> -
> - mutex_lock(&ab8500->lock);
> -
> - if (ab8500->write_masked == NULL) {
> - u8 data;
> -
> - ret = ab8500->read(ab8500, addr);
> - if (ret< 0) {
> - dev_err(ab8500->dev, "failed to read reg %#x: %d\n",
> - addr, ret);
> - goto out;
> - }
> -
> - data = (u8)ret;
> - data = (~bitmask& data) | (bitmask& bitvalues);
> -
> - ret = ab8500->write(ab8500, addr, data);
> - if (ret< 0)
> - dev_err(ab8500->dev, "failed to write reg %#x: %d\n",
> - addr, ret);
> -
> - dev_vdbg(ab8500->dev, "mask: addr %#x => data %#x\n", addr,
> - data);
> - goto out;
> - }
> - ret = ab8500->write_masked(ab8500, addr, bitmask, bitvalues);
> - if (ret< 0)
> - dev_err(ab8500->dev, "failed to modify reg %#x: %d\n", addr,
> - ret);
> -out:
> - mutex_unlock(&ab8500->lock);
> - return ret;
> + return prcmu_abb_write_masked(bank, reg,&bitmask,&bitvalues, 1);
> }
>
> static int ab8500_mask_and_set_register(struct device *dev,
> @@ -1013,7 +948,6 @@ int __devinit ab8500_init(struct ab8500 *ab8500, enum ab8500_version version)
> if (plat)
> ab8500->irq_base = plat->irq_base;
>
> - mutex_init(&ab8500->lock);
> mutex_init(&ab8500->irq_lock);
>
> if (version != AB8500_VERSION_UNDEFINED)
> diff --git a/include/linux/mfd/abx500/ab8500.h b/include/linux/mfd/abx500/ab8500.h
> index fccc300..5f70328 100644
> --- a/include/linux/mfd/abx500/ab8500.h
> +++ b/include/linux/mfd/abx500/ab8500.h
> @@ -232,7 +232,6 @@ enum ab8500_version {
> */
> struct ab8500 {
> struct device *dev;
> - struct mutex lock;
> struct mutex irq_lock;
>
> int irq_base;
--
Lee Jones
Linaro ST-Ericsson Landing Team Lead
M: +44 77 88 633 515
Linaro.org │ Open source software for ARM SoCs
Follow Linaro: Facebook | Twitter | Blog
next prev parent reply other threads:[~2012-05-04 21:24 UTC|newest]
Thread overview: 75+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-05-04 18:23 [PATCH 00/15] DT enablement for Snowball Lee Jones
[not found] ` <1336155805-18554-1-git-send-email-lee.jones-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org>
2012-05-04 18:23 ` [PATCH 01/15] i2c/busses: Add Device Tree support to the Nomadik I2C driver Lee Jones
[not found] ` <1336155805-18554-2-git-send-email-lee.jones-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org>
2012-05-04 20:02 ` Arnd Bergmann
[not found] ` <201205042002.20943.arnd-r2nGTMty4D4@public.gmane.org>
2012-05-04 21:27 ` Lee Jones
2012-05-05 6:17 ` Lee Jones
[not found] ` <4FA4C5EA.7030006-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org>
2012-05-09 8:42 ` Linus Walleij
2012-05-04 18:23 ` [PATCH 02/15] ARM: ux500: Remove unused i2c platform_data initialisation code Lee Jones
[not found] ` <1336155805-18554-3-git-send-email-lee.jones-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org>
2012-05-09 8:46 ` Linus Walleij
[not found] ` <CACRpkdZ70FasMuTTgBe68xaePB-4UNZ0W44BCxDve7fqXYT+vg-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2012-05-09 10:22 ` Lee Jones
[not found] ` <4FAA4576.1020106-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org>
2012-05-10 11:24 ` Linus Walleij
2012-05-04 18:23 ` [PATCH 03/15] ARM: ux500: Provide auxdata to be used as name base clock search for nmk-i2c Lee Jones
[not found] ` <1336155805-18554-4-git-send-email-lee.jones-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org>
2012-05-09 8:48 ` Linus Walleij
2012-05-04 18:23 ` [PATCH 04/15] ARM: ux500: CONFIG: Compile in support for leds-gpio Lee Jones
[not found] ` <1336155805-18554-5-git-send-email-lee.jones-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org>
2012-05-09 8:49 ` Linus Walleij
[not found] ` <CACRpkdbv780oUaDL1-m4kj5iRr5=1U6QhE975Z4gNADoTNk8YA-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2012-05-09 10:23 ` Lee Jones
[not found] ` <4FAA45B5.2030000-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org>
2012-05-10 11:25 ` Linus Walleij
2012-05-04 18:23 ` [PATCH 05/15] ARM: ux500: Enable the user LED on Snowball via Device Tree Lee Jones
[not found] ` <1336155805-18554-6-git-send-email-lee.jones-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org>
2012-05-09 8:50 ` Linus Walleij
2012-05-04 18:23 ` [PATCH 06/15] mfd/ab8500: Remove confusing ab8500-i2c file and merge into ab8500-core Lee Jones
[not found] ` <1336155805-18554-7-git-send-email-lee.jones-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org>
2012-05-04 20:25 ` Arnd Bergmann
[not found] ` <201205042025.15421.arnd-r2nGTMty4D4@public.gmane.org>
2012-05-04 21:24 ` Lee Jones [this message]
2012-05-05 6:30 ` Lee Jones
2012-05-07 16:54 ` Mark Brown
2012-05-09 12:20 ` Linus Walleij
[not found] ` <CACRpkdanG7KgYuZw29KwZe7wRp-AVZJ9n_hwBEZzf5gDAbGneg-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2012-05-14 8:41 ` Lee Jones
[not found] ` <4FB0C52E.9030109-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org>
2012-05-14 9:11 ` Linus Walleij
2012-05-04 18:23 ` [PATCH 07/15] drivers/power: Carry out platform_data error checking on ab8500 devices Lee Jones
[not found] ` <1336155805-18554-8-git-send-email-lee.jones-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org>
2012-05-09 8:51 ` Linus Walleij
[not found] ` <CACRpkdYkqj6Zr=05Byk+tPc1ohjfDoZKCkTmu9zcZpgKxV8wpg-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2012-05-09 10:24 ` Lee Jones
2012-05-04 18:23 ` [PATCH 08/15] ARM: ux500: PRCMU related configuration and layout corrections for Device Tree Lee Jones
[not found] ` <1336155805-18554-9-git-send-email-lee.jones-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org>
2012-05-09 8:53 ` Linus Walleij
[not found] ` <CACRpkdanU4eWhRobxzBV1mcU5T6QLCrWfBAczRFtn6gguhRNng-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2012-05-09 10:27 ` Lee Jones
[not found] ` <4FAA469B.2030200-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org>
2012-05-10 11:27 ` Linus Walleij
2012-05-04 18:23 ` [PATCH 09/15] drivers/mfd: Enable Device Tree support for the db8500-prcmu Lee Jones
[not found] ` <1336155805-18554-10-git-send-email-lee.jones-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org>
2012-05-09 8:56 ` Linus Walleij
2012-05-09 14:30 ` Samuel Ortiz
2012-05-04 18:23 ` [PATCH 10/15] drivers/mfd: db8500-prcmu: Add support for regulator supply for nmk-i2c.4 Lee Jones
[not found] ` <1336155805-18554-11-git-send-email-lee.jones-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org>
2012-05-09 8:56 ` Linus Walleij
2012-05-09 14:31 ` Samuel Ortiz
2012-05-04 18:23 ` [PATCH 11/15] drivers/mfd: Enable Device Tree for ab8500-core driver Lee Jones
[not found] ` <1336155805-18554-12-git-send-email-lee.jones-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org>
2012-05-09 9:02 ` Linus Walleij
[not found] ` <CACRpkdaju5y6pduWrkH97LujzqJu5hAaGozyHY3Rsvvn7ZyKhA-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2012-05-09 10:28 ` Lee Jones
[not found] ` <4FAA46E1.4050708-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org>
2012-05-09 11:18 ` Mark Brown
2012-05-09 11:56 ` Arnd Bergmann
2012-05-10 10:26 ` Russell King - ARM Linux
[not found] ` <20120510102657.GD3190-l+eeeJia6m9vn6HldHNs0ANdhmdF6hFW@public.gmane.org>
2012-05-10 12:27 ` Linus Walleij
2012-05-11 10:12 ` Samuel Ortiz
2012-05-14 8:45 ` Lee Jones
2012-05-04 18:23 ` [PATCH 12/15] drivers/regulator: ab8500: Split up probe() into manageable pieces Lee Jones
[not found] ` <1336155805-18554-13-git-send-email-lee.jones-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org>
2012-05-07 16:58 ` Mark Brown
[not found] ` <CAF2Aj3h7pgh=Kbt+M5Xd_RDRbJN7K+WbaH1+8nM2Eakb1QNpsg@mail.gmail.com>
[not found] ` <CAF2Aj3h7pgh=Kbt+M5Xd_RDRbJN7K+WbaH1+8nM2Eakb1QNpsg-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2012-05-07 18:44 ` Mark Brown
[not found] ` <20120507184453.GQ17002-yzvPICuk2AATkU/dhu1WVueM+bqZidxxQQ4Iyu8u01E@public.gmane.org>
2012-05-08 11:08 ` Lee Jones
2012-05-04 18:23 ` [PATCH 13/15] ARM: ux500: Add support for ab8500 regulators into the Device Tree Lee Jones
[not found] ` <1336155805-18554-14-git-send-email-lee.jones-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org>
2012-05-09 9:04 ` Linus Walleij
2012-05-04 18:23 ` [PATCH 14/15] drivers/regulators: Enable the ab8500 for " Lee Jones
[not found] ` <1336155805-18554-15-git-send-email-lee.jones-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org>
2012-05-07 17:08 ` Mark Brown
[not found] ` <20120507170832.GO17002-yzvPICuk2AATkU/dhu1WVueM+bqZidxxQQ4Iyu8u01E@public.gmane.org>
2012-05-08 12:04 ` Lee Jones
[not found] ` <4FA90BE1.3050304-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org>
2012-05-08 12:19 ` Mark Brown
[not found] ` <20120508121940.GL15893-yzvPICuk2AATkU/dhu1WVueM+bqZidxxQQ4Iyu8u01E@public.gmane.org>
2012-05-08 12:38 ` Lee Jones
[not found] ` <4FA913BA.30908-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org>
2012-05-08 13:34 ` Mark Brown
[not found] ` <20120508133411.GP15893-yzvPICuk2AATkU/dhu1WVueM+bqZidxxQQ4Iyu8u01E@public.gmane.org>
2012-05-08 14:54 ` Lee Jones
[not found] ` <4FA93391.8040905-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org>
2012-05-08 14:57 ` Mark Brown
[not found] ` <20120508145758.GV15893-yzvPICuk2AATkU/dhu1WVueM+bqZidxxQQ4Iyu8u01E@public.gmane.org>
2012-05-08 17:00 ` Lee Jones
2012-05-08 13:48 ` Arnd Bergmann
[not found] ` <201205081348.14269.arnd-r2nGTMty4D4@public.gmane.org>
2012-05-08 14:29 ` Mark Brown
[not found] ` <20120508142926.GT15893-yzvPICuk2AATkU/dhu1WVueM+bqZidxxQQ4Iyu8u01E@public.gmane.org>
2012-05-08 14:36 ` Arnd Bergmann
[not found] ` <201205081436.46471.arnd-r2nGTMty4D4@public.gmane.org>
2012-05-08 14:44 ` Mark Brown
2012-05-14 15:49 ` Lee Jones
[not found] ` <4FB12981.8050603-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org>
2012-05-14 16:18 ` Arnd Bergmann
2012-05-14 17:01 ` Mark Brown
2012-05-14 15:57 ` Lee Jones
[not found] ` <4FB12B73.50302-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org>
2012-05-14 16:39 ` Mark Brown
2012-05-04 18:23 ` [PATCH 15/15] ARM: ux500: Disable platform setup of the ab8500 when DT is enabled Lee Jones
[not found] ` <1336155805-18554-16-git-send-email-lee.jones-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org>
2012-05-09 9:05 ` Linus Walleij
2012-05-04 20:26 ` [PATCH 00/15] DT enablement for Snowball Arnd Bergmann
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=4FA448FA.8000404@linaro.org \
--to=lee.jones-qsej5fyqhm4dnm+yrofe0a@public.gmane.org \
--cc=arnd-r2nGTMty4D4@public.gmane.org \
--cc=ben-linux-elnMNo+KYs3YtjvyW6yDsg@public.gmane.org \
--cc=broonie-yzvPICuk2AATkU/dhu1WVueM+bqZidxxQQ4Iyu8u01E@public.gmane.org \
--cc=cjb-2X9k7bc8m7Mdnm+yROfE0A@public.gmane.org \
--cc=grant.likely-s3s/WqlpOiPyB63q8FvJNQ@public.gmane.org \
--cc=linus.walleij-0IS4wlFg1OjSUeElwK9/Pw@public.gmane.org \
--cc=linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r@public.gmane.org \
--cc=linux-i2c-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
--cc=sameo-VuQAYsv1563Yd54FQh9/CA@public.gmane.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;
as well as URLs for NNTP newsgroup(s).