+static inline struct obd_device_target *obd2obt(struct obd_device *obd)
+{
+ struct obd_device_target *obt;
+
+ BUILD_BUG_ON(sizeof(obd->u) < sizeof(*obt));
+
+ if (!obd)
+ return NULL;
+ obt = (void *)&obd->u;
+ LASSERT(obt->obt_magic == OBT_MAGIC);
+ return obt;
+}
+
+static inline struct obd_device_target *obd_obt_init(struct obd_device *obd)
+{
+ struct obd_device_target *obt;
+
+ obt = (void *)&obd->u;
+ obt->obt_magic = OBT_MAGIC;
+ obt->obt_instance = 0;
+
+ return obt;
+}
+
+static inline struct echo_obd *obd2echo(struct obd_device *obd)
+{
+ struct echo_obd *echo;
+
+ BUILD_BUG_ON(sizeof(obd->u) < sizeof(*echo));
+
+ if (!obd)
+ return NULL;
+ echo = (void *)&obd->u;
+
+ return echo;
+}
+
+static inline struct ost_obd *obd2ost(struct obd_device *obd)
+{
+ struct ost_obd *ost;
+
+ BUILD_BUG_ON(sizeof(obd->u) < sizeof(*ost));
+
+ if (!obd)
+ return NULL;
+ ost = (void *)&obd->u;
+
+ return ost;
+}
+