Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

ALSA: hwdep: Take private_data as drvdata for sysfs

For referring to a different object from sysfs ops, take hwdep
private_data as stored via dev_set_drvdata() at creating the device
object. In that way, the same sysfs ops can be used by different
device types.

Signed-off-by: Takashi Iwai <tiwai@suse.de>

+17 -30
+2
sound/core/hwdep.c
··· 441 441 struct device *d = snd_get_device(SNDRV_DEVICE_TYPE_HWDEP, 442 442 hwdep->card, hwdep->device); 443 443 if (d) { 444 + if (hwdep->private_data) 445 + dev_set_drvdata(d, hwdep->private_data); 444 446 err = sysfs_create_groups(&d->kobj, hwdep->groups); 445 447 if (err < 0) 446 448 dev_warn(card->dev,
+15 -30
sound/pci/hda/hda_hwdep.c
··· 163 163 struct device_attribute *attr, 164 164 char *buf) 165 165 { 166 - struct snd_hwdep *hwdep = dev_get_drvdata(dev); 167 - struct hda_codec *codec = hwdep->private_data; 166 + struct hda_codec *codec = dev_get_drvdata(dev); 168 167 snd_hda_update_power_acct(codec); 169 168 return sprintf(buf, "%u\n", jiffies_to_msecs(codec->power_on_acct)); 170 169 } ··· 172 173 struct device_attribute *attr, 173 174 char *buf) 174 175 { 175 - struct snd_hwdep *hwdep = dev_get_drvdata(dev); 176 - struct hda_codec *codec = hwdep->private_data; 176 + struct hda_codec *codec = dev_get_drvdata(dev); 177 177 snd_hda_update_power_acct(codec); 178 178 return sprintf(buf, "%u\n", jiffies_to_msecs(codec->power_off_acct)); 179 179 } ··· 249 251 struct device_attribute *attr, \ 250 252 char *buf) \ 251 253 { \ 252 - struct snd_hwdep *hwdep = dev_get_drvdata(dev); \ 253 - struct hda_codec *codec = hwdep->private_data; \ 254 + struct hda_codec *codec = dev_get_drvdata(dev); \ 254 255 return sprintf(buf, "0x%x\n", codec->type); \ 255 256 } 256 257 ··· 258 261 struct device_attribute *attr, \ 259 262 char *buf) \ 260 263 { \ 261 - struct snd_hwdep *hwdep = dev_get_drvdata(dev); \ 262 - struct hda_codec *codec = hwdep->private_data; \ 264 + struct hda_codec *codec = dev_get_drvdata(dev); \ 263 265 return sprintf(buf, "%s\n", \ 264 266 codec->type ? codec->type : ""); \ 265 267 } ··· 277 281 struct device_attribute *attr, \ 278 282 const char *buf, size_t count) \ 279 283 { \ 280 - struct snd_hwdep *hwdep = dev_get_drvdata(dev); \ 281 - struct hda_codec *codec = hwdep->private_data; \ 284 + struct hda_codec *codec = dev_get_drvdata(dev); \ 282 285 unsigned long val; \ 283 286 int err = kstrtoul(buf, 0, &val); \ 284 287 if (err < 0) \ ··· 291 296 struct device_attribute *attr, \ 292 297 const char *buf, size_t count) \ 293 298 { \ 294 - struct snd_hwdep *hwdep = dev_get_drvdata(dev); \ 295 - struct hda_codec *codec = hwdep->private_data; \ 299 + struct hda_codec *codec = dev_get_drvdata(dev); \ 296 300 char *s = kstrndup_noeol(buf, 64); \ 297 301 if (!s) \ 298 302 return -ENOMEM; \ ··· 312 318 struct device_attribute *attr, \ 313 319 const char *buf, size_t count) \ 314 320 { \ 315 - struct snd_hwdep *hwdep = dev_get_drvdata(dev); \ 316 - struct hda_codec *codec = hwdep->private_data; \ 321 + struct hda_codec *codec = dev_get_drvdata(dev); \ 317 322 int err = 0; \ 318 323 if (*buf) \ 319 324 err = type##_codec(codec); \ ··· 326 333 struct device_attribute *attr, 327 334 char *buf) 328 335 { 329 - struct snd_hwdep *hwdep = dev_get_drvdata(dev); 330 - struct hda_codec *codec = hwdep->private_data; 336 + struct hda_codec *codec = dev_get_drvdata(dev); 331 337 int i, len = 0; 332 338 mutex_lock(&codec->user_mutex); 333 339 for (i = 0; i < codec->init_verbs.used; i++) { ··· 365 373 struct device_attribute *attr, 366 374 const char *buf, size_t count) 367 375 { 368 - struct snd_hwdep *hwdep = dev_get_drvdata(dev); 369 - struct hda_codec *codec = hwdep->private_data; 376 + struct hda_codec *codec = dev_get_drvdata(dev); 370 377 int err = parse_init_verbs(codec, buf); 371 378 if (err < 0) 372 379 return err; ··· 376 385 struct device_attribute *attr, 377 386 char *buf) 378 387 { 379 - struct snd_hwdep *hwdep = dev_get_drvdata(dev); 380 - struct hda_codec *codec = hwdep->private_data; 388 + struct hda_codec *codec = dev_get_drvdata(dev); 381 389 int i, len = 0; 382 390 mutex_lock(&codec->user_mutex); 383 391 for (i = 0; i < codec->hints.used; i++) { ··· 470 480 struct device_attribute *attr, 471 481 const char *buf, size_t count) 472 482 { 473 - struct snd_hwdep *hwdep = dev_get_drvdata(dev); 474 - struct hda_codec *codec = hwdep->private_data; 483 + struct hda_codec *codec = dev_get_drvdata(dev); 475 484 int err = parse_hints(codec, buf); 476 485 if (err < 0) 477 486 return err; ··· 496 507 struct device_attribute *attr, 497 508 char *buf) 498 509 { 499 - struct snd_hwdep *hwdep = dev_get_drvdata(dev); 500 - struct hda_codec *codec = hwdep->private_data; 510 + struct hda_codec *codec = dev_get_drvdata(dev); 501 511 return pin_configs_show(codec, &codec->init_pins, buf); 502 512 } 503 513 ··· 504 516 struct device_attribute *attr, 505 517 char *buf) 506 518 { 507 - struct snd_hwdep *hwdep = dev_get_drvdata(dev); 508 - struct hda_codec *codec = hwdep->private_data; 519 + struct hda_codec *codec = dev_get_drvdata(dev); 509 520 return pin_configs_show(codec, &codec->user_pins, buf); 510 521 } 511 522 ··· 512 525 struct device_attribute *attr, 513 526 char *buf) 514 527 { 515 - struct snd_hwdep *hwdep = dev_get_drvdata(dev); 516 - struct hda_codec *codec = hwdep->private_data; 528 + struct hda_codec *codec = dev_get_drvdata(dev); 517 529 return pin_configs_show(codec, &codec->driver_pins, buf); 518 530 } 519 531 ··· 536 550 struct device_attribute *attr, 537 551 const char *buf, size_t count) 538 552 { 539 - struct snd_hwdep *hwdep = dev_get_drvdata(dev); 540 - struct hda_codec *codec = hwdep->private_data; 553 + struct hda_codec *codec = dev_get_drvdata(dev); 541 554 int err = parse_user_pin_configs(codec, buf); 542 555 if (err < 0) 543 556 return err;