File tree Expand file tree Collapse file tree 1 file changed +22
-6
lines changed Expand file tree Collapse file tree 1 file changed +22
-6
lines changed Original file line number Diff line number Diff line change @@ -184,18 +184,40 @@ static struct attribute *dp0_attrs[] = {
184
184
NULL ,
185
185
};
186
186
187
+ static umode_t dp0_attr_visible (struct kobject * kobj , struct attribute * attr ,
188
+ int n )
189
+ {
190
+ struct sdw_slave * slave = dev_to_sdw_dev (kobj_to_dev (kobj ));
191
+
192
+ if (slave -> prop .dp0_prop )
193
+ return attr -> mode ;
194
+ return 0 ;
195
+ }
196
+
197
+ static bool dp0_group_visible (struct kobject * kobj )
198
+ {
199
+ struct sdw_slave * slave = dev_to_sdw_dev (kobj_to_dev (kobj ));
200
+
201
+ if (slave -> prop .dp0_prop )
202
+ return true;
203
+ return false;
204
+ }
205
+ DEFINE_SYSFS_GROUP_VISIBLE (dp0 );
206
+
187
207
/*
188
208
* we don't use ATTRIBUTES_GROUP here since we want to add a subdirectory
189
209
* for dp0-level properties
190
210
*/
191
211
static const struct attribute_group dp0_group = {
192
212
.attrs = dp0_attrs ,
213
+ .is_visible = SYSFS_GROUP_VISIBLE (dp0 ),
193
214
.name = "dp0" ,
194
215
};
195
216
196
217
static const struct attribute_group * slave_groups [] = {
197
218
& slave_attr_group ,
198
219
& sdw_slave_dev_attr_group ,
220
+ & dp0_group ,
199
221
NULL ,
200
222
};
201
223
@@ -207,12 +229,6 @@ int sdw_slave_sysfs_init(struct sdw_slave *slave)
207
229
if (ret < 0 )
208
230
return ret ;
209
231
210
- if (slave -> prop .dp0_prop ) {
211
- ret = devm_device_add_group (& slave -> dev , & dp0_group );
212
- if (ret < 0 )
213
- return ret ;
214
- }
215
-
216
232
if (slave -> prop .source_ports || slave -> prop .sink_ports ) {
217
233
ret = sdw_slave_sysfs_dpn_init (slave );
218
234
if (ret < 0 )
You can’t perform that action at this time.
0 commit comments