Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 284332
b: refs/heads/master
c: eb8a54a
h: refs/heads/master
v: v3
  • Loading branch information
Timur Tabi authored and David S. Miller committed Jan 12, 2012
1 parent 0ea3186 commit d7e95c2
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 7 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 1398eee08222a038fa5f017900f387e81f6e3ff4
refs/heads/master: eb8a54a78e974e1af3e17fa38bb74d3747c5c1bd
24 changes: 19 additions & 5 deletions trunk/drivers/net/phy/mdio_bus.c
Original file line number Diff line number Diff line change
Expand Up @@ -37,22 +37,36 @@
#include <asm/uaccess.h>

/**
* mdiobus_alloc - allocate a mii_bus structure
* mdiobus_alloc_size - allocate a mii_bus structure
*
* Description: called by a bus driver to allocate an mii_bus
* structure to fill in.
*
* 'size' is an an extra amount of memory to allocate for private storage.
* If non-zero, then bus->priv is points to that memory.
*/
struct mii_bus *mdiobus_alloc(void)
struct mii_bus *mdiobus_alloc_size(size_t size)
{
struct mii_bus *bus;
size_t aligned_size = ALIGN(sizeof(*bus), NETDEV_ALIGN);
size_t alloc_size;

/* If we alloc extra space, it should be aligned */
if (size)
alloc_size = aligned_size + size;
else
alloc_size = sizeof(*bus);

bus = kzalloc(sizeof(*bus), GFP_KERNEL);
if (bus != NULL)
bus = kzalloc(alloc_size, GFP_KERNEL);
if (bus) {
bus->state = MDIOBUS_ALLOCATED;
if (size)
bus->priv = (void *)bus + aligned_size;
}

return bus;
}
EXPORT_SYMBOL(mdiobus_alloc);
EXPORT_SYMBOL(mdiobus_alloc_size);

/**
* mdiobus_release - mii_bus device release callback
Expand Down
7 changes: 6 additions & 1 deletion trunk/include/linux/phy.h
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,12 @@ struct mii_bus {
};
#define to_mii_bus(d) container_of(d, struct mii_bus, dev)

struct mii_bus *mdiobus_alloc(void);
struct mii_bus *mdiobus_alloc_size(size_t);
static inline struct mii_bus *mdiobus_alloc(void)
{
return mdiobus_alloc_size(0);
}

int mdiobus_register(struct mii_bus *bus);
void mdiobus_unregister(struct mii_bus *bus);
void mdiobus_free(struct mii_bus *bus);
Expand Down

0 comments on commit d7e95c2

Please sign in to comment.