Re: [RFC PATCH 2/4] mmc: sdio: bind sdio device with acpi device

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Fri, Oct 19, 2012 at 01:25:46AM +0200, Rafael J. Wysocki wrote:
> On Friday 12 of October 2012 11:12:39 Aaron Lu wrote:
> > ACPI spec defines the _ADDR encoding for sdio bus as:
> > High word - slot number (0 based)
> > Low word  - function number
> > 
> > This patch adds support for sdio device binding with acpi using the
> > generic ACPI glue framework.
> > 
> > Signed-off-by: Aaron Lu <aaron.lu@xxxxxxxxx>
> > ---
> >  drivers/mmc/core/Makefile    |  1 +
> >  drivers/mmc/core/sdio_acpi.c | 35 +++++++++++++++++++++++++++++++++++
> >  drivers/mmc/core/sdio_bus.c  | 14 ++++++++++++--
> >  drivers/mmc/core/sdio_bus.h  |  2 ++
> >  4 files changed, 50 insertions(+), 2 deletions(-)
> >  create mode 100644 drivers/mmc/core/sdio_acpi.c
> > 
> > diff --git a/drivers/mmc/core/Makefile b/drivers/mmc/core/Makefile
> > index 38ed210..c8300aa 100644
> > --- a/drivers/mmc/core/Makefile
> > +++ b/drivers/mmc/core/Makefile
> > @@ -10,3 +10,4 @@ mmc_core-y			:= core.o bus.o host.o \
> >  				   quirks.o slot-gpio.o
> >  
> >  mmc_core-$(CONFIG_DEBUG_FS)	+= debugfs.o
> > +mmc_core-$(CONFIG_ACPI)		+= sdio_acpi.o
> > diff --git a/drivers/mmc/core/sdio_acpi.c b/drivers/mmc/core/sdio_acpi.c
> > new file mode 100644
> > index 0000000..0f92e90
> > --- /dev/null
> > +++ b/drivers/mmc/core/sdio_acpi.c
> > @@ -0,0 +1,35 @@
> > +#include <linux/mmc/host.h>
> > +#include <linux/mmc/card.h>
> > +#include <linux/mmc/sdhci.h>
> > +#include <linux/mmc/sdio_func.h>
> > +#include <linux/acpi.h>
> > +#include <acpi/acpi_bus.h>
> > +#include "sdio_bus.h"
> > +
> > +static int acpi_sdio_find_device(struct device *dev, acpi_handle *handle)
> > +{
> > +	struct sdio_func *func;
> > +	struct sdhci_host *host;
> > +	u64 addr;
> > +
> > +	func = dev_to_sdio_func(dev);
> > +	host = mmc_priv(func->card->host);
> > +
> > +	addr = (host->slotno << 16) | func->num;
> > +
> > +	*handle = acpi_get_child(DEVICE_ACPI_HANDLE(dev), addr);
> > +	if (!*handle)
> > +		return -ENODEV;
> > +
> > +	return 0;
> > +}
> > +
> > +static struct acpi_bus_type acpi_sdio_bus = {
> > +	.bus = &sdio_bus_type,
> > +	.find_device = acpi_sdio_find_device,
> > +};
> > +
> > +int sdio_acpi_register(void)
> 
> I'd call it sdio_acpi_register_bus().

OK, will update this in v2.

> 
> > +{
> > +	return register_acpi_bus_type(&acpi_sdio_bus);
> > +}
> > diff --git a/drivers/mmc/core/sdio_bus.c b/drivers/mmc/core/sdio_bus.c
> > index 6bf6879..aaec9e2 100644
> > --- a/drivers/mmc/core/sdio_bus.c
> > +++ b/drivers/mmc/core/sdio_bus.c
> > @@ -23,6 +23,7 @@
> >  
> >  #include "sdio_cis.h"
> >  #include "sdio_bus.h"
> > +#include "sdio_acpi.h"
> >  
> >  /* show configuration fields */
> >  #define sdio_config_attr(field, format_string)				\
> > @@ -209,7 +210,7 @@ static const struct dev_pm_ops sdio_bus_pm_ops = {
> >  
> >  #endif /* !CONFIG_PM */
> >  
> > -static struct bus_type sdio_bus_type = {
> > +struct bus_type sdio_bus_type = {
> >  	.name		= "sdio",
> >  	.dev_attrs	= sdio_dev_attrs,
> >  	.match		= sdio_bus_match,
> > @@ -221,7 +222,16 @@ static struct bus_type sdio_bus_type = {
> >  
> >  int sdio_register_bus(void)
> >  {
> > -	return bus_register(&sdio_bus_type);
> > +	int ret;
> > +
> > +	ret = bus_register(&sdio_bus_type);
> > +	if (ret)
> > +		goto out;
> > +
> > +	ret = sdio_acpi_register();
> 
> What happens if this fails?

Oh, yes, it shouldn't affect the sdio_register_bus function. So I'll not
check its return value in v2.

Thanks,
Aaron

> 
> > +
> > +out:
> > +	return ret;
> >  }
> >  
> >  void sdio_unregister_bus(void)
> > diff --git a/drivers/mmc/core/sdio_bus.h b/drivers/mmc/core/sdio_bus.h
> > index 567a768..91c0e93 100644
> > --- a/drivers/mmc/core/sdio_bus.h
> > +++ b/drivers/mmc/core/sdio_bus.h
> > @@ -18,5 +18,7 @@ void sdio_remove_func(struct sdio_func *func);
> >  int sdio_register_bus(void);
> >  void sdio_unregister_bus(void);
> >  
> > +extern struct bus_type sdio_bus_type;
> > +
> >  #endif
> 
> Thanks,
> Rafael
> 
> 
> -- 
> I speak only for myself.
> Rafael J. Wysocki, Intel Open Source Technology Center.
--
To unsubscribe from this list: send the line "unsubscribe linux-acpi" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[Index of Archives]     [Linux IBM ACPI]     [Linux Power Management]     [Linux Kernel]     [Linux Laptop]     [Kernel Newbies]     [Share Photos]     [Security]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Samba]     [Video 4 Linux]     [Device Mapper]     [Linux Resources]

  Powered by Linux