Page Menu
Home
FreeBSD
Search
Configure Global Search
Log In
Files
F137972527
D7570.id19550.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Flag For Later
Award Token
Size
5 KB
Referenced Files
None
Subscribers
None
D7570.id19550.diff
View Options
Index: sys/dev/bhnd/bcma/bcma_bhndb.c
===================================================================
--- sys/dev/bhnd/bcma/bcma_bhndb.c
+++ sys/dev/bhnd/bcma/bcma_bhndb.c
@@ -51,15 +51,22 @@
static int
bcma_bhndb_probe(device_t dev)
{
- const struct bhnd_chipid *cid;
+ const struct bhnd_chipid *cid;
+ int error;
+
+ /* Defer to default probe implementation */
+ if ((error = bcma_probe(dev)) > 0)
+ return (error);
/* Check bus type */
cid = BHNDB_GET_CHIPID(device_get_parent(dev), dev);
if (cid->chip_type != BHND_CHIPTYPE_BCMA)
return (ENXIO);
- /* Delegate to default probe implementation */
- return (bcma_probe(dev));
+ /* Set device description */
+ bhnd_set_default_bus_desc(dev, cid);
+
+ return (error);
}
static int
Index: sys/dev/bhnd/bcma/bcma_nexus.c
===================================================================
--- sys/dev/bhnd/bcma/bcma_nexus.c
+++ sys/dev/bhnd/bcma/bcma_nexus.c
@@ -82,6 +82,9 @@
return (error);
}
+ /* Set device description */
+ bhnd_set_default_bus_desc(dev, &sc->bcma_cid);
+
return (0);
}
Index: sys/dev/bhnd/bhnd.h
===================================================================
--- sys/dev/bhnd/bhnd.h
+++ sys/dev/bhnd/bhnd.h
@@ -49,6 +49,9 @@
extern devclass_t bhnd_hostb_devclass;
extern devclass_t bhnd_nvram_devclass;
+#define BHND_CHIPID_MAX_NAMELEN 32 /**< maximum buffer required for a
+ bhnd_format_chip_id() */
+
/**
* bhnd child instance variables
*/
@@ -254,6 +257,8 @@
const char *bhnd_core_name(const struct bhnd_core_info *ci);
bhnd_devclass_t bhnd_core_class(const struct bhnd_core_info *ci);
+int bhnd_format_chip_id(char *buffer, size_t size,
+ uint16_t chip_id);
device_t bhnd_match_child(device_t dev,
const struct bhnd_core_match *desc);
@@ -321,6 +326,9 @@
const char *name);
void bhnd_set_default_core_desc(device_t dev);
+void bhnd_set_default_bus_desc(device_t dev,
+ const struct bhnd_chipid *chip_id);
+
int bhnd_nvram_getvar_str(device_t dev,
const char *name, char *buf, size_t len,
size_t *rlen);
Index: sys/dev/bhnd/bhnd_subr.c
===================================================================
--- sys/dev/bhnd/bhnd_subr.c
+++ sys/dev/bhnd/bhnd_subr.c
@@ -288,6 +288,30 @@
}
/**
+ * Write a human readable name representation of the given
+ * BHND_CHIPID_* constant to @p buffer.
+ *
+ * @param buffer Output buffer, or NULL to compute the required size.
+ * @param size Capacity of @p buffer, in bytes.
+ * @param chip_id Chip ID to be formatted.
+ *
+ * @return Returns the required number of bytes on success, or a negative
+ * integer on failure. No more than @p size-1 characters be written, with
+ * the @p size'th set to '\0'.
+ *
+ * @sa BHND_CHIPID_MAX_NAMELEN
+ */
+int
+bhnd_format_chip_id(char *buffer, size_t size, uint16_t chip_id)
+{
+ /* All hex formatted IDs are within the range of 0x4000-0x9C3F (40000-1) */
+ if (chip_id >= 0x4000 && chip_id <= 0x9C3F)
+ return (snprintf(buffer, size, "BCM%hX", chip_id));
+ else
+ return (snprintf(buffer, size, "BCM%hu", chip_id));
+}
+
+/**
* Initialize a core info record with data from from a bhnd-attached @p dev.
*
* @param dev A bhnd device.
@@ -1232,6 +1256,52 @@
bhnd_set_custom_core_desc(dev, bhnd_get_device_name(dev));
}
+
+/**
+ * Using the bhnd @p chip_id, populate the bhnd(4) bus @p dev's device
+ * description.
+ *
+ * @param dev A bhnd-bus attached device.
+ */
+void
+bhnd_set_default_bus_desc(device_t dev, const struct bhnd_chipid *chip_id)
+{
+ const char *bus_name;
+ char *desc;
+ char chip_name[BHND_CHIPID_MAX_NAMELEN];
+
+ /* Determine chip type's bus name */
+ switch (chip_id->chip_type) {
+ case BHND_CHIPTYPE_SIBA:
+ bus_name = "SIBA bus";
+ break;
+ case BHND_CHIPTYPE_BCMA:
+ case BHND_CHIPTYPE_BCMA_ALT:
+ bus_name = "BCMA bus";
+ break;
+ case BHND_CHIPTYPE_UBUS:
+ bus_name = "UBUS bus";
+ break;
+ default:
+ bus_name = "Unknown Type";
+ break;
+ }
+
+ /* Format chip name */
+ bhnd_format_chip_id(chip_name, sizeof(chip_name),
+ chip_id->chip_id);
+
+ /* Format and set device description */
+ asprintf(&desc, M_BHND, "%s %s", chip_name, bus_name);
+ if (desc != NULL) {
+ device_set_desc_copy(dev, desc);
+ free(desc, M_BHND);
+ } else {
+ device_set_desc(dev, bus_name);
+ }
+
+}
+
/**
* Helper function for implementing BHND_BUS_IS_HW_DISABLED().
*
Index: sys/dev/bhnd/siba/siba_bhndb.c
===================================================================
--- sys/dev/bhnd/siba/siba_bhndb.c
+++ sys/dev/bhnd/siba/siba_bhndb.c
@@ -80,15 +80,22 @@
static int
siba_bhndb_probe(device_t dev)
{
- const struct bhnd_chipid *cid;
+ const struct bhnd_chipid *cid;
+ int error;
+
+ /* Defer to default probe implementation */
+ if ((error = siba_probe(dev)) > 0)
+ return (error);
/* Check bus type */
cid = BHNDB_GET_CHIPID(device_get_parent(dev), dev);
if (cid->chip_type != BHND_CHIPTYPE_SIBA)
return (ENXIO);
- /* Delegate to default probe implementation */
- return (siba_probe(dev));
+ /* Set device description */
+ bhnd_set_default_bus_desc(dev, cid);
+
+ return (error);
}
static int
Index: sys/dev/bhnd/siba/siba_nexus.c
===================================================================
--- sys/dev/bhnd/siba/siba_nexus.c
+++ sys/dev/bhnd/siba/siba_nexus.c
@@ -75,6 +75,9 @@
return (error);
}
+ /* Set device description */
+ bhnd_set_default_bus_desc(dev, &sc->siba_cid);
+
return (0);
}
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Fri, Nov 28, 7:29 PM (58 m, 5 s)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
26297112
Default Alt Text
D7570.id19550.diff (5 KB)
Attached To
Mode
D7570: Include the chip model (e.g. BCM4xxx) in bhnd(4) bus's device descriptions.
Attached
Detach File
Event Timeline
Log In to Comment