mirror of
https://github.com/torvalds/linux.git
synced 2026-05-25 15:41:52 +02:00
Merge branch 'net-phy-improve-mdio-boardinfo-handling'
Heiner Kallweit says: ==================== net: phy: improve mdio-boardinfo handling This series includes smaller improvements to mdio-boardinfo handling. ==================== Link: https://patch.msgid.link/6ae7bda0-c093-468a-8ac0-50a2afa73c45@gmail.com Signed-off-by: Jakub Kicinski <kuba@kernel.org>
This commit is contained in:
commit
a7075659f7
|
|
@ -3,17 +3,23 @@
|
|||
* mdio-boardinfo - Collect pre-declarations for MDIO devices
|
||||
*/
|
||||
|
||||
#include <linux/kernel.h>
|
||||
#include <linux/slab.h>
|
||||
#include <linux/export.h>
|
||||
#include <linux/mutex.h>
|
||||
#include <linux/kernel.h>
|
||||
#include <linux/list.h>
|
||||
#include <linux/mutex.h>
|
||||
#include <linux/phy.h>
|
||||
#include <linux/slab.h>
|
||||
|
||||
#include "mdio-boardinfo.h"
|
||||
|
||||
static LIST_HEAD(mdio_board_list);
|
||||
static DEFINE_MUTEX(mdio_board_lock);
|
||||
|
||||
struct mdio_board_entry {
|
||||
struct list_head list;
|
||||
struct mdio_board_info board_info;
|
||||
};
|
||||
|
||||
/**
|
||||
* mdiobus_setup_mdiodev_from_board_info - create and setup MDIO devices
|
||||
* from pre-collected board specific MDIO information
|
||||
|
|
@ -26,24 +32,18 @@ void mdiobus_setup_mdiodev_from_board_info(struct mii_bus *bus,
|
|||
(struct mii_bus *bus,
|
||||
struct mdio_board_info *bi))
|
||||
{
|
||||
struct mdio_board_entry *be;
|
||||
struct mdio_board_entry *tmp;
|
||||
struct mdio_board_info *bi;
|
||||
int ret;
|
||||
struct mdio_board_entry *be, *tmp;
|
||||
|
||||
mutex_lock(&mdio_board_lock);
|
||||
list_for_each_entry_safe(be, tmp, &mdio_board_list, list) {
|
||||
bi = &be->board_info;
|
||||
struct mdio_board_info *bi = &be->board_info;
|
||||
|
||||
if (strcmp(bus->id, bi->bus_id))
|
||||
continue;
|
||||
|
||||
mutex_unlock(&mdio_board_lock);
|
||||
ret = cb(bus, bi);
|
||||
cb(bus, bi);
|
||||
mutex_lock(&mdio_board_lock);
|
||||
if (ret)
|
||||
continue;
|
||||
|
||||
}
|
||||
mutex_unlock(&mdio_board_lock);
|
||||
}
|
||||
|
|
@ -62,14 +62,13 @@ int mdiobus_register_board_info(const struct mdio_board_info *info,
|
|||
unsigned int n)
|
||||
{
|
||||
struct mdio_board_entry *be;
|
||||
unsigned int i;
|
||||
|
||||
be = kcalloc(n, sizeof(*be), GFP_KERNEL);
|
||||
if (!be)
|
||||
return -ENOMEM;
|
||||
|
||||
for (i = 0; i < n; i++, be++, info++) {
|
||||
memcpy(&be->board_info, info, sizeof(*info));
|
||||
for (int i = 0; i < n; i++, be++) {
|
||||
be->board_info = info[i];
|
||||
mutex_lock(&mdio_board_lock);
|
||||
list_add_tail(&be->list, &mdio_board_list);
|
||||
mutex_unlock(&mdio_board_lock);
|
||||
|
|
|
|||
|
|
@ -7,13 +7,8 @@
|
|||
#ifndef __MDIO_BOARD_INFO_H
|
||||
#define __MDIO_BOARD_INFO_H
|
||||
|
||||
#include <linux/phy.h>
|
||||
#include <linux/mutex.h>
|
||||
|
||||
struct mdio_board_entry {
|
||||
struct list_head list;
|
||||
struct mdio_board_info board_info;
|
||||
};
|
||||
struct mii_bus;
|
||||
struct mdio_board_info;
|
||||
|
||||
void mdiobus_setup_mdiodev_from_board_info(struct mii_bus *bus,
|
||||
int (*cb)
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user