@@ -124,6 +124,8 @@ static void hwdep_free(struct snd_hwdep *hwdep)
124124 clear_hwdep_elements (hwdep -> private_data );
125125}
126126
127+ static const struct attribute_group * snd_hda_dev_attr_groups [];
128+
127129int snd_hda_create_hwdep (struct hda_codec * codec )
128130{
129131 char hwname [16 ];
@@ -140,6 +142,7 @@ int snd_hda_create_hwdep(struct hda_codec *codec)
140142 hwdep -> private_data = codec ;
141143 hwdep -> private_free = hwdep_free ;
142144 hwdep -> exclusive = 1 ;
145+ hwdep -> groups = snd_hda_dev_attr_groups ;
143146
144147 hwdep -> ops .open = hda_hwdep_open ;
145148 hwdep -> ops .ioctl = hda_hwdep_ioctl ;
@@ -176,21 +179,8 @@ static ssize_t power_off_acct_show(struct device *dev,
176179 return sprintf (buf , "%u\n" , jiffies_to_msecs (codec -> power_off_acct ));
177180}
178181
179- static struct device_attribute power_attrs [] = {
180- __ATTR_RO (power_on_acct ),
181- __ATTR_RO (power_off_acct ),
182- };
183-
184- int snd_hda_hwdep_add_power_sysfs (struct hda_codec * codec )
185- {
186- struct snd_hwdep * hwdep = codec -> hwdep ;
187- int i ;
188-
189- for (i = 0 ; i < ARRAY_SIZE (power_attrs ); i ++ )
190- snd_add_device_sysfs_file (SNDRV_DEVICE_TYPE_HWDEP , hwdep -> card ,
191- hwdep -> device , & power_attrs [i ]);
192- return 0 ;
193- }
182+ static DEVICE_ATTR_RO (power_on_acct );
183+ static DEVICE_ATTR_RO (power_off_acct );
194184#endif /* CONFIG_PM */
195185
196186#ifdef CONFIG_SND_HDA_RECONFIG
@@ -568,44 +558,21 @@ static ssize_t user_pin_configs_store(struct device *dev,
568558 return count ;
569559}
570560
571- #define CODEC_ATTR_RW (type ) \
572- __ATTR(type, 0644, type##_show, type##_store)
573- #define CODEC_ATTR_RO (type ) \
574- __ATTR_RO(type)
575- #define CODEC_ATTR_WO (type ) \
576- __ATTR(type, 0200, NULL, type##_store)
577-
578- static struct device_attribute codec_attrs [] = {
579- CODEC_ATTR_RW (vendor_id ),
580- CODEC_ATTR_RW (subsystem_id ),
581- CODEC_ATTR_RW (revision_id ),
582- CODEC_ATTR_RO (afg ),
583- CODEC_ATTR_RO (mfg ),
584- CODEC_ATTR_RW (vendor_name ),
585- CODEC_ATTR_RW (chip_name ),
586- CODEC_ATTR_RW (modelname ),
587- CODEC_ATTR_RW (init_verbs ),
588- CODEC_ATTR_RW (hints ),
589- CODEC_ATTR_RO (init_pin_configs ),
590- CODEC_ATTR_RW (user_pin_configs ),
591- CODEC_ATTR_RO (driver_pin_configs ),
592- CODEC_ATTR_WO (reconfig ),
593- CODEC_ATTR_WO (clear ),
594- };
595-
596- /*
597- * create sysfs files on hwdep directory
598- */
599- int snd_hda_hwdep_add_sysfs (struct hda_codec * codec )
600- {
601- struct snd_hwdep * hwdep = codec -> hwdep ;
602- int i ;
603-
604- for (i = 0 ; i < ARRAY_SIZE (codec_attrs ); i ++ )
605- snd_add_device_sysfs_file (SNDRV_DEVICE_TYPE_HWDEP , hwdep -> card ,
606- hwdep -> device , & codec_attrs [i ]);
607- return 0 ;
608- }
561+ static DEVICE_ATTR_RW (vendor_id );
562+ static DEVICE_ATTR_RW (subsystem_id );
563+ static DEVICE_ATTR_RW (revision_id );
564+ static DEVICE_ATTR_RO (afg );
565+ static DEVICE_ATTR_RO (mfg );
566+ static DEVICE_ATTR_RW (vendor_name );
567+ static DEVICE_ATTR_RW (chip_name );
568+ static DEVICE_ATTR_RW (modelname );
569+ static DEVICE_ATTR_RW (init_verbs );
570+ static DEVICE_ATTR_RW (hints );
571+ static DEVICE_ATTR_RO (init_pin_configs );
572+ static DEVICE_ATTR_RW (user_pin_configs );
573+ static DEVICE_ATTR_RO (driver_pin_configs );
574+ static DEVICE_ATTR_WO (reconfig );
575+ static DEVICE_ATTR_WO (clear );
609576
610577/*
611578 * Look for hint string
@@ -884,3 +851,40 @@ int snd_hda_load_patch(struct hda_bus *bus, size_t fw_size, const void *fw_buf)
884851}
885852EXPORT_SYMBOL_GPL (snd_hda_load_patch );
886853#endif /* CONFIG_SND_HDA_PATCH_LOADER */
854+
855+ /*
856+ * sysfs entries
857+ */
858+ static struct attribute * hda_dev_attrs [] = {
859+ #ifdef CONFIG_PM
860+ & dev_attr_power_on_acct .attr ,
861+ & dev_attr_power_off_acct .attr ,
862+ #endif
863+ #ifdef CONFIG_SND_HDA_RECONFIG
864+ & dev_attr_vendor_id .attr ,
865+ & dev_attr_subsystem_id .attr ,
866+ & dev_attr_revision_id .attr ,
867+ & dev_attr_afg .attr ,
868+ & dev_attr_mfg .attr ,
869+ & dev_attr_vendor_name .attr ,
870+ & dev_attr_chip_name .attr ,
871+ & dev_attr_modelname .attr ,
872+ & dev_attr_init_verbs .attr ,
873+ & dev_attr_hints .attr ,
874+ & dev_attr_init_pin_configs .attr ,
875+ & dev_attr_user_pin_configs .attr ,
876+ & dev_attr_driver_pin_configs .attr ,
877+ & dev_attr_reconfig .attr ,
878+ & dev_attr_clear .attr ,
879+ #endif
880+ NULL
881+ };
882+
883+ static struct attribute_group hda_dev_attr_group = {
884+ .attrs = hda_dev_attrs ,
885+ };
886+
887+ static const struct attribute_group * snd_hda_dev_attr_groups [] = {
888+ & hda_dev_attr_group ,
889+ NULL
890+ };
0 commit comments