Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit ad913c11 authored by Dominik Brodowski's avatar Dominik Brodowski
Browse files

pcmcia: pcmcia_config_loop() improvement by passing vcc



By passing the current Vcc setting to the pcmcia_config_loop callback
function, we can remove pcmcia_get_configuration_info() calls from many
drivers.

Signed-off-by: default avatarDominik Brodowski <linux@dominikbrodowski.net>
parent 8e2fc39d
Loading
Loading
Loading
Loading
+4 −8
Original line number Diff line number Diff line
@@ -150,7 +150,6 @@ do { last_fn = (fn); if ((last_ret = (ret)) != 0) goto cs_failed; } while (0)


struct pcmcia_config_check {
	config_info_t conf;
	unsigned long ctl_base;
	int skip_vcc;
	int is_kme;
@@ -159,6 +158,7 @@ struct pcmcia_config_check {
static int pcmcia_check_one_config(struct pcmcia_device *pdev,
				   cistpl_cftable_entry_t *cfg,
				   cistpl_cftable_entry_t *dflt,
				   unsigned int vcc,
				   void *priv_data)
{
	struct pcmcia_config_check *stk = priv_data;
@@ -166,12 +166,10 @@ static int pcmcia_check_one_config(struct pcmcia_device *pdev,
	/* Check for matching Vcc, unless we're desperate */
	if (!stk->skip_vcc) {
		if (cfg->vcc.present & (1 << CISTPL_POWER_VNOM)) {
			if (stk->conf.Vcc !=
			    cfg->vcc.param[CISTPL_POWER_VNOM] / 10000)
			if (vcc != cfg->vcc.param[CISTPL_POWER_VNOM] / 10000)
				return -ENODEV;
		} else if (dflt->vcc.present & (1 << CISTPL_POWER_VNOM)) {
			if (stk->conf.Vcc !=
			    dflt->vcc.param[CISTPL_POWER_VNOM] / 10000)
			if (vcc != dflt->vcc.param[CISTPL_POWER_VNOM] / 10000)
				return -ENODEV;
		}
	}
@@ -257,10 +255,8 @@ static int pcmcia_init_one(struct pcmcia_device *pdev)
	if (!stk)
		goto out1;
	stk->is_kme = is_kme;

	/* Not sure if this is right... look up the current Vcc */
	CS_CHECK(GetConfigurationInfo, pcmcia_get_configuration_info(pdev, &stk->conf));
	stk->skip_vcc = io_base = ctl_base = 0;

	if (pcmcia_loop_config(pdev, pcmcia_check_one_config, stk)) {
		stk->skip_vcc = 1;
		if (pcmcia_loop_config(pdev, pcmcia_check_one_config, stk))
+2 −0
Original line number Diff line number Diff line
@@ -681,6 +681,7 @@ static void bt3c_detach(struct pcmcia_device *link)
static int bt3c_check_config(struct pcmcia_device *p_dev,
			     cistpl_cftable_entry_t *cf,
			     cistpl_cftable_entry_t *dflt,
			     unsigned int vcc,
			     void *priv_data)
{
	unsigned long try = (unsigned long) priv_data;
@@ -701,6 +702,7 @@ static int bt3c_check_config(struct pcmcia_device *p_dev,
static int bt3c_check_config_notpicky(struct pcmcia_device *p_dev,
				      cistpl_cftable_entry_t *cf,
				      cistpl_cftable_entry_t *dflt,
				      unsigned int vcc,
				      void *priv_data)
{
	static unsigned int base[5] = { 0x3f8, 0x2f8, 0x3e8, 0x2e8, 0x0 };
+6 −5
Original line number Diff line number Diff line
@@ -610,16 +610,17 @@ static void btuart_detach(struct pcmcia_device *link)
static int btuart_check_config(struct pcmcia_device *p_dev,
			       cistpl_cftable_entry_t *cf,
			       cistpl_cftable_entry_t *dflt,
			       unsigned int vcc,
			       void *priv_data)
{
	unsigned long try = (unsigned long) priv_data;
	int *try = priv_data;

	if (cf->vpp1.present & (1 << CISTPL_POWER_VNOM))
		p_dev->conf.Vpp = cf->vpp1.param[CISTPL_POWER_VNOM] / 10000;
	if ((cf->io.nwin > 0) && (cf->io.win[0].len == 8) &&
	    (cf->io.win[0].base != 0)) {
		p_dev->io.BasePort1 = cf->io.win[0].base;
		p_dev->io.IOAddrLines = (try == 0) ? 16 :
		p_dev->io.IOAddrLines = (*try == 0) ? 16 :
			cf->io.flags & CISTPL_IO_LINES_MASK;
		if (!pcmcia_request_io(p_dev, &p_dev->io))
			return 0;
@@ -630,6 +631,7 @@ static int btuart_check_config(struct pcmcia_device *p_dev,
static int btuart_check_config_notpicky(struct pcmcia_device *p_dev,
					cistpl_cftable_entry_t *cf,
					cistpl_cftable_entry_t *dflt,
					unsigned int vcc,
					void *priv_data)
{
	static unsigned int base[5] = { 0x3f8, 0x2f8, 0x3e8, 0x2e8, 0x0 };
@@ -650,13 +652,12 @@ static int btuart_config(struct pcmcia_device *link)
{
	btuart_info_t *info = link->priv;
	int i;
	unsigned long try;
	int try;

	/* First pass: look for a config entry that looks normal.
	   Two tries: without IO aliases, then with aliases */
	for (try = 0; try < 2; try++)
		if (!pcmcia_loop_config(link, btuart_check_config,
					(void *) try))
		if (!pcmcia_loop_config(link, btuart_check_config, &try))
			goto found_port;

	/* Second pass: try to find an entry that isn't picky about
+1 −0
Original line number Diff line number Diff line
@@ -593,6 +593,7 @@ static void dtl1_detach(struct pcmcia_device *link)
static int dtl1_confcheck(struct pcmcia_device *p_dev,
			  cistpl_cftable_entry_t *cf,
			  cistpl_cftable_entry_t *dflt,
			  unsigned int vcc,
			  void *priv_data)
{
	if ((cf->io.nwin == 1) && (cf->io.win[0].len > 8)) {
+1 −0
Original line number Diff line number Diff line
@@ -1762,6 +1762,7 @@ static void cmm_cm4000_release(struct pcmcia_device * link)
static int cm4000_config_check(struct pcmcia_device *p_dev,
			       cistpl_cftable_entry_t *cfg,
			       cistpl_cftable_entry_t *dflt,
			       unsigned int vcc,
			       void *priv_data)
{
	if (!cfg->io.nwin)
Loading