Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1698324

Re: [PATCH v4 02/12] ALSA: ac97: add an ac97 bus

From Robert Jarzmik <robert.jarzmik@free.fr>
Newsgroups linux.kernel
Subject Re: [PATCH v4 02/12] ALSA: ac97: add an ac97 bus
Date 2017-07-27 23:10 +0200
Message-ID <u7YcG-2T1-35@gated-at.bofh.it> (permalink)
References <u6SCl-1Fc-3@gated-at.bofh.it> <u6SCm-1Fc-33@gated-at.bofh.it> <u7fSh-8jG-1@gated-at.bofh.it>
Organization linux.* mail to news gateway

Show all headers | View raw


Takashi Iwai <tiwai@suse.de> writes:

> On Mon, 24 Jul 2017 22:49:18 +0200,
> Robert Jarzmik wrote:

...zip...
>> +#ifndef AC97_COMPAT_H
>> +#define AC97_COMPAT_H
>> +
>> +#include <sound/ac97_codec.h>
>> +#include <sound/soc.h>
>
> Is this inclusion needed?  The code here doesn't look ASoC-specific at
> all.
Mmm no, actually it's not, good point.

...zip...
>> +#ifndef AC97_CONTROLLER_H
>> +#define AC97_CONTROLLER_H
>> +
>> +#include <linux/list.h>
>> +
>> +#define AC97_BUS_MAX_CODECS 4
>> +#define AC97_SLOTS_AVAILABLE_ALL 0xf
>> +
>> +struct device;
>
> You need the definition struct device in below (it's no pointer), thus
> you have to include <linux/device.h> instead.
Fair enough, vor v5.
>> +struct ac97_controller {
>> +	const struct ac97_controller_ops *ops;
>
> The struct isn't declared beforehand?  GCC will warn.
Actually it doesn't.
It's interesting as ac97_controller depends on ac97_controller_ops, and
ac97_controller_ops depends on ac97_controller;

As for why it doesn't warn, every time I used controller.h, I also used
codec.h. And codec.h holds a :
struct ac97_controller;

So it's declared beforehand after all ...

But I will add before "struct ac97_controller" a :
struct ac97_controller_ops;

>> +	struct list_head controllers;
>> +	struct device adap;
>> +	int nr;
>> +	struct device *parent;
>> +	unsigned short slots_available;
>
> I'd move parent field below, so that 64bit pointer can be aligned
> better.
Okay, got it.

...zip...
>> +
>> +	device_initialize(&codec->dev);
>> +	dev_set_name(&codec->dev, "%s:%u", dev_name(ac97_ctrl->parent), idx);
>> +
>> +	ret = device_add(&codec->dev);
>> +	if (ret)
>> +		goto err_free_codec;
>> +
>> +	return 0;
>> +err_free_codec:
>> +	kfree(codec);
>
> This may leave the device name string.  You need to call
> put_device() even if device_add() returns an error.
You're right, I'll change that.

...zip...
>> +int snd_ac97_codec_driver_register(struct ac97_codec_driver *drv)
>> +{
>> +	int ret;
>> +
>> +	drv->driver.bus = &ac97_bus_type;
>> +	ret = driver_register(&drv->driver);
>> +
>> +	return ret;
>
> This can be simplified.
Indeed.

>> +}
>> +EXPORT_SYMBOL(snd_ac97_codec_driver_register);
>
> No GPL?  (Ditto for other entries, too)
Euh yeah, GPL forever. I will change all the occurrences.

>> +int snd_ac97_reset(struct snd_ac97 *ac97, bool try_warm, unsigned int id,
>> +	unsigned int id_mask)
>> +{
>> +	struct ac97_codec_device *adev = to_ac97_device(ac97->private_data);
>> +	struct ac97_controller *actrl = adev->ac97_ctrl;
>> +
>> +	if (try_warm) {
>> +		compat_ac97_warm_reset(ac97);
>> +		if (snd_ac97_bus_scan_one(actrl, adev->num) == adev->vendor_id)
>
> Can we ignore id_mask here?  I'm not quite sure whether it's fixed...
Probably not, but I will take a bit more time to cross-check that one.

Thanks for the review, I'll follow up on that last question when I'll have
settled on the correct answer.

Cheers.

-- 
Robert

Back to linux.kernel | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

[PATCH v4 00/12] AC97 device/driver model revamp Robert Jarzmik <robert.jarzmik@free.fr> - 2017-07-24 23:00 +0200
  [PATCH v4 10/12] ASoC: wm9705: add private structure Robert Jarzmik <robert.jarzmik@free.fr> - 2017-07-24 23:00 +0200
  [PATCH v4 02/12] ALSA: ac97: add an ac97 bus Robert Jarzmik <robert.jarzmik@free.fr> - 2017-07-24 23:00 +0200
    Re: [PATCH v4 02/12] ALSA: ac97: add an ac97 bus Takashi Iwai <tiwai@suse.de> - 2017-07-25 23:50 +0200
      Re: [PATCH v4 02/12] ALSA: ac97: add an ac97 bus Robert Jarzmik <robert.jarzmik@free.fr> - 2017-07-27 23:10 +0200
  [PATCH v4 06/12] mfd: wm97xx-core: core support for wm97xx Codec Robert Jarzmik <robert.jarzmik@free.fr> - 2017-07-24 23:00 +0200
    Re: [PATCH v4 06/12] mfd: wm97xx-core: core support for wm97xx Codec Charles Keepax <ckeepax@opensource.cirrus.com> - 2017-07-25 12:20 +0200

csiph-web