Skip to content

Commit

Permalink
ARM: sa1111: provide to_sa1111_device() macro
Browse files Browse the repository at this point in the history
Provide a nicer to_sa1111_device macro to convert a struct device to a
sa1111_dev.  We will need this for drivers when converting them to
dev_pm_ops, or removing shutdown methods.

Signed-off-by: Russell King <rmk+kernel@armlinux.org.uk>
  • Loading branch information
Russell King committed Sep 21, 2016
1 parent cf6e4ca commit b60752f
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 10 deletions.
18 changes: 9 additions & 9 deletions arch/arm/common/sa1111.c
Original file line number Diff line number Diff line change
Expand Up @@ -691,7 +691,7 @@ sa1111_configure_smc(struct sa1111 *sachip, int sdram, unsigned int drac,

static void sa1111_dev_release(struct device *_dev)
{
struct sa1111_dev *dev = SA1111_DEV(_dev);
struct sa1111_dev *dev = to_sa1111_device(_dev);

kfree(dev);
}
Expand Down Expand Up @@ -899,7 +899,7 @@ static int __sa1111_probe(struct device *me, struct resource *mem, int irq)

static int sa1111_remove_one(struct device *dev, void *data)
{
struct sa1111_dev *sadev = SA1111_DEV(dev);
struct sa1111_dev *sadev = to_sa1111_device(dev);
if (dev->bus != &sa1111_bus_type)
return 0;
device_del(&sadev->dev);
Expand Down Expand Up @@ -1373,15 +1373,15 @@ EXPORT_SYMBOL_GPL(sa1111_get_irq);
*/
static int sa1111_match(struct device *_dev, struct device_driver *_drv)
{
struct sa1111_dev *dev = SA1111_DEV(_dev);
struct sa1111_dev *dev = to_sa1111_device(_dev);
struct sa1111_driver *drv = SA1111_DRV(_drv);

return !!(dev->devid & drv->devid);
}

static int sa1111_bus_suspend(struct device *dev, pm_message_t state)
{
struct sa1111_dev *sadev = SA1111_DEV(dev);
struct sa1111_dev *sadev = to_sa1111_device(dev);
struct sa1111_driver *drv = SA1111_DRV(dev->driver);
int ret = 0;

Expand All @@ -1392,7 +1392,7 @@ static int sa1111_bus_suspend(struct device *dev, pm_message_t state)

static int sa1111_bus_resume(struct device *dev)
{
struct sa1111_dev *sadev = SA1111_DEV(dev);
struct sa1111_dev *sadev = to_sa1111_device(dev);
struct sa1111_driver *drv = SA1111_DRV(dev->driver);
int ret = 0;

Expand All @@ -1406,12 +1406,12 @@ static void sa1111_bus_shutdown(struct device *dev)
struct sa1111_driver *drv = SA1111_DRV(dev->driver);

if (drv && drv->shutdown)
drv->shutdown(SA1111_DEV(dev));
drv->shutdown(to_sa1111_device(dev));
}

static int sa1111_bus_probe(struct device *dev)
{
struct sa1111_dev *sadev = SA1111_DEV(dev);
struct sa1111_dev *sadev = to_sa1111_device(dev);
struct sa1111_driver *drv = SA1111_DRV(dev->driver);
int ret = -ENODEV;

Expand All @@ -1422,7 +1422,7 @@ static int sa1111_bus_probe(struct device *dev)

static int sa1111_bus_remove(struct device *dev)
{
struct sa1111_dev *sadev = SA1111_DEV(dev);
struct sa1111_dev *sadev = to_sa1111_device(dev);
struct sa1111_driver *drv = SA1111_DRV(dev->driver);
int ret = 0;

Expand Down Expand Up @@ -1487,7 +1487,7 @@ static int sa1111_needs_bounce(struct device *dev, dma_addr_t addr, size_t size)
static int sa1111_notifier_call(struct notifier_block *n, unsigned long action,
void *data)
{
struct sa1111_dev *dev = SA1111_DEV(data);
struct sa1111_dev *dev = to_sa1111_device(data);

switch (action) {
case BUS_NOTIFY_ADD_DEVICE:
Expand Down
2 changes: 1 addition & 1 deletion arch/arm/include/asm/hardware/sa1111.h
Original file line number Diff line number Diff line change
Expand Up @@ -420,7 +420,7 @@ struct sa1111_dev {
u64 dma_mask;
};

#define SA1111_DEV(_d) container_of((_d), struct sa1111_dev, dev)
#define to_sa1111_device(x) container_of(x, struct sa1111_dev, dev)

#define sa1111_get_drvdata(d) dev_get_drvdata(&(d)->dev)
#define sa1111_set_drvdata(d,p) dev_set_drvdata(&(d)->dev, p)
Expand Down

0 comments on commit b60752f

Please sign in to comment.