]> err.no Git - linux-2.6/blobdiff - drivers/media/video/tuner-i2c.h
V4L/DVB (7184): make hybrid_tuner_request_state tolerant of devices without i2c adapters
[linux-2.6] / drivers / media / video / tuner-i2c.h
index 8ec5b41d459f240dddce67feb3265c07018c677e..60ba794809feabb881b64b4e030a03e4b62c89dd 100644 (file)
@@ -83,7 +83,8 @@ static inline int tuner_i2c_xfer_send_recv(struct tuner_i2c_props *props,
 
 #define tuner_printk(kernlvl, i2cprops, fmt, arg...) do {              \
        printk(kernlvl "%s %d-%04x: " fmt, i2cprops.name,               \
-                       i2c_adapter_id(i2cprops.adap),                  \
+                       i2cprops.adap ?                                 \
+                               i2c_adapter_id(i2cprops.adap) : -1,     \
                        i2cprops.addr, ##arg);                          \
         } while (0)
 
@@ -128,9 +129,10 @@ static inline int tuner_i2c_xfer_send_recv(struct tuner_i2c_props *props,
 ({                                                                     \
        int __ret = 0;                                                  \
        list_for_each_entry(state, &list, hybrid_tuner_instance_list) { \
-               if ((i2c_adapter_id(state->i2c_props.adap) ==           \
-                    i2c_adapter_id(i2cadap)) &&                        \
-                   (state->i2c_props.addr == i2caddr)) {               \
+               if ((state->i2c_props.addr == i2caddr) &&               \
+                   ((state->i2c_props.adap ?                           \
+                       i2c_adapter_id(state->i2c_props.adap) : -1) ==  \
+                    (i2cadap ? i2c_adapter_id(i2cadap) : -1))) {       \
                        __tuner_info(state->i2c_props,                  \
                                     "attaching existing instance\n");  \
                        state->i2c_props.count++;                       \
@@ -155,13 +157,17 @@ __fail:                                                                   \
        __ret;                                                          \
 })
 
-#define hybrid_tuner_release_state(state) do {                         \
+#define hybrid_tuner_release_state(state)                              \
+({                                                                     \
+       int __ret;                                                      \
        state->i2c_props.count--;                                       \
+       __ret = state->i2c_props.count;                                 \
        if (!state->i2c_props.count) {                                  \
                __tuner_info(state->i2c_props, "destroying instance\n");\
                list_del(&state->hybrid_tuner_instance_list);           \
                kfree(state);                                           \
        }                                                               \
-} while (0)
+       __ret;                                                          \
+})
 
 #endif /* __TUNER_I2C_H__ */