History

platform/mellanox: mlxreg-hotplug: Extend logic for hotplug devices operations

Extend the structure 'mlxreg_hotplug_device" with platform device field to allow transition of the register map and system interrupt line number to underlying hotplug devices, sharing the same register map and same interrupt line with 'mlxreg-hotplug' driver. Extend logic for hotplug devices creation and removing according to the action associated with the hotplug device description. Previously hotplug driver was capable to attach / de-attach upon hotplug events only I2C devices handled by simple I2C drivers. Now it should be able to attach also devices handled by the platform drivers. The motivation is to allow transition of platform data like: - system interrupt line number, sharing with 'mlxreg-hotplug' to underlying hotplug devices. - shared register map of programmable devices on main board to underlying hotplug devices. Additioanlly the number of 'sysfs' attributes is increased, since modular system defines more 'sysfs' attributes.

Vadim Pasternak committed 5 years ago

Commit bb1023b1 parent a5d8f572 files · +112 −35Browse files

Showing the changes to include/linux/platform_data (1 of 2 files). Show all

Unified · Split

include/linux/platform_data/mlxreg.h+24−0
@@ -69,6 +69,19 @@ enum mlxreg_hotplug_device_action { · 68 unmodified lines
6969 MLXREG_HOTPLUG_DEVICE_NO_ACTION = 2,
7070 };
7171
72+/**
73+ * struct mlxreg_core_hotplug_notifier - hotplug notifier block:
74+ *
75+ * @identity: notifier identity name;
76+ * @handle: user handle to be passed by user handler function;
77+ * @user_handler: user handler function associated with the event;
78+ */
79+struct mlxreg_core_hotplug_notifier {
80+ char identity[MLXREG_CORE_LABEL_MAX_SIZE];
81+ void *handle;
82+ int (*user_handler)(void *handle, enum mlxreg_hotplug_kind kind, u8 action);
83+};
84+
7285 /**
7386 * struct mlxreg_hotplug_device - I2C device data:
7487 *
@@ -76,7 +89,11 @@ enum mlxreg_hotplug_device_action { · 1 unmodified line
7689 * @client: I2C device client;
7790 * @brdinfo: device board information;
7891 * @nr: I2C device adapter number, to which device is to be attached;
92+ * @pdev: platform device, if device is instantiated as a platform device;
7993 * @action: action to be performed upon event receiving;
94+ * @handle: user handle to be passed by user handler function;
95+ * @user_handler: user handler function associated with the event;
96+ * @notifier: pointer to event notifier block;
8097 *
8198 * Structure represents I2C hotplug device static data (board topology) and
8299 * dynamic data (related kernel objects handles).
@@ -86,7 +103,11 @@ struct mlxreg_hotplug_device { · 3 unmodified lines
86103 struct i2c_client *client;
87104 struct i2c_board_info *brdinfo;
88105 int nr;
106+ struct platform_device *pdev;
89107 enum mlxreg_hotplug_device_action action;
108+ void *handle;
109+ int (*user_handler)(void *handle, enum mlxreg_hotplug_kind kind, u8 action);
110+ struct mlxreg_core_hotplug_notifier *notifier;
90111 };
91112
92113 /**
@@ -104,10 +125,12 @@ struct mlxreg_hotplug_device { · 11 unmodified lines
104125 * @mode: access mode;
105126 * @np - pointer to node platform associated with attribute;
106127 * @hpdev - hotplug device data;
128+ * @notifier: pointer to event notifier block;
107129 * @health_cntr: dynamic device health indication counter;
108130 * @attached: true if device has been attached after good health indication;
109131 * @regnum: number of registers occupied by multi-register attribute;
110132 * @slot: slot number, at which device is located;
133+ * @secured: if set indicates that entry access is secured;
111134 */
112135 struct mlxreg_core_data {
113136 char label[MLXREG_CORE_LABEL_MAX_SIZE];
@@ -122,6 +145,7 @@ struct mlxreg_core_data { · 8 unmodified lines
122145 umode_t mode;
123146 struct device_node *np;
124147 struct mlxreg_hotplug_device hpdev;
148+ struct mlxreg_core_hotplug_notifier *notifier;
125149 u32 health_cntr;
126150 bool attached;
127151 u8 regnum;