i2c: mux: mlxcpld: Add callback to notify mux creation completion
authorVadim Pasternak <vadimp@nvidia.com>
Mon, 8 Feb 2021 20:16:06 +0000 (22:16 +0200)
committerWolfram Sang <wsa@kernel.org>
Tue, 9 Feb 2021 10:35:44 +0000 (11:35 +0100)
Add notification to inform caller that mux objects array has been
created. It allows to user, invoked platform device registration for
"i2c-mux-mlxcpld" driver, to be notified that mux infrastructure is
available, and thus some devices could be connected to this
infrastructure.

Signed-off-by: Vadim Pasternak <vadimp@nvidia.com>
Acked-by: Peter Rosin <peda@axentia.se>
Signed-off-by: Wolfram Sang <wsa@kernel.org>
drivers/i2c/muxes/i2c-mux-mlxcpld.c
include/linux/platform_data/mlxcpld.h

index 5e0672f9979b7ec8834b6e2f22dd403af7c45784..1a879f6a31efdf5378600e4aba51ac19b7062ad1 100644 (file)
@@ -159,6 +159,10 @@ static int mlxcpld_mux_probe(struct platform_device *pdev)
                        goto virt_reg_failed;
        }
 
+       /* Notify caller when all channels' adapters are created. */
+       if (pdata->completion_notify)
+               pdata->completion_notify(pdata->handle, muxc->parent, muxc->adapter);
+
        return 0;
 
 virt_reg_failed:
index a7bee798d99175f69f065b21e04a75cb63728db1..d7610b5288568ccecc0601899a351ed56c931b01 100644 (file)
  * @num_adaps - number of adapters
  * @sel_reg_addr - mux select register offset in CPLD space
  * @reg_size: register size in bytes
+ * @handle: handle to be passed by callback
+ * @completion_notify: callback to notify when all the adapters are created
  */
 struct mlxcpld_mux_plat_data {
        int *chan_ids;
        int num_adaps;
        int sel_reg_addr;
        u8 reg_size;
+       void *handle;
+       int (*completion_notify)(void *handle, struct i2c_adapter *parent,
+                                struct i2c_adapter *adapters[]);
 };
 
 #endif /* _LINUX_I2C_MLXCPLD_H */