Skip to content

Commit 62f134a

Browse files
gregkhtiwai
authored andcommitted
ALSA: core: fix up bus match const issues.
In commit d69d804 ("driver core: have match() callback in struct bus_type take a const *"), the match bus callback was changed to have the driver be a const pointer. Unfortunately that const attribute was thrown away when container_of() is called, which is not correct and was not caught by the compiler due to how container_of() is implemented. Fix this up by correctly preserving the const attribute of the driver passed to the bus match function which requires the hdac_driver match function to also take a const pointer for the driver structure. Cc: Jaroslav Kysela <perex@perex.cz> Cc: Takashi Iwai <tiwai@suse.com> Fixes: d69d804 ("driver core: have match() callback in struct bus_type take a const *") Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org> Link: https://patch.msgid.link/2025052204-hyphen-thermal-3e72@gregkh Signed-off-by: Takashi Iwai <tiwai@suse.de>
1 parent 462e244 commit 62f134a

File tree

4 files changed

+8
-8
lines changed

4 files changed

+8
-8
lines changed

include/sound/hdaudio.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -223,7 +223,7 @@ struct hdac_driver {
223223
struct device_driver driver;
224224
int type;
225225
const struct hda_device_id *id_table;
226-
int (*match)(struct hdac_device *dev, struct hdac_driver *drv);
226+
int (*match)(struct hdac_device *dev, const struct hdac_driver *drv);
227227
void (*unsol_event)(struct hdac_device *dev, unsigned int event);
228228

229229
/* fields used by ext bus APIs */
@@ -235,7 +235,7 @@ struct hdac_driver {
235235
#define drv_to_hdac_driver(_drv) container_of(_drv, struct hdac_driver, driver)
236236

237237
const struct hda_device_id *
238-
hdac_get_device_id(struct hdac_device *hdev, struct hdac_driver *drv);
238+
hdac_get_device_id(struct hdac_device *hdev, const struct hdac_driver *drv);
239239

240240
/*
241241
* Bus verb operators

sound/core/seq_device.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ MODULE_LICENSE("GPL");
4343
static int snd_seq_bus_match(struct device *dev, const struct device_driver *drv)
4444
{
4545
struct snd_seq_device *sdev = to_seq_dev(dev);
46-
struct snd_seq_driver *sdrv = to_seq_drv(drv);
46+
const struct snd_seq_driver *sdrv = to_seq_drv(drv);
4747

4848
return strcmp(sdrv->id, sdev->id) == 0 &&
4949
sdrv->argsize == sdev->argsize;

sound/hda/hda_bus_type.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ MODULE_LICENSE("GPL");
2121
* driver id_table and returns the matching device id entry.
2222
*/
2323
const struct hda_device_id *
24-
hdac_get_device_id(struct hdac_device *hdev, struct hdac_driver *drv)
24+
hdac_get_device_id(struct hdac_device *hdev, const struct hdac_driver *drv)
2525
{
2626
if (drv->id_table) {
2727
const struct hda_device_id *id = drv->id_table;
@@ -38,7 +38,7 @@ hdac_get_device_id(struct hdac_device *hdev, struct hdac_driver *drv)
3838
}
3939
EXPORT_SYMBOL_GPL(hdac_get_device_id);
4040

41-
static int hdac_codec_match(struct hdac_device *dev, struct hdac_driver *drv)
41+
static int hdac_codec_match(struct hdac_device *dev, const struct hdac_driver *drv)
4242
{
4343
if (hdac_get_device_id(dev, drv))
4444
return 1;
@@ -49,7 +49,7 @@ static int hdac_codec_match(struct hdac_device *dev, struct hdac_driver *drv)
4949
static int hda_bus_match(struct device *dev, const struct device_driver *drv)
5050
{
5151
struct hdac_device *hdev = dev_to_hdac_dev(dev);
52-
struct hdac_driver *hdrv = drv_to_hdac_driver(drv);
52+
const struct hdac_driver *hdrv = drv_to_hdac_driver(drv);
5353

5454
if (hdev->type != hdrv->type)
5555
return 0;

sound/pci/hda/hda_bind.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,10 @@
1818
/*
1919
* find a matching codec id
2020
*/
21-
static int hda_codec_match(struct hdac_device *dev, struct hdac_driver *drv)
21+
static int hda_codec_match(struct hdac_device *dev, const struct hdac_driver *drv)
2222
{
2323
struct hda_codec *codec = container_of(dev, struct hda_codec, core);
24-
struct hda_codec_driver *driver =
24+
const struct hda_codec_driver *driver =
2525
container_of(drv, struct hda_codec_driver, core);
2626
const struct hda_device_id *list;
2727
/* check probe_id instead of vendor_id if set */

0 commit comments

Comments
 (0)