* [PATCH v2 0/3] Raspberry Pi sdhost cleanups
@ 2019-02-03 8:27 Lukas Wunner
[not found] ` <cover.1549181242.git.lukas-JFq808J9C/izQB+pC5nmwQ@public.gmane.org>
0 siblings, 1 reply; 7+ messages in thread
From: Lukas Wunner @ 2019-02-03 8:27 UTC (permalink / raw)
To: Ulf Hansson, Eric Anholt, Stefan Wahren
Cc: linux-mmc-u79uwXL29TY76Z2rM5mHXA, Shraddha Barke,
Vaishali Thakkar, Frank Pavlic,
linux-rpi-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r
Three mostly trivial cleanups for the Raspberry Pi sdhost driver, v2.
Only change since v1: Use container_of() in patch [2/3] instead of
open-coding the same (Alexander Graf).
The issue addressed by patch [2/3] appears to be present in 32 other
drivers as can be seen with "git grep -e '->mmc = ' -- drivers/mmc/host".
Perhaps cleaning them up would be suitable for Outreachy applicants to
get their feet wet? Adding Shraddha Barke and Vaishali Thakkar to cc.
Thanks,
Lukas
Lukas Wunner (3):
mmc: bcm2835: Drop DMA channel error pointer check
mmc: bcm2835: Drop pointer to mmc_host from bcm2835_host
mmc: bcm2835: Deduplicate reset of driver data on remove
drivers/mmc/host/bcm2835.c | 23 +++++++++++------------
include/linux/mmc/host.h | 5 +++++
2 files changed, 16 insertions(+), 12 deletions(-)
--
2.20.1
^ permalink raw reply [flat|nested] 7+ messages in thread
* [PATCH v2 1/3] mmc: bcm2835: Drop DMA channel error pointer check
[not found] ` <cover.1549181242.git.lukas-JFq808J9C/izQB+pC5nmwQ@public.gmane.org>
2019-02-03 8:27 ` [PATCH v2 3/3] mmc: bcm2835: Deduplicate reset of driver data on remove Lukas Wunner
2019-02-03 8:27 ` [PATCH v2 2/3] mmc: bcm2835: Drop pointer to mmc_host from bcm2835_host Lukas Wunner
@ 2019-02-03 8:27 ` Lukas Wunner
2019-02-05 12:48 ` [PATCH v2 0/3] Raspberry Pi sdhost cleanups Ulf Hansson
3 siblings, 0 replies; 7+ messages in thread
From: Lukas Wunner @ 2019-02-03 8:27 UTC (permalink / raw)
To: Ulf Hansson, Eric Anholt, Stefan Wahren
Cc: linux-mmc-u79uwXL29TY76Z2rM5mHXA, Shraddha Barke,
Vaishali Thakkar, Frank Pavlic,
linux-rpi-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r
bcm2835_add_host() invokes IS_ERR_OR_NULL() on a DMA channel pointer,
however dma_request_slave_channel() (which was used to populate the
pointer) never returns an error pointer. So a NULL pointer check is
sufficient.
Tested-by: Stefan Wahren <stefan.wahren-eS4NqCHxEME@public.gmane.org>
Signed-off-by: Lukas Wunner <lukas-JFq808J9C/izQB+pC5nmwQ@public.gmane.org>
Cc: Frank Pavlic <f.pavlic-XB/JSsFECOqzQB+pC5nmwQ@public.gmane.org>
---
drivers/mmc/host/bcm2835.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/mmc/host/bcm2835.c b/drivers/mmc/host/bcm2835.c
index c9e7aa50bb0a..ab8d58a60352 100644
--- a/drivers/mmc/host/bcm2835.c
+++ b/drivers/mmc/host/bcm2835.c
@@ -1286,7 +1286,7 @@ static int bcm2835_add_host(struct bcm2835_host *host)
spin_lock_init(&host->lock);
mutex_init(&host->mutex);
- if (IS_ERR_OR_NULL(host->dma_chan_rxtx)) {
+ if (!host->dma_chan_rxtx) {
dev_warn(dev, "unable to initialise DMA channel. Falling back to PIO\n");
host->use_dma = false;
} else {
--
2.20.1
^ permalink raw reply related [flat|nested] 7+ messages in thread
* [PATCH v2 2/3] mmc: bcm2835: Drop pointer to mmc_host from bcm2835_host
[not found] ` <cover.1549181242.git.lukas-JFq808J9C/izQB+pC5nmwQ@public.gmane.org>
2019-02-03 8:27 ` [PATCH v2 3/3] mmc: bcm2835: Deduplicate reset of driver data on remove Lukas Wunner
@ 2019-02-03 8:27 ` Lukas Wunner
[not found] ` <ffa656c9f2c0e397a38e5827ba586f13e723f81b.1549181242.git.lukas-JFq808J9C/izQB+pC5nmwQ@public.gmane.org>
2019-02-03 8:27 ` [PATCH v2 1/3] mmc: bcm2835: Drop DMA channel error pointer check Lukas Wunner
2019-02-05 12:48 ` [PATCH v2 0/3] Raspberry Pi sdhost cleanups Ulf Hansson
3 siblings, 1 reply; 7+ messages in thread
From: Lukas Wunner @ 2019-02-03 8:27 UTC (permalink / raw)
To: Ulf Hansson, Eric Anholt, Stefan Wahren
Cc: linux-mmc-u79uwXL29TY76Z2rM5mHXA, Shraddha Barke,
Vaishali Thakkar, Frank Pavlic,
linux-rpi-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r
The BCM2835 MMC host driver uses a pointer to get from the private
bcm2835_host structure to the generic mmc_host structure. However the
latter is always immediately preceding the former in memory, so compute
its address with a subtraction (which is cheaper than a dereference) and
drop the superfluous pointer.
No functional change intended.
Signed-off-by: Lukas Wunner <lukas-JFq808J9C/izQB+pC5nmwQ@public.gmane.org>
Cc: Frank Pavlic <f.pavlic-XB/JSsFECOqzQB+pC5nmwQ@public.gmane.org>
Cc: Alexander Graf <agraf-l3A5Bk7waGM@public.gmane.org>
---
drivers/mmc/host/bcm2835.c | 20 ++++++++++----------
include/linux/mmc/host.h | 5 +++++
2 files changed, 15 insertions(+), 10 deletions(-)
diff --git a/drivers/mmc/host/bcm2835.c b/drivers/mmc/host/bcm2835.c
index ab8d58a60352..246c8ec24148 100644
--- a/drivers/mmc/host/bcm2835.c
+++ b/drivers/mmc/host/bcm2835.c
@@ -148,7 +148,6 @@ struct bcm2835_host {
void __iomem *ioaddr;
u32 phys_addr;
- struct mmc_host *mmc;
struct platform_device *pdev;
int clock; /* Current clock speed */
@@ -618,7 +617,7 @@ static void bcm2835_finish_request(struct bcm2835_host *host)
"failed to terminate DMA (%d)\n", err);
}
- mmc_request_done(host->mmc, mrq);
+ mmc_request_done(mmc_from_priv(host), mrq);
}
static
@@ -837,7 +836,7 @@ static void bcm2835_timeout(struct work_struct *work)
dev_err(dev, "timeout waiting for hardware interrupt.\n");
bcm2835_dumpregs(host);
- bcm2835_reset(host->mmc);
+ bcm2835_reset(mmc_from_priv(host));
if (host->data) {
host->data->error = -ETIMEDOUT;
@@ -1100,6 +1099,7 @@ static void bcm2835_dma_complete_work(struct work_struct *work)
static void bcm2835_set_clock(struct bcm2835_host *host, unsigned int clock)
{
+ struct mmc_host *mmc = mmc_from_priv(host);
int div;
/* The SDCDIV register has 11 bits, and holds (div - 2). But
@@ -1143,18 +1143,18 @@ static void bcm2835_set_clock(struct bcm2835_host *host, unsigned int clock)
div = SDCDIV_MAX_CDIV;
clock = host->max_clk / (div + 2);
- host->mmc->actual_clock = clock;
+ mmc->actual_clock = clock;
/* Calibrate some delays */
host->ns_per_fifo_word = (1000000000 / clock) *
- ((host->mmc->caps & MMC_CAP_4_BIT_DATA) ? 8 : 32);
+ ((mmc->caps & MMC_CAP_4_BIT_DATA) ? 8 : 32);
host->cdiv = div;
writel(host->cdiv, host->ioaddr + SDCDIV);
/* Set the timeout to 500ms */
- writel(host->mmc->actual_clock / 2, host->ioaddr + SDTOUT);
+ writel(mmc->actual_clock / 2, host->ioaddr + SDTOUT);
}
static void bcm2835_request(struct mmc_host *mmc, struct mmc_request *mrq)
@@ -1264,7 +1264,7 @@ static const struct mmc_host_ops bcm2835_ops = {
static int bcm2835_add_host(struct bcm2835_host *host)
{
- struct mmc_host *mmc = host->mmc;
+ struct mmc_host *mmc = mmc_from_priv(host);
struct device *dev = &host->pdev->dev;
char pio_limit_string[20];
int ret;
@@ -1370,7 +1370,6 @@ static int bcm2835_probe(struct platform_device *pdev)
mmc->ops = &bcm2835_ops;
host = mmc_priv(mmc);
- host->mmc = mmc;
host->pdev = pdev;
spin_lock_init(&host->lock);
@@ -1441,8 +1440,9 @@ static int bcm2835_probe(struct platform_device *pdev)
static int bcm2835_remove(struct platform_device *pdev)
{
struct bcm2835_host *host = platform_get_drvdata(pdev);
+ struct mmc_host *mmc = mmc_from_priv(host);
- mmc_remove_host(host->mmc);
+ mmc_remove_host(mmc);
writel(SDVDD_POWER_OFF, host->ioaddr + SDVDD);
@@ -1454,7 +1454,7 @@ static int bcm2835_remove(struct platform_device *pdev)
if (host->dma_chan_rxtx)
dma_release_channel(host->dma_chan_rxtx);
- mmc_free_host(host->mmc);
+ mmc_free_host(mmc);
platform_set_drvdata(pdev, NULL);
return 0;
diff --git a/include/linux/mmc/host.h b/include/linux/mmc/host.h
index 4d35ff36ceff..d893902b2f1c 100644
--- a/include/linux/mmc/host.h
+++ b/include/linux/mmc/host.h
@@ -478,6 +478,11 @@ static inline void *mmc_priv(struct mmc_host *host)
return (void *)host->private;
}
+static inline struct mmc_host *mmc_from_priv(void *priv)
+{
+ return container_of(priv, struct mmc_host, private);
+}
+
#define mmc_host_is_spi(host) ((host)->caps & MMC_CAP_SPI)
#define mmc_dev(x) ((x)->parent)
--
2.20.1
^ permalink raw reply related [flat|nested] 7+ messages in thread
* [PATCH v2 3/3] mmc: bcm2835: Deduplicate reset of driver data on remove
[not found] ` <cover.1549181242.git.lukas-JFq808J9C/izQB+pC5nmwQ@public.gmane.org>
@ 2019-02-03 8:27 ` Lukas Wunner
2019-02-03 8:27 ` [PATCH v2 2/3] mmc: bcm2835: Drop pointer to mmc_host from bcm2835_host Lukas Wunner
` (2 subsequent siblings)
3 siblings, 0 replies; 7+ messages in thread
From: Lukas Wunner @ 2019-02-03 8:27 UTC (permalink / raw)
To: Ulf Hansson, Eric Anholt, Stefan Wahren
Cc: linux-mmc-u79uwXL29TY76Z2rM5mHXA, Shraddha Barke,
Vaishali Thakkar, Frank Pavlic,
linux-rpi-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r
The BCM2835 MMC host driver sets the device's driver data pointer to
NULL on ->remove() even though the driver core subsequently does the
same in __device_release_driver(). Drop the duplicate assignment.
Tested-by: Stefan Wahren <stefan.wahren-eS4NqCHxEME@public.gmane.org>
Signed-off-by: Lukas Wunner <lukas-JFq808J9C/izQB+pC5nmwQ@public.gmane.org>
Cc: Frank Pavlic <f.pavlic-XB/JSsFECOqzQB+pC5nmwQ@public.gmane.org>
---
drivers/mmc/host/bcm2835.c | 1 -
1 file changed, 1 deletion(-)
diff --git a/drivers/mmc/host/bcm2835.c b/drivers/mmc/host/bcm2835.c
index 246c8ec24148..7e0d3a49c06d 100644
--- a/drivers/mmc/host/bcm2835.c
+++ b/drivers/mmc/host/bcm2835.c
@@ -1455,7 +1455,6 @@ static int bcm2835_remove(struct platform_device *pdev)
dma_release_channel(host->dma_chan_rxtx);
mmc_free_host(mmc);
- platform_set_drvdata(pdev, NULL);
return 0;
}
--
2.20.1
^ permalink raw reply related [flat|nested] 7+ messages in thread
* Re: [PATCH v2 2/3] mmc: bcm2835: Drop pointer to mmc_host from bcm2835_host
[not found] ` <ffa656c9f2c0e397a38e5827ba586f13e723f81b.1549181242.git.lukas-JFq808J9C/izQB+pC5nmwQ@public.gmane.org>
@ 2019-02-03 15:57 ` Alexander Graf
0 siblings, 0 replies; 7+ messages in thread
From: Alexander Graf @ 2019-02-03 15:57 UTC (permalink / raw)
To: Lukas Wunner
Cc: Ulf Hansson, linux-rpi-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r,
linux-mmc-u79uwXL29TY76Z2rM5mHXA, Vaishali Thakkar, Frank Pavlic,
Shraddha Barke
> Am 03.02.2019 um 09:27 schrieb Lukas Wunner <lukas-JFq808J9C/izQB+pC5nmwQ@public.gmane.org>:
>
> The BCM2835 MMC host driver uses a pointer to get from the private
> bcm2835_host structure to the generic mmc_host structure. However the
> latter is always immediately preceding the former in memory, so compute
> its address with a subtraction (which is cheaper than a dereference) and
> drop the superfluous pointer.
>
> No functional change intended.
>
> Signed-off-by: Lukas Wunner <lukas-JFq808J9C/izQB+pC5nmwQ@public.gmane.org>
> Cc: Frank Pavlic <f.pavlic-XB/JSsFECOqzQB+pC5nmwQ@public.gmane.org>
> Cc: Alexander Graf <agraf-l3A5Bk7waGM@public.gmane.org>
Reviewed-by: Alexander Graf <agraf-l3A5Bk7waGM@public.gmane.org>
Alex
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH v2 0/3] Raspberry Pi sdhost cleanups
[not found] ` <cover.1549181242.git.lukas-JFq808J9C/izQB+pC5nmwQ@public.gmane.org>
` (2 preceding siblings ...)
2019-02-03 8:27 ` [PATCH v2 1/3] mmc: bcm2835: Drop DMA channel error pointer check Lukas Wunner
@ 2019-02-05 12:48 ` Ulf Hansson
[not found] ` <20190205132652.xpy2aygu33lm43sz@wunner.de>
3 siblings, 1 reply; 7+ messages in thread
From: Ulf Hansson @ 2019-02-05 12:48 UTC (permalink / raw)
To: Lukas Wunner
Cc: linux-rpi-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r,
linux-mmc-u79uwXL29TY76Z2rM5mHXA, Vaishali Thakkar, Frank Pavlic,
Shraddha Barke
On Sun, 3 Feb 2019 at 09:27, Lukas Wunner <lukas-JFq808J9C/izQB+pC5nmwQ@public.gmane.org> wrote:
>
> Three mostly trivial cleanups for the Raspberry Pi sdhost driver, v2.
>
> Only change since v1: Use container_of() in patch [2/3] instead of
> open-coding the same (Alexander Graf).
>
> The issue addressed by patch [2/3] appears to be present in 32 other
> drivers as can be seen with "git grep -e '->mmc = ' -- drivers/mmc/host".
> Perhaps cleaning them up would be suitable for Outreachy applicants to
> get their feet wet? Adding Shraddha Barke and Vaishali Thakkar to cc.
>
> Thanks,
>
> Lukas
>
>
> Lukas Wunner (3):
> mmc: bcm2835: Drop DMA channel error pointer check
> mmc: bcm2835: Drop pointer to mmc_host from bcm2835_host
> mmc: bcm2835: Deduplicate reset of driver data on remove
>
> drivers/mmc/host/bcm2835.c | 23 +++++++++++------------
> include/linux/mmc/host.h | 5 +++++
> 2 files changed, 16 insertions(+), 12 deletions(-)
>
> --
> 2.20.1
>
Applied for next, thanks!
Kind regards
Uffe
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH v2 0/3] Raspberry Pi sdhost cleanups
[not found] ` <20190205132652.xpy2aygu33lm43sz-JFq808J9C/izQB+pC5nmwQ@public.gmane.org>
@ 2019-02-05 13:34 ` Ulf Hansson
0 siblings, 0 replies; 7+ messages in thread
From: Ulf Hansson @ 2019-02-05 13:34 UTC (permalink / raw)
To: Lukas Wunner
Cc: linux-rpi-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r,
linux-mmc-u79uwXL29TY76Z2rM5mHXA, Vaishali Thakkar, Frank Pavlic,
Shraddha Barke
On Tue, 5 Feb 2019 at 14:26, Lukas Wunner <lukas-JFq808J9C/izQB+pC5nmwQ@public.gmane.org> wrote:
>
> On Tue, Feb 05, 2019 at 01:48:31PM +0100, Ulf Hansson wrote:
> > On Sun, 3 Feb 2019 at 09:27, Lukas Wunner <lukas-JFq808J9C/izQB+pC5nmwQ@public.gmane.org> wrote:
> > > Three mostly trivial cleanups for the Raspberry Pi sdhost driver, v2.
> > >
> > > Only change since v1: Use container_of() in patch [2/3] instead of
> > > open-coding the same (Alexander Graf).
> > >
> > > The issue addressed by patch [2/3] appears to be present in 32 other
> > > drivers as can be seen with "git grep -e '->mmc = ' -- drivers/mmc/host".
> > > Perhaps cleaning them up would be suitable for Outreachy applicants to
> > > get their feet wet? Adding Shraddha Barke and Vaishali Thakkar to cc.
>
> FWIW this is now documented as something for Outreachy applicants
> to look into, I hope that's okay:
>
> https://github.com/nerdyvaishali/kernelbridge/commit/6f8cbf7f8e36
Great, cool, thanks! :-)
Kind regards
Uffe
^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2019-02-05 13:34 UTC | newest]
Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-02-03 8:27 [PATCH v2 0/3] Raspberry Pi sdhost cleanups Lukas Wunner
[not found] ` <cover.1549181242.git.lukas-JFq808J9C/izQB+pC5nmwQ@public.gmane.org>
2019-02-03 8:27 ` [PATCH v2 3/3] mmc: bcm2835: Deduplicate reset of driver data on remove Lukas Wunner
2019-02-03 8:27 ` [PATCH v2 2/3] mmc: bcm2835: Drop pointer to mmc_host from bcm2835_host Lukas Wunner
[not found] ` <ffa656c9f2c0e397a38e5827ba586f13e723f81b.1549181242.git.lukas-JFq808J9C/izQB+pC5nmwQ@public.gmane.org>
2019-02-03 15:57 ` Alexander Graf
2019-02-03 8:27 ` [PATCH v2 1/3] mmc: bcm2835: Drop DMA channel error pointer check Lukas Wunner
2019-02-05 12:48 ` [PATCH v2 0/3] Raspberry Pi sdhost cleanups Ulf Hansson
[not found] ` <20190205132652.xpy2aygu33lm43sz@wunner.de>
[not found] ` <20190205132652.xpy2aygu33lm43sz-JFq808J9C/izQB+pC5nmwQ@public.gmane.org>
2019-02-05 13:34 ` Ulf Hansson
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.